Merge branch 'feature/manual-layout' into 'feature/manual-layout'

Feature/manual layout Puzzle Refactoring

See merge request smart-pattern/valentina!8
This commit is contained in:
Roman Telezhynskyi 2020-06-03 07:42:59 +00:00
commit 55c9103ef1
54 changed files with 2535 additions and 2318 deletions

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file dialogaboutpuzzle.cpp ** @file vpdialogabout.cpp
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 11 4, 2020 ** @date 11 4, 2020
** **
@ -26,8 +26,8 @@
** **
*************************************************************************/ *************************************************************************/
#include "dialogaboutpuzzle.h" #include "vpdialogabout.h"
#include "ui_dialogaboutpuzzle.h" #include "ui_vpdialogabout.h"
#include "../version.h" #include "../version.h"
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "../fervor/fvupdater.h" #include "../fervor/fvupdater.h"
@ -40,9 +40,9 @@
#include <QtDebug> #include <QtDebug>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogAboutPuzzle::DialogAboutPuzzle(QWidget *parent) VPDialogAbout::VPDialogAbout(QWidget *parent)
:QDialog(parent), :QDialog(parent),
ui(new Ui::DialogAboutPuzzle), ui(new Ui::VPDialogAbout),
isInitialized(false) isInitialized(false)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -57,7 +57,7 @@ DialogAboutPuzzle::DialogAboutPuzzle(QWidget *parent)
qWarning() << tr("Cannot open your default browser"); qWarning() << tr("Cannot open your default browser");
} }
}); });
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &DialogAboutPuzzle::close); connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &VPDialogAbout::close);
connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, []() connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, []()
{ {
// Set feed URL before doing anything else // Set feed URL before doing anything else
@ -72,13 +72,13 @@ DialogAboutPuzzle::DialogAboutPuzzle(QWidget *parent)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogAboutPuzzle::~DialogAboutPuzzle() VPDialogAbout::~VPDialogAbout()
{ {
delete ui; delete ui;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogAboutPuzzle::changeEvent(QEvent *event) void VPDialogAbout::changeEvent(QEvent *event)
{ {
if (event->type() == QEvent::LanguageChange) if (event->type() == QEvent::LanguageChange)
{ {
@ -92,7 +92,7 @@ void DialogAboutPuzzle::changeEvent(QEvent *event)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogAboutPuzzle::showEvent(QShowEvent *event) void VPDialogAbout::showEvent(QShowEvent *event)
{ {
QDialog::showEvent( event ); QDialog::showEvent( event );
if ( event->spontaneous() ) if ( event->spontaneous() )
@ -113,7 +113,7 @@ void DialogAboutPuzzle::showEvent(QShowEvent *event)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogAboutPuzzle::FontPointSize(QWidget *w, int pointSize) void VPDialogAbout::FontPointSize(QWidget *w, int pointSize)
{ {
SCASSERT(w != nullptr) SCASSERT(w != nullptr)
@ -123,7 +123,7 @@ void DialogAboutPuzzle::FontPointSize(QWidget *w, int pointSize)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogAboutPuzzle::RetranslateUi() void VPDialogAbout::RetranslateUi()
{ {
ui->label_Puzzle_Version->setText(QString("Puzzle %1").arg(APP_VERSION_STR)); ui->label_Puzzle_Version->setText(QString("Puzzle %1").arg(APP_VERSION_STR));
ui->labelBuildRevision->setText(tr("Build revision: %1").arg(BUILD_REVISION)); ui->labelBuildRevision->setText(tr("Build revision: %1").arg(BUILD_REVISION));

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file dialogaboutpuzzle.h ** @file vpdialogabout.h
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 11 4, 2020 ** @date 11 4, 2020
** **
@ -26,31 +26,31 @@
** **
*************************************************************************/ *************************************************************************/
#ifndef DIALOGABOUTPUZZLE_H #ifndef VPDIALOGABOUT_H
#define DIALOGABOUTPUZZLE_H #define VPDIALOGABOUT_H
#include <QDialog> #include <QDialog>
namespace Ui namespace Ui
{ {
class DialogAboutPuzzle; class VPDialogAbout;
} }
class DialogAboutPuzzle : public QDialog class VPDialogAbout : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogAboutPuzzle(QWidget *parent = nullptr); explicit VPDialogAbout(QWidget *parent = nullptr);
virtual ~DialogAboutPuzzle(); virtual ~VPDialogAbout();
protected: protected:
virtual void changeEvent(QEvent* event) override; virtual void changeEvent(QEvent* event) override;
virtual void showEvent(QShowEvent *event) override; virtual void showEvent(QShowEvent *event) override;
private: private:
Q_DISABLE_COPY(DialogAboutPuzzle) Q_DISABLE_COPY(VPDialogAbout)
Ui::DialogAboutPuzzle *ui; Ui::VPDialogAbout *ui;
bool isInitialized; bool isInitialized;
void FontPointSize(QWidget *w, int pointSize); void FontPointSize(QWidget *w, int pointSize);
@ -58,4 +58,4 @@ private:
void RetranslateUi(); void RetranslateUi();
}; };
#endif // DIALOGABOUTPUZZLE_H #endif // VPDIALOGABOUT_H

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>DialogAboutPuzzle</class> <class>VPDialogAbout</class>
<widget class="QDialog" name="DialogAboutPuzzle"> <widget class="QDialog" name="VPDialogAbout">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
@ -296,6 +296,7 @@
</widget> </widget>
<resources> <resources>
<include location="../share/resources/puzzleicon.qrc"/> <include location="../share/resources/puzzleicon.qrc"/>
<include location="../share/resources/puzzleicon.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>

View File

@ -29,7 +29,7 @@
#include <QMessageBox> // For QT_REQUIRE_VERSION #include <QMessageBox> // For QT_REQUIRE_VERSION
#include <QTimer> #include <QTimer>
#include "puzzleapplication.h" #include "vpapplication.h"
#include "../fervor/fvupdater.h" #include "../fervor/fvupdater.h"
#include "../vmisc/vsysexits.h" #include "../vmisc/vsysexits.h"
#include "../vmisc/def.h" #include "../vmisc/def.h"
@ -64,7 +64,7 @@ int main(int argc, char *argv[])
InitHighDpiScaling(argc, argv); InitHighDpiScaling(argc, argv);
#endif //Q_OS_MAC #endif //Q_OS_MAC
PuzzleApplication app(argc, argv); VPApplication app(argc, argv);
app.InitOptions(); app.InitOptions();
if (FvUpdater::IsStaledTestBuild()) if (FvUpdater::IsStaledTestBuild())
@ -78,7 +78,7 @@ int main(int argc, char *argv[])
return V_EX_UNAVAILABLE; return V_EX_UNAVAILABLE;
} }
QTimer::singleShot(0, &app, &PuzzleApplication::ProcessCMD); QTimer::singleShot(0, &app, &VPApplication::ProcessCMD);
#if defined(APPIMAGE) && defined(Q_OS_LINUX) #if defined(APPIMAGE) && defined(Q_OS_LINUX)
if (exe_dir) if (exe_dir)

View File

@ -2,54 +2,57 @@
# This need for corect working file translations.pro # This need for corect working file translations.pro
SOURCES += \ SOURCES += \
$$PWD/dialogs/vpdialogabout.cpp \
$$PWD/main.cpp \ $$PWD/main.cpp \
$$PWD/puzzlecommands.cpp \ $$PWD/vpapplication.cpp \
$$PWD/puzzlemainwindow.cpp \ $$PWD/vpcarrousel.cpp \
$$PWD/puzzleapplication.cpp \ $$PWD/vpcarrouselpiece.cpp \
$$PWD/vpiececarrouselpiecepreview.cpp \ $$PWD/vpcarrouselpiecelist.cpp \
$$PWD/vpuzzlecommandline.cpp \ $$PWD/vpcommandline.cpp \
$$PWD/dialogs/dialogaboutpuzzle.cpp \ $$PWD/vpcommands.cpp \
$$PWD/vpiececarrousel.cpp \ $$PWD/vpgraphicspiece.cpp \
$$PWD/vpuzzlegraphicslayout.cpp \ $$PWD/vpgraphicssheet.cpp \
$$PWD/vpuzzlegraphicspiece.cpp \ $$PWD/vplayout.cpp \
$$PWD/vpuzzlelayout.cpp \ $$PWD/vpmaingraphicsview.cpp \
$$PWD/vpuzzlelayer.cpp \ $$PWD/vpmainwindow.cpp \
$$PWD/vpuzzlemaingraphicsview.cpp \ $$PWD/vpmimedatapiece.cpp \
$$PWD/vpuzzlemimedatapiece.cpp \ $$PWD/vppiece.cpp \
$$PWD/vpuzzlepiece.cpp \ $$PWD/vppiecelist.cpp \
$$PWD/vpuzzlesettings.cpp \ $$PWD/vpsettings.cpp \
$$PWD/xml/layoutliterals.cpp \ $$PWD/vpsheet.cpp \
$$PWD/xml/vpuzzlelayoutfilewriter.cpp \ $$PWD/xml/vplayoutfilereader.cpp \
$$PWD/xml/vpuzzlelayoutfilereader.cpp \ $$PWD/xml/vplayoutfilewriter.cpp \
$$PWD/vpiececarrousellayer.cpp \ $$PWD/xml/vplayoutliterals.cpp
$$PWD/vpiececarrouselpiece.cpp
*msvc*:SOURCES += $$PWD/stable.cpp *msvc*:SOURCES +=
HEADERS += \ HEADERS += \
$$PWD/puzzlecommands.h \ $$PWD/dialogs/vpdialogabout.h \
$$PWD/puzzlemainwindow.h \ $$PWD/vpapplication.h \
$$PWD/stable.h \ $$PWD/vpcarrousel.h \
$$PWD/puzzleapplication.h \ $$PWD/vpcarrouselpiece.h \
$$PWD/vpiececarrouselpiecepreview.h \ $$PWD/vpcarrouselpiecelist.h \
$$PWD/vpuzzlecommandline.h \ $$PWD/vpcommandline.h \
$$PWD/dialogs/dialogaboutpuzzle.h \ $$PWD/vpcommands.h \
$$PWD/vpiececarrousel.h \ $$PWD/vpgraphicspiece.h \
$$PWD/vpuzzlegraphicslayout.h \ $$PWD/vpgraphicssheet.h \
$$PWD/vpuzzlegraphicspiece.h \ $$PWD/vplayout.h \
$$PWD/vpuzzlelayout.h \ $$PWD/vpmaingraphicsview.h \
$$PWD/vpuzzlelayer.h \ $$PWD/vpmainwindow.h \
$$PWD/vpuzzlemaingraphicsview.h \ $$PWD/vpmimedatapiece.h \
$$PWD/vpuzzlemimedatapiece.h \ $$PWD/vppiece.h \
$$PWD/vpuzzlepiece.h \ $$PWD/vppiecelist.h \
$$PWD/vpuzzlesettings.h \ $$PWD/vpsettings.h \
$$PWD/xml/layoutliterals.h \ $$PWD/vpsheet.h \
$$PWD/xml/vpuzzlelayoutfilewriter.h \ $$PWD/vpstable.h \
$$PWD/xml/vpuzzlelayoutfilereader.h \ $$PWD/xml/vplayoutfilereader.h \
$$PWD/vpiececarrousellayer.h \ $$PWD/xml/vplayoutfilewriter.h \
$$PWD/vpiececarrouselpiece.h $$PWD/xml/vplayoutliterals.h
FORMS += \ FORMS += \
$$PWD/puzzlemainwindow.ui \ $$PWD/dialogs/vpdialogabout.ui \
$$PWD/dialogs/dialogaboutpuzzle.ui \ $$PWD/vpcarrousel.ui \
$$PWD/vpiececarrousel.ui $$PWD/vpmainwindow.ui
SOURCES += \
$$PWD/vpstable.cpp

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file puzzleapplication.cpp ** @file vpapplication.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com> ** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 16 2, 2020 ** @date 16 2, 2020
** **
@ -26,9 +26,9 @@
** **
*************************************************************************/ *************************************************************************/
#include "puzzleapplication.h" #include "vpapplication.h"
#include "version.h" #include "version.h"
#include "puzzlemainwindow.h" #include "vpmainwindow.h"
#include "../ifc/exception/vexceptionobjecterror.h" #include "../ifc/exception/vexceptionobjecterror.h"
#include "../ifc/exception/vexceptionbadid.h" #include "../ifc/exception/vexceptionbadid.h"
#include "../ifc/exception/vexceptionconversionerror.h" #include "../ifc/exception/vexceptionconversionerror.h"
@ -232,7 +232,7 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
PuzzleApplication::PuzzleApplication(int &argc, char **argv) VPApplication::VPApplication(int &argc, char **argv)
:VAbstractApplication(argc, argv), :VAbstractApplication(argc, argv),
mainWindows(), mainWindows(),
localServer(nullptr) localServer(nullptr)
@ -250,7 +250,7 @@ PuzzleApplication::PuzzleApplication(int &argc, char **argv)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
PuzzleApplication::~PuzzleApplication() VPApplication::~VPApplication()
{ {
qDeleteAll(mainWindows); qDeleteAll(mainWindows);
} }
@ -263,7 +263,7 @@ PuzzleApplication::~PuzzleApplication()
* @return value that is returned from the receiver's event handler. * @return value that is returned from the receiver's event handler.
*/ */
// reimplemented from QApplication so we can throw exceptions in slots // reimplemented from QApplication so we can throw exceptions in slots
bool PuzzleApplication::notify(QObject *receiver, QEvent *event) bool VPApplication::notify(QObject *receiver, QEvent *event)
{ {
try try
{ {
@ -324,29 +324,29 @@ bool PuzzleApplication::notify(QObject *receiver, QEvent *event)
/** /**
* @brief IsAppInGUIMode little hack that allow to have access to application state from VAbstractApplication class. * @brief IsAppInGUIMode little hack that allow to have access to application state from VAbstractApplication class.
*/ */
bool PuzzleApplication::IsAppInGUIMode() const bool VPApplication::IsAppInGUIMode() const
{ {
return CommandLine()->IsGuiEnabled(); return CommandLine()->IsGuiEnabled();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
PuzzleMainWindow *PuzzleApplication::MainWindow() VPMainWindow *VPApplication::MainWindow()
{ {
Clean(); Clean();
if (mainWindows.isEmpty()) if (mainWindows.isEmpty())
{ {
VPuzzleCommandLinePtr cmd; VPCommandLinePtr cmd;
VPuzzleCommandLine::ProcessInstance(cmd, QStringList()); VPCommandLine::ProcessInstance(cmd, QStringList());
NewMainWindow(VPuzzleCommandLinePtr()); NewMainWindow(VPCommandLinePtr());
} }
return mainWindows[0]; return mainWindows[0];
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QList<PuzzleMainWindow *> PuzzleApplication::MainWindows() QList<VPMainWindow *> VPApplication::MainWindows()
{ {
Clean(); Clean();
QList<PuzzleMainWindow*> list; QList<VPMainWindow*> list;
for (auto &w : mainWindows) for (auto &w : mainWindows)
{ {
list.append(w); list.append(w);
@ -355,9 +355,9 @@ QList<PuzzleMainWindow *> PuzzleApplication::MainWindows()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
PuzzleMainWindow *PuzzleApplication::NewMainWindow(const VPuzzleCommandLinePtr &cmd) VPMainWindow *VPApplication::NewMainWindow(const VPCommandLinePtr &cmd)
{ {
PuzzleMainWindow *puzzle = new PuzzleMainWindow(cmd); VPMainWindow *puzzle = new VPMainWindow(cmd);
mainWindows.prepend(puzzle); mainWindows.prepend(puzzle);
if (cmd->IsGuiEnabled()) if (cmd->IsGuiEnabled())
{ {
@ -367,7 +367,7 @@ PuzzleMainWindow *PuzzleApplication::NewMainWindow(const VPuzzleCommandLinePtr &
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleApplication::InitOptions() void VPApplication::InitOptions()
{ {
qInstallMessageHandler(noisyFailureMsgHandler); qInstallMessageHandler(noisyFailureMsgHandler);
@ -382,7 +382,7 @@ void PuzzleApplication::InitOptions()
LoadTranslation(QLocale().name());// By default the console version uses system locale LoadTranslation(QLocale().name());// By default the console version uses system locale
VPuzzleCommandLine::Instance(*this); VPCommandLine::Instance(*this);
static const char * GENERIC_ICON_TO_CHECK = "document-open"; static const char * GENERIC_ICON_TO_CHECK = "document-open";
if (QIcon::hasThemeIcon(GENERIC_ICON_TO_CHECK) == false) if (QIcon::hasThemeIcon(GENERIC_ICON_TO_CHECK) == false)
@ -397,29 +397,29 @@ void PuzzleApplication::InitOptions()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
const VTranslateVars *PuzzleApplication::TrVars() const VTranslateVars *VPApplication::TrVars()
{ {
return nullptr; return nullptr;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleApplication::OpenSettings() void VPApplication::OpenSettings()
{ {
settings = new VPuzzleSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), settings = new VPSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(),
QCoreApplication::applicationName(), this); QCoreApplication::applicationName(), this);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleSettings *PuzzleApplication::PuzzleSettings() VPSettings *VPApplication::PuzzleSettings()
{ {
SCASSERT(settings != nullptr) SCASSERT(settings != nullptr)
return qobject_cast<VPuzzleSettings *>(settings); return qobject_cast<VPSettings *>(settings);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleApplication::ActivateDarkMode() void VPApplication::ActivateDarkMode()
{ {
VPuzzleSettings *settings = qApp->PuzzleSettings(); VPSettings *settings = qApp->PuzzleSettings();
if (settings->GetDarkMode()) if (settings->GetDarkMode())
{ {
QFile f(":qdarkstyle/style.qss"); QFile f(":qdarkstyle/style.qss");
@ -437,10 +437,10 @@ void PuzzleApplication::ActivateDarkMode()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleApplication::ParseCommandLine(const SocketConnection &connection, const QStringList &arguments) void VPApplication::ParseCommandLine(const SocketConnection &connection, const QStringList &arguments)
{ {
VPuzzleCommandLinePtr cmd; VPCommandLinePtr cmd;
VPuzzleCommandLine::ProcessInstance(cmd, arguments); VPCommandLine::ProcessInstance(cmd, arguments);
if (cmd->IsGuiEnabled() && connection == SocketConnection::Client) if (cmd->IsGuiEnabled() && connection == SocketConnection::Client)
{ {
@ -461,7 +461,7 @@ void PuzzleApplication::ParseCommandLine(const SocketConnection &connection, con
qCDebug(mApp, "Can't establish connection to the server '%s'", qUtf8Printable(serverName)); qCDebug(mApp, "Can't establish connection to the server '%s'", qUtf8Printable(serverName));
localServer = new QLocalServer(this); localServer = new QLocalServer(this);
connect(localServer, &QLocalServer::newConnection, this, &PuzzleApplication::NewLocalSocketConnection); connect(localServer, &QLocalServer::newConnection, this, &VPApplication::NewLocalSocketConnection);
if (not localServer->listen(serverName)) if (not localServer->listen(serverName))
{ {
qCDebug(mApp, "Can't begin to listen for incoming connections on name '%s'", qCDebug(mApp, "Can't begin to listen for incoming connections on name '%s'",
@ -484,7 +484,7 @@ void PuzzleApplication::ParseCommandLine(const SocketConnection &connection, con
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleApplication::ProcessArguments(const VPuzzleCommandLinePtr &cmd) void VPApplication::ProcessArguments(const VPCommandLinePtr &cmd)
{ {
const QStringList rawLayouts = cmd->OptionRawLayouts(); const QStringList rawLayouts = cmd->OptionRawLayouts();
const QStringList args = cmd->OptionFileNames(); const QStringList args = cmd->OptionFileNames();
@ -545,13 +545,13 @@ void PuzzleApplication::ProcessArguments(const VPuzzleCommandLinePtr &cmd)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleApplication::ProcessCMD() void VPApplication::ProcessCMD()
{ {
ParseCommandLine(SocketConnection::Client, arguments()); ParseCommandLine(SocketConnection::Client, arguments());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool PuzzleApplication::event(QEvent *e) bool VPApplication::event(QEvent *e)
{ {
switch(e->type()) switch(e->type())
{ {
@ -563,7 +563,7 @@ bool PuzzleApplication::event(QEvent *e)
const QString macFileOpen = fileOpenEvent->file(); const QString macFileOpen = fileOpenEvent->file();
if(not macFileOpen.isEmpty()) if(not macFileOpen.isEmpty())
{ {
PuzzleMainWindow *mw = MainWindow(); VPMainWindow *mw = MainWindow();
if (mw) if (mw)
{ {
mw->LoadFile(macFileOpen); // open file in existing window mw->LoadFile(macFileOpen); // open file in existing window
@ -576,7 +576,7 @@ bool PuzzleApplication::event(QEvent *e)
case QEvent::ApplicationActivate: case QEvent::ApplicationActivate:
{ {
Clean(); Clean();
PuzzleMainWindow *mw = MainWindow(); VPMainWindow *mw = MainWindow();
if (mw && not mw->isMinimized()) if (mw && not mw->isMinimized())
{ {
mw->show(); mw->show();
@ -591,13 +591,13 @@ bool PuzzleApplication::event(QEvent *e)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleApplication::InitTrVars() void VPApplication::InitTrVars()
{ {
// do nothing // do nothing
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleApplication::AboutToQuit() void VPApplication::AboutToQuit()
{ {
// If try to use the method QApplication::exit program can't sync settings and show warning about QApplication // If try to use the method QApplication::exit program can't sync settings and show warning about QApplication
// instance. Solution is to call sync() before quit. // instance. Solution is to call sync() before quit.
@ -606,7 +606,7 @@ void PuzzleApplication::AboutToQuit()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleApplication::NewLocalSocketConnection() void VPApplication::NewLocalSocketConnection()
{ {
QScopedPointer<QLocalSocket>socket(localServer->nextPendingConnection()); QScopedPointer<QLocalSocket>socket(localServer->nextPendingConnection());
if (socket.isNull()) if (socket.isNull())
@ -625,7 +625,7 @@ void PuzzleApplication::NewLocalSocketConnection()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleApplication::Clean() void VPApplication::Clean()
{ {
// cleanup any deleted main windows first // cleanup any deleted main windows first
for (int i = mainWindows.count() - 1; i >= 0; --i) for (int i = mainWindows.count() - 1; i >= 0; --i)
@ -638,7 +638,7 @@ void PuzzleApplication::Clean()
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
VPuzzleCommandLinePtr PuzzleApplication::CommandLine() const VPCommandLinePtr VPApplication::CommandLine() const
{ {
return VPuzzleCommandLine::instance; return VPCommandLine::instance;
} }

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file puzzleapplication.h ** @file vpapplication.h
** @author Roman Telezhynskyi <dismine(at)gmail.com> ** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 16 2, 2020 ** @date 16 2, 2020
** **
@ -25,52 +25,52 @@
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
*************************************************************************/ *************************************************************************/
#ifndef PUZZLEAPPLICATION_H #ifndef VPAPPLICATION_H
#define PUZZLEAPPLICATION_H #define VPAPPLICATION_H
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "vpuzzlesettings.h" #include "vpsettings.h"
#include "../vmisc/vabstractapplication.h" #include "../vmisc/vabstractapplication.h"
#include "vpuzzlecommandline.h" #include "vpcommandline.h"
#include <memory> #include <memory>
class PuzzleApplication;// use in define class VPApplication;// use in define
class PuzzleMainWindow; class VPMainWindow;
class QLocalServer; class QLocalServer;
#if defined(qApp) #if defined(qApp)
#undef qApp #undef qApp
#endif #endif
#define qApp (static_cast<PuzzleApplication*>(VAbstractApplication::instance())) #define qApp (static_cast<VPApplication*>(VAbstractApplication::instance()))
enum class SocketConnection : bool {Client = false, Server = true}; enum class SocketConnection : bool {Client = false, Server = true};
class PuzzleApplication : public VAbstractApplication class VPApplication : public VAbstractApplication
{ {
Q_OBJECT Q_OBJECT
public: public:
PuzzleApplication(int &argc, char **argv); VPApplication(int &argc, char **argv);
virtual ~PuzzleApplication() override; virtual ~VPApplication() override;
virtual bool notify(QObject * receiver, QEvent * event) override; virtual bool notify(QObject * receiver, QEvent * event) override;
virtual bool IsAppInGUIMode() const override; virtual bool IsAppInGUIMode() const override;
PuzzleMainWindow *MainWindow(); VPMainWindow *MainWindow();
QList<PuzzleMainWindow*> MainWindows(); QList<VPMainWindow*> MainWindows();
PuzzleMainWindow *NewMainWindow(const VPuzzleCommandLinePtr &cmd); VPMainWindow *NewMainWindow(const VPCommandLinePtr &cmd);
void InitOptions(); void InitOptions();
virtual const VTranslateVars *TrVars() override; virtual const VTranslateVars *TrVars() override;
virtual void OpenSettings() override; virtual void OpenSettings() override;
VPuzzleSettings *PuzzleSettings(); VPSettings *PuzzleSettings();
void ActivateDarkMode(); void ActivateDarkMode();
void ParseCommandLine(const SocketConnection &connection, const QStringList &arguments); void ParseCommandLine(const SocketConnection &connection, const QStringList &arguments);
void ProcessArguments(const VPuzzleCommandLinePtr &cmd); void ProcessArguments(const VPCommandLinePtr &cmd);
VPuzzleCommandLinePtr CommandLine() const; VPCommandLinePtr CommandLine() const;
public slots: public slots:
void ProcessCMD(); void ProcessCMD();
@ -85,11 +85,11 @@ private slots:
void NewLocalSocketConnection(); void NewLocalSocketConnection();
private: private:
Q_DISABLE_COPY(PuzzleApplication) Q_DISABLE_COPY(VPApplication)
QList<QPointer<PuzzleMainWindow> > mainWindows; QList<QPointer<VPMainWindow> > mainWindows;
QLocalServer *localServer; QLocalServer *localServer;
void Clean(); void Clean();
}; };
#endif // PUZZLEAPPLICATION_H #endif // VPAPPLICATION_H

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpiececarrousel.cpp ** @file vpcarrousel.cpp
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 13 4, 2020 ** @date 13 4, 2020
** **
@ -25,14 +25,16 @@
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
*************************************************************************/ *************************************************************************/
#include "vpiececarrousel.h" #include "vpcarrousel.h"
#include "ui_vpiececarrousel.h" #include "ui_vpcarrousel.h"
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QMessageBox> #include <QMessageBox>
#include <QScrollBar> #include <QScrollBar>
#include <QFontMetrics>
#include "../vmisc/backport/qoverload.h" #include "../vmisc/backport/qoverload.h"
#include "vpuzzlelayer.h" #include "vppiecelist.h"
#include "vpsheet.h"
#include <QLoggingCategory> #include <QLoggingCategory>
#include <QMenu> #include <QMenu>
@ -41,95 +43,82 @@
Q_LOGGING_CATEGORY(pCarrousel, "p.carrousel") Q_LOGGING_CATEGORY(pCarrousel, "p.carrousel")
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPieceCarrousel::VPieceCarrousel(VPuzzleLayout *layout, QWidget *parent) : VPCarrousel::VPCarrousel(VPLayout *layout, QWidget *parent) :
QWidget(parent), QWidget(parent),
ui(new Ui::VPieceCarrousel), ui(new Ui::VPCarrousel),
m_layout(layout) m_layout(layout)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->listWidget->SetCarrousel(this);
// init the combo box // init the combo box
connect(ui->comboBoxLayer, QOverload<int>::of(&QComboBox::currentIndexChanged), this, connect(ui->comboBoxPieceList, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&VPieceCarrousel::on_ActiveLayerChanged); &VPCarrousel::on_ActivePieceListChanged);
ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu);
// ------ then we fill the carrousel with the layout content // ------ then we fill the carrousel with the layout content
Refresh(); Refresh();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPieceCarrousel::Refresh() void VPCarrousel::Refresh()
{ {
// NOTE: alternative to clearing the carrousel and adding things again, we could make comparision
// --- clears the content of the carrousel // --- clears the content of the carrousel
Clear(); Clear();
// --- add the content saved in the layout to the carrousel. // --- add the content saved in the layout to the carrousel.
// Do not rely on m_layout because we do not control it. // Do not rely on m_layout because we do not control it.
m_layers = m_layout->GetLayers(); m_pieceLists = QList<VPPieceList*>();
m_layers.prepend(m_layout->GetUnplacedPiecesLayer()); m_pieceLists.append(m_layout->GetUnplacedPieceList());
m_pieceLists.append(m_layout->GetFocusedSheet()->GetPieceList());
for (auto layer : m_layers) ui->comboBoxPieceList->blockSignals(true);
{
// add layer name to combo
ui->comboBoxLayer->blockSignals(true);
ui->comboBoxLayer->addItem(layer->GetName());
ui->comboBoxLayer->blockSignals(false);
}
on_ActiveLayerChanged(0); ui->comboBoxPieceList->addItem(m_layout->GetUnplacedPieceList()->GetName());
ui->comboBoxPieceList->addItem(tr("Pieces of ") + m_layout->GetFocusedSheet()->GetName());
ui->comboBoxPieceList->blockSignals(false);
on_ActivePieceListChanged(0);
RefreshOrientation(); RefreshOrientation();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPieceCarrousel::Clear() void VPCarrousel::Clear()
{ {
// remove the combobox entries // remove the combobox entries
ui->comboBoxLayer->clear(); ui->comboBoxPieceList->clear();
ui->listWidget->clear(); ui->listWidget->clear();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPieceCarrousel::on_ActiveLayerChanged(int index) void VPCarrousel::on_ActivePieceListChanged(int index)
{ {
qCDebug(pCarrousel, "index changed %i", index); qCDebug(pCarrousel, "index changed %i", index);
ui->listWidget->clear(); if (index >= 0 && index < m_pieceLists.size())
if (index >= 0 && index < m_layers.size())
{ {
VPuzzleLayer *layer = m_layers.at(index); VPPieceList *pieceList = m_pieceLists.at(index);
if (layer) ui->listWidget->SetCurrentPieceList(pieceList);
{
QList<VPuzzlePiece*> pieces = layer->GetPieces();
for (auto piece : pieces)
{
new QListWidgetItem(piece->PieceIcon(QSize(120, 120)) , piece->GetName(), ui->listWidget);
}
}
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPieceCarrousel::SetOrientation(Qt::Orientation orientation) void VPCarrousel::SetOrientation(Qt::Orientation orientation)
{ {
m_orientation = orientation; m_orientation = orientation;
RefreshOrientation(); RefreshOrientation();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPieceCarrousel::RefreshOrientation() void VPCarrousel::RefreshOrientation()
{ {
// then update the scrollarea min height / width and scrollbar behaviour // then update the scrollarea min height / width and scrollbar behaviour
if(m_orientation == Qt::Horizontal) if(m_orientation == Qt::Horizontal)
{ {
ui->comboBoxLayer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); ui->comboBoxPieceList->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
// scroll bar policy of scroll area // scroll bar policy of scroll area
ui->listWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); ui->listWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
@ -139,7 +128,7 @@ void VPieceCarrousel::RefreshOrientation()
} }
else // Qt::Vertical else // Qt::Vertical
{ {
ui->comboBoxLayer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); ui->comboBoxPieceList->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
// scroll bar policy of scroll area // scroll bar policy of scroll area
ui->listWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); ui->listWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
@ -150,7 +139,17 @@ void VPieceCarrousel::RefreshOrientation()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPieceCarrousel::ClearSelection() void VPCarrousel::ClearSelection()
{ {
m_layout->ClearSelection(); m_layout->ClearSelection();
} }
//---------------------------------------------------------------------------------------------------------------------
void VPCarrousel::ClearSelectionExceptForCurrentPieceList()
{
if (m_layout != nullptr)
{
m_layout->ClearSelectionExceptForGivenPieceList(ui->listWidget->GetCurrentPieceList());
}
}

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpiececarrousel.h ** @file vpcarrousel.h
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 13 04, 2020 ** @date 13 04, 2020
** **
@ -26,26 +26,26 @@
** **
*************************************************************************/ *************************************************************************/
#ifndef VPIECECARROUSEL_H #ifndef VPCARROUSEL_H
#define VPIECECARROUSEL_H #define VPCARROUSEL_H
#include <QWidget> #include <QWidget>
#include <QComboBox> #include <QComboBox>
#include <QScrollArea> #include <QScrollArea>
#include "vpuzzlelayout.h" #include "vplayout.h"
#include "vpuzzlepiece.h" #include "vppiece.h"
namespace Ui namespace Ui
{ {
class VPieceCarrousel; class VPCarrousel;
} }
class VPieceCarrousel : public QWidget class VPCarrousel : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit VPieceCarrousel(VPuzzleLayout *layout, QWidget *parent = nullptr); explicit VPCarrousel(VPLayout *layout, QWidget *parent = nullptr);
virtual ~VPieceCarrousel() = default; virtual ~VPCarrousel() = default;
/** /**
* @brief SetOrientation Sets the orientation to the given value and refreshes * @brief SetOrientation Sets the orientation to the given value and refreshes
@ -75,12 +75,19 @@ public:
*/ */
void ClearSelection(); void ClearSelection();
private: /**
Q_DISABLE_COPY(VPieceCarrousel) * @brief ClearSelectionExceptForCurrentPieceList Clears the selection of all pieces of
Ui::VPieceCarrousel *ui; * the layout except for the one in the current piece list
*/
void ClearSelectionExceptForCurrentPieceList();
VPuzzleLayout *m_layout; private:
QList<VPuzzleLayer*> m_layers{}; Q_DISABLE_COPY(VPCarrousel)
Ui::VPCarrousel *ui;
VPLayout *m_layout{nullptr};
QList<VPPieceList*> m_pieceLists{};
Qt::Orientation m_orientation{Qt::Vertical}; Qt::Orientation m_orientation{Qt::Vertical};
@ -88,10 +95,10 @@ private:
private slots: private slots:
/** /**
* @brief on_ActiveLayerChanged Called when the active layer is changed * @brief on_ActivePieceListChanged Called when the active piece list is changed
* @param index * @param index
*/ */
void on_ActiveLayerChanged(int index); void on_ActivePieceListChanged(int index);
}; };
#endif // VPIECECARROUSEL_H #endif // VPCARROUSEL_H

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>VPieceCarrousel</class> <class>VPCarrousel</class>
<widget class="QWidget" name="VPieceCarrousel"> <widget class="QWidget" name="VPCarrousel">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
@ -27,7 +27,7 @@
<number>6</number> <number>6</number>
</property> </property>
<item> <item>
<widget class="QComboBox" name="comboBoxLayer"> <widget class="QComboBox" name="comboBoxPieceList">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -37,12 +37,12 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QListWidget" name="listWidget"> <widget class="VPCarrouselPieceList" name="listWidget">
<property name="verticalScrollBarPolicy"> <property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum> <enum>Qt::ScrollBarAlwaysOn</enum>
</property> </property>
<property name="dragDropMode"> <property name="dragDropMode">
<enum>QAbstractItemView::DragOnly</enum> <enum>QAbstractItemView::NoDragDrop</enum>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
@ -72,6 +72,13 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>VPCarrouselPieceList</class>
<extends>QListWidget</extends>
<header>vpcarrouselpiecelist.h</header>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

View File

@ -0,0 +1,122 @@
/************************************************************************
**
** @file vpcarrouselpiece.cpp
** @author Ronan Le Tiec
** @date 25 4, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vpcarrouselpiece.h"
#include <QApplication>
#include <QMenu>
#include <QPainter>
#include "vpmimedatapiece.h"
#include "vpcarrouselpiecelist.h"
#include "vpcarrousel.h"
#include "vpsheet.h"
#include <QLoggingCategory>
Q_LOGGING_CATEGORY(pCarrouselPiece, "p.carrouselPiece")
//---------------------------------------------------------------------------------------------------------------------
VPCarrouselPiece::VPCarrouselPiece(VPPiece *piece, QListWidget* parent) :
QListWidgetItem(parent,1001),
m_piece(piece)
{
int width = 120 - 8;
QFontMetrics metrix = QFontMetrics(QFont());
QString clippedText = metrix.elidedText(piece->GetName(), Qt::ElideRight, width);
setIcon(CreatePieceIcon(QSize(120, 120)));
setText(clippedText);
}
//---------------------------------------------------------------------------------------------------------------------
VPCarrouselPiece::~VPCarrouselPiece()
{
}
//---------------------------------------------------------------------------------------------------------------------
VPPiece * VPCarrouselPiece::GetPiece()
{
return m_piece;
}
//---------------------------------------------------------------------------------------------------------------------
void VPCarrouselPiece::RefreshSelection()
{
setSelected(m_piece->GetIsSelected());
}
//---------------------------------------------------------------------------------------------------------------------
QIcon VPCarrouselPiece::CreatePieceIcon(const QSize &size) const
{
QVector<QPointF> points = m_piece->GetSeamLine();
if(points.isEmpty())
{
points = m_piece->GetCuttingLine();
}
QPolygonF shape(points);
shape << shape.first();
QRectF boundingRect = shape.boundingRect();
qreal canvasSize = qMax(boundingRect.height(), boundingRect.width());
QRectF canvas = QRectF(0, 0, canvasSize, canvasSize);
qreal dx = canvas.center().x() - boundingRect.center().x();
qreal dy = canvas.center().y() - boundingRect.center().y();
QPixmap pixmap(size);
pixmap.fill(QColor("white"));
QPainter painter;
painter.begin(&pixmap);
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::SmoothPixmapTransform);
int spacing = 2;
painter.translate(spacing, spacing);
qreal scaleFactorX = canvasSize * 100 / (size.width() - spacing*2) / 100;
qreal scaleFactorY = canvasSize * 100 / (size.height() - spacing*2) / 100;
painter.scale(1./scaleFactorX, 1./scaleFactorY);
painter.setPen(QPen(Qt::black, 0.8*qMax(scaleFactorX, scaleFactorY)));
painter.translate(dx, dy);
painter.drawPolygon(shape);
painter.end();
QIcon icon;
icon.addPixmap(pixmap,QIcon::Normal);
icon.addPixmap(pixmap,QIcon::Selected);
return icon;
}

View File

@ -1,8 +1,8 @@
/************************************************************************ /************************************************************************
** **
** @file vpiececarrouselpiecepreview.h ** @file vpcarrouselpiece.h
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 3 5, 2020 ** @date 25 4, 2020
** **
** @brief ** @brief
** @copyright ** @copyright
@ -25,21 +25,45 @@
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
*************************************************************************/ *************************************************************************/
#ifndef VPCARROUSELPIECE_H
#define VPCARROUSELPIECE_H
#ifndef VPUZZLEPIECECARROUSELPIECEPREVIEW_H #include <QMouseEvent>
#define VPUZZLEPIECECARROUSELPIECEPREVIEW_H #include <QListWidgetItem>
#include <QGraphicsView> #include "vppiece.h"
class VPieceCarrouselPiecePreview: public QGraphicsView
class VPCarrouselPiece : public QListWidgetItem
{ {
public: public:
VPieceCarrouselPiecePreview(QWidget *parent = nullptr); explicit VPCarrouselPiece(VPPiece *piece, QListWidget* parent);
~VPieceCarrouselPiecePreview(); ~VPCarrouselPiece();
/**
* @brief GetPiece Returns the corresponding layout piece
* @return the corresponding layout piece
*/
VPPiece * GetPiece();
/**
* @brief RefreshSelection refreshes the selection of the piece according to the selection information of m_piece
*/
void RefreshSelection();
/**
* @brief CreatePieceIcon Creates an icon of the piece of given size
* @param size of the icon
* @return the created icon
*/
QIcon CreatePieceIcon(const QSize &size) const;
private:
VPPiece *m_piece;
private slots:
protected:
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
}; };
#endif // VPUZZLEPIECECARROUSELPIECEPREVIEW_H #endif // VPCARROUSELPIECE_H

View File

@ -0,0 +1,307 @@
/************************************************************************
**
** @file vpcarrouselpiecelist.cpp
** @author Ronan Le Tiec
** @date 25 4, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vpcarrouselpiecelist.h"
#include <QDrag>
#include <QDragMoveEvent>
#include <QPainter>
#include <QApplication>
#include <QMenu>
#include "vpcarrousel.h"
#include "vpcarrouselpiece.h"
#include "../vmisc/backport/qoverload.h"
#include "vpmimedatapiece.h"
#include <QLoggingCategory>
Q_LOGGING_CATEGORY(pCarrouselPieceList, "p.carrouselPieceList")
//---------------------------------------------------------------------------------------------------------------------
VPCarrouselPieceList::VPCarrouselPieceList(QWidget* parent) :
QListWidget(parent),
m_dragStart(QPoint())
{
setStyleSheet("QListWidget::item{border: 2px solid transparent; color: black;} QListWidget::item:selected {border: 2px solid red;}");
setContextMenuPolicy(Qt::DefaultContextMenu);
setSelectionMode(QAbstractItemView::MultiSelection);
setViewMode(QListView::IconMode);
connect(this, &VPCarrouselPieceList::itemSelectionChanged, this, &VPCarrouselPieceList::on_SelectionChangedInternal);
}
//---------------------------------------------------------------------------------------------------------------------
VPCarrouselPieceList::~VPCarrouselPieceList()
{
}
//---------------------------------------------------------------------------------------------------------------------
void VPCarrouselPieceList::SetCarrousel(VPCarrousel *carrousel)
{
m_carrousel = carrousel;
}
//---------------------------------------------------------------------------------------------------------------------
void VPCarrouselPieceList::Refresh()
{
clear();
if(m_pieceList != nullptr)
{
m_pieceList->disconnect(this);
// Updates the carrousel pieces from the pieces list
QList<VPPiece*> pieces = m_pieceList->GetPieces();
// create the corresponding carrousel pieces
for (auto piece : pieces)
{
// update the label of the piece
VPCarrouselPiece* carrouselpiece = new VPCarrouselPiece(piece,this);
carrouselpiece->setSelected(piece->GetIsSelected());
connect(piece, &VPPiece::SelectionChanged, this, &VPCarrouselPieceList::on_SelectionChangedExternal);
}
sortItems();
connect(m_pieceList, &VPPieceList::PieceAdded, this, &VPCarrouselPieceList::on_PieceAdded);
connect(m_pieceList, &VPPieceList::PieceRemoved, this, &VPCarrouselPieceList::on_PieceRemoved);
}
}
//---------------------------------------------------------------------------------------------------------------------
VPPieceList* VPCarrouselPieceList::GetCurrentPieceList()
{
return m_pieceList;
}
//---------------------------------------------------------------------------------------------------------------------
void VPCarrouselPieceList::SetCurrentPieceList(VPPieceList* pieceList)
{
m_pieceList = pieceList;
Refresh();
}
//---------------------------------------------------------------------------------------------------------------------
void VPCarrouselPieceList::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{
m_dragStart = event->pos();
}
if (!(event->modifiers() & Qt::ControlModifier))
{
// clearSelection doesn't work properly here so we go through the elements.
for(auto item: selectedItems())
{
item->setSelected(false);
}
}
QListWidget::mousePressEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
void VPCarrouselPieceList::mouseMoveEvent(QMouseEvent *event)
{
if ((event->buttons() & Qt::LeftButton) &&
((event->pos() - m_dragStart).manhattanLength() >= QApplication::startDragDistance()) &&
(selectedItems().count() > 0) &&
(m_pieceList->GetSheet() == nullptr)) // only if it's from unplaced pieces
{
startDrag(Qt::MoveAction);
}
else
{
QListWidget::mouseMoveEvent(event);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPCarrouselPieceList::startDrag(Qt::DropActions supportedActions)
{
Q_UNUSED(supportedActions)
QListWidgetItem* _item = currentItem();
if(_item->type() == 1001)
{
VPCarrouselPiece *pieceItem = static_cast<VPCarrouselPiece *> (_item);
// starts the dragging
QDrag *drag = new QDrag(this);
VPMimeDataPiece *mimeData = new VPMimeDataPiece();
VPPiece* piece = pieceItem->GetPiece();
mimeData->SetPiecePtr(piece);
mimeData->setObjectName("piecePointer");
QPixmap pixmap = pieceItem->CreatePieceIcon(QSize(120,120)).pixmap(QSize(120,120));
drag->setPixmap(pixmap);
drag->setMimeData(mimeData);
if(drag->exec() == Qt::MoveAction)
{
delete takeItem(row(_item));
clearSelection();
piece->SetIsSelected(true);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPCarrouselPieceList::dragMoveEvent(QDragMoveEvent* e)
{
qCDebug(pCarrouselPieceList, "drag move");
e->acceptProposedAction();
}
//---------------------------------------------------------------------------------------------------------------------
void VPCarrouselPieceList::contextMenuEvent(QContextMenuEvent *event)
{
QListWidgetItem* _item = currentItem();
if(_item->type() == 1001)
{
VPCarrouselPiece *pieceItem = static_cast<VPCarrouselPiece *> (_item);
QMenu contextMenu;
if(m_pieceList->GetSheet() == nullptr)
{
VPPieceList* sheetPieces = pieceItem->GetPiece()->GetPieceList()->GetLayout()->GetFocusedSheet()->GetPieceList();
QAction *moveAction = contextMenu.addAction(tr("Move to Sheet"));
QVariant data = QVariant::fromValue(sheetPieces);
moveAction->setData(data);
connect(moveAction, &QAction::triggered, this, &VPCarrouselPieceList::on_ActionPieceMovedToPieceList);
}
// remove from piece list action
if(m_pieceList->GetSheet() != nullptr)
{
VPPieceList* unplacedPieces = pieceItem->GetPiece()->GetPieceList()->GetLayout()->GetUnplacedPieceList();
QAction *removeAction = contextMenu.addAction(tr("Remove from Sheet"));
QVariant data = QVariant::fromValue(unplacedPieces);
removeAction->setData(data);
connect(removeAction, &QAction::triggered, this, &VPCarrouselPieceList::on_ActionPieceMovedToPieceList);
}
contextMenu.exec(event->globalPos());
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPCarrouselPieceList::on_ActionPieceMovedToPieceList()
{
QListWidgetItem* _item = currentItem();
if(_item->type() == 1001)
{
VPCarrouselPiece *pieceItem = static_cast<VPCarrouselPiece *> (_item);
QAction *act = qobject_cast<QAction *>(sender());
QVariant v = act->data();
VPPieceList *pieceList = v.value<VPPieceList *>();
if(pieceList != nullptr)
{
pieceList->GetLayout()->MovePieceToPieceList(pieceItem->GetPiece(), pieceList);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPCarrouselPieceList::on_PieceAdded(VPPiece* piece)
{
if(piece->GetPieceList() == m_pieceList)
{
// update the label of the piece
VPCarrouselPiece* carrouselpiece = new VPCarrouselPiece(piece,this);
carrouselpiece->setSelected(piece->GetIsSelected());
connect(piece, &VPPiece::SelectionChanged, this, &VPCarrouselPieceList::on_SelectionChangedExternal);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPCarrouselPieceList::on_PieceRemoved(VPPiece* piece)
{
for(int i = 0; i < count(); ++i)
{
QListWidgetItem* _item = item(i);
if(_item->type() == 1001)
{
VPCarrouselPiece *itemPiece = static_cast<VPCarrouselPiece *> (_item);
if(piece == itemPiece->GetPiece())
{
delete takeItem(row(_item));
return;
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPCarrouselPieceList::on_SelectionChangedInternal()
{
blockSignals(true);
for(int i = 0; i < count(); ++i)
{
QListWidgetItem* _item = item(i);
if(_item->type() == 1001)
{
VPCarrouselPiece *itemPiece = static_cast<VPCarrouselPiece *> (_item);
itemPiece->GetPiece()->SetIsSelected(itemPiece->isSelected());
}
}
m_carrousel->ClearSelectionExceptForCurrentPieceList();
// TODO FIXME: when selecting pieces on the sheet, and then selecting a unplaced piece in the piece carrousel
// the selection is cleared in the sheet (good !) but the cliked item in unplaced pieces in not selected (bad!)
blockSignals(false);
}
//---------------------------------------------------------------------------------------------------------------------
void VPCarrouselPieceList::on_SelectionChangedExternal()
{
blockSignals(true);
for(int i = 0; i < count(); ++i)
{
QListWidgetItem* _item = item(i);
if(_item->type() == 1001)
{
VPCarrouselPiece *itemPiece = static_cast<VPCarrouselPiece *> (_item);
itemPiece->RefreshSelection();
}
}
blockSignals(false);
}

View File

@ -0,0 +1,114 @@
/************************************************************************
**
** @file vpcarrouselpiecelist.h
** @author Ronan Le Tiec
** @date 25 4, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VPCARROUSELPIECELIST_H
#define VPCARROUSELPIECELIST_H
#include <QListWidget>
#include "vppiecelist.h"
#include "vpcarrousel.h"
class VPCarrouselPieceList : public QListWidget
{
Q_OBJECT
public:
VPCarrouselPieceList(QWidget* parent);
~VPCarrouselPieceList();
/**
* @brief Refresh refreshes the items of the carrousel piece list
*/
void Refresh();
/**
* @brief GetPieceList Returns the corresponding VPPieceList
* @return the VPPieceList
*/
VPPieceList* GetCurrentPieceList();
/**
* @brief SetCurrentPieceList Sets the current piece list to the given piece list and redraw
* the carrousel.
*/
void SetCurrentPieceList(VPPieceList *pieceList);
/**
* @brief SetCarrousel Sets the carrousel corresponding to the list
* @param carrousel
*/
void SetCarrousel(VPCarrousel *carrousel);
public slots:
/**
* @brief on_SelectionChangedExternal when the selection was changed outside of the carrousel
*/
void on_SelectionChangedExternal();
protected:
void startDrag(Qt::DropActions supportedActions) override;
void dragMoveEvent(QDragMoveEvent* e) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void contextMenuEvent(QContextMenuEvent *event) override;
private:
Q_DISABLE_COPY(VPCarrouselPieceList)
VPPieceList *m_pieceList{nullptr};
QPoint m_dragStart;
VPCarrousel *m_carrousel{nullptr};
private slots:
/**
* @brief on_PieceUpdated This slot is called when a piece was added
*/
void on_PieceAdded(VPPiece* piece);
/**
* @brief on_PieceUpdated This slot is called when a piece was removed
*/
void on_PieceRemoved(VPPiece* piece);
/**
* @brief on_SelectionChangedInternal when the selection was changed inside of the carrousel
*/
void on_SelectionChangedInternal();
/**
* @brief on_ActionPieceMovedToPieceList when a piece is moved to another piece list via a context menu
*/
void on_ActionPieceMovedToPieceList();
};
#endif // VPCARROUSELPIECELIST_H

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlecommandline.cpp ** @file vpcommandline.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com> ** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 12 4, 2020 ** @date 12 4, 2020
** **
@ -25,31 +25,31 @@
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
*************************************************************************/ *************************************************************************/
#include "vpuzzlecommandline.h" #include "vpcommandline.h"
#include "puzzlecommands.h" #include "vpcommands.h"
#include "../vmisc/vsysexits.h" #include "../vmisc/vsysexits.h"
#include "../vmisc/literals.h" #include "../vmisc/literals.h"
#include <QDebug> #include <QDebug>
std::shared_ptr<VPuzzleCommandLine> VPuzzleCommandLine::instance = nullptr; std::shared_ptr<VPCommandLine> VPCommandLine::instance = nullptr;
#define translate(context, source) QCoreApplication::translate((context), source) #define translate(context, source) QCoreApplication::translate((context), source)
//------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------
bool VPuzzleCommandLine::IsExportEnabled() const bool VPCommandLine::IsExportEnabled() const
{ {
const bool result = IsOptionSet(LONG_OPTION_EXPORT_FILE); const bool result = IsOptionSet(LONG_OPTION_EXPORT_FILE);
int argSize = parser.positionalArguments().size(); int argSize = parser.positionalArguments().size();
if (result && argSize != 1) if (result && argSize != 1)
{ {
qCritical() << translate("Puzzle", "Export options can be used with single input file only.") << "/n"; qCritical() << translate("Puzzle", "Export options can be used with single input file only.") << "/n";
const_cast<VPuzzleCommandLine*>(this)->parser.showHelp(V_EX_USAGE); const_cast<VPCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
} }
return result; return result;
} }
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
QString VPuzzleCommandLine::OptionExportFile() const QString VPCommandLine::OptionExportFile() const
{ {
QString path; QString path;
if (IsExportEnabled()) if (IsExportEnabled())
@ -61,49 +61,49 @@ QString VPuzzleCommandLine::OptionExportFile() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QStringList VPuzzleCommandLine::OptionRawLayouts() const QStringList VPCommandLine::OptionRawLayouts() const
{ {
return OptionValues(LONG_OPTION_RAW_LAYOUT); return OptionValues(LONG_OPTION_RAW_LAYOUT);
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
bool VPuzzleCommandLine::IsTestModeEnabled() const bool VPCommandLine::IsTestModeEnabled() const
{ {
const bool r = IsOptionSet(LONG_OPTION_TEST); const bool r = IsOptionSet(LONG_OPTION_TEST);
if (r && parser.positionalArguments().size() != 1) if (r && parser.positionalArguments().size() != 1)
{ {
qCritical() << translate("VCommandLine", "Test option can be used with single input file only.") << "/n"; qCritical() << translate("VCommandLine", "Test option can be used with single input file only.") << "/n";
const_cast<VPuzzleCommandLine*>(this)->parser.showHelp(V_EX_USAGE); const_cast<VPCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
} }
return r; return r;
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
bool VPuzzleCommandLine::IsGuiEnabled() const bool VPCommandLine::IsGuiEnabled() const
{ {
return isGuiEnabled; return isGuiEnabled;
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
QStringList VPuzzleCommandLine::OptionFileNames() const QStringList VPCommandLine::OptionFileNames() const
{ {
return parser.positionalArguments(); return parser.positionalArguments();
} }
//------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------
bool VPuzzleCommandLine::IsNoScalingEnabled() const bool VPCommandLine::IsNoScalingEnabled() const
{ {
return IsOptionSet(LONG_OPTION_NO_HDPI_SCALING); return IsOptionSet(LONG_OPTION_NO_HDPI_SCALING);
} }
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
void VPuzzleCommandLine::ShowHelp(int exitCode) void VPCommandLine::ShowHelp(int exitCode)
{ {
parser.showHelp(exitCode); parser.showHelp(exitCode);
} }
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
VPuzzleCommandLine::VPuzzleCommandLine(): VPCommandLine::VPCommandLine():
parser(), parser(),
isGuiEnabled(false) isGuiEnabled(false)
{ {
@ -116,18 +116,18 @@ VPuzzleCommandLine::VPuzzleCommandLine():
} }
//------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------
VPuzzleCommandLinePtr VPuzzleCommandLine::Instance(const QCoreApplication &app) VPCommandLinePtr VPCommandLine::Instance(const QCoreApplication &app)
{ {
VPuzzleCommandLine::ProcessInstance(instance, app.arguments()); VPCommandLine::ProcessInstance(instance, app.arguments());
return instance; return instance;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleCommandLine::ProcessInstance(VPuzzleCommandLinePtr &instance, const QStringList &arguments) void VPCommandLine::ProcessInstance(VPCommandLinePtr &instance, const QStringList &arguments)
{ {
if (instance == nullptr) if (instance == nullptr)
{ {
instance.reset(new VPuzzleCommandLine); instance.reset(new VPCommandLine);
} }
instance->parser.process(arguments); instance->parser.process(arguments);
@ -135,7 +135,7 @@ void VPuzzleCommandLine::ProcessInstance(VPuzzleCommandLinePtr &instance, const
} }
//------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------
void VPuzzleCommandLine::InitCommandLineOptions() void VPCommandLine::InitCommandLineOptions()
{ {
//keep in mind order here - that is how user will see it, so group-up for usability //keep in mind order here - that is how user will see it, so group-up for usability
//================================================================================================================= //=================================================================================================================
@ -193,19 +193,19 @@ void VPuzzleCommandLine::InitCommandLineOptions()
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
bool VPuzzleCommandLine::IsOptionSet(const QString &option) const bool VPCommandLine::IsOptionSet(const QString &option) const
{ {
return parser.isSet(option); return parser.isSet(option);
} }
//------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------
QString VPuzzleCommandLine::OptionValue(const QString &option) const QString VPCommandLine::OptionValue(const QString &option) const
{ {
return parser.value(option); return parser.value(option);
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
QStringList VPuzzleCommandLine::OptionValues(const QString &option) const QStringList VPCommandLine::OptionValues(const QString &option) const
{ {
return parser.values(option); return parser.values(option);
} }

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlecommandline.h ** @file vpcommandline.h
** @author Dmytro Hladkykh <vorzelmir@gmail.com> ** @author Dmytro Hladkykh <vorzelmir@gmail.com>
** @date 12 4, 2020 ** @date 12 4, 2020
** **
@ -25,21 +25,21 @@
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
*************************************************************************/ *************************************************************************/
#ifndef VPUZZLECOMMANDLINE_H #ifndef VPCOMMANDLINE_H
#define VPUZZLECOMMANDLINE_H #define VPCOMMANDLINE_H
#include <memory> #include <memory>
#include <QCoreApplication> #include <QCoreApplication>
#include <QCommandLineParser> #include <QCommandLineParser>
class VPuzzleCommandLine; class VPCommandLine;
using VPuzzleCommandLinePtr = std::shared_ptr<VPuzzleCommandLine>; using VPCommandLinePtr = std::shared_ptr<VPCommandLine>;
class VPuzzleCommandLine: public QObject class VPCommandLine: public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
virtual ~VPuzzleCommandLine() = default; virtual ~VPCommandLine() = default;
/** @brief if user enabled export from cmd */ /** @brief if user enabled export from cmd */
bool IsExportEnabled() const; bool IsExportEnabled() const;
@ -64,17 +64,17 @@ public:
Q_NORETURN void ShowHelp(int exitCode = 0); Q_NORETURN void ShowHelp(int exitCode = 0);
protected: protected:
VPuzzleCommandLine(); VPCommandLine();
/** @brief create the single instance of the class inside puzzleapplication */ /** @brief create the single instance of the class inside vpapplication */
static VPuzzleCommandLinePtr Instance(const QCoreApplication &app); static VPCommandLinePtr Instance(const QCoreApplication &app);
static void ProcessInstance(VPuzzleCommandLinePtr &instance, const QStringList &arguments); static void ProcessInstance(VPCommandLinePtr &instance, const QStringList &arguments);
private: private:
Q_DISABLE_COPY(VPuzzleCommandLine) Q_DISABLE_COPY(VPCommandLine)
static VPuzzleCommandLinePtr instance; static VPCommandLinePtr instance;
QCommandLineParser parser; QCommandLineParser parser;
bool isGuiEnabled; bool isGuiEnabled;
friend class PuzzleApplication; friend class VPApplication;
/** @brief add options to the QCommandLineParser that there are in the cmd can be */ /** @brief add options to the QCommandLineParser that there are in the cmd can be */
void InitCommandLineOptions(); void InitCommandLineOptions();
@ -84,4 +84,4 @@ private:
QStringList OptionValues(const QString &option) const; QStringList OptionValues(const QString &option) const;
}; };
#endif // VPUZZLECOMMANDLINE_H #endif // VPCOMMANDLINE_H

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file commands.cpp ** @file vpcommands.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com> ** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 13 4, 2020 ** @date 13 4, 2020
** **
@ -25,7 +25,7 @@
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
*************************************************************************/ *************************************************************************/
#include "puzzlecommands.h" #include "vpcommands.h"
#include <QStringList> #include <QStringList>

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file commands.h ** @file vpcommands.h
** @author Roman Telezhynskyi <dismine(at)gmail.com> ** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 13 4, 2020 ** @date 13 4, 2020
** **
@ -25,8 +25,8 @@
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
*************************************************************************/ *************************************************************************/
#ifndef COMMANDS_H #ifndef VPCOMMANDS_H
#define COMMANDS_H #define VPCOMMANDS_H
#include <QString> #include <QString>
@ -60,4 +60,4 @@ extern const QString LONG_OPTION_TILED_PDF_LANDSCAPE;
QStringList AllKeys(); QStringList AllKeys();
#endif // COMMANDS_H #endif // VPCOMMANDS_H

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlegraphicspiece.cpp ** @file vpgraphicspiece.cpp
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 4 5, 2020 ** @date 4 5, 2020
** **
@ -26,7 +26,7 @@
** **
*************************************************************************/ *************************************************************************/
#include "vpuzzlegraphicspiece.h" #include "vpgraphicspiece.h"
#include <QPen> #include <QPen>
#include <QBrush> #include <QBrush>
@ -39,15 +39,16 @@
#include <QtMath> #include <QtMath>
#include <QGraphicsScene> #include <QGraphicsScene>
#include "vpuzzlepiece.h" #include "vppiece.h"
#include "vpuzzlelayer.h" #include "vppiecelist.h"
#include "vpuzzlelayout.h" #include "vplayout.h"
#include "vpsheet.h"
#include <QLoggingCategory> #include <QLoggingCategory>
Q_LOGGING_CATEGORY(pGraphicsPiece, "p.graphicsPiece") Q_LOGGING_CATEGORY(pGraphicsPiece, "p.graphicsPiece")
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleGraphicsPiece::VPuzzleGraphicsPiece(VPuzzlePiece *piece, QGraphicsItem *parent) : VPGraphicsPiece::VPGraphicsPiece(VPPiece *piece, QGraphicsItem *parent) :
QGraphicsObject(parent), QGraphicsObject(parent),
m_piece(piece), m_piece(piece),
m_cuttingLine(QPainterPath()), m_cuttingLine(QPainterPath()),
@ -59,13 +60,13 @@ VPuzzleGraphicsPiece::VPuzzleGraphicsPiece(VPuzzlePiece *piece, QGraphicsItem *p
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleGraphicsPiece::~VPuzzleGraphicsPiece() VPGraphicsPiece::~VPGraphicsPiece()
{ {
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleGraphicsPiece::Init() void VPGraphicsPiece::Init()
{ {
// set some infos // set some infos
setFlags(ItemIsSelectable | ItemIsMovable | ItemSendsGeometryChanges); setFlags(ItemIsSelectable | ItemIsMovable | ItemSendsGeometryChanges);
@ -74,39 +75,47 @@ void VPuzzleGraphicsPiece::Init()
// initialises the seam line // initialises the seam line
QVector<QPointF> seamLinePoints = m_piece->GetSeamLine(); QVector<QPointF> seamLinePoints = m_piece->GetSeamLine();
if(!seamLinePoints.isEmpty())
{
m_seamLine.moveTo(seamLinePoints.first()); m_seamLine.moveTo(seamLinePoints.first());
for (int i = 1; i < seamLinePoints.size(); ++i) for (int i = 1; i < seamLinePoints.size(); ++i)
m_seamLine.lineTo(seamLinePoints.at(i)); m_seamLine.lineTo(seamLinePoints.at(i));
}
// initiliases the cutting line // initiliases the cutting line
QVector<QPointF> cuttingLinepoints = m_piece->GetCuttingLine(); QVector<QPointF> cuttingLinepoints = m_piece->GetCuttingLine();
if(!cuttingLinepoints.isEmpty())
{
m_cuttingLine.moveTo(cuttingLinepoints.first()); m_cuttingLine.moveTo(cuttingLinepoints.first());
for (int i = 1; i < cuttingLinepoints.size(); ++i) for (int i = 1; i < cuttingLinepoints.size(); ++i)
m_cuttingLine.lineTo(cuttingLinepoints.at(i)); m_cuttingLine.lineTo(cuttingLinepoints.at(i));
}
// initialises the grainline // initialises the grainline
QVector<QPointF> grainLinepoints = m_piece->GetGrainline(); QVector<QPointF> grainLinepoints = m_piece->GetGrainline();
if(!grainLinepoints.isEmpty())
{
m_grainline.moveTo(grainLinepoints.first()); m_grainline.moveTo(grainLinepoints.first());
for (int i = 1; i < grainLinepoints.size(); ++i) for (int i = 1; i < grainLinepoints.size(); ++i)
m_grainline.lineTo(grainLinepoints.at(i)); m_grainline.lineTo(grainLinepoints.at(i));
}
// TODO : initialises the other elements labels, passmarks etc. // TODO : initialises the other elements labels, passmarks etc.
// Initialises the connectors // Initialises the connectors
connect(m_piece, &VPuzzlePiece::SelectionChanged, this, &VPuzzleGraphicsPiece::on_PieceSelectionChanged); connect(m_piece, &VPPiece::SelectionChanged, this, &VPGraphicsPiece::on_PieceSelectionChanged);
connect(m_piece, &VPuzzlePiece::PositionChanged, this, &VPuzzleGraphicsPiece::on_PiecePositionChanged); connect(m_piece, &VPPiece::PositionChanged, this, &VPGraphicsPiece::on_PiecePositionChanged);
connect(m_piece, &VPuzzlePiece::RotationChanged, this, &VPuzzleGraphicsPiece::on_PieceRotationChanged); connect(m_piece, &VPPiece::RotationChanged, this, &VPGraphicsPiece::on_PieceRotationChanged);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzlePiece* VPuzzleGraphicsPiece::GetPiece() VPPiece* VPGraphicsPiece::GetPiece()
{ {
return m_piece; return m_piece;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QRectF VPuzzleGraphicsPiece::boundingRect() const QRectF VPGraphicsPiece::boundingRect() const
{ {
if(!m_cuttingLine.isEmpty()) if(!m_cuttingLine.isEmpty())
{ {
@ -117,7 +126,7 @@ QRectF VPuzzleGraphicsPiece::boundingRect() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QPainterPath VPuzzleGraphicsPiece::shape() const QPainterPath VPGraphicsPiece::shape() const
{ {
if(!m_cuttingLine.isEmpty()) if(!m_cuttingLine.isEmpty())
{ {
@ -128,7 +137,7 @@ QPainterPath VPuzzleGraphicsPiece::shape() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleGraphicsPiece::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void VPGraphicsPiece::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{ {
Q_UNUSED(widget); Q_UNUSED(widget);
Q_UNUSED(option); Q_UNUSED(option);
@ -171,7 +180,7 @@ void VPuzzleGraphicsPiece::paint(QPainter *painter, const QStyleOptionGraphicsIt
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleGraphicsPiece::mousePressEvent(QGraphicsSceneMouseEvent *event) void VPGraphicsPiece::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
bool selectionState = isSelected(); bool selectionState = isSelected();
//perform the default behaviour //perform the default behaviour
@ -206,7 +215,7 @@ void VPuzzleGraphicsPiece::mousePressEvent(QGraphicsSceneMouseEvent *event)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleGraphicsPiece::mouseMoveEvent(QGraphicsSceneMouseEvent * event) void VPGraphicsPiece::mouseMoveEvent(QGraphicsSceneMouseEvent * event)
{ {
if((event->buttons() == Qt::LeftButton) && (event->modifiers() & Qt::AltModifier)) if((event->buttons() == Qt::LeftButton) && (event->modifiers() & Qt::AltModifier))
{ {
@ -237,7 +246,7 @@ void VPuzzleGraphicsPiece::mouseMoveEvent(QGraphicsSceneMouseEvent * event)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleGraphicsPiece::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VPGraphicsPiece::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
bool selectionState = isSelected(); bool selectionState = isSelected();
@ -264,7 +273,7 @@ void VPuzzleGraphicsPiece::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleGraphicsPiece::hoverMoveEvent(QGraphicsSceneHoverEvent *event) void VPGraphicsPiece::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{ {
if(event->modifiers() & Qt::AltModifier) if(event->modifiers() & Qt::AltModifier)
@ -284,73 +293,82 @@ void VPuzzleGraphicsPiece::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleGraphicsPiece::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) void VPGraphicsPiece::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{ {
// TODO/FIXME context menu needs to be refactored
QMenu contextMenu; QMenu contextMenu;
// move to layer actions -- TODO : To be tested properly when we have several layers // move to piece list actions -- TODO : To be tested properly when we have several piece lists
QList<VPuzzleLayer*> layers = m_piece->GetLayer()->GetLayout()->GetLayers(); QList<VPPieceList*> pieceLists = QList<VPPieceList*>();
layers.removeAll(m_piece->GetLayer()); for(auto sheet : m_piece->GetPieceList()->GetLayout()->GetSheets())
{
pieceLists.append(sheet->GetPieceList());
}
if(layers.count() > 0) pieceLists.removeAll(m_piece->GetPieceList());
if(pieceLists.count() > 0)
{ {
QMenu *moveMenu = contextMenu.addMenu(tr("Move to")); QMenu *moveMenu = contextMenu.addMenu(tr("Move to"));
// TODO order in alphabetical order // TODO order in alphabetical order
for (auto layer : layers) for (auto pieceList : pieceLists)
{ {
QAction* moveToLayer = moveMenu->addAction(layer->GetName()); QAction* moveToPieceList = moveMenu->addAction(pieceList->GetName());
QVariant data = QVariant::fromValue(layer); QVariant data = QVariant::fromValue(pieceList);
moveToLayer->setData(data); moveToPieceList->setData(data);
connect(moveToLayer, &QAction::triggered, this, &VPuzzleGraphicsPiece::on_ActionPieceMovedToLayer); connect(moveToPieceList, &QAction::triggered, this, &VPGraphicsPiece::on_ActionPieceMovedToPieceList);
} }
} }
// remove from layout action // remove from layout action
QAction *removeAction = contextMenu.addAction(tr("Remove from Layout")); QAction *removeAction = contextMenu.addAction(tr("Remove from Sheet"));
QVariant data = QVariant::fromValue(m_piece->GetLayer()->GetLayout()->GetUnplacedPiecesLayer()); QVariant data = QVariant::fromValue(m_piece->GetPieceList()->GetLayout()->GetUnplacedPieceList());
removeAction->setData(data); removeAction->setData(data);
connect(removeAction, &QAction::triggered, this, &VPuzzleGraphicsPiece::on_ActionPieceMovedToLayer); connect(removeAction, &QAction::triggered, this, &VPGraphicsPiece::on_ActionPieceMovedToPieceList);
contextMenu.exec(event->screenPos()); contextMenu.exec(event->screenPos());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleGraphicsPiece::on_ActionPieceMovedToLayer() void VPGraphicsPiece::on_ActionPieceMovedToPieceList()
{ {
QAction *act = qobject_cast<QAction *>(sender()); QAction *act = qobject_cast<QAction *>(sender());
QVariant v = act->data(); QVariant v = act->data();
VPuzzleLayer *layer = v.value<VPuzzleLayer *>(); VPPieceList *pieceList = v.value<VPPieceList *>();
if(layer != nullptr) if(pieceList != nullptr)
{ {
layer->GetLayout()->MovePieceToLayer(m_piece, layer); pieceList->GetLayout()->MovePieceToPieceList(m_piece, pieceList);
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleGraphicsPiece::on_PieceSelectionChanged() void VPGraphicsPiece::on_PieceSelectionChanged()
{ {
setSelected(m_piece->GetIsSelected()); setSelected(m_piece->GetIsSelected());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleGraphicsPiece::on_PiecePositionChanged() void VPGraphicsPiece::on_PiecePositionChanged()
{ {
setPos(m_piece->GetPosition()); setPos(m_piece->GetPosition());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleGraphicsPiece::on_PieceRotationChanged() void VPGraphicsPiece::on_PieceRotationChanged()
{ {
setTransformOriginPoint(boundingRect().center()); setTransformOriginPoint(boundingRect().center());
setRotation(-m_piece->GetRotation()); setRotation(-m_piece->GetRotation());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVariant VPuzzleGraphicsPiece::itemChange(GraphicsItemChange change, const QVariant &value) QVariant VPGraphicsPiece::itemChange(GraphicsItemChange change, const QVariant &value)
{ {
if (scene()) { if (scene()) {

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlegraphicspiece.h ** @file vpgraphicspiece.h
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 4 5, 2020 ** @date 4 5, 2020
** **
@ -26,26 +26,26 @@
** **
*************************************************************************/ *************************************************************************/
#ifndef VPUZZLEGRAPHICSPIECE_H #ifndef VPGRAPHICSPIECE_H
#define VPUZZLEGRAPHICSPIECE_H #define VPGRAPHICSPIECE_H
#include <QGraphicsItem> #include <QGraphicsItem>
class VPuzzlePiece; class VPPiece;
class VPuzzleGraphicsPiece : public QGraphicsObject class VPGraphicsPiece : public QGraphicsObject
{ {
Q_OBJECT Q_OBJECT
public: public:
VPuzzleGraphicsPiece(VPuzzlePiece *piece, QGraphicsItem *parent = nullptr); VPGraphicsPiece(VPPiece *piece, QGraphicsItem *parent = nullptr);
~VPuzzleGraphicsPiece(); ~VPGraphicsPiece();
void Init(); void Init();
/** /**
* @brief GetPiece Returns the piece that corresponds to the graphics piece * @brief GetPiece Returns the piece that corresponds to the graphics piece
* @return the piece * @return the piece
*/ */
VPuzzlePiece* GetPiece(); VPPiece* GetPiece();
public slots: public slots:
/** /**
@ -80,14 +80,14 @@ protected:
private slots: private slots:
/** /**
* @brief on_ActionPieceMovedToLayer Slot called when the piece is moved via the * @brief on_ActionPieceMovedToPieceList Slot called when the piece is moved via the
* context menu to anoter layer * context menu to anoter piece list
*/ */
void on_ActionPieceMovedToLayer(); void on_ActionPieceMovedToPieceList();
private: private:
Q_DISABLE_COPY(VPuzzleGraphicsPiece) Q_DISABLE_COPY(VPGraphicsPiece)
VPuzzlePiece *m_piece; VPPiece *m_piece;
QPainterPath m_cuttingLine; QPainterPath m_cuttingLine;
QPainterPath m_seamLine; QPainterPath m_seamLine;
@ -97,4 +97,4 @@ private:
}; };
#endif // VPUZZLEGRAPHICSPIECE_H #endif // VPGRAPHICSPIECE_H

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlegraphicslayout.cpp ** @file vpgraphicssheet.cpp
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 3 5, 2020 ** @date 3 5, 2020
** **
@ -26,25 +26,25 @@
** **
*************************************************************************/ *************************************************************************/
#include "vpuzzlegraphicslayout.h" #include "vpgraphicssheet.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleGraphicsLayout::VPuzzleGraphicsLayout(VPuzzleLayout *layout, QGraphicsItem *parent): VPGraphicsSheet::VPGraphicsSheet(VPSheet *sheet, QGraphicsItem *parent):
QGraphicsItem(parent), QGraphicsItem(parent),
m_layout(layout), m_sheet(sheet),
m_boundingRect(GetLayoutRect()) m_boundingRect(GetSheetRect())
{ {
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleGraphicsLayout::~VPuzzleGraphicsLayout() VPGraphicsSheet::~VPGraphicsSheet()
{ {
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleGraphicsLayout::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void VPGraphicsSheet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{ {
Q_UNUSED(widget); Q_UNUSED(widget);
Q_UNUSED(option); Q_UNUSED(option);
@ -60,23 +60,23 @@ void VPuzzleGraphicsLayout::paint(QPainter *painter, const QStyleOptionGraphicsI
pen.setColor(Qt::black); pen.setColor(Qt::black);
painter->setPen(pen); painter->setPen(pen);
painter->drawRect(GetLayoutRect()); painter->drawRect(GetSheetRect());
m_boundingRect = GetLayoutRect(); m_boundingRect = GetSheetRect();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QRectF VPuzzleGraphicsLayout::GetLayoutRect() const QRectF VPGraphicsSheet::GetSheetRect() const
{ {
QRectF rect = QRectF(QPointF(0,0), m_layout->GetLayoutSize()); QRectF rect = QRectF(QPointF(0,0), m_sheet->GetSheetSize());
return rect; return rect;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QRectF VPuzzleGraphicsLayout::GetMarginsRect() const QRectF VPGraphicsSheet::GetMarginsRect() const
{ {
QMarginsF margins = m_layout->GetLayoutMargins(); QMarginsF margins = m_sheet->GetSheetMargins();
QSizeF size = m_layout->GetLayoutSize(); QSizeF size = m_sheet->GetSheetSize();
QRectF rect = QRectF( QRectF rect = QRectF(
QPointF(margins.left(),margins.top()), QPointF(margins.left(),margins.top()),
QPointF(size.width()-margins.right(), size.height()-margins.bottom()) QPointF(size.width()-margins.right(), size.height()-margins.bottom())
@ -86,7 +86,7 @@ QRectF VPuzzleGraphicsLayout::GetMarginsRect() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QRectF VPuzzleGraphicsLayout::boundingRect() const QRectF VPGraphicsSheet::boundingRect() const
{ {
return m_boundingRect; return m_boundingRect;
} }

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlegraphicslayout.h ** @file vpgraphicssheet.h
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 3 5, 2020 ** @date 3 5, 2020
** **
@ -26,33 +26,33 @@
** **
*************************************************************************/ *************************************************************************/
#ifndef VPUZZLEGRAPHICSLAYOUT_H #ifndef VPGRAPHICSSHEET_H
#define VPUZZLEGRAPHICSLAYOUT_H #define VPGRAPHICSSHEET_H
#include <QGraphicsItem> #include <QGraphicsItem>
#include <QPainter> #include <QPainter>
#include "vpuzzlelayout.h" #include "vpsheet.h"
class VPuzzleGraphicsLayout : public QGraphicsItem class VPGraphicsSheet : public QGraphicsItem
{ {
public: public:
explicit VPuzzleGraphicsLayout(VPuzzleLayout *layout, QGraphicsItem *parent = nullptr); explicit VPGraphicsSheet(VPSheet *sheet, QGraphicsItem *parent = nullptr);
~VPuzzleGraphicsLayout(); ~VPGraphicsSheet();
QRectF boundingRect() const override; QRectF boundingRect() const override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget) override; void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget) override;
QRectF GetLayoutRect() const; QRectF GetSheetRect() const;
QRectF GetMarginsRect() const; QRectF GetMarginsRect() const;
private: private:
Q_DISABLE_COPY(VPuzzleGraphicsLayout) Q_DISABLE_COPY(VPGraphicsSheet)
VPuzzleLayout *m_layout{nullptr}; VPSheet *m_sheet{nullptr};
QRectF m_boundingRect; QRectF m_boundingRect;
}; };
#endif // VPUZZLEGRAPHICSLAYOUT_H #endif // VPGRAPHICSSHEET_H

View File

@ -1,155 +0,0 @@
/************************************************************************
**
** @file vpiececarrousellayer.cpp
** @author Ronan Le Tiec
** @date 25 4, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vpiececarrousellayer.h"
#include "vpiececarrousel.h"
#include "../vmisc/backport/qoverload.h"
#include <QVBoxLayout>
#include <QLoggingCategory>
Q_LOGGING_CATEGORY(pCarrouselLayer, "p.carrouselLayer")
//---------------------------------------------------------------------------------------------------------------------
VPieceCarrouselLayer::VPieceCarrouselLayer(VPuzzleLayer *layer, VPieceCarrousel *carrousel) :
m_layer(layer),
m_carrousel(carrousel),
m_carrouselPieces(QList<VPieceCarrouselPiece*>())
{
Init();
}
//---------------------------------------------------------------------------------------------------------------------
VPieceCarrouselLayer::~VPieceCarrouselLayer()
{
Clear();
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrouselLayer::Init()
{
// initiales the structure
QVBoxLayout *layoutPiecesLayout = new QVBoxLayout();
layoutPiecesLayout->setMargin(0);
setLayout(layoutPiecesLayout);
// then refresh the content
Refresh();
// add the connections
connect(m_layer, &VPuzzleLayer::PieceAdded, this, &VPieceCarrouselLayer::on_PieceAdded);
connect(m_layer, &VPuzzleLayer::PieceRemoved, this, &VPieceCarrouselLayer::on_PieceRemoved);
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrouselLayer::Refresh()
{
Clear();
// Updates the carrousel pieces from the pieces list
QList<VPuzzlePiece*> pieces = m_layer->GetPieces();
// sort the pieces in alphabetical order
std::sort(pieces.begin(), pieces.end(),
[](const VPuzzlePiece* a, const VPuzzlePiece* b) -> bool { return a->GetName() < b->GetName();});
// create the corresponding carrousel pieces
bool _isVisible = isVisible();
setVisible(true);
for (auto piece : pieces)
{
VPieceCarrouselPiece *carrouselPiece = new VPieceCarrouselPiece(piece, this);
m_carrouselPieces.append(carrouselPiece);
layout()->addWidget(carrouselPiece);
carrouselPiece->CleanPreview(); // fitInView only works if the widget is displayed.
}
setVisible(_isVisible);
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrouselLayer::Clear()
{
// Removes and deletes the carrousel pieces from the layer
while (!m_carrouselPieces.isEmpty())
{
VPieceCarrouselPiece *carrouselPiece = m_carrouselPieces.takeLast();
if(carrouselPiece != nullptr)
{
layout()->removeWidget(carrouselPiece);
delete carrouselPiece;
}
}
}
//---------------------------------------------------------------------------------------------------------------------
QList<VPieceCarrouselPiece*> VPieceCarrouselLayer::GetCarrouselPieces()
{
return m_carrouselPieces;
}
//---------------------------------------------------------------------------------------------------------------------
VPieceCarrousel* VPieceCarrouselLayer::GetCarrousel()
{
return m_carrousel;
}
//---------------------------------------------------------------------------------------------------------------------
VPuzzleLayer* VPieceCarrouselLayer::GetLayer()
{
return m_layer;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrouselLayer::on_PieceAdded(VPuzzlePiece* piece)
{
Q_UNUSED(piece)
// TODO/ FIXME: see if we find a solution more efficient refreshing the complete layout everytime.
Refresh();
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrouselLayer::on_PieceRemoved(VPuzzlePiece* piece)
{
for (auto carrouselPiece : m_carrouselPieces)
{
if(carrouselPiece->GetPiece() == piece)
{
m_carrouselPieces.removeAll(carrouselPiece);
layout()->removeWidget(carrouselPiece);
delete carrouselPiece;
return;
}
}
}

View File

@ -1,84 +0,0 @@
/************************************************************************
**
** @file vpiececarrousellayer.h
** @author Ronan Le Tiec
** @date 25 4, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VPIECECARROUSELLAYER_H
#define VPIECECARROUSELLAYER_H
#include <QWidget>
#include "vpuzzlelayer.h"
#include "vpiececarrouselpiece.h"
class VPieceCarrousel;
class VPieceCarrouselLayer : public QWidget
{
Q_OBJECT
public:
VPieceCarrouselLayer(VPuzzleLayer *layer, VPieceCarrousel *carrousel);
~VPieceCarrouselLayer();
void Init();
void Refresh();
/**
* @brief Clear it clears the carrousel layer from its pieces
*/
void Clear();
QList<VPieceCarrouselPiece*> GetCarrouselPieces();
VPieceCarrousel* GetCarrousel();
/**
* @brief GetPuzzleLayer Returns the corresponding VPuzzleLayer
* @return the VPuzzleLayer
*/
VPuzzleLayer* GetLayer();
private:
Q_DISABLE_COPY(VPieceCarrouselLayer)
VPuzzleLayer *m_layer;
VPieceCarrousel *m_carrousel;
QList<VPieceCarrouselPiece*> m_carrouselPieces;
private slots:
/**
* @brief on_PieceUpdated This slot is called when a piece was added
*/
void on_PieceAdded(VPuzzlePiece* piece);
/**
* @brief on_PieceUpdated This slot is called when a piece was removed
*/
void on_PieceRemoved(VPuzzlePiece* piece);
};
#endif // VPIECECARROUSELLAYER_H

View File

@ -1,285 +0,0 @@
/************************************************************************
**
** @file vpiececarrouselpiece.cpp
** @author Ronan Le Tiec
** @date 25 4, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vpiececarrouselpiece.h"
#include <QLabel>
#include <QVBoxLayout>
#include <QGraphicsScene>
#include <QPainter>
#include <QDrag>
#include <QPainter>
#include <QApplication>
#include <QMenu>
#include "vpuzzlemimedatapiece.h"
#include "vpiececarrousellayer.h"
#include "vpiececarrousel.h"
#include <QLoggingCategory>
Q_LOGGING_CATEGORY(pCarrouselPiece, "p.carrouselPiece")
//---------------------------------------------------------------------------------------------------------------------
VPieceCarrouselPiece::VPieceCarrouselPiece(VPuzzlePiece *piece, VPieceCarrouselLayer *carrouselLayer) :
m_piece(piece),
m_carrouselLayer(carrouselLayer),
m_dragStart(QPoint())
{
Init();
}
//---------------------------------------------------------------------------------------------------------------------
VPieceCarrouselPiece::~VPieceCarrouselPiece()
{
delete m_piecePreview;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrouselPiece::Init()
{
// Define the structure
setFixedSize(124,128);
QVBoxLayout *pieceLayout = new QVBoxLayout();
pieceLayout->setMargin(0);
pieceLayout->setSpacing(0);
setLayout(pieceLayout);
setStyleSheet("background-color:white; border: 2px solid transparent;");
// define the preview of the piece
m_piecePreview = new VPieceCarrouselPiecePreview(this);
// m_graphicsView = new VMainGraphicsView(this);
// --> undefined reference to 'VMainGraphicsView::VMainGraphicView(QWidget*)'
QGraphicsScene *graphicsScene = new QGraphicsScene(this);
m_piecePreview->setScene(graphicsScene);
m_piecePreview->setFixedSize(120,100);
m_piecePreview->setStyleSheet("border: 4px solid transparent;");
m_piecePreview->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
// define the label
m_label = new QLabel();
m_label->sizePolicy();
m_label->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
m_label->setFixedSize(120,24);
m_label->setStyleSheet("border: 0px;");
m_label->setMouseTracking(false);
pieceLayout->addWidget(m_piecePreview);
pieceLayout->addWidget(m_label);
// connect the signals
connect(m_piece, &VPuzzlePiece::SelectionChanged, this, &VPieceCarrouselPiece::on_PieceSelectionChanged);
// then refresh the data
Refresh();
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrouselPiece::CleanPreview()
{
m_piecePreview->fitInView(m_piecePreview->scene()->sceneRect(), Qt::KeepAspectRatio);
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrouselPiece::Refresh()
{
// update the graphic view / the scene
QVector<QPointF> points = m_piece->GetSeamLine();
if(points.isEmpty())
{
points = m_piece->GetCuttingLine();
}
QPen pen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
pen.setCosmetic(true);
QBrush noBrush(Qt::NoBrush);
QPainterPath path;
path.moveTo(points.first());
for (int i = 1; i < points.size(); ++i)
path.lineTo(points.at(i));
m_piecePreview->scene()->addPath(path, pen, noBrush);
m_piecePreview->fitInView(m_piecePreview->scene()->sceneRect(), Qt::KeepAspectRatio);
// update the label of the piece
QFontMetrics metrix(m_label->font());
int width = m_label->width() - 8;
QString clippedText = metrix.elidedText(m_piece->GetName(), Qt::ElideRight, width);
m_label->setText(clippedText);
// set the tooltip
setToolTip(m_piece->GetName());
// set the selection state correctly.
on_PieceSelectionChanged();
}
//---------------------------------------------------------------------------------------------------------------------
VPuzzlePiece * VPieceCarrouselPiece::GetPiece()
{
return m_piece;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrouselPiece::on_PieceSelectionChanged()
{
if(m_piece->GetIsSelected())
{
setStyleSheet("background-color:white; border: 2px solid red;");
}
else
{
setStyleSheet("background-color:white; border: 2px solid transparent;");
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrouselPiece::mousePressEvent(QMouseEvent *event)
{
qCDebug(pCarrouselPiece, "mouse pressed");
if (event->button() == Qt::LeftButton)
{
if(!(event->modifiers() & Qt::ControlModifier))
{
m_carrouselLayer->GetCarrousel()->ClearSelection();
m_piece->SetIsSelected(true);
}
else
{
m_piece->SetIsSelected(!m_piece->GetIsSelected());
}
m_dragStart = event->pos();
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrouselPiece::mouseMoveEvent(QMouseEvent *event)
{
if (!(event->buttons() & Qt::LeftButton))
{
return;
}
if(m_piece->GetLayer() != m_piece->GetLayer()->GetLayout()->GetUnplacedPiecesLayer())
{
return;
}
if((event->pos() - m_dragStart).manhattanLength() < QApplication::startDragDistance())
{
return;
}
// make sure the multiple selection is removed
m_carrouselLayer->GetCarrousel()->ClearSelection();
m_piece->SetIsSelected(true);
// starts the dragging
QDrag *drag = new QDrag(this);
VPuzzleMimeDataPiece *mimeData = new VPuzzleMimeDataPiece();
mimeData->SetPiecePtr(m_piece);
mimeData->setObjectName("piecePointer");
// in case we would want to have the pieces original size:
//drag->setHotSpot(QPoint(0,0));
//QPixmap pixmap(m_piecePreview->sceneRect().size().toSize());
QPixmap pixmap(112,92);
pixmap.fill(Qt::transparent);
QPainter painter(&pixmap);
painter.setRenderHint(QPainter::Antialiasing);
m_piecePreview->scene()->render(&painter);
drag->setPixmap(pixmap);
drag->setMimeData(mimeData);
drag->exec();
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrouselPiece::contextMenuEvent(QContextMenuEvent *event)
{
QMenu contextMenu;
VPuzzleLayer* unplacedLayer = m_piece->GetLayer()->GetLayout()->GetUnplacedPiecesLayer();
QList<VPuzzleLayer*> layers = m_piece->GetLayer()->GetLayout()->GetLayers();
// move to layer actions -- TODO : To be tested properly when we have several layers
layers.removeAll(m_piece->GetLayer());
if(layers.count() > 0)
{
QMenu *moveMenu = contextMenu.addMenu(tr("Move to"));
// TODO order in alphabetical order
for (auto layer : layers)
{
QAction* moveToLayer = moveMenu->addAction(layer->GetName());
QVariant data = QVariant::fromValue(layer);
moveToLayer->setData(data);
connect(moveToLayer, &QAction::triggered, this, &VPieceCarrouselPiece::on_ActionPieceMovedToLayer);
}
}
// remove from layout action
if(m_piece->GetLayer() != unplacedLayer)
{
QAction *removeAction = contextMenu.addAction(tr("Remove from Layout"));
QVariant data = QVariant::fromValue(m_piece->GetLayer()->GetLayout()->GetUnplacedPiecesLayer());
removeAction->setData(data);
connect(removeAction, &QAction::triggered, this, &VPieceCarrouselPiece::on_ActionPieceMovedToLayer);
}
contextMenu.exec(event->globalPos());
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrouselPiece::on_ActionPieceMovedToLayer()
{
QAction *act = qobject_cast<QAction *>(sender());
QVariant v = act->data();
VPuzzleLayer *layer = v.value<VPuzzleLayer *>();
if(layer != nullptr)
{
layer->GetLayout()->MovePieceToLayer(m_piece, layer);
}
}

View File

@ -1,96 +0,0 @@
/************************************************************************
**
** @file vpiececarrouselpiece.h
** @author Ronan Le Tiec
** @date 25 4, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VPIECECARROUSELPIECE_H
#define VPIECECARROUSELPIECE_H
#include <QFrame>
#include <QLabel>
#include <QGraphicsView>
#include <QMouseEvent>
#include "vpuzzlepiece.h"
#include "vpiececarrouselpiecepreview.h"
class VPieceCarrouselLayer;
class VPieceCarrouselPiece : public QFrame
{
Q_OBJECT
public:
explicit VPieceCarrouselPiece(VPuzzlePiece *piece, VPieceCarrouselLayer *carrouselLayer);
~VPieceCarrouselPiece();
void Init();
void Refresh();
/**
* @brief CleanPiecesPreview fitInView of the qGraphicsView of the pieces works properly
* only when the piece is in place in the layer and we call it from the layer.
*/
void CleanPreview();
/**
* @brief GetLayoutPiece Returns the corresponding layout piece
* @return the corresponding layout piece
*/
VPuzzlePiece * GetPiece();
public slots:
void on_PieceSelectionChanged();
protected:
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void contextMenuEvent(QContextMenuEvent *event) override;
private slots:
/**
* @brief on_ActionPieceMovedToLayer Slot called when the piece is moved via the
* context menu to anoter layer
*/
void on_ActionPieceMovedToLayer();
private:
Q_DISABLE_COPY(VPieceCarrouselPiece)
VPuzzlePiece *m_piece;
VPieceCarrouselLayer *m_carrouselLayer;
QLabel *m_label{nullptr};
VPieceCarrouselPiecePreview *m_piecePreview{nullptr};
QPoint m_dragStart;
private slots:
};
#endif // VPIECECARROUSELPIECE_H

View File

@ -1,55 +0,0 @@
/************************************************************************
**
** @file vpiececarrouselpiecepreview.cpp
** @author Ronan Le Tiec
** @date 3 5, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vpiececarrouselpiecepreview.h"
#include <QMouseEvent>
//---------------------------------------------------------------------------------------------------------------------
VPieceCarrouselPiecePreview::VPieceCarrouselPiecePreview(QWidget *parent):
QGraphicsView(parent)
{
}
//---------------------------------------------------------------------------------------------------------------------
VPieceCarrouselPiecePreview::~VPieceCarrouselPiecePreview()
{
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrouselPiecePreview::mousePressEvent(QMouseEvent *event)
{
event->ignore();
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrouselPiecePreview::mouseMoveEvent(QMouseEvent *event)
{
event->ignore();
}

207
src/app/puzzle/vplayout.cpp Normal file
View File

@ -0,0 +1,207 @@
/************************************************************************
**
** @file vplayout.cpp
** @author Ronan Le Tiec
** @date 13 4, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vplayout.h"
#include "vppiecelist.h"
#include "vppiece.h"
#include "vpsheet.h"
#include <QLoggingCategory>
Q_LOGGING_CATEGORY(pLayout, "p.layout")
//---------------------------------------------------------------------------------------------------------------------
VPLayout::VPLayout() :
m_unplacedPieceList(new VPPieceList(this)),
m_sheets(QList<VPSheet*>())
{
m_unplacedPieceList->SetName(QObject::tr("Unplaced pieces"));
}
//---------------------------------------------------------------------------------------------------------------------
VPLayout::~VPLayout()
{
qDeleteAll(m_sheets);
delete m_unplacedPieceList;
}
//---------------------------------------------------------------------------------------------------------------------
VPPieceList* VPLayout::GetUnplacedPieceList()
{
return m_unplacedPieceList;
}
//---------------------------------------------------------------------------------------------------------------------
VPSheet* VPLayout::AddSheet()
{
VPSheet *newSheet = new VPSheet(this);
m_sheets.append(newSheet);
return newSheet;
}
//---------------------------------------------------------------------------------------------------------------------
VPSheet* VPLayout::AddSheet(VPSheet *sheet)
{
m_sheets.append(sheet);
return sheet;
}
//---------------------------------------------------------------------------------------------------------------------
QList<VPSheet *> VPLayout::GetSheets()
{
return m_sheets;
}
//---------------------------------------------------------------------------------------------------------------------
QList<VPPiece *> VPLayout::GetSelectedPieces()
{
QList<VPPiece *> result = QList<VPPiece *>();
QList<VPPieceList *> pieceLists = QList<VPPieceList *>();
pieceLists.append(m_unplacedPieceList);
for (auto sheet : m_sheets)
{
pieceLists.append(sheet->GetPieceList());
}
for (auto pieceList : pieceLists)
{
for (auto piece : pieceList->GetPieces())
{
if(piece->GetIsSelected())
{
result.append(piece);
}
}
}
return result;
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayout::SetUnit(Unit unit)
{
m_unit = unit;
}
//---------------------------------------------------------------------------------------------------------------------
Unit VPLayout::GetUnit() const
{
return m_unit;
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayout::SetWarningSuperpositionOfPieces(bool state)
{
m_warningSuperpositionOfPieces = state;
}
//---------------------------------------------------------------------------------------------------------------------
bool VPLayout::GetWarningSuperpositionOfPieces() const
{
return m_warningSuperpositionOfPieces;
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayout::SetWarningPiecesOutOfBound(bool state)
{
m_warningPiecesOutOfBound = state;
}
//---------------------------------------------------------------------------------------------------------------------
bool VPLayout::GetWarningPiecesOutOfBound() const
{
return m_warningPiecesOutOfBound;
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayout::ClearSelection()
{
m_unplacedPieceList->ClearSelection();
for (auto sheet : m_sheets)
{
sheet->ClearSelection();
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayout::ClearSelectionExceptForGivenPieceList(VPPieceList* pieceList)
{
if(m_unplacedPieceList != pieceList)
{
m_unplacedPieceList->ClearSelection();
}
for (auto sheet : m_sheets)
{
if(sheet->GetPieceList() != pieceList)
{
sheet->ClearSelection();
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayout::MovePieceToPieceList(VPPiece* piece, VPPieceList* pieceList)
{
VPPieceList* pieceListBefore = piece->GetPieceList();
if(pieceListBefore != nullptr)
{
piece->GetPieceList()->RemovePiece(piece);
}
pieceList->AddPiece(piece);
// signal, that a piece was moved
emit PieceMovedToPieceList(piece, pieceListBefore,pieceList);
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayout::SetFocusedSheet(VPSheet *focusedSheet)
{
if(focusedSheet == nullptr)
{
m_focusedSheet = m_sheets.first();
}
else
{
m_focusedSheet = focusedSheet;
}
}
//---------------------------------------------------------------------------------------------------------------------
VPSheet* VPLayout::GetFocusedSheet()
{
return m_focusedSheet;
}

147
src/app/puzzle/vplayout.h Normal file
View File

@ -0,0 +1,147 @@
/************************************************************************
**
** @file vplayout.h
** @author Ronan Le Tiec
** @date 13 4, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VPLAYOUT_H
#define VPLAYOUT_H
#include <QList>
#include "def.h"
class VPPieceList;
class VPPiece;
class VPSheet;
class VPLayout : public QObject
{
Q_OBJECT
public:
VPLayout();
virtual ~VPLayout();
/**
* @brief GetUnplacedPieceList Returns the piece list of unplaced pieces
* @return the unplaced pieces list
*/
VPPieceList* GetUnplacedPieceList();
VPSheet* AddSheet();
VPSheet* AddSheet(VPSheet *sheet);
QList<VPSheet *> GetSheets();
/**
* @brief GetSelectedPieces Returns the list of the selected pieces
* @return the selected pieces
*/
QList<VPPiece *> GetSelectedPieces();
/**
* @brief SetUnit Sets the unit of the layout to the given unit
* @param unit the new unit
*/
void SetUnit(Unit unit);
/**
* @brief GetUnit Returns the current unit of the layout
* @return the unit
*/
Unit GetUnit() const;
void SetWarningSuperpositionOfPieces(bool state);
bool GetWarningSuperpositionOfPieces() const;
void SetWarningPiecesOutOfBound(bool state);
bool GetWarningPiecesOutOfBound() const;
/**
* @brief ClearSelection goes through the unplaced pieces and through the sheets and calls
* SetIsSelected(false) for the pieces that were selected.
*/
void ClearSelection();
/**
* @brief ClearSelectionExceptForPieceList same as clearSelection but it leaves the selection
* for the given piece list like it ist.
*
* @param pieceList the piece list to let be the way it is.
*/
void ClearSelectionExceptForGivenPieceList(VPPieceList* pieceList);
/**
* @brief MovePieceToPieceList Moves the given piece to the given piece list
* @param piece the piece to move
* @param pieceList the piece list to move the piece to
*/
void MovePieceToPieceList(VPPiece* piece, VPPieceList* pieceList);
/**
* @brief SetFocusedSheet Sets the focused sheet, to which pieces are added from the carrousel via drag
* and drop
* @param focusedSheet the new active sheet. If nullptr, then it sets automaticaly the first sheet from m_sheets
*/
void SetFocusedSheet(VPSheet *focusedSheet = nullptr);
/**
* @brief GetFocusedSheet Returns the focused sheet, to which pieces are added from the carrousel via drag
* and drop
* @return the focused sheet
*/
VPSheet* GetFocusedSheet();
signals:
void PieceMovedToPieceList(VPPiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter);
private:
Q_DISABLE_COPY(VPLayout)
VPPieceList *m_unplacedPieceList;
QList<VPSheet*> m_sheets;
/**
TODO : To be replaced by m_focusedSheet
* @brief m_focusedPieceList pointer the the focused piece list, to which pieces will be
* added via drag and drop, or if no piece list is defined.
*/
VPPieceList *m_focusedPieceList{nullptr};
VPSheet *m_focusedSheet{nullptr};
// format
Unit m_unit{Unit::Cm};
bool m_warningSuperpositionOfPieces{false};
bool m_warningPiecesOutOfBound{false};
};
#endif // VPLAYOUT_H

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlemaingraphicsview.cpp ** @file vpmaingraphicsview.cpp
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 3 5, 2020 ** @date 3 5, 2020
** **
@ -26,14 +26,16 @@
** **
*************************************************************************/ *************************************************************************/
#include "vpuzzlemaingraphicsview.h" #include "vpmaingraphicsview.h"
#include <QDragEnterEvent> #include <QDragEnterEvent>
#include <QMimeData> #include <QMimeData>
#include <QKeyEvent> #include <QKeyEvent>
#include "vpuzzlemimedatapiece.h" #include "vpmimedatapiece.h"
#include "vpuzzlelayer.h" #include "vppiecelist.h"
#include "vplayout.h"
#include "vpsheet.h"
#include "../vwidgets/vmaingraphicsscene.h" #include "../vwidgets/vmaingraphicsscene.h"
#include <QLoggingCategory> #include <QLoggingCategory>
@ -42,37 +44,38 @@ Q_LOGGING_CATEGORY(pMainGraphicsView, "p.mainGraphicsView")
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleMainGraphicsView::VPuzzleMainGraphicsView(VPuzzleLayout *layout, QWidget *parent) : VPMainGraphicsView::VPMainGraphicsView(VPLayout *layout, QWidget *parent) :
VMainGraphicsView(parent), VMainGraphicsView(parent),
m_layout(layout) m_layout(layout)
{ {
// TODO : list of scenes
m_scene = new VMainGraphicsScene(this); m_scene = new VMainGraphicsScene(this);
setScene(m_scene); setScene(m_scene);
m_graphicsLayout = new VPuzzleGraphicsLayout(layout); m_graphicsSheet = new VPGraphicsSheet(layout->GetFocusedSheet());
m_graphicsLayout->setPos(0, 0); m_graphicsSheet->setPos(0, 0);
m_scene->addItem(m_graphicsLayout); m_scene->addItem(m_graphicsSheet);
setAcceptDrops(true); setAcceptDrops(true);
// add the connections // add the connections
connect(m_layout, &VPuzzleLayout::PieceMovedToLayer, this, &VPuzzleMainGraphicsView::on_PieceMovedToLayer); connect(m_layout, &VPLayout::PieceMovedToPieceList, this, &VPMainGraphicsView::on_PieceMovedToPieceList);
connect(m_scene, &VMainGraphicsScene::selectionChanged, this, connect(m_scene, &VMainGraphicsScene::selectionChanged, this,
&VPuzzleMainGraphicsView::on_SceneSelectionChanged); &VPMainGraphicsView::on_SceneSelectionChanged);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleMainGraphicsView::RefreshLayout() void VPMainGraphicsView::RefreshLayout()
{ {
// FIXME: Is that the way to go? // FIXME: Is that the way to go?
m_graphicsLayout->update(); m_graphicsSheet->update();
m_scene->update(); m_scene->update();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleMainGraphicsView::dragEnterEvent(QDragEnterEvent *event) void VPMainGraphicsView::dragEnterEvent(QDragEnterEvent *event)
{ {
const QMimeData *mime = event->mimeData(); const QMimeData *mime = event->mimeData();
@ -84,7 +87,7 @@ void VPuzzleMainGraphicsView::dragEnterEvent(QDragEnterEvent *event)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleMainGraphicsView::dragMoveEvent(QDragMoveEvent *event) void VPMainGraphicsView::dragMoveEvent(QDragMoveEvent *event)
{ {
const QMimeData *mime = event->mimeData(); const QMimeData *mime = event->mimeData();
@ -95,7 +98,7 @@ void VPuzzleMainGraphicsView::dragMoveEvent(QDragMoveEvent *event)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleMainGraphicsView::dragLeaveEvent(QDragLeaveEvent *event) void VPMainGraphicsView::dragLeaveEvent(QDragLeaveEvent *event)
{ {
event->accept(); event->accept();
} }
@ -103,7 +106,7 @@ void VPuzzleMainGraphicsView::dragLeaveEvent(QDragLeaveEvent *event)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleMainGraphicsView::dropEvent(QDropEvent *event) void VPMainGraphicsView::dropEvent(QDropEvent *event)
{ {
const QMimeData *mime = event->mimeData(); const QMimeData *mime = event->mimeData();
@ -111,9 +114,9 @@ void VPuzzleMainGraphicsView::dropEvent(QDropEvent *event)
if(mime->objectName() == "piecePointer") if(mime->objectName() == "piecePointer")
{ {
const VPuzzleMimeDataPiece *mimePiece = qobject_cast<const VPuzzleMimeDataPiece *> (mime); const VPMimeDataPiece *mimePiece = qobject_cast<const VPMimeDataPiece *> (mime);
VPuzzlePiece *piece = mimePiece->GetPiecePtr(); VPPiece *piece = mimePiece->GetPiecePtr();
if(piece != nullptr) if(piece != nullptr)
{ {
qCDebug(pMainGraphicsView(), "element dropped, %s", qUtf8Printable(piece->GetName())); qCDebug(pMainGraphicsView(), "element dropped, %s", qUtf8Printable(piece->GetName()));
@ -122,42 +125,42 @@ void VPuzzleMainGraphicsView::dropEvent(QDropEvent *event)
QPoint point = event->pos(); QPoint point = event->pos();
piece->SetPosition(mapToScene(point)); piece->SetPosition(mapToScene(point));
// change the layer of the piece // change the piecelist of the piece
VPuzzleLayer *focusedLayer = m_layout->GetFocusedLayer(); VPPieceList *focusedPieceList = m_layout->GetFocusedSheet()->GetPieceList();
if(focusedLayer != nullptr) if(focusedPieceList != nullptr)
{ {
m_layout->MovePieceToLayer(piece, focusedLayer); m_layout->MovePieceToPieceList(piece, focusedPieceList);
} }
} }
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleMainGraphicsView::keyPressEvent(QKeyEvent *event) void VPMainGraphicsView::keyPressEvent(QKeyEvent *event)
{ {
if(event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete) if(event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete)
{ {
QList<VPuzzleGraphicsPiece*> tmpGraphicsPieces = m_graphicsPieces; QList<VPGraphicsPiece*> tmpGraphicsPieces = m_graphicsPieces;
for(auto graphicsPiece : tmpGraphicsPieces) for(auto graphicsPiece : tmpGraphicsPieces)
{ {
VPuzzlePiece *piece = graphicsPiece->GetPiece(); VPPiece *piece = graphicsPiece->GetPiece();
if(piece->GetIsSelected()) if(piece->GetIsSelected())
{ {
piece->SetIsSelected(false); piece->SetIsSelected(false);
m_layout->MovePieceToLayer(piece, m_layout->GetUnplacedPiecesLayer()); m_layout->MovePieceToPieceList(piece, m_layout->GetUnplacedPieceList());
} }
} }
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleMainGraphicsView::on_PieceMovedToLayer(VPuzzlePiece *piece, VPuzzleLayer *layerBefore, VPuzzleLayer *layerAfter) void VPMainGraphicsView::on_PieceMovedToPieceList(VPPiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter)
{ {
Q_UNUSED(layerBefore) Q_UNUSED(pieceListBefore)
VPuzzleGraphicsPiece *_graphicsPiece = nullptr; VPGraphicsPiece *_graphicsPiece = nullptr;
for(auto graphicPiece : m_graphicsPieces) for(auto graphicPiece : m_graphicsPieces)
{ {
if(graphicPiece->GetPiece() == piece) if(graphicPiece->GetPiece() == piece)
@ -166,16 +169,16 @@ void VPuzzleMainGraphicsView::on_PieceMovedToLayer(VPuzzlePiece *piece, VPuzzleL
} }
} }
if(layerAfter == m_layout->GetUnplacedPiecesLayer() && _graphicsPiece != nullptr) if(pieceListAfter == m_layout->GetUnplacedPieceList() && _graphicsPiece != nullptr)
{ {
scene()->removeItem(_graphicsPiece); scene()->removeItem(_graphicsPiece);
m_graphicsPieces.removeAll(_graphicsPiece); m_graphicsPieces.removeAll(_graphicsPiece);
} }
else if(layerAfter != m_layout->GetUnplacedPiecesLayer()) else if(pieceListAfter != m_layout->GetUnplacedPieceList())
{ {
if(_graphicsPiece == nullptr) if(_graphicsPiece == nullptr)
{ {
_graphicsPiece = new VPuzzleGraphicsPiece(piece); _graphicsPiece = new VPGraphicsPiece(piece);
m_graphicsPieces.append(_graphicsPiece); m_graphicsPieces.append(_graphicsPiece);
} }
@ -188,11 +191,11 @@ void VPuzzleMainGraphicsView::on_PieceMovedToLayer(VPuzzlePiece *piece, VPuzzleL
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleMainGraphicsView::on_SceneSelectionChanged() void VPMainGraphicsView::on_SceneSelectionChanged()
{ {
// most of the selection behaviour taks place automatically // most of the selection behaviour taks place automatically
// but we need to make sure that the unplaced pieces are unselected when the scene selection has changed // but we need to make sure that the unplaced pieces are unselected when the scene selection has changed
// because as they are not part of the scene, they are not updated // because as they are not part of the scene, they are not updated
m_layout->GetUnplacedPiecesLayer()->ClearSelection(); m_layout->GetUnplacedPieceList()->ClearSelection();
} }

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlemaingraphicsview.h ** @file vpmaingraphicsview.h
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 3 5, 2020 ** @date 3 5, 2020
** **
@ -26,22 +26,22 @@
** **
*************************************************************************/ *************************************************************************/
#ifndef VPUZZLEMAINGRAPHICSVIEW_H #ifndef VPMAINGRAPHICSVIEW_H
#define VPUZZLEMAINGRAPHICSVIEW_H #define VPMAINGRAPHICSVIEW_H
#include "vpuzzlegraphicslayout.h" #include "vpgraphicssheet.h"
#include "vpuzzlegraphicspiece.h" #include "vpgraphicspiece.h"
#include "../vwidgets/vmaingraphicsview.h" #include "../vwidgets/vmaingraphicsview.h"
class VMainGraphicsScene; class VMainGraphicsScene;
class VPuzzleMainGraphicsView : public VMainGraphicsView class VPMainGraphicsView : public VMainGraphicsView
{ {
Q_OBJECT Q_OBJECT
public: public:
VPuzzleMainGraphicsView(VPuzzleLayout *layout, QWidget *parent); VPMainGraphicsView(VPLayout *layout, QWidget *parent);
~VPuzzleMainGraphicsView() = default; ~VPMainGraphicsView() = default;
/** /**
* @brief RefreshLayout Refreshes the rectangles for the layout border and the margin * @brief RefreshLayout Refreshes the rectangles for the layout border and the margin
@ -58,13 +58,13 @@ protected:
private slots: private slots:
/** /**
* @brief on_PieceMovedToLayer The slot is called when the given piece was moved from the given layer to the other * @brief on_PieceMovedToPieceList The slot is called when the given piece was moved from the given piece list to the other
* given layer * given piece list
* @param piece the piece that was moved * @param piece the piece that was moved
* @param layerBefore the layer before the move * @param pieceListBefore the piece list before the move
* @param layerAfter the layer after the move * @param pieceListAfter the piece list after the move
*/ */
void on_PieceMovedToLayer(VPuzzlePiece *piece, VPuzzleLayer *layerBefore, VPuzzleLayer *layerAfter); void on_PieceMovedToPieceList(VPPiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter);
/** /**
* @brief on_SceneSelectionChanged Slot is called when the scene selection has changed * @brief on_SceneSelectionChanged Slot is called when the scene selection has changed
@ -72,15 +72,15 @@ private slots:
void on_SceneSelectionChanged(); void on_SceneSelectionChanged();
private: private:
Q_DISABLE_COPY(VPuzzleMainGraphicsView) Q_DISABLE_COPY(VPMainGraphicsView)
VMainGraphicsScene *m_scene{nullptr}; VMainGraphicsScene *m_scene{nullptr};
VPuzzleGraphicsLayout *m_graphicsLayout{nullptr}; VPGraphicsSheet *m_graphicsSheet{nullptr};
VPuzzleLayout *m_layout{nullptr}; VPLayout *m_layout{nullptr};
QList<VPuzzleGraphicsPiece*> m_graphicsPieces{}; QList<VPGraphicsPiece*> m_graphicsPieces{};
}; };
#endif // VPUZZLEMAINGRAPHICVIEW_H #endif // VPMAINGRAPHICSVIEW_H

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file puzzlemainwindow.cpp ** @file vpmainwindow.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com> ** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 16 2, 2020 ** @date 16 2, 2020
** **
@ -25,20 +25,22 @@
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
*************************************************************************/ *************************************************************************/
#include "puzzlemainwindow.h" #include "vpmainwindow.h"
#include <QFileDialog> #include <QFileDialog>
#include <QCloseEvent>
#include "ui_puzzlemainwindow.h" #include "ui_vpmainwindow.h"
#include "dialogs/dialogaboutpuzzle.h" #include "dialogs/vpdialogabout.h"
#include "xml/vpuzzlelayoutfilewriter.h" #include "xml/vplayoutfilewriter.h"
#include "xml/vpuzzlelayoutfilereader.h" #include "xml/vplayoutfilereader.h"
#include "puzzleapplication.h" #include "vpapplication.h"
#include "../vlayout/vrawlayout.h" #include "../vlayout/vrawlayout.h"
#include "../vmisc/vsysexits.h" #include "../vmisc/vsysexits.h"
#include "../vmisc/projectversion.h" #include "../vmisc/projectversion.h"
#include "../ifc/xml/vlayoutconverter.h" #include "../ifc/xml/vlayoutconverter.h"
#include "../ifc/exception/vexception.h" #include "../ifc/exception/vexception.h"
#include "vpsheet.h"
#include <QLoggingCategory> #include <QLoggingCategory>
@ -51,18 +53,24 @@ Q_LOGGING_CATEGORY(pWindow, "p.window")
QT_WARNING_POP QT_WARNING_POP
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
PuzzleMainWindow::PuzzleMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *parent) : VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
ui(new Ui::PuzzleMainWindow), ui(new Ui::VPMainWindow),
m_cmd(cmd) m_cmd(cmd)
{ {
m_layout = new VPLayout();
m_layout = new VPuzzleLayout(); // create a standard sheet
VPSheet *sheet = new VPSheet(m_layout);
sheet->SetName(QObject::tr("Sheet #1"));
m_layout->AddSheet(sheet);
m_layout->SetFocusedSheet();
// ----- for test purposes, to be removed------------------ // ----- for test purposes, to be removed------------------
m_layout->SetLayoutMarginsConverted(2, 2, 2, 2); sheet->SetSheetMarginsConverted(2, 2, 2, 2);
m_layout->SetLayoutSizeConverted(30.0, 45); sheet->SetSheetSizeConverted(30.0, 45);
m_layout->SetPiecesGapConverted(1); sheet->SetPiecesGapConverted(1);
m_layout->SetUnit(Unit::Cm); m_layout->SetUnit(Unit::Cm);
m_layout->SetWarningSuperpositionOfPieces(true); m_layout->SetWarningSuperpositionOfPieces(true);
// -------------------------------------------------------- // --------------------------------------------------------
@ -71,7 +79,7 @@ PuzzleMainWindow::PuzzleMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *pa
InitMenuBar(); InitMenuBar();
InitProperties(); InitProperties();
InitPieceCarrousel(); InitCarrousel();
InitMainGraphics(); InitMainGraphics();
@ -81,14 +89,14 @@ PuzzleMainWindow::PuzzleMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *pa
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
PuzzleMainWindow::~PuzzleMainWindow() VPMainWindow::~VPMainWindow()
{ {
delete ui; delete ui;
delete m_pieceCarrousel; delete m_carrousel;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool PuzzleMainWindow::LoadFile(QString path) bool VPMainWindow::LoadFile(QString path)
{ {
try try
{ {
@ -105,11 +113,11 @@ bool PuzzleMainWindow::LoadFile(QString path)
QFile file(path); QFile file(path);
file.open(QIODevice::ReadOnly); file.open(QIODevice::ReadOnly);
QScopedPointer<VPuzzleLayoutFileReader> fileReader(new VPuzzleLayoutFileReader()); QScopedPointer<VPLayoutFileReader> fileReader(new VPLayoutFileReader());
if(m_layout == nullptr) if(m_layout == nullptr)
{ {
m_layout = new VPuzzleLayout(); m_layout = new VPLayout();
} }
fileReader->ReadFile(m_layout, &file); fileReader->ReadFile(m_layout, &file);
@ -120,12 +128,12 @@ bool PuzzleMainWindow::LoadFile(QString path)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool PuzzleMainWindow::SaveFile(const QString &path) bool VPMainWindow::SaveFile(const QString &path)
{ {
QFile file(path); QFile file(path);
file.open(QIODevice::WriteOnly); file.open(QIODevice::WriteOnly);
VPuzzleLayoutFileWriter *fileWriter = new VPuzzleLayoutFileWriter(); VPLayoutFileWriter *fileWriter = new VPLayoutFileWriter();
fileWriter->WriteFile(m_layout, &file); fileWriter->WriteFile(m_layout, &file);
// TODO / FIXME : better return value and error handling // TODO / FIXME : better return value and error handling
@ -134,7 +142,7 @@ bool PuzzleMainWindow::SaveFile(const QString &path)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::ImportRawLayouts(const QStringList &rawLayouts) void VPMainWindow::ImportRawLayouts(const QStringList &rawLayouts)
{ {
VRawLayout rawLayoutReader; VRawLayout rawLayoutReader;
@ -163,11 +171,11 @@ void PuzzleMainWindow::ImportRawLayouts(const QStringList &rawLayouts)
// TODO for feature "Update piece" : CreateOrUpdate() function indstead of CreatePiece() // TODO for feature "Update piece" : CreateOrUpdate() function indstead of CreatePiece()
VPuzzlePiece *piece = CreatePiece(rawPiece); VPPiece *piece = CreatePiece(rawPiece);
m_layout->GetUnplacedPiecesLayer()->AddPiece(piece); m_layout->GetUnplacedPieceList()->AddPiece(piece);
} }
m_pieceCarrousel->Refresh(); m_carrousel->Refresh();
} }
else else
{ {
@ -182,9 +190,9 @@ void PuzzleMainWindow::ImportRawLayouts(const QStringList &rawLayouts)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzlePiece* PuzzleMainWindow::CreatePiece(const VLayoutPiece &rawPiece) VPPiece* VPMainWindow::CreatePiece(const VLayoutPiece &rawPiece)
{ {
VPuzzlePiece *piece = new VPuzzlePiece(); VPPiece *piece = new VPPiece();
piece->SetName(rawPiece.GetName()); piece->SetName(rawPiece.GetName());
piece->SetUuid(rawPiece.GetUUID()); piece->SetUuid(rawPiece.GetUUID());
@ -201,22 +209,22 @@ VPuzzlePiece* PuzzleMainWindow::CreatePiece(const VLayoutPiece &rawPiece)
// TODO : set all the information we need for the piece! // TODO : set all the information we need for the piece!
// //
connect(piece, &VPuzzlePiece::SelectionChanged, this, &PuzzleMainWindow::on_PieceSelectionChanged); connect(piece, &VPPiece::SelectionChanged, this, &VPMainWindow::on_PieceSelectionChanged);
connect(piece, &VPuzzlePiece::PositionChanged, this, &PuzzleMainWindow::on_PiecePositionChanged); connect(piece, &VPPiece::PositionChanged, this, &VPMainWindow::on_PiecePositionChanged);
connect(piece, &VPuzzlePiece::RotationChanged, this, &PuzzleMainWindow::on_PieceRotationChanged); connect(piece, &VPPiece::RotationChanged, this, &VPMainWindow::on_PieceRotationChanged);
return piece; return piece;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::InitMenuBar() void VPMainWindow::InitMenuBar()
{ {
// most of the actions are connected through name convention (auto-connection) // most of the actions are connected through name convention (auto-connection)
// -------------------- connects the actions for the file menu // -------------------- connects the actions for the file menu
connect(ui->actionExit, &QAction::triggered, this, &PuzzleMainWindow::close); connect(ui->actionExit, &QAction::triggered, this, &VPMainWindow::close);
// -------------------- connects the actions for the edit menu // -------------------- connects the actions for the edit menu
// TODO : initialise the undo / redo // TODO : initialise the undo / redo
@ -231,28 +239,27 @@ void PuzzleMainWindow::InitMenuBar()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::InitProperties() void VPMainWindow::InitProperties()
{ {
InitPropertyTabCurrentPiece(); InitPropertyTabCurrentPiece();
InitPropertyTabLayout(); InitPropertyTabLayout();
InitPropertyTabLayers();
InitPropertyTabTiles(); InitPropertyTabTiles();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::InitPropertyTabCurrentPiece() void VPMainWindow::InitPropertyTabCurrentPiece()
{ {
// ------------------------------ placement ----------------------------------- // ------------------------------ placement -----------------------------------
connect(ui->doubleSpinBoxCurrentPieceBoxPositionX, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, connect(ui->doubleSpinBoxCurrentPieceBoxPositionX, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&PuzzleMainWindow::on_CurrentPiecePositionEdited); &VPMainWindow::on_CurrentPiecePositionEdited);
connect(ui->doubleSpinBoxCurrentPieceBoxPositionY, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, connect(ui->doubleSpinBoxCurrentPieceBoxPositionY, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&PuzzleMainWindow::on_CurrentPiecePositionEdited); &VPMainWindow::on_CurrentPiecePositionEdited);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::InitPropertyTabLayout() void VPMainWindow::InitPropertyTabLayout()
{ {
// -------------------- init the unit combobox --------------------- // -------------------- init the unit combobox ---------------------
ui->comboBoxLayoutUnit->addItem(tr("Centimeters"), QVariant(UnitsToStr(Unit::Cm))); ui->comboBoxLayoutUnit->addItem(tr("Centimeters"), QVariant(UnitsToStr(Unit::Cm)));
@ -270,32 +277,32 @@ void PuzzleMainWindow::InitPropertyTabLayout()
// see https://doc.qt.io/qt-5/designer-using-a-ui-file.html#widgets-and-dialogs-with-auto-connect // see https://doc.qt.io/qt-5/designer-using-a-ui-file.html#widgets-and-dialogs-with-auto-connect
// -------------------- layout width, length, orientation ------------------------ // -------------------- layout width, length, orientation ------------------------
connect(ui->doubleSpinBoxLayoutWidth, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, connect(ui->doubleSpinBoxSheetWidth, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&PuzzleMainWindow::on_LayoutSizeChanged); &VPMainWindow::on_SheetSizeChanged);
connect(ui->doubleSpinBoxLayoutLength, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, connect(ui->doubleSpinBoxSheetLength, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&PuzzleMainWindow::on_LayoutSizeChanged); &VPMainWindow::on_SheetSizeChanged);
connect(ui->radioButtonLayoutPortrait, QOverload<bool>::of(&QRadioButton::clicked), this, connect(ui->radioButtonSheetPortrait, QOverload<bool>::of(&QRadioButton::clicked), this,
&PuzzleMainWindow::on_LayoutOrientationChanged); &VPMainWindow::on_SheetOrientationChanged);
connect(ui->radioButtonLayoutLandscape, QOverload<bool>::of(&QRadioButton::clicked), this, connect(ui->radioButtonSheetLandscape, QOverload<bool>::of(&QRadioButton::clicked), this,
&PuzzleMainWindow::on_LayoutOrientationChanged); &VPMainWindow::on_SheetOrientationChanged);
// -------------------- margins ------------------------ // -------------------- margins ------------------------
connect(ui->doubleSpinBoxLayoutMarginTop, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, connect(ui->doubleSpinBoxSheetMarginTop, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&PuzzleMainWindow::on_LayoutMarginChanged); &VPMainWindow::on_SheetMarginChanged);
connect(ui->doubleSpinBoxLayoutMarginRight, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, connect(ui->doubleSpinBoxSheetMarginRight, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&PuzzleMainWindow::on_LayoutMarginChanged); &VPMainWindow::on_SheetMarginChanged);
connect(ui->doubleSpinBoxLayoutMarginBottom, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, connect(ui->doubleSpinBoxSheetMarginBottom, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&PuzzleMainWindow::on_LayoutMarginChanged); &VPMainWindow::on_SheetMarginChanged);
connect(ui->doubleSpinBoxLayoutMarginLeft, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, connect(ui->doubleSpinBoxSheetMarginLeft, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&PuzzleMainWindow::on_LayoutMarginChanged); &VPMainWindow::on_SheetMarginChanged);
// ------------------- follow grainline ----------------------- // ------------------- follow grainline -----------------------
connect(ui->radioButtonLayoutFollowGrainlineNo, QOverload<bool>::of(&QRadioButton::clicked), this, connect(ui->radioButtonSheetFollowGrainlineNo, QOverload<bool>::of(&QRadioButton::clicked), this,
&PuzzleMainWindow::on_LayoutFollowGrainlineChanged); &VPMainWindow::on_SheetFollowGrainlineChanged);
connect(ui->radioButtonLayoutFollowGrainlineVertical, QOverload<bool>::of(&QRadioButton::clicked), this, connect(ui->radioButtonSheetFollowGrainlineVertical, QOverload<bool>::of(&QRadioButton::clicked), this,
&PuzzleMainWindow::on_LayoutFollowGrainlineChanged); &VPMainWindow::on_SheetFollowGrainlineChanged);
connect(ui->radioButtonLayoutFollowGrainlineHorizontal, QOverload<bool>::of(&QRadioButton::clicked), this, connect(ui->radioButtonSheetFollowGrainlineHorizontal, QOverload<bool>::of(&QRadioButton::clicked), this,
&PuzzleMainWindow::on_LayoutFollowGrainlineChanged); &VPMainWindow::on_SheetFollowGrainlineChanged);
// -------------------- export --------------------------- // -------------------- export ---------------------------
@ -304,7 +311,7 @@ void PuzzleMainWindow::InitPropertyTabLayout()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::InitPropertyTabTiles() void VPMainWindow::InitPropertyTabTiles()
{ {
// for the MVP we don't want the tiles tab. // for the MVP we don't want the tiles tab.
// we remove it. As soon as we need it, update this code // we remove it. As soon as we need it, update this code
@ -312,26 +319,18 @@ void PuzzleMainWindow::InitPropertyTabTiles()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::InitPropertyTabLayers() void VPMainWindow::InitCarrousel()
{ {
// for the MVP we don't want the layers tab. m_carrousel = new VPCarrousel(m_layout, ui->dockWidgetCarrousel);
// we remove it. As soon as we need it, update this code ui->dockWidgetCarrousel->setWidget(m_carrousel);
ui->tabWidgetProperties->removeTab(3); // remove layers
}
//--------------------------------------------------------------------------------------------------------------------- connect(ui->dockWidgetCarrousel, QOverload<Qt::DockWidgetArea>::of(&QDockWidget::dockLocationChanged), this,
void PuzzleMainWindow::InitPieceCarrousel() &VPMainWindow::on_CarrouselLocationChanged);
{
m_pieceCarrousel = new VPieceCarrousel(m_layout, ui->dockWidgetPieceCarrousel);
ui->dockWidgetPieceCarrousel->setWidget(m_pieceCarrousel);
connect(ui->dockWidgetPieceCarrousel, QOverload<Qt::DockWidgetArea>::of(&QDockWidget::dockLocationChanged), this,
&PuzzleMainWindow::on_PieceCarrouselLocationChanged);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::SetPropertiesData() void VPMainWindow::SetPropertiesData()
{ {
if(m_layout == nullptr) if(m_layout == nullptr)
{ {
@ -340,14 +339,14 @@ void PuzzleMainWindow::SetPropertiesData()
else else
{ {
SetPropertyTabCurrentPieceData(); SetPropertyTabCurrentPieceData();
SetPropertyTabLayoutData(); SetPropertyTabSheetData();
SetPropertyTabTilesData(); SetPropertyTabTilesData();
SetPropertyTabLayersData(); SetPropertyTabLayoutData();
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::SetPropertyTabCurrentPieceData() void VPMainWindow::SetPropertyTabCurrentPieceData()
{ {
if(m_selectedPieces.count() == 0) if(m_selectedPieces.count() == 0)
{ {
@ -364,7 +363,7 @@ void PuzzleMainWindow::SetPropertyTabCurrentPieceData()
ui->containerCurrentPieceData->setVisible(true); ui->containerCurrentPieceData->setVisible(true);
ui->containerCurrentPieceMultipleData->setVisible(false); ui->containerCurrentPieceMultipleData->setVisible(false);
VPuzzlePiece *selectedPiece = m_selectedPieces.first(); VPPiece *selectedPiece = m_selectedPieces.first();
// set the value to the current piece // set the value to the current piece
ui->lineEditCurrentPieceName->setText(selectedPiece->GetName()); ui->lineEditCurrentPieceName->setText(selectedPiece->GetName());
@ -394,8 +393,45 @@ void PuzzleMainWindow::SetPropertyTabCurrentPieceData()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::SetPropertyTabLayoutData() void VPMainWindow::SetPropertyTabSheetData()
{ {
// set name // TODO FIXME make it better
ui->lineEditSheetName->setText(m_layout->GetFocusedSheet()->GetName());
// set Width / Length
QSizeF size = m_layout->GetFocusedSheet()->GetSheetSizeConverted();
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetWidth, size.width());
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetLength, size.height());
// Set Orientation
if(size.width() <= size.height())
{
ui->radioButtonSheetPortrait->setChecked(true);
}
else
{
ui->radioButtonSheetLandscape->setChecked(true);
}
// set margins
QMarginsF margins = m_layout->GetFocusedSheet()->GetSheetMarginsConverted();
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginLeft, margins.left());
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginTop, margins.top());
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginRight, margins.right());
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginBottom, margins.bottom());
// set pieces gap
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPiecesGap, m_layout->GetFocusedSheet()->GetPiecesGapConverted());
// set the checkboxes
SetCheckBoxValue(ui->checkBoxSheetStickyEdges, m_layout->GetFocusedSheet()->GetStickyEdges());
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::SetPropertyTabLayoutData()
{
// TODO FIXME : Set name and description
// set Unit // set Unit
int index = ui->comboBoxLayoutUnit->findData(QVariant(UnitsToStr(m_layout->GetUnit()))); int index = ui->comboBoxLayoutUnit->findData(QVariant(UnitsToStr(m_layout->GetUnit())));
if(index != -1) if(index != -1)
@ -405,53 +441,21 @@ void PuzzleMainWindow::SetPropertyTabLayoutData()
ui->comboBoxLayoutUnit->blockSignals(false); ui->comboBoxLayoutUnit->blockSignals(false);
} }
// set Width / Length // set controls
QSizeF size = m_layout->GetLayoutSizeConverted();
SetDoubleSpinBoxValue(ui->doubleSpinBoxLayoutWidth, size.width());
SetDoubleSpinBoxValue(ui->doubleSpinBoxLayoutLength, size.height());
// Set Orientation
if(size.width() <= size.height())
{
ui->radioButtonLayoutPortrait->setChecked(true);
}
else
{
ui->radioButtonLayoutLandscape->setChecked(true);
}
// set margins
QMarginsF margins = m_layout->GetLayoutMarginsConverted();
SetDoubleSpinBoxValue(ui->doubleSpinBoxLayoutMarginLeft, margins.left());
SetDoubleSpinBoxValue(ui->doubleSpinBoxLayoutMarginTop, margins.top());
SetDoubleSpinBoxValue(ui->doubleSpinBoxLayoutMarginRight, margins.right());
SetDoubleSpinBoxValue(ui->doubleSpinBoxLayoutMarginBottom, margins.bottom());
// set pieces gap
SetDoubleSpinBoxValue(ui->doubleSpinBoxLayoutPiecesGap, m_layout->GetPiecesGapConverted());
// set the checkboxes
SetCheckBoxValue(ui->checkBoxLayoutWarningPiecesOutOfBound, m_layout->GetWarningPiecesOutOfBound()); SetCheckBoxValue(ui->checkBoxLayoutWarningPiecesOutOfBound, m_layout->GetWarningPiecesOutOfBound());
SetCheckBoxValue(ui->checkBoxLayoutWarningPiecesSuperposition, m_layout->GetWarningSuperpositionOfPieces()); SetCheckBoxValue(ui->checkBoxLayoutWarningPiecesSuperposition, m_layout->GetWarningSuperpositionOfPieces());
SetCheckBoxValue(ui->checkBoxLayoutStickyEdges, m_layout->GetStickyEdges());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::SetPropertyTabTilesData() void VPMainWindow::SetPropertyTabTilesData()
{ {
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::SetPropertyTabLayersData() void VPMainWindow::InitMainGraphics()
{ {
m_graphicsView = new VPMainGraphicsView(m_layout, this);
}
//---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::InitMainGraphics()
{
m_graphicsView = new VPuzzleMainGraphicsView(m_layout, this);
ui->centralWidget->layout()->addWidget(m_graphicsView); ui->centralWidget->layout()->addWidget(m_graphicsView);
m_graphicsView->RefreshLayout(); m_graphicsView->RefreshLayout();
@ -459,7 +463,7 @@ void PuzzleMainWindow::InitMainGraphics()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::SetDoubleSpinBoxValue(QDoubleSpinBox *spinBox, qreal value) void VPMainWindow::SetDoubleSpinBoxValue(QDoubleSpinBox *spinBox, qreal value)
{ {
spinBox->blockSignals(true); spinBox->blockSignals(true);
spinBox->setValue(value); spinBox->setValue(value);
@ -467,7 +471,7 @@ void PuzzleMainWindow::SetDoubleSpinBoxValue(QDoubleSpinBox *spinBox, qreal valu
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::SetCheckBoxValue(QCheckBox *checkbox, bool value) void VPMainWindow::SetCheckBoxValue(QCheckBox *checkbox, bool value)
{ {
checkbox->blockSignals(true); checkbox->blockSignals(true);
checkbox->setChecked(value); checkbox->setChecked(value);
@ -475,10 +479,10 @@ void PuzzleMainWindow::SetCheckBoxValue(QCheckBox *checkbox, bool value)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::ReadSettings() void VPMainWindow::ReadSettings()
{ {
qCDebug(pWindow, "Reading settings."); qCDebug(pWindow, "Reading settings.");
const VPuzzleSettings *settings = qApp->PuzzleSettings(); const VPSettings *settings = qApp->PuzzleSettings();
if (settings->status() == QSettings::NoError) if (settings->status() == QSettings::NoError)
{ {
@ -502,9 +506,9 @@ void PuzzleMainWindow::ReadSettings()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::WriteSettings() void VPMainWindow::WriteSettings()
{ {
VPuzzleSettings *settings = qApp->PuzzleSettings(); VPSettings *settings = qApp->PuzzleSettings();
settings->SetGeometry(saveGeometry()); settings->SetGeometry(saveGeometry());
settings->SetWindowState(saveState()); settings->SetWindowState(saveState());
settings->SetToolbarsState(saveState(APP_VERSION)); settings->SetToolbarsState(saveState(APP_VERSION));
@ -520,7 +524,7 @@ void PuzzleMainWindow::WriteSettings()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool PuzzleMainWindow::MaybeSave() bool VPMainWindow::MaybeSave()
{ {
// TODO: Implement maybe save check // TODO: Implement maybe save check
// if (this->isWindowModified()) // if (this->isWindowModified())
@ -568,11 +572,11 @@ bool PuzzleMainWindow::MaybeSave()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_actionNew_triggered() void VPMainWindow::on_actionNew_triggered()
{ {
// just for test purpuses, to be removed: // just for test purpuses, to be removed:
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText("TODO PuzzleMainWindow::New"); msgBox.setText("TODO VPMainWindow::New");
int ret = msgBox.exec(); int ret = msgBox.exec();
Q_UNUSED(ret); Q_UNUSED(ret);
@ -583,7 +587,7 @@ void PuzzleMainWindow::on_actionNew_triggered()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::closeEvent(QCloseEvent *event) void VPMainWindow::closeEvent(QCloseEvent *event)
{ {
#if defined(Q_OS_MAC) && QT_VERSION < QT_VERSION_CHECK(5, 11, 1) #if defined(Q_OS_MAC) && QT_VERSION < QT_VERSION_CHECK(5, 11, 1)
// Workaround for Qt bug https://bugreports.qt.io/browse/QTBUG-43344 // Workaround for Qt bug https://bugreports.qt.io/browse/QTBUG-43344
@ -607,7 +611,7 @@ void PuzzleMainWindow::closeEvent(QCloseEvent *event)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_actionOpen_triggered() void VPMainWindow::on_actionOpen_triggered()
{ {
qCDebug(pWindow, "Openning puzzle layout file."); qCDebug(pWindow, "Openning puzzle layout file.");
@ -661,11 +665,11 @@ void PuzzleMainWindow::on_actionOpen_triggered()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_actionSave_triggered() void VPMainWindow::on_actionSave_triggered()
{ {
// just for test purpuses, to be removed: // just for test purpuses, to be removed:
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText("TODO PuzzleMainWindow::Save"); msgBox.setText("TODO VPMainWindow::Save");
int ret = msgBox.exec(); int ret = msgBox.exec();
Q_UNUSED(ret); Q_UNUSED(ret);
@ -674,7 +678,7 @@ void PuzzleMainWindow::on_actionSave_triggered()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_actionSaveAs_triggered() void VPMainWindow::on_actionSaveAs_triggered()
{ {
// TODO / FIXME : See valentina how the save is done over there. we need to add the extension .vlt, check for empty file names etc. // TODO / FIXME : See valentina how the save is done over there. we need to add the extension .vlt, check for empty file names etc.
@ -704,7 +708,7 @@ void PuzzleMainWindow::on_actionSaveAs_triggered()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_actionImportRawLayout_triggered() void VPMainWindow::on_actionImportRawLayout_triggered()
{ {
// TODO: here the code is probably just bad, to be edited // TODO: here the code is probably just bad, to be edited
@ -733,11 +737,11 @@ void PuzzleMainWindow::on_actionImportRawLayout_triggered()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_actionCloseLayout_triggered() void VPMainWindow::on_actionCloseLayout_triggered()
{ {
// just for test purpuses, to be removed: // just for test purpuses, to be removed:
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText("TODO PuzzleMainWindow::CloseLayout"); msgBox.setText("TODO VPMainWindow::CloseLayout");
int ret = msgBox.exec(); int ret = msgBox.exec();
Q_UNUSED(ret); Q_UNUSED(ret);
@ -746,21 +750,21 @@ void PuzzleMainWindow::on_actionCloseLayout_triggered()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_actionAboutQt_triggered() void VPMainWindow::on_actionAboutQt_triggered()
{ {
QMessageBox::aboutQt(this, tr("About Qt")); QMessageBox::aboutQt(this, tr("About Qt"));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_actionAboutPuzzle_triggered() void VPMainWindow::on_actionAboutPuzzle_triggered()
{ {
auto *aboutDialog = new DialogAboutPuzzle(this); auto *aboutDialog = new VPDialogAbout(this);
aboutDialog->setAttribute(Qt::WA_DeleteOnClose, true); aboutDialog->setAttribute(Qt::WA_DeleteOnClose, true);
aboutDialog->show(); aboutDialog->show();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_comboBoxLayoutUnit_currentIndexChanged(int index) void VPMainWindow::on_comboBoxLayoutUnit_currentIndexChanged(int index)
{ {
Q_UNUSED(index); Q_UNUSED(index);
QVariant comboBoxValue = ui->comboBoxLayoutUnit->currentData(); QVariant comboBoxValue = ui->comboBoxLayoutUnit->currentData();
@ -778,16 +782,16 @@ void PuzzleMainWindow::on_comboBoxLayoutUnit_currentIndexChanged(int index)
m_layout->SetUnit(Unit::Inch); m_layout->SetUnit(Unit::Inch);
} }
SetPropertyTabLayoutData(); SetPropertyTabSheetData();
SetPropertyTabCurrentPieceData(); SetPropertyTabCurrentPieceData();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_comboBoxLayoutTemplate_currentIndexChanged(int index) void VPMainWindow::on_comboBoxSheetTemplate_currentIndexChanged(int index)
{ {
// just for test purpuses, to be removed: // just for test purpuses, to be removed:
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText("TODO PuzzleMainWindow::LayoutTemplateChanged"); msgBox.setText("TODO VPMainWindow::SheetTemplateChanged");
int ret = msgBox.exec(); int ret = msgBox.exec();
Q_UNUSED(index); Q_UNUSED(index);
@ -798,20 +802,20 @@ void PuzzleMainWindow::on_comboBoxLayoutTemplate_currentIndexChanged(int index)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_LayoutSizeChanged() void VPMainWindow::on_SheetSizeChanged()
{ {
m_layout->SetLayoutSizeConverted(ui->doubleSpinBoxLayoutWidth->value(), ui->doubleSpinBoxLayoutLength->value()); m_layout->GetFocusedSheet()->SetSheetSizeConverted(ui->doubleSpinBoxSheetWidth->value(), ui->doubleSpinBoxSheetLength->value());
// updates orientation - no need to block signals because the signal reacts on "clicked" // updates orientation - no need to block signals because the signal reacts on "clicked"
if(ui->doubleSpinBoxLayoutWidth->value() <= ui->doubleSpinBoxLayoutLength->value()) if(ui->doubleSpinBoxSheetWidth->value() <= ui->doubleSpinBoxSheetLength->value())
{ {
//portrait //portrait
ui->radioButtonLayoutPortrait->setChecked(true); ui->radioButtonSheetPortrait->setChecked(true);
} }
else else
{ {
//landscape //landscape
ui->radioButtonLayoutLandscape->setChecked(true); ui->radioButtonSheetLandscape->setChecked(true);
} }
// TODO Undo / Redo // TODO Undo / Redo
@ -820,16 +824,16 @@ void PuzzleMainWindow::on_LayoutSizeChanged()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_LayoutOrientationChanged() void VPMainWindow::on_SheetOrientationChanged()
{ {
// swap the width and length // swap the width and length
qreal width_before = ui->doubleSpinBoxLayoutWidth->value(); qreal width_before = ui->doubleSpinBoxSheetWidth->value();
qreal length_before = ui->doubleSpinBoxLayoutLength->value(); qreal length_before = ui->doubleSpinBoxSheetLength->value();
SetDoubleSpinBoxValue(ui->doubleSpinBoxLayoutWidth, length_before); SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetWidth, length_before);
SetDoubleSpinBoxValue(ui->doubleSpinBoxLayoutLength, width_before); SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetLength, width_before);
m_layout->SetLayoutSizeConverted(ui->doubleSpinBoxLayoutWidth->value(), ui->doubleSpinBoxLayoutLength->value()); m_layout->GetFocusedSheet()->SetSheetSizeConverted(ui->doubleSpinBoxSheetWidth->value(), ui->doubleSpinBoxSheetLength->value());
// TODO Undo / Redo // TODO Undo / Redo
@ -837,11 +841,11 @@ void PuzzleMainWindow::on_LayoutOrientationChanged()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_pushButtonLayoutRemoveUnusedLength_clicked() void VPMainWindow::on_pushButtonSheetRemoveUnusedLength_clicked()
{ {
// just for test purpuses, to be removed: // just for test purpuses, to be removed:
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText("TODO PuzzleMainWindow::LayoutRemoveUnusedLength"); msgBox.setText("TODO VPMainWindow::on_pushButtonSheetRemoveUnusedLength_clicked");
int ret = msgBox.exec(); int ret = msgBox.exec();
Q_UNUSED(ret); Q_UNUSED(ret);
@ -851,13 +855,13 @@ void PuzzleMainWindow::on_pushButtonLayoutRemoveUnusedLength_clicked()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_LayoutMarginChanged() void VPMainWindow::on_SheetMarginChanged()
{ {
m_layout->SetLayoutMarginsConverted( m_layout->GetFocusedSheet()->SetSheetMarginsConverted(
ui->doubleSpinBoxLayoutMarginLeft->value(), ui->doubleSpinBoxSheetMarginLeft->value(),
ui->doubleSpinBoxLayoutMarginTop->value(), ui->doubleSpinBoxSheetMarginTop->value(),
ui->doubleSpinBoxLayoutMarginRight->value(), ui->doubleSpinBoxSheetMarginRight->value(),
ui->doubleSpinBoxLayoutMarginBottom->value() ui->doubleSpinBoxSheetMarginBottom->value()
); );
// TODO Undo / Redo // TODO Undo / Redo
@ -867,11 +871,11 @@ void PuzzleMainWindow::on_LayoutMarginChanged()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_LayoutFollowGrainlineChanged() void VPMainWindow::on_SheetFollowGrainlineChanged()
{ {
// just for test purpuses, to be removed: // just for test purpuses, to be removed:
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText("TODO PuzzleMainWindow::LayoutFollowGrainlineChanged"); msgBox.setText("TODO VPMainWindow::on_SheetFollowGrainlineChanged");
int ret = msgBox.exec(); int ret = msgBox.exec();
Q_UNUSED(ret); Q_UNUSED(ret);
@ -881,16 +885,16 @@ void PuzzleMainWindow::on_LayoutFollowGrainlineChanged()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_doubleSpinBoxLayoutPiecesGap_valueChanged(double value) void VPMainWindow::on_doubleSpinBoxSheetPiecesGap_valueChanged(double value)
{ {
m_layout->SetPiecesGapConverted(value); m_layout->GetFocusedSheet()->SetPiecesGapConverted(value);
// TODO Undo / Redo // TODO Undo / Redo
// TODO update the QGraphicView // TODO update the QGraphicView
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_checkBoxLayoutWarningPiecesSuperposition_toggled(bool checked) void VPMainWindow::on_checkBoxLayoutWarningPiecesSuperposition_toggled(bool checked)
{ {
m_layout->SetWarningSuperpositionOfPieces(checked); m_layout->SetWarningSuperpositionOfPieces(checked);
@ -899,7 +903,7 @@ void PuzzleMainWindow::on_checkBoxLayoutWarningPiecesSuperposition_toggled(bool
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_checkBoxLayoutWarningPiecesOutOfBound_toggled(bool checked) void VPMainWindow::on_checkBoxLayoutWarningPiecesOutOfBound_toggled(bool checked)
{ {
m_layout->SetWarningPiecesOutOfBound(checked); m_layout->SetWarningPiecesOutOfBound(checked);
@ -908,20 +912,20 @@ void PuzzleMainWindow::on_checkBoxLayoutWarningPiecesOutOfBound_toggled(bool che
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_checkBoxLayoutStickyEdges_toggled(bool checked) void VPMainWindow::on_checkBoxSheetStickyEdges_toggled(bool checked)
{ {
m_layout->SetStickyEdges(checked); m_layout->GetFocusedSheet()->SetStickyEdges(checked);
// TODO Undo / Redo // TODO Undo / Redo
// TODO update the QGraphicView // TODO update the QGraphicView
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_pushButtonLayoutExport_clicked() void VPMainWindow::on_pushButtonSheetExport_clicked()
{ {
// just for test purpuses, to be removed: // just for test purpuses, to be removed:
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText("TODO PuzzleMainWindow::LayoutExport"); msgBox.setText("TODO VPMainWindow::on_pushButtonSheetExport_clicked");
int ret = msgBox.exec(); int ret = msgBox.exec();
Q_UNUSED(ret); Q_UNUSED(ret);
@ -931,7 +935,7 @@ void PuzzleMainWindow::on_pushButtonLayoutExport_clicked()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_checkBoxCurrentPieceShowSeamline_toggled(bool checked) void VPMainWindow::on_checkBoxCurrentPieceShowSeamline_toggled(bool checked)
{ {
if(m_selectedPieces.count() == 1) if(m_selectedPieces.count() == 1)
{ {
@ -940,7 +944,7 @@ void PuzzleMainWindow::on_checkBoxCurrentPieceShowSeamline_toggled(bool checked)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_checkBoxCurrentPieceMirrorPiece_toggled(bool checked) void VPMainWindow::on_checkBoxCurrentPieceMirrorPiece_toggled(bool checked)
{ {
if(m_selectedPieces.count() == 1) if(m_selectedPieces.count() == 1)
{ {
@ -949,22 +953,22 @@ void PuzzleMainWindow::on_checkBoxCurrentPieceMirrorPiece_toggled(bool checked)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_doubleSpinBoxCurrentPieceAngle_valueChanged(double value) void VPMainWindow::on_doubleSpinBoxCurrentPieceAngle_valueChanged(double value)
{ {
if(m_selectedPieces.count() == 1) if(m_selectedPieces.count() == 1)
{ {
VPuzzlePiece *piece = m_selectedPieces.first(); VPPiece *piece = m_selectedPieces.first();
piece->SetRotation(value); piece->SetRotation(value);
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_CurrentPiecePositionEdited() void VPMainWindow::on_CurrentPiecePositionEdited()
{ {
if(m_selectedPieces.count() == 1) if(m_selectedPieces.count() == 1)
{ {
VPuzzlePiece *piece = m_selectedPieces.first(); VPPiece *piece = m_selectedPieces.first();
QPointF pos(UnitConvertor(ui->doubleSpinBoxCurrentPieceBoxPositionX->value(), m_layout->GetUnit(), Unit::Px), QPointF pos(UnitConvertor(ui->doubleSpinBoxCurrentPieceBoxPositionX->value(), m_layout->GetUnit(), Unit::Px),
UnitConvertor(ui->doubleSpinBoxCurrentPieceBoxPositionY->value(), m_layout->GetUnit(), Unit::Px)); UnitConvertor(ui->doubleSpinBoxCurrentPieceBoxPositionY->value(), m_layout->GetUnit(), Unit::Px));
piece->SetPosition(pos); piece->SetPosition(pos);
@ -972,20 +976,20 @@ void PuzzleMainWindow::on_CurrentPiecePositionEdited()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_PieceCarrouselLocationChanged(Qt::DockWidgetArea area) void VPMainWindow::on_CarrouselLocationChanged(Qt::DockWidgetArea area)
{ {
if(area == Qt::BottomDockWidgetArea || area == Qt::TopDockWidgetArea) if(area == Qt::BottomDockWidgetArea || area == Qt::TopDockWidgetArea)
{ {
m_pieceCarrousel->SetOrientation(Qt::Horizontal); m_carrousel->SetOrientation(Qt::Horizontal);
} }
else if (area == Qt::LeftDockWidgetArea || area == Qt::RightDockWidgetArea) else if (area == Qt::LeftDockWidgetArea || area == Qt::RightDockWidgetArea)
{ {
m_pieceCarrousel->SetOrientation(Qt::Vertical); m_carrousel->SetOrientation(Qt::Vertical);
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_PieceSelectionChanged() void VPMainWindow::on_PieceSelectionChanged()
{ {
m_selectedPieces = m_layout->GetSelectedPieces(); m_selectedPieces = m_layout->GetSelectedPieces();
@ -995,11 +999,11 @@ void PuzzleMainWindow::on_PieceSelectionChanged()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_PiecePositionChanged() void VPMainWindow::on_PiecePositionChanged()
{ {
if(m_selectedPieces.count() == 1) if(m_selectedPieces.count() == 1)
{ {
VPuzzlePiece *piece = m_selectedPieces.first(); VPPiece *piece = m_selectedPieces.first();
QPointF pos = piece->GetPosition(); QPointF pos = piece->GetPosition();
SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionX, SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionX,
@ -1010,11 +1014,11 @@ void PuzzleMainWindow::on_PiecePositionChanged()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_PieceRotationChanged() void VPMainWindow::on_PieceRotationChanged()
{ {
if(m_selectedPieces.count() == 1) if(m_selectedPieces.count() == 1)
{ {
VPuzzlePiece *piece = m_selectedPieces.first(); VPPiece *piece = m_selectedPieces.first();
qreal angle = piece->GetRotation(); qreal angle = piece->GetRotation();
SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceAngle, angle); SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceAngle, angle);

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file puzzlemainwindow.h ** @file vpmainwindow.h
** @author Roman Telezhynskyi <dismine(at)gmail.com> ** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 16 2, 2020 ** @date 16 2, 2020
** **
@ -25,33 +25,33 @@
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
*************************************************************************/ *************************************************************************/
#ifndef PUZZLEMAINWINDOW_H #ifndef VPMAINWINDOW_H
#define PUZZLEMAINWINDOW_H #define VPMAINWINDOW_H
#include <QMainWindow> #include <QMainWindow>
#include <QMessageBox> #include <QMessageBox>
#include <QDoubleSpinBox> #include <QDoubleSpinBox>
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "vpiececarrousel.h" #include "vpcarrousel.h"
#include "vpuzzlemaingraphicsview.h" #include "vpmaingraphicsview.h"
#include "vpuzzlelayout.h" #include "vplayout.h"
#include "vpuzzlepiece.h" #include "vppiece.h"
#include "../vlayout/vlayoutpiece.h" #include "../vlayout/vlayoutpiece.h"
#include "vpuzzlecommandline.h" #include "vpcommandline.h"
namespace Ui namespace Ui
{ {
class PuzzleMainWindow; class VPMainWindow;
} }
class PuzzleMainWindow : public QMainWindow class VPMainWindow : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit PuzzleMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *parent = nullptr); explicit VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent = nullptr);
virtual ~PuzzleMainWindow(); virtual ~VPMainWindow();
/** /**
* @brief LoadFile Loads the layout file of given path in m_layout. * @brief LoadFile Loads the layout file of given path in m_layout.
@ -87,22 +87,22 @@ protected:
virtual void closeEvent(QCloseEvent *event) override; virtual void closeEvent(QCloseEvent *event) override;
private: private:
Q_DISABLE_COPY(PuzzleMainWindow) Q_DISABLE_COPY(VPMainWindow)
Ui::PuzzleMainWindow *ui; Ui::VPMainWindow *ui;
VPieceCarrousel *m_pieceCarrousel{nullptr}; VPCarrousel *m_carrousel{nullptr};
VPuzzleMainGraphicsView *m_graphicsView{nullptr}; VPMainGraphicsView *m_graphicsView{nullptr};
VPuzzleCommandLinePtr m_cmd; VPCommandLinePtr m_cmd;
VPuzzleLayout *m_layout{nullptr}; VPLayout *m_layout{nullptr};
QList<VPuzzlePiece *>m_selectedPieces{QList<VPuzzlePiece *>()}; QList<VPPiece *>m_selectedPieces{QList<VPPiece *>()};
/** /**
* @brief CreatePiece creates a piece from the given VLayoutPiece data * @brief CreatePiece creates a piece from the given VLayoutPiece data
* @param rawPiece the raw piece data * @param rawPiece the raw piece data
*/ */
VPuzzlePiece* CreatePiece(const VLayoutPiece &rawPiece); VPPiece* CreatePiece(const VLayoutPiece &rawPiece);
/** /**
* @brief InitMenuBar Inits the menu bar (File, Edit, Help ...) * @brief InitMenuBar Inits the menu bar (File, Edit, Help ...)
@ -130,14 +130,9 @@ private:
void InitPropertyTabTiles(); void InitPropertyTabTiles();
/** /**
* @brief InitPropertyTabLayers Inits the layers tab in the properties * @brief InitCarrousel Inits the carrousel
*/ */
void InitPropertyTabLayers(); void InitCarrousel();
/**
* @brief InitPieceCarrousel Inits the piece carrousel
*/
void InitPieceCarrousel();
/** /**
* @brief InitMainGraphics Initialises the puzzle main graphics * @brief InitMainGraphics Initialises the puzzle main graphics
@ -157,10 +152,10 @@ private:
void SetPropertyTabCurrentPieceData(); void SetPropertyTabCurrentPieceData();
/** /**
* @brief SetPropertyTabLayoutData Sets the values of UI elements * @brief SetPropertyTabSheetData Sets the values of UI elements
* in the Layout Tab to the values saved in m_layout * in the Sheet Tab to the values saved in focused sheet
*/ */
void SetPropertyTabLayoutData(); void SetPropertyTabSheetData();
/** /**
* @brief SetPropertyTabTilesData Sets the values of UI elements * @brief SetPropertyTabTilesData Sets the values of UI elements
@ -169,10 +164,10 @@ private:
void SetPropertyTabTilesData(); void SetPropertyTabTilesData();
/** /**
* @brief SetPropertyTabLayersData Sets the values of UI elements * @brief SetPropertyTabLayoutData Sets the values of UI elements
* in the Layers Tab to the values saved in m_layout * in the Layout Tab to the values saved in m_layout
*/ */
void SetPropertyTabLayersData(); void SetPropertyTabLayoutData();
/** /**
* @brief SetDoubleSpinBoxValue sets the given spinbox to the given value. * @brief SetDoubleSpinBoxValue sets the given spinbox to the given value.
@ -259,38 +254,38 @@ private slots:
* The slot is automatically connected through name convention. * The slot is automatically connected through name convention.
* @param index the index of the selected templated * @param index the index of the selected templated
*/ */
void on_comboBoxLayoutTemplate_currentIndexChanged(int index); void on_comboBoxSheetTemplate_currentIndexChanged(int index);
/** /**
* @brief LayoutSizeChanged When the width or the length has been changed in * @brief LayoutSizeChanged When the width or the length has been changed in
* the layout property tab * the layout property tab
*/ */
void on_LayoutSizeChanged(); void on_SheetSizeChanged();
/** /**
* @brief LayoutOrientationChanged When one of the radio boxes for the layout * @brief LayoutOrientationChanged When one of the radio boxes for the layout
* orientation has been clicked * orientation has been clicked
*/ */
void on_LayoutOrientationChanged(); void on_SheetOrientationChanged();
/** /**
* @brief on_pushButtonLayoutRemoveUnusedLength_clicked When the button * @brief on_pushButtonLayoutRemoveUnusedLength_clicked When the button
* "Remove unused length" in the layout property tab is clicked. * "Remove unused length" in the layout property tab is clicked.
* The slot is automatically connected through name convention. * The slot is automatically connected through name convention.
*/ */
void on_pushButtonLayoutRemoveUnusedLength_clicked(); void on_pushButtonSheetRemoveUnusedLength_clicked();
/** /**
* @brief on_LayoutMarginChanged When one of the margin values has been changed * @brief on_LayoutMarginChanged When one of the margin values has been changed
* in the layout property tab. * in the layout property tab.
*/ */
void on_LayoutMarginChanged(); void on_SheetMarginChanged();
/** /**
* @brief LayoutFollowGrainlineChanged When one of the radio boxes for the * @brief LayoutFollowGrainlineChanged When one of the radio boxes for the
* "Follow grainline" has been clicked in the layout property tab. * "Follow grainline" has been clicked in the layout property tab.
*/ */
void on_LayoutFollowGrainlineChanged(); void on_SheetFollowGrainlineChanged();
/** /**
* @brief on_doubleSpinBoxLayoutPiecesGap_valueChanged When the "pieces gap" * @brief on_doubleSpinBoxLayoutPiecesGap_valueChanged When the "pieces gap"
@ -298,7 +293,7 @@ private slots:
* The slot is automatically connected through name convention. * The slot is automatically connected through name convention.
* @param value the new value of the pieces gap * @param value the new value of the pieces gap
*/ */
void on_doubleSpinBoxLayoutPiecesGap_valueChanged(double value); void on_doubleSpinBoxSheetPiecesGap_valueChanged(double value);
/** /**
* @brief on_checkBoxLayoutWarningPiecesSuperposition_toggled When the * @brief on_checkBoxLayoutWarningPiecesSuperposition_toggled When the
@ -324,14 +319,14 @@ private slots:
* The slot is automatically connected through name convention. * The slot is automatically connected through name convention.
* @param checked the new checked value * @param checked the new checked value
*/ */
void on_checkBoxLayoutStickyEdges_toggled(bool checked); void on_checkBoxSheetStickyEdges_toggled(bool checked);
/** /**
* @brief on_pushButtonLayoutExport_clicked When the button * @brief on_pushButtonLayoutExport_clicked When the button
* "Export layout" in the layout property is clicked. * "Export layout" in the layout property is clicked.
* The slot is automatically connected through name convention. * The slot is automatically connected through name convention.
*/ */
void on_pushButtonLayoutExport_clicked(); void on_pushButtonSheetExport_clicked();
/** /**
* @brief on_checkBoxCurrentPieceShowSeamline_toggled When the * @brief on_checkBoxCurrentPieceShowSeamline_toggled When the
@ -364,11 +359,11 @@ private slots:
void on_CurrentPiecePositionEdited(); void on_CurrentPiecePositionEdited();
/** /**
* @brief PieceCarrouselLocationChanged When the piece carrousel's location * @brief CarrouselLocationChanged When the piece carrousel's location
* has been changed * has been changed
* @param area The new area where the piece carrousel has been placed * @param area The new area where the piece carrousel has been placed
*/ */
void on_PieceCarrouselLocationChanged(Qt::DockWidgetArea area); void on_CarrouselLocationChanged(Qt::DockWidgetArea area);
/** /**
* @brief on_PieceSelectionChanged When the piece selection has changed * @brief on_PieceSelectionChanged When the piece selection has changed
@ -387,4 +382,4 @@ private slots:
}; };
#endif // PUZZLEMAINWINDOW_H #endif // VPMAINWINDOW_H

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>PuzzleMainWindow</class> <class>VPMainWindow</class>
<widget class="QMainWindow" name="PuzzleMainWindow"> <widget class="QMainWindow" name="VPMainWindow">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
@ -82,7 +82,7 @@
</attribute> </attribute>
</widget> </widget>
<widget class="QStatusBar" name="statusBar"/> <widget class="QStatusBar" name="statusBar"/>
<widget class="QDockWidget" name="dockWidgetPieceCarrousel"> <widget class="QDockWidget" name="dockWidgetCarrousel">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -110,7 +110,7 @@
<attribute name="dockWidgetArea"> <attribute name="dockWidgetArea">
<number>1</number> <number>1</number>
</attribute> </attribute>
<widget class="QWidget" name="widgetPieceCarrousel"> <widget class="QWidget" name="widgetCarrousel">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -230,7 +230,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>342</width> <width>342</width>
<height>1318</height> <height>1264</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
@ -253,6 +253,18 @@
<item> <item>
<widget class="QWidget" name="containerCurrentPieceData" native="true"> <widget class="QWidget" name="containerCurrentPieceData" native="true">
<layout class="QVBoxLayout" name="containerCurrentPieceDataLayout"> <layout class="QVBoxLayout" name="containerCurrentPieceDataLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item> <item>
<widget class="QGroupBox" name="groupBoxCurrentPieceInfo"> <widget class="QGroupBox" name="groupBoxCurrentPieceInfo">
<property name="title"> <property name="title">
@ -398,6 +410,18 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="labelCurrentPieceNoPieceSelected"> <widget class="QLabel" name="labelCurrentPieceNoPieceSelected">
<property name="minimumSize"> <property name="minimumSize">
@ -420,6 +444,18 @@
<item> <item>
<widget class="QWidget" name="containerCurrentPieceMultipleData" native="true"> <widget class="QWidget" name="containerCurrentPieceMultipleData" native="true">
<layout class="QVBoxLayout" name="verticalLayout_11"> <layout class="QVBoxLayout" name="verticalLayout_11">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="labelCurrentPieceMultiplePieceSelected"> <widget class="QLabel" name="labelCurrentPieceMultiplePieceSelected">
<property name="minimumSize"> <property name="minimumSize">
@ -458,7 +494,7 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tabLayoutProperty"> <widget class="QWidget" name="tabSheetProperty">
<attribute name="icon"> <attribute name="icon">
<iconset resource="share/resources/puzzleicon.qrc"> <iconset resource="share/resources/puzzleicon.qrc">
<normaloff>:/puzzleicon/64x64/iconLayout.png</normaloff>:/puzzleicon/64x64/iconLayout.png</iconset> <normaloff>:/puzzleicon/64x64/iconLayout.png</normaloff>:/puzzleicon/64x64/iconLayout.png</iconset>
@ -483,7 +519,7 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QScrollArea" name="scrollAreaLayout"> <widget class="QScrollArea" name="scrollAreaSheet">
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::NoFrame</enum> <enum>QFrame::NoFrame</enum>
</property> </property>
@ -507,12 +543,12 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QLabel" name="labelLayout"> <widget class="QLabel" name="labelSheet">
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">font-weight: bold;</string> <string notr="true">font-weight: bold;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Layout</string> <string>Current sheet</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
@ -520,7 +556,30 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBoxLayoutFormat"> <widget class="QGroupBox" name="groupBoxSheetInfos">
<property name="title">
<string>Infos</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_17">
<item>
<layout class="QFormLayout" name="formLayout_8">
<item row="0" column="0">
<widget class="QLabel" name="labelSheetName">
<property name="text">
<string>Name </string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEditSheetName"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxSheetFormat">
<property name="title"> <property name="title">
<string>Format</string> <string>Format</string>
</property> </property>
@ -528,64 +587,54 @@
<item> <item>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="labelLayoutUnit"> <widget class="QLabel" name="labelSheetTemplate">
<property name="text">
<string>Unit</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxLayoutUnit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelLayoutTemplate">
<property name="text"> <property name="text">
<string>Template</string> <string>Template</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="0" column="1">
<widget class="QComboBox" name="comboBoxLayoutTemplate"/> <widget class="QComboBox" name="comboBoxSheetTemplate"/>
</item> </item>
<item row="2" column="0"> <item row="1" column="0">
<widget class="QLabel" name="labelLayoutwidth"> <widget class="QLabel" name="labelSheetwidth">
<property name="text"> <property name="text">
<string>Width</string> <string>Width</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxLayoutWidth"> <widget class="QDoubleSpinBox" name="doubleSpinBoxSheetWidth">
<property name="maximum"> <property name="maximum">
<double>100000.000000000000000</double> <double>100000.000000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="2" column="0">
<widget class="QDoubleSpinBox" name="doubleSpinBoxLayoutLength"> <widget class="QLabel" name="labelSheetLength">
<property name="text">
<string>Length</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxSheetLength">
<property name="maximum"> <property name="maximum">
<double>100000.000000000000000</double> <double>100000.000000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QLabel" name="labelLayoutLength"> <widget class="QLabel" name="labelSheetOrientation">
<property name="text">
<string>Length</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="labelLayoutOrientation">
<property name="text"> <property name="text">
<string>Orientation</string> <string>Orientation</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QRadioButton" name="radioButtonLayoutPortrait"> <widget class="QRadioButton" name="radioButtonSheetPortrait">
<property name="toolTip"> <property name="toolTip">
<string>Portrait</string> <string>Portrait</string>
</property> </property>
@ -608,7 +657,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QRadioButton" name="radioButtonLayoutLandscape"> <widget class="QRadioButton" name="radioButtonSheetLandscape">
<property name="toolTip"> <property name="toolTip">
<string>Landscape</string> <string>Landscape</string>
</property> </property>
@ -632,7 +681,7 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButtonLayoutRemoveUnusedLength"> <widget class="QPushButton" name="pushButtonSheetRemoveUnusedLength">
<property name="text"> <property name="text">
<string>Remove unused length</string> <string>Remove unused length</string>
</property> </property>
@ -642,13 +691,13 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBoxLayoutMargin"> <widget class="QGroupBox" name="groupBoxSheetMargin">
<property name="title"> <property name="title">
<string>Margins</string> <string>Margins</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="1" column="2"> <item row="1" column="2">
<widget class="QLabel" name="labelLayoutMarginRight"> <widget class="QLabel" name="labelSheetMarginRight">
<property name="text"> <property name="text">
<string>Right:</string> <string>Right:</string>
</property> </property>
@ -658,7 +707,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLabel" name="labelLayoutMarginTop"> <widget class="QLabel" name="labelSheetMarginTop">
<property name="text"> <property name="text">
<string>Top:</string> <string>Top:</string>
</property> </property>
@ -668,21 +717,21 @@
</widget> </widget>
</item> </item>
<item row="1" column="3"> <item row="1" column="3">
<widget class="QDoubleSpinBox" name="doubleSpinBoxLayoutMarginRight"> <widget class="QDoubleSpinBox" name="doubleSpinBoxSheetMarginRight">
<property name="singleStep"> <property name="singleStep">
<double>0.100000000000000</double> <double>0.100000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxLayoutMarginLeft"> <widget class="QDoubleSpinBox" name="doubleSpinBoxSheetMarginLeft">
<property name="singleStep"> <property name="singleStep">
<double>0.100000000000000</double> <double>0.100000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="labelLayoutMarginLeft"> <widget class="QLabel" name="labelSheetMarginLeft">
<property name="text"> <property name="text">
<string>Left:</string> <string>Left:</string>
</property> </property>
@ -692,7 +741,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item row="0" column="2">
<widget class="QDoubleSpinBox" name="doubleSpinBoxLayoutMarginTop"> <widget class="QDoubleSpinBox" name="doubleSpinBoxSheetMarginTop">
<property name="alignment"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property> </property>
@ -702,14 +751,14 @@
</widget> </widget>
</item> </item>
<item row="2" column="2"> <item row="2" column="2">
<widget class="QDoubleSpinBox" name="doubleSpinBoxLayoutMarginBottom"> <widget class="QDoubleSpinBox" name="doubleSpinBoxSheetMarginBottom">
<property name="singleStep"> <property name="singleStep">
<double>0.100000000000000</double> <double>0.100000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="QLabel" name="labelLayoutMarginBottom"> <widget class="QLabel" name="labelSheetMarginBottom">
<property name="text"> <property name="text">
<string>Bottom:</string> <string>Bottom:</string>
</property> </property>
@ -722,7 +771,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBoxLayoutControl"> <widget class="QGroupBox" name="groupBoxSheetControl">
<property name="title"> <property name="title">
<string>Control</string> <string>Control</string>
</property> </property>
@ -730,7 +779,7 @@
<item> <item>
<layout class="QFormLayout" name="formLayout_2"> <layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="labelLayoutFollowGrainline"> <widget class="QLabel" name="labelSheetFollowGrainline">
<property name="text"> <property name="text">
<string>Follow grainline</string> <string>Follow grainline</string>
</property> </property>
@ -739,7 +788,7 @@
<item row="0" column="1"> <item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item> <item>
<widget class="QRadioButton" name="radioButtonLayoutFollowGrainlineNo"> <widget class="QRadioButton" name="radioButtonSheetFollowGrainlineNo">
<property name="text"> <property name="text">
<string>No</string> <string>No</string>
</property> </property>
@ -749,7 +798,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QRadioButton" name="radioButtonLayoutFollowGrainlineVertical"> <widget class="QRadioButton" name="radioButtonSheetFollowGrainlineVertical">
<property name="toolTip"> <property name="toolTip">
<string>Vertical grainline</string> <string>Vertical grainline</string>
</property> </property>
@ -769,7 +818,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QRadioButton" name="radioButtonLayoutFollowGrainlineHorizontal"> <widget class="QRadioButton" name="radioButtonSheetFollowGrainlineHorizontal">
<property name="toolTip"> <property name="toolTip">
<string>Horizontal grainline</string> <string>Horizontal grainline</string>
</property> </property>
@ -791,33 +840,19 @@
</layout> </layout>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="labelLayoutPiecesGap"> <widget class="QLabel" name="labelSheetPiecesGap">
<property name="text"> <property name="text">
<string>Pieces gap</string> <string>Pieces gap</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxLayoutPiecesGap"/> <widget class="QDoubleSpinBox" name="doubleSpinBoxSheetPiecesGap"/>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkBoxLayoutWarningPiecesSuperposition"> <widget class="QCheckBox" name="checkBoxSheetStickyEdges">
<property name="text">
<string>Warning superposition of pieces</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxLayoutWarningPiecesOutOfBound">
<property name="text">
<string>Warning pieces out of bound</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxLayoutStickyEdges">
<property name="text"> <property name="text">
<string>Sticky edges</string> <string>Sticky edges</string>
</property> </property>
@ -827,7 +862,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="LayoutExport"> <widget class="QGroupBox" name="SheetExport">
<property name="title"> <property name="title">
<string>Export</string> <string>Export</string>
</property> </property>
@ -835,21 +870,21 @@
<item> <item>
<layout class="QFormLayout" name="formLayout_3"> <layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="labelLayoutExportFormat"> <widget class="QLabel" name="labelSheetExportFormat">
<property name="text"> <property name="text">
<string>Format</string> <string>Format</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QComboBox" name="comboBoxLayoutExportFormat"/> <widget class="QComboBox" name="comboBoxSheetExportFormat"/>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButtonLayoutExport"> <widget class="QPushButton" name="pushButtonSheetExport">
<property name="text"> <property name="text">
<string>Export Layout</string> <string>Export Sheet</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -857,7 +892,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="verticalSpacerLayout"> <spacer name="verticalSpacerSheet">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
@ -929,7 +964,7 @@
<string notr="true">font-weight: bold;</string> <string notr="true">font-weight: bold;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Tiles</string> <string>Tiles of current sheet</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
@ -955,18 +990,11 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tabLayersProperty"> <widget class="QWidget" name="tabLayoutProperty">
<attribute name="icon">
<iconset resource="share/resources/puzzleicon.qrc">
<normaloff>:/puzzleicon/64x64/iconLayers.png</normaloff>:/puzzleicon/64x64/iconLayers.png</iconset>
</attribute>
<attribute name="title"> <attribute name="title">
<string/> <string>Prop.</string>
</attribute> </attribute>
<attribute name="toolTip"> <layout class="QVBoxLayout" name="verticalLayoutLayoutProperty">
<string>Layers properties</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayoutLayersProperty">
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>
@ -980,7 +1008,7 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QScrollArea" name="scrollAreaLayers"> <widget class="QScrollArea" name="scrollAreaLayout">
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::NoFrame</enum> <enum>QFrame::NoFrame</enum>
</property> </property>
@ -993,7 +1021,7 @@
<property name="widgetResizable"> <property name="widgetResizable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<widget class="QWidget" name="scrollAreaWidgetContentsLayers"> <widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
@ -1004,12 +1032,12 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="labelLayout">
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">font-weight: bold;</string> <string notr="true">font-weight: bold;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Layers</string> <string>Layout</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
@ -1017,7 +1045,90 @@
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="verticalSpacer"> <widget class="QGroupBox" name="groupBoxLayoutInfos">
<property name="title">
<string>Infos</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_16">
<item>
<layout class="QFormLayout" name="formLayout_7">
<item row="0" column="0">
<widget class="QLabel" name="labelLayoutName">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEditLayoutName">
<property name="text">
<string>My layout</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Description</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="plainTextEditLayoutDescription"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxLayoutFormat">
<property name="title">
<string>Format</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<layout class="QFormLayout" name="formLayoutLayout">
<item row="0" column="0">
<widget class="QLabel" name="labelLayoutUnit">
<property name="text">
<string>Unit</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxLayoutUnit"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxLayoutControl">
<property name="title">
<string>Control</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_14">
<item>
<widget class="QCheckBox" name="checkBoxLayoutWarningPiecesSuperposition">
<property name="text">
<string>Warning superposition of pieces</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxLayoutWarningPiecesOutOfBound">
<property name="text">
<string>Warning pieces out of bound</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacerLayout">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
@ -1121,12 +1232,11 @@
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<tabstops> <tabstops>
<tabstop>scrollAreaLayout</tabstop> <tabstop>scrollAreaSheet</tabstop>
<tabstop>doubleSpinBoxLayoutMarginTop</tabstop> <tabstop>doubleSpinBoxSheetMarginTop</tabstop>
<tabstop>doubleSpinBoxLayoutMarginLeft</tabstop> <tabstop>doubleSpinBoxSheetMarginLeft</tabstop>
<tabstop>doubleSpinBoxLayoutMarginRight</tabstop> <tabstop>doubleSpinBoxSheetMarginRight</tabstop>
<tabstop>doubleSpinBoxLayoutMarginBottom</tabstop> <tabstop>doubleSpinBoxSheetMarginBottom</tabstop>
<tabstop>scrollAreaLayers</tabstop>
<tabstop>scrollAreaTiles</tabstop> <tabstop>scrollAreaTiles</tabstop>
</tabstops> </tabstops>
<resources> <resources>

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlemimedatapiece.cpp ** @file vpmimedatapiece.cpp
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 4 5, 2020 ** @date 4 5, 2020
** **
@ -26,28 +26,28 @@
** **
*************************************************************************/ *************************************************************************/
#include "vpuzzlemimedatapiece.h" #include "vpmimedatapiece.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleMimeDataPiece::VPuzzleMimeDataPiece() VPMimeDataPiece::VPMimeDataPiece()
{ {
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleMimeDataPiece::~VPuzzleMimeDataPiece() VPMimeDataPiece::~VPMimeDataPiece()
{ {
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzlePiece* VPuzzleMimeDataPiece::GetPiecePtr() const VPPiece* VPMimeDataPiece::GetPiecePtr() const
{ {
return m_piece; return m_piece;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleMimeDataPiece::SetPiecePtr(VPuzzlePiece* piece) void VPMimeDataPiece::SetPiecePtr(VPPiece* piece)
{ {
m_piece = piece; m_piece = piece;
} }

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlemimedatapiece.h ** @file vpmimedatapiece.h
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 4 5, 2020 ** @date 4 5, 2020
** **
@ -26,40 +26,40 @@
** **
*************************************************************************/ *************************************************************************/
#ifndef VPUZZLEMIMEDATAPIECE_H #ifndef VPMIMEDATAPIECE_H
#define VPUZZLEMIMEDATAPIECE_H #define VPMIMEDATAPIECE_H
#include <QMimeData> #include <QMimeData>
#include "vpuzzlepiece.h" #include "vppiece.h"
class VPuzzleMimeDataPiece : public QMimeData class VPMimeDataPiece : public QMimeData
{ {
Q_OBJECT Q_OBJECT
public: public:
VPuzzleMimeDataPiece(); VPMimeDataPiece();
~VPuzzleMimeDataPiece(); ~VPMimeDataPiece();
/** /**
* @brief GetPiecePtr Returns the piece pointer of the mime data * @brief GetPiecePtr Returns the piece pointer of the mime data
* @return piece pointer * @return piece pointer
*/ */
VPuzzlePiece* GetPiecePtr() const; VPPiece* GetPiecePtr() const;
/** /**
* @brief SetPiecePtr sets the piece pointer to the given value * @brief SetPiecePtr sets the piece pointer to the given value
* @param piece the piece pointer * @param piece the piece pointer
*/ */
void SetPiecePtr(VPuzzlePiece* piece); void SetPiecePtr(VPPiece* piece);
private: private:
Q_DISABLE_COPY(VPuzzleMimeDataPiece) Q_DISABLE_COPY(VPMimeDataPiece)
VPuzzlePiece *m_piece{nullptr}; VPPiece *m_piece{nullptr};
}; };
#endif // VPUZZLEMIMEDATAPIECE_H #endif // VPMIMEDATAPIECE_H

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlepiece.cpp ** @file vppiece.cpp
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 13 4, 2020 ** @date 13 4, 2020
** **
@ -25,11 +25,11 @@
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
*************************************************************************/ *************************************************************************/
#include "vpuzzlepiece.h" #include "vppiece.h"
#include <QtMath> #include <QtMath>
#include "vpuzzlelayer.h" #include "vppiecelist.h"
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include <QIcon> #include <QIcon>
@ -39,77 +39,77 @@
Q_LOGGING_CATEGORY(pPiece, "p.piece") Q_LOGGING_CATEGORY(pPiece, "p.piece")
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzlePiece::VPuzzlePiece() VPPiece::VPPiece()
{ {
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzlePiece::~VPuzzlePiece() VPPiece::~VPPiece()
{ {
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VPuzzlePiece::GetName() const QString VPPiece::GetName() const
{ {
return m_name; return m_name;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetName(const QString &name) void VPPiece::SetName(const QString &name)
{ {
m_name = name; m_name = name;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QUuid VPuzzlePiece::GetUuid() const QUuid VPPiece::GetUuid() const
{ {
return m_uuid; return m_uuid;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetUuid(const QUuid &uuid) void VPPiece::SetUuid(const QUuid &uuid)
{ {
m_uuid = uuid; m_uuid = uuid;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VPuzzlePiece::GetCuttingLine() const QVector<QPointF> VPPiece::GetCuttingLine() const
{ {
return m_cuttingLine; return m_cuttingLine;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetCuttingLine(const QVector<QPointF> &cuttingLine) void VPPiece::SetCuttingLine(const QVector<QPointF> &cuttingLine)
{ {
m_cuttingLine = cuttingLine; m_cuttingLine = cuttingLine;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VPuzzlePiece::GetSeamLine() const QVector<QPointF> VPPiece::GetSeamLine() const
{ {
return m_seamLine; return m_seamLine;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetSeamLine(const QVector<QPointF> &seamLine) void VPPiece::SetSeamLine(const QVector<QPointF> &seamLine)
{ {
m_seamLine = seamLine; m_seamLine = seamLine;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VPuzzlePiece::GetShowSeamLine() const bool VPPiece::GetShowSeamLine() const
{ {
return m_showSeamline; return m_showSeamline;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetShowSeamLine(bool value) void VPPiece::SetShowSeamLine(bool value)
{ {
m_showSeamline = value; m_showSeamline = value;
@ -117,13 +117,13 @@ void VPuzzlePiece::SetShowSeamLine(bool value)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VPuzzlePiece::GetPieceMirrored() const bool VPPiece::GetPieceMirrored() const
{ {
return m_mirrorPiece; return m_mirrorPiece;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetPieceMirrored(bool value) void VPPiece::SetPieceMirrored(bool value)
{ {
m_mirrorPiece = value; m_mirrorPiece = value;
@ -131,7 +131,7 @@ void VPuzzlePiece::SetPieceMirrored(bool value)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetPosition(QPointF point) void VPPiece::SetPosition(QPointF point)
{ {
m_transform.translate(point.x() - m_transform.dx(), point.y() - m_transform.dy()); m_transform.translate(point.x() - m_transform.dx(), point.y() - m_transform.dy());
@ -139,13 +139,13 @@ void VPuzzlePiece::SetPosition(QPointF point)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QPointF VPuzzlePiece::GetPosition() QPointF VPPiece::GetPosition()
{ {
return QPointF(m_transform.dx(), m_transform.dy()); return QPointF(m_transform.dx(), m_transform.dy());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetRotation(qreal angle) void VPPiece::SetRotation(qreal angle)
{ {
// qreal currentAngle = GetRotation(); // qreal currentAngle = GetRotation();
// qreal newAngle = angle - currentAngle; // qreal newAngle = angle - currentAngle;
@ -172,7 +172,7 @@ void VPuzzlePiece::SetRotation(qreal angle)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VPuzzlePiece::GetRotation() qreal VPPiece::GetRotation()
{ {
return m_pieceAngle; return m_pieceAngle;
@ -191,7 +191,7 @@ qreal VPuzzlePiece::GetRotation()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetIsSelected(bool value) void VPPiece::SetIsSelected(bool value)
{ {
if(m_isSelected != value) if(m_isSelected != value)
{ {
@ -201,100 +201,59 @@ void VPuzzlePiece::SetIsSelected(bool value)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VPuzzlePiece::GetIsSelected() bool VPPiece::GetIsSelected()
{ {
return m_isSelected; return m_isSelected;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetIsGrainlineEnabled(bool value) void VPPiece::SetIsGrainlineEnabled(bool value)
{ {
m_isGrainlineEnabled = value; m_isGrainlineEnabled = value;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VPuzzlePiece::GetIsGrainlineEnabled() bool VPPiece::GetIsGrainlineEnabled()
{ {
return m_isGrainlineEnabled; return m_isGrainlineEnabled;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetGrainlineAngle(qreal value) void VPPiece::SetGrainlineAngle(qreal value)
{ {
m_grainlineAngle = value; m_grainlineAngle = value;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VPuzzlePiece::GetGrainlineAngle() qreal VPPiece::GetGrainlineAngle()
{ {
return m_grainlineAngle; return m_grainlineAngle;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetGrainline(QVector<QPointF> grainline) void VPPiece::SetGrainline(QVector<QPointF> grainline)
{ {
m_grainline = grainline; m_grainline = grainline;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VPuzzlePiece::GetGrainline() QVector<QPointF> VPPiece::GetGrainline()
{ {
return m_grainline; return m_grainline;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleLayer* VPuzzlePiece::GetLayer() VPPieceList* VPPiece::GetPieceList()
{ {
return m_layer; return m_pieceList;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetLayer(VPuzzleLayer* layer) void VPPiece::SetPieceList(VPPieceList* pieceList)
{ {
if(layer != m_layer) if(pieceList != m_pieceList)
{ {
m_layer = layer; m_pieceList = pieceList;
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QIcon VPuzzlePiece::PieceIcon(const QSize &size) const
{
QVector<QPointF> points = GetSeamLine();
if(points.isEmpty())
{
points = GetCuttingLine();
}
QPolygonF shape(points);
shape << shape.first();
QRectF boundingRect = shape.boundingRect();
qreal canvasSize = qMax(boundingRect.height(), boundingRect.width());
QRectF canvas = QRectF(0, 0, canvasSize, canvasSize);
qreal dx = canvas.center().x() - boundingRect.center().x();
qreal dy = canvas.center().y() - boundingRect.center().y();
QPixmap pixmap(size);
pixmap.fill(QColor("white"));
QPainter painter;
painter.begin(&pixmap);
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::SmoothPixmapTransform);
int spacing = 2;
painter.translate(spacing, spacing);
qreal scaleFactorX = canvasSize * 100 / (size.width() - spacing*2) / 100;
qreal scaleFactorY = canvasSize * 100 / (size.height() - spacing*2) / 100;
painter.scale(1./scaleFactorX, 1./scaleFactorY);
painter.setPen(QPen(Qt::black, 0.8*qMax(scaleFactorX, scaleFactorY)));
painter.translate(dx, dy);
painter.drawPolygon(shape);
painter.end();
return QIcon(pixmap);
}

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlepiece.h ** @file vppiece.h
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 13 4, 2020 ** @date 13 4, 2020
** **
@ -25,22 +25,22 @@
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
*************************************************************************/ *************************************************************************/
#ifndef VPUZZLEPIECE_H #ifndef VPPIECE_H
#define VPUZZLEPIECE_H #define VPPIECE_H
#include <QUuid> #include <QUuid>
#include <QVector> #include <QVector>
#include <QPoint> #include <QPoint>
#include <QTransform> #include <QTransform>
class VPuzzleLayer; class VPPieceList;
class VPuzzlePiece : public QObject class VPPiece : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
VPuzzlePiece(); VPPiece();
~VPuzzlePiece(); ~VPPiece();
/** /**
* @brief GetName Returns the name of the piece * @brief GetName Returns the name of the piece
@ -187,16 +187,16 @@ public:
bool GetIsSelected(); bool GetIsSelected();
/** /**
* @brief GetLayer Returns the layer in which the piece is. * @brief GetPieceList Returns the piecelist in which the piece is.
* @return layer of the piece * @return pieceList of the piece
*/ */
VPuzzleLayer* GetLayer(); VPPieceList* GetPieceList();
/** /**
* @brief SetLayer Sets the layer of the piece to the given layer * @brief SetPieceList Sets the pieceList of the piece to the given pieceList
* @param layer * @param pieceList
*/ */
void SetLayer(VPuzzleLayer* layer); void SetPieceList(VPPieceList* pieceList);
QIcon PieceIcon(const QSize &size) const; QIcon PieceIcon(const QSize &size) const;
@ -226,7 +226,7 @@ signals:
void PropertiesChanged(); void PropertiesChanged();
private: private:
Q_DISABLE_COPY(VPuzzlePiece) Q_DISABLE_COPY(VPPiece)
QUuid m_uuid{QUuid()}; QUuid m_uuid{QUuid()};
QString m_name{QString()}; QString m_name{QString()};
QVector<QPointF> m_cuttingLine{QVector<QPointF>()}; QVector<QPointF> m_cuttingLine{QVector<QPointF>()};
@ -244,7 +244,7 @@ private:
bool m_mirrorPiece{false}; bool m_mirrorPiece{false};
bool m_isSelected{false}; bool m_isSelected{false};
VPuzzleLayer *m_layer{nullptr}; VPPieceList *m_pieceList{nullptr};
}; };
#endif // VPUZZLEPIECE_H #endif // VPPIECE_H

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlelayer.cpp ** @file vppiecelist.cpp
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 13 4, 2020 ** @date 13 4, 2020
** **
@ -25,42 +25,49 @@
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
*************************************************************************/ *************************************************************************/
#include "vpuzzlelayer.h" #include "vppiecelist.h"
#include "vpuzzlelayout.h" #include "vplayout.h"
#include <QLoggingCategory> #include <QLoggingCategory>
Q_LOGGING_CATEGORY(pLayer, "p.layer") Q_LOGGING_CATEGORY(pPieceList, "p.pieceList")
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleLayer::VPuzzleLayer(VPuzzleLayout *layout): VPPieceList::VPPieceList(VPLayout *layout, VPSheet *sheet):
m_sheet(sheet),
m_layout(layout) m_layout(layout)
{ {
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleLayer::~VPuzzleLayer() VPPieceList::~VPPieceList()
{ {
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleLayout* VPuzzleLayer::GetLayout() VPLayout* VPPieceList::GetLayout()
{ {
return m_layout; return m_layout;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QList<VPuzzlePiece *> VPuzzleLayer::GetPieces() VPSheet* VPPieceList::GetSheet()
{
return m_sheet;
}
//---------------------------------------------------------------------------------------------------------------------
QList<VPPiece *> VPPieceList::GetPieces()
{ {
return m_pieces; return m_pieces;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayer::ClearSelection() void VPPieceList::ClearSelection()
{ {
for (auto piece: m_pieces) for (auto piece: m_pieces)
{ {
@ -69,45 +76,45 @@ void VPuzzleLayer::ClearSelection()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayer::AddPiece(VPuzzlePiece *piece) void VPPieceList::AddPiece(VPPiece *piece)
{ {
qCDebug(pLayer(), "piece -- %s -- added to %s", qUtf8Printable(piece->GetName()), qUtf8Printable(this->GetName())); qCDebug(pPieceList(), "piece -- %s -- added to %s", qUtf8Printable(piece->GetName()), qUtf8Printable(this->GetName()));
m_pieces.append(piece); m_pieces.append(piece);
piece->SetLayer(this); piece->SetPieceList(this);
emit PieceAdded(piece); emit PieceAdded(piece);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayer::RemovePiece(VPuzzlePiece *piece) void VPPieceList::RemovePiece(VPPiece *piece)
{ {
m_pieces.removeAll(piece); m_pieces.removeAll(piece);
piece->SetLayer(nullptr); piece->SetPieceList(nullptr);
emit PieceRemoved(piece); emit PieceRemoved(piece);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VPuzzleLayer::GetName() const QString VPPieceList::GetName() const
{ {
return m_name; return m_name;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayer::SetName(const QString &name) void VPPieceList::SetName(const QString &name)
{ {
m_name = name; m_name = name;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayer::SetIsVisible(bool value) void VPPieceList::SetIsVisible(bool value)
{ {
m_isVisible = value; m_isVisible = value;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VPuzzleLayer::GetIsVisible() const bool VPPieceList::GetIsVisible() const
{ {
return m_isVisible; return m_isVisible;
} }

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlelayer.h ** @file vppiecelist.h
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 13 4, 2020 ** @date 13 4, 2020
** **
@ -25,24 +25,25 @@
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
*************************************************************************/ *************************************************************************/
#ifndef VPUZZLELAYER_H #ifndef VPPIECELIST_H
#define VPUZZLELAYER_H #define VPPIECELIST_H
#include <QList> #include <QList>
#include "vpuzzlepiece.h" #include "vppiece.h"
#include "vpsheet.h"
class VPuzzleLayout; class VPLayout;
class VPuzzleLayer : public QObject class VPPieceList : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
VPuzzleLayer(VPuzzleLayout *layout); VPPieceList(VPLayout *layout, VPSheet *sheet = nullptr);
~VPuzzleLayer(); ~VPPieceList();
QList<VPuzzlePiece *> GetPieces(); QList<VPPiece *> GetPieces();
void AddPiece(VPuzzlePiece *piece); void AddPiece(VPPiece *piece);
void RemovePiece(VPuzzlePiece *piece); void RemovePiece(VPPiece *piece);
// here add some more function if we want to add/move a piece at a // here add some more function if we want to add/move a piece at a
// certain position in the list // certain position in the list
@ -54,13 +55,21 @@ public:
bool GetIsVisible() const; bool GetIsVisible() const;
/** /**
* @brief GetLayout Returns the layout in which this layer is * @brief GetLayout Returns the layout in which this piece list is
* @return the layout of this layer * @return the layout of this piece list
*/ */
VPuzzleLayout* GetLayout(); VPLayout* GetLayout();
/** /**
* @brief ClearSelection Clears the selection of the pieces in this layer * @brief GetSheet returns the sheet corresponding to this piece list, or nullptr
* if no sheet associated
* @return the sheet
*/
VPSheet* GetSheet();
/**
* @brief ClearSelection Clears the selection of the pieces in this piece list
*/ */
void ClearSelection(); void ClearSelection();
@ -68,24 +77,26 @@ signals:
/** /**
* @brief PieceAdded The signal is emited when a piece was added * @brief PieceAdded The signal is emited when a piece was added
*/ */
void PieceAdded(VPuzzlePiece *piece); void PieceAdded(VPPiece *piece);
/** /**
* @brief PieceRemoved The signal is emited when a piece was removed * @brief PieceRemoved The signal is emited when a piece was removed
*/ */
void PieceRemoved(VPuzzlePiece *piece); void PieceRemoved(VPPiece *piece);
private: private:
Q_DISABLE_COPY(VPuzzleLayer) Q_DISABLE_COPY(VPPieceList)
QString m_name{}; QString m_name{};
QList<VPuzzlePiece *> m_pieces{}; QList<VPPiece *> m_pieces{};
VPuzzleLayout *m_layout{nullptr}; VPSheet *m_sheet{nullptr};
VPLayout *m_layout{nullptr};
// control // control
bool m_isVisible{true}; bool m_isVisible{true};
}; };
#endif // VPUZZLELAYER_H #endif // VPPIECELIST_H

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlesettings.cpp ** @file vpsettings.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com> ** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 16 2, 2020 ** @date 16 2, 2020
** **
@ -25,7 +25,7 @@
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
*************************************************************************/ *************************************************************************/
#include "vpuzzlesettings.h" #include "vpsettings.h"
namespace namespace
{ {
@ -34,48 +34,48 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockPropertiesContentsActive, (Q
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleSettings::VPuzzleSettings(Format format, Scope scope, const QString &organization, const QString &application, VPSettings::VPSettings(Format format, Scope scope, const QString &organization, const QString &application,
QObject *parent) QObject *parent)
: VCommonSettings(format, scope, organization, application, parent) : VCommonSettings(format, scope, organization, application, parent)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleSettings::VPuzzleSettings(const QString &fileName, QSettings::Format format, QObject *parent) VPSettings::VPSettings(const QString &fileName, QSettings::Format format, QObject *parent)
: VCommonSettings(fileName, format, parent) : VCommonSettings(fileName, format, parent)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VPuzzleSettings::IsDockWidgetPropertiesActive() const bool VPSettings::IsDockWidgetPropertiesActive() const
{ {
return value(*settingDockWidgetPropertiesActive, GetDefDockWidgetPropertiesActive()).toBool(); return value(*settingDockWidgetPropertiesActive, GetDefDockWidgetPropertiesActive()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VPuzzleSettings::GetDefDockWidgetPropertiesActive() bool VPSettings::GetDefDockWidgetPropertiesActive()
{ {
return true; return true;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleSettings::SetDockWidgetPropertiesActive(bool value) void VPSettings::SetDockWidgetPropertiesActive(bool value)
{ {
setValue(*settingDockWidgetPropertiesActive, value); setValue(*settingDockWidgetPropertiesActive, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VPuzzleSettings::IsDockWidgetPropertiesContentsActive() const bool VPSettings::IsDockWidgetPropertiesContentsActive() const
{ {
return value(*settingDockWidgetPropertiesActive, GetDefDockWidgetPropertiesActive()).toBool(); return value(*settingDockWidgetPropertiesActive, GetDefDockWidgetPropertiesActive()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VPuzzleSettings::GetDefDockWidgetPropertiesContentsActive() bool VPSettings::GetDefDockWidgetPropertiesContentsActive()
{ {
return true; return true;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleSettings::SetDockWidgetPropertiesContentsActive(bool value) void VPSettings::SetDockWidgetPropertiesContentsActive(bool value)
{ {
setValue(*settingDockPropertiesContentsActive, value); setValue(*settingDockPropertiesContentsActive, value);
} }

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlesettings.h ** @file vpsettings.h
** @author Roman Telezhynskyi <dismine(at)gmail.com> ** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 16 2, 2020 ** @date 16 2, 2020
** **
@ -25,20 +25,20 @@
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
*************************************************************************/ *************************************************************************/
#ifndef VPUZZLESETTINGS_H #ifndef VPSETTINGS_H
#define VPUZZLESETTINGS_H #define VPSETTINGS_H
#include <QByteArray> #include <QByteArray>
#include "vcommonsettings.h" #include "vcommonsettings.h"
class VPuzzleSettings : public VCommonSettings class VPSettings : public VCommonSettings
{ {
Q_OBJECT Q_OBJECT
public: public:
VPuzzleSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), VPSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(),
QObject *parent = nullptr); QObject *parent = nullptr);
VPuzzleSettings(const QString &fileName, Format format, QObject *parent = nullptr); VPSettings(const QString &fileName, Format format, QObject *parent = nullptr);
bool IsDockWidgetPropertiesActive() const; bool IsDockWidgetPropertiesActive() const;
static bool GetDefDockWidgetPropertiesActive(); static bool GetDefDockWidgetPropertiesActive();
@ -49,7 +49,7 @@ public:
void SetDockWidgetPropertiesContentsActive(bool value); void SetDockWidgetPropertiesContentsActive(bool value);
private: private:
Q_DISABLE_COPY(VPuzzleSettings) Q_DISABLE_COPY(VPSettings)
}; };
#endif // VPUZZLESETTINGS_H #endif // VPSETTINGS_H

204
src/app/puzzle/vpsheet.cpp Normal file
View File

@ -0,0 +1,204 @@
/************************************************************************
**
** @file vpsheet.cpp
** @author Ronan Le Tiec
** @date 23 5, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vpsheet.h"
#include "vppiecelist.h"
#include "vplayout.h"
//---------------------------------------------------------------------------------------------------------------------
VPSheet::VPSheet(VPLayout* layout) :
m_layout(layout)
{
m_pieceList = new VPPieceList(layout, this);
}
//---------------------------------------------------------------------------------------------------------------------
VPSheet::~VPSheet()
{
delete m_pieceList;
}
//---------------------------------------------------------------------------------------------------------------------
VPPieceList* VPSheet::GetPieceList()
{
return m_pieceList;
}
//---------------------------------------------------------------------------------------------------------------------
QString VPSheet::GetName() const
{
return m_name;
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetName(const QString &name)
{
m_name = name;
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetSheetSize(qreal width, qreal height)
{
m_size.setWidth(width);
m_size.setHeight(height);
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetSheetSizeConverted(qreal width, qreal height)
{
m_size.setWidth(UnitConvertor(width, m_layout->GetUnit(), Unit::Px));
m_size.setHeight(UnitConvertor(height, m_layout->GetUnit(), Unit::Px));
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetSheetSize(const QSizeF &size)
{
m_size = size;
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetSheetSizeConverted(const QSizeF &size)
{
m_size = QSizeF(
UnitConvertor(size.width(), m_layout->GetUnit(), Unit::Px),
UnitConvertor(size.height(), m_layout->GetUnit(), Unit::Px)
);
}
//---------------------------------------------------------------------------------------------------------------------
QSizeF VPSheet::GetSheetSize() const
{
return m_size;
}
//---------------------------------------------------------------------------------------------------------------------
QSizeF VPSheet::GetSheetSizeConverted() const
{
QSizeF convertedSize = QSizeF(
UnitConvertor(m_size.width(), Unit::Px, m_layout->GetUnit()),
UnitConvertor(m_size.height(), Unit::Px, m_layout->GetUnit())
);
return convertedSize;
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetSheetMargins(qreal left, qreal top, qreal right, qreal bottom)
{
m_margins.setLeft(left);
m_margins.setTop(top);
m_margins.setRight(right);
m_margins.setBottom(bottom);
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetSheetMarginsConverted(qreal left, qreal top, qreal right, qreal bottom)
{
m_margins.setLeft(UnitConvertor(left, m_layout->GetUnit(), Unit::Px));
m_margins.setTop(UnitConvertor(top, m_layout->GetUnit(), Unit::Px));
m_margins.setRight(UnitConvertor(right, m_layout->GetUnit(), Unit::Px));
m_margins.setBottom(UnitConvertor(bottom, m_layout->GetUnit(), Unit::Px));
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetSheetMargins(const QMarginsF &margins)
{
m_margins = margins;
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetSheetMarginsConverted(const QMarginsF &margins)
{
m_margins = UnitConvertor(margins, m_layout->GetUnit(), Unit::Px);
}
//---------------------------------------------------------------------------------------------------------------------
QMarginsF VPSheet::GetSheetMargins() const
{
return m_margins;
}
//---------------------------------------------------------------------------------------------------------------------
QMarginsF VPSheet::GetSheetMarginsConverted() const
{
return UnitConvertor(m_margins, Unit::Px, m_layout->GetUnit());
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetFollowGrainline(FollowGrainline state)
{
m_followGrainLine = state;
}
//---------------------------------------------------------------------------------------------------------------------
FollowGrainline VPSheet::GetFollowGrainline() const
{
return m_followGrainLine;
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetPiecesGap(qreal value)
{
m_piecesGap = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetPiecesGapConverted(qreal value)
{
m_piecesGap = UnitConvertor(value, m_layout->GetUnit(), Unit::Px);
}
//---------------------------------------------------------------------------------------------------------------------
qreal VPSheet::GetPiecesGap() const
{
return m_piecesGap;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VPSheet::GetPiecesGapConverted() const
{
return UnitConvertor(m_piecesGap, Unit::Px, m_layout->GetUnit());
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetStickyEdges(bool state)
{
m_stickyEdges = state;
}
//---------------------------------------------------------------------------------------------------------------------
bool VPSheet::GetStickyEdges() const
{
return m_stickyEdges;
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::ClearSelection()
{
m_pieceList->ClearSelection();
}

225
src/app/puzzle/vpsheet.h Normal file
View File

@ -0,0 +1,225 @@
/************************************************************************
**
** @file vpsheet.h
** @author Ronan Le Tiec
** @date 23 5, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VPSHEET_H
#define VPSHEET_H
#include <QObject>
#include <QSizeF>
#include <QMarginsF>
#include <QList>
#include "def.h"
// is this the right place for the definition?
enum class FollowGrainline : qint8 { No = 0, Follow90 = 1, Follow180 = 2};
class VPLayout;
class VPPieceList;
class VPSheet : public QObject
{
Q_OBJECT
public:
VPSheet(VPLayout* layout);
~VPSheet();
/**
* @brief GetPieceList returns the piece list of the sheet
* @return
*/
VPPieceList* GetPieceList();
/**
* @brief GetName Returns the name of the sheet
* @return the name
*/
QString GetName() const;
/**
* @brief SetName Sets the name of the sheet to the given name
* @param name the new sheet's name
*/
void SetName(const QString &name);
/**
* @brief SetSheetSize sets the size of the sheet, the values have to be in Unit::Px
* @param width sheet width
* @param height sheet height
*/
void SetSheetSize(qreal width, qreal height);
/**
* @brief SetSheetSize sets the size of the sheet, the values have to be in the layout's unit
* @param width sheet width
* @param height sheet height
*/
void SetSheetSizeConverted(qreal width, qreal height);
/**
* @brief SetSheetSize sets the size of the sheet, the values have to be in Unit::Px
* @param size sheet size
*/
void SetSheetSize(const QSizeF &size);
/**
* @brief SetSheetSizeConverted sets the size of the sheet, the values have to be in the layout's unit
* @param size sheet size
*/
void SetSheetSizeConverted(const QSizeF &size);
/**
* @brief GetSheetSize Returns the size in Unit::Px
* @return sheet size in Unit::Px
*/
QSizeF GetSheetSize() const;
/**
* @brief GetSheetSizeConverted Returns the size in the layout's unit
* @return the size in the layout's unit
*/
QSizeF GetSheetSizeConverted() const;
/**
* @brief SetSheetMargins, set the margins of the sheet, the values have to be in Unit::Px
* @param left in Unit::Px
* @param top in Unit::Px
* @param right in Unit::Px
* @param bottom in Unit::Px
*/
void SetSheetMargins(qreal left, qreal top, qreal right, qreal bottom);
/**
* @brief SetSheetMargins, set the margins of the sheet, the values have to be in the unit of the layout
* @param left in Unit::Px
* @param top in Unit::Px
* @param right in Unit::Px
* @param bottom in Unit::Px
*/
void SetSheetMarginsConverted(qreal left, qreal top, qreal right, qreal bottom);
/**
* @brief SetSheetMargins set the margins of the sheet, the values have to be in Unit::Px
* @param margins sheet margins
*/
void SetSheetMargins(const QMarginsF &margins);
/**
* @brief SetSheetMargins set the margins of the sheet, the values have to be in the unit of the layout
* @param margins sheet margins
*/
void SetSheetMarginsConverted(const QMarginsF &margins);
/**
* @brief GetSheetMargins Returns the size in Unit::Px
* @return the size in Unit::Px
*/
QMarginsF GetSheetMargins() const;
/**
* @brief GetSheetMarginsConverted Returns the margins in the layout's unit
* @return the margins in the sheet's unit
*/
QMarginsF GetSheetMarginsConverted() const;
/**
* @brief SetFollowGrainline Sets the type of grainline for the pieces to follow
* @param state the type of grainline
*/
void SetFollowGrainline(FollowGrainline state);
/**
* @brief GetFollowGrainline Returns if the sheet's pieces follow a grainline or not
* @return wether the pieces follow a grainline and if so, which grainline
*/
FollowGrainline GetFollowGrainline() const;
/**
* @brief SetPiecesGap sets the pieces gap to the given value, the unit has to be in Unit::Px
* @param value pieces gap
*/
void SetPiecesGap(qreal value);
/**
* @brief SetPiecesGapConverted sets the pieces gap to the given value, the unit has to be in the layout's unit
* @param value pieces gap
*/
void SetPiecesGapConverted(qreal value);
/**
* @brief GetPiecesGap returns the pieces gap in Unit::Px
* @return the pieces gap in Unit::Px
*/
qreal GetPiecesGap() const;
/**
* @brief GetPiecesGapConverted returns the pieces gap in the layout's unit
* @return the pieces gap in the layout's unit
*/
qreal GetPiecesGapConverted() const;
/**
* @brief ClearSelection goes through the piece list and pieces and calls
* SetIsSelected(false) for the pieces that were selected.
*/
void ClearSelection();
void SetStickyEdges(bool state);
bool GetStickyEdges() const;
private:
Q_DISABLE_COPY(VPSheet)
VPLayout *m_layout;
VPPieceList *m_pieceList {nullptr};
QString m_name{};
/**
* @brief m_size the Size in Unit::Px
*/
QSizeF m_size{};
// margins
/**
* @brief m_margins the margins in Unit::Px
*/
QMarginsF m_margins{};
// control
FollowGrainline m_followGrainLine{FollowGrainline::No};
/**
* @brief m_piecesGap the pieces gap in Unit::Px
*/
qreal m_piecesGap{0};
bool m_stickyEdges{false};
};
#endif // VPSHEET_H

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file stable.cpp ** @file vpstable.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com> ** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date November 15, 2013 ** @date November 15, 2013
** **
@ -27,4 +27,4 @@
*************************************************************************/ *************************************************************************/
// Build the precompiled headers. // Build the precompiled headers.
#include "stable.h" #include "vpstable.h"

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file stable.h ** @file vpstable.h
** @author Roman Telezhynskyi <dismine(at)gmail.com> ** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date November 15, 2013 ** @date November 15, 2013
** **
@ -26,8 +26,8 @@
** **
*************************************************************************/ *************************************************************************/
#ifndef STABLE_H #ifndef VPSTABLE_H
#define STABLE_H #define VPSTABLE_H
/* I like to include this pragma too, so the build log indicates if pre-compiled headers were in use. */ /* I like to include this pragma too, so the build log indicates if pre-compiled headers were in use. */
#pragma message("Compiling precompiled headers for puzzle utility.\n") #pragma message("Compiling precompiled headers for puzzle utility.\n")
@ -69,4 +69,4 @@
#endif /*__cplusplus*/ #endif /*__cplusplus*/
#endif // STABLE_H #endif // VPSTABLE_H

View File

@ -1,318 +0,0 @@
/************************************************************************
**
** @file vpuzzlelayout.cpp
** @author Ronan Le Tiec
** @date 13 4, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vpuzzlelayout.h"
#include "vpuzzlelayer.h"
#include "vpuzzlepiece.h"
//---------------------------------------------------------------------------------------------------------------------
VPuzzleLayout::VPuzzleLayout() :
m_unplacedPiecesLayer(new VPuzzleLayer(this))
{
m_unplacedPiecesLayer->SetName(QObject::tr("Unplaced pieces"));
// create a standard default layer:
VPuzzleLayer *layer = new VPuzzleLayer(this);
layer->SetName(QObject::tr("Layout"));
AddLayer(layer);
// sets the default active layer
SetFocusedLayer();
}
//---------------------------------------------------------------------------------------------------------------------
VPuzzleLayout::~VPuzzleLayout()
{
qDeleteAll(m_layers);
delete m_unplacedPiecesLayer;
}
//---------------------------------------------------------------------------------------------------------------------
VPuzzleLayer* VPuzzleLayout::GetUnplacedPiecesLayer()
{
return m_unplacedPiecesLayer;
}
//---------------------------------------------------------------------------------------------------------------------
VPuzzleLayer* VPuzzleLayout::AddLayer()
{
VPuzzleLayer *newLayer = new VPuzzleLayer(this);
m_layers.append(newLayer);
return newLayer;
}
//---------------------------------------------------------------------------------------------------------------------
VPuzzleLayer* VPuzzleLayout::AddLayer(VPuzzleLayer *layer)
{
m_layers.append(layer);
return layer;
}
//---------------------------------------------------------------------------------------------------------------------
QList<VPuzzleLayer *> VPuzzleLayout::GetLayers()
{
return m_layers;
}
//---------------------------------------------------------------------------------------------------------------------
QList<VPuzzlePiece *> VPuzzleLayout::GetSelectedPieces()
{
QList<VPuzzlePiece *> result = QList<VPuzzlePiece *>();
QList<VPuzzleLayer *> layers = m_layers;
layers.prepend(m_unplacedPiecesLayer);
for (auto layer : layers)
{
for (auto piece : layer->GetPieces())
{
if(piece->GetIsSelected())
{
result.append(piece);
}
}
}
return result;
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayout::SetUnit(Unit unit)
{
m_unit = unit;
}
//---------------------------------------------------------------------------------------------------------------------
Unit VPuzzleLayout::GetUnit() const
{
return m_unit;
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayout::SetLayoutSize(qreal width, qreal height)
{
m_size.setWidth(width);
m_size.setHeight(height);
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayout::SetLayoutSizeConverted(qreal width, qreal height)
{
m_size.setWidth(UnitConvertor(width, m_unit, Unit::Px));
m_size.setHeight(UnitConvertor(height, m_unit, Unit::Px));
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayout::SetLayoutSize(const QSizeF &size)
{
m_size = size;
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayout::SetLayoutSizeConverted(const QSizeF &size)
{
m_size = QSizeF(
UnitConvertor(size.width(), m_unit, Unit::Px),
UnitConvertor(size.height(), m_unit, Unit::Px)
);
}
//---------------------------------------------------------------------------------------------------------------------
QSizeF VPuzzleLayout::GetLayoutSize() const
{
return m_size;
}
//---------------------------------------------------------------------------------------------------------------------
QSizeF VPuzzleLayout::GetLayoutSizeConverted() const
{
QSizeF convertedSize = QSizeF(
UnitConvertor(m_size.width(), Unit::Px, m_unit),
UnitConvertor(m_size.height(), Unit::Px, m_unit)
);
return convertedSize;
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayout::SetLayoutMargins(qreal left, qreal top, qreal right, qreal bottom)
{
m_margins.setLeft(left);
m_margins.setTop(top);
m_margins.setRight(right);
m_margins.setBottom(bottom);
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayout::SetLayoutMarginsConverted(qreal left, qreal top, qreal right, qreal bottom)
{
m_margins.setLeft(UnitConvertor(left, m_unit, Unit::Px));
m_margins.setTop(UnitConvertor(top, m_unit, Unit::Px));
m_margins.setRight(UnitConvertor(right, m_unit, Unit::Px));
m_margins.setBottom(UnitConvertor(bottom, m_unit, Unit::Px));
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayout::SetLayoutMargins(const QMarginsF &margins)
{
m_margins = margins;
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayout::SetLayoutMarginsConverted(const QMarginsF &margins)
{
m_margins = UnitConvertor(margins, m_unit, Unit::Px);
}
//---------------------------------------------------------------------------------------------------------------------
QMarginsF VPuzzleLayout::GetLayoutMargins() const
{
return m_margins;
}
//---------------------------------------------------------------------------------------------------------------------
QMarginsF VPuzzleLayout::GetLayoutMarginsConverted() const
{
return UnitConvertor(m_margins, Unit::Px, m_unit);
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayout::SetFollowGrainline(FollowGrainline state)
{
m_followGrainLine = state;
}
//---------------------------------------------------------------------------------------------------------------------
FollowGrainline VPuzzleLayout::GetFollowGrainline() const
{
return m_followGrainLine;
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayout::SetPiecesGap(qreal value)
{
m_piecesGap = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayout::SetPiecesGapConverted(qreal value)
{
m_piecesGap = UnitConvertor(value, m_unit, Unit::Px);
}
//---------------------------------------------------------------------------------------------------------------------
qreal VPuzzleLayout::GetPiecesGap() const
{
return m_piecesGap;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VPuzzleLayout::GetPiecesGapConverted() const
{
return UnitConvertor(m_piecesGap, Unit::Px, m_unit);
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayout::SetWarningSuperpositionOfPieces(bool state)
{
m_warningSuperpositionOfPieces = state;
}
//---------------------------------------------------------------------------------------------------------------------
bool VPuzzleLayout::GetWarningSuperpositionOfPieces() const
{
return m_warningSuperpositionOfPieces;
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayout::SetWarningPiecesOutOfBound(bool state)
{
m_warningPiecesOutOfBound = state;
}
//---------------------------------------------------------------------------------------------------------------------
bool VPuzzleLayout::GetWarningPiecesOutOfBound() const
{
return m_warningPiecesOutOfBound;
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayout::SetStickyEdges(bool state)
{
m_stickyEdges = state;
}
//---------------------------------------------------------------------------------------------------------------------
bool VPuzzleLayout::GetStickyEdges() const
{
return m_stickyEdges;
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayout::ClearSelection()
{
m_unplacedPiecesLayer->ClearSelection();
for (auto layer : m_layers)
{
layer->ClearSelection();
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayout::SetFocusedLayer(VPuzzleLayer* focusedLayer)
{
if(focusedLayer == nullptr)
{
m_focusedLayer = m_layers.first();
}
else
{
m_focusedLayer = focusedLayer;
}
}
//---------------------------------------------------------------------------------------------------------------------
VPuzzleLayer* VPuzzleLayout::GetFocusedLayer()
{
return m_focusedLayer;
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayout::MovePieceToLayer(VPuzzlePiece* piece, VPuzzleLayer* layer)
{
VPuzzleLayer* layerBefore = piece->GetLayer();
if(layerBefore != nullptr)
{
piece->GetLayer()->RemovePiece(piece);
}
layer->AddPiece(piece);
// signal, that a piece was moved
emit PieceMovedToLayer(piece, layerBefore,layer);
}

View File

@ -1,267 +0,0 @@
/************************************************************************
**
** @file vpuzzlelayout.h
** @author Ronan Le Tiec
** @date 13 4, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VPUZZLELAYOUT_H
#define VPUZZLELAYOUT_H
#include <QSizeF>
#include <QMarginsF>
#include <QList>
#include "def.h"
class VPuzzleLayer;
class VPuzzlePiece;
// is this the right place for the definition?
enum class FollowGrainline : qint8 { No = 0, Follow90 = 1, Follow180 = 2};
class VPuzzleLayout : public QObject
{
Q_OBJECT
public:
VPuzzleLayout();
virtual ~VPuzzleLayout();
VPuzzleLayer* GetUnplacedPiecesLayer();
VPuzzleLayer* AddLayer();
VPuzzleLayer* AddLayer(VPuzzleLayer *layer);
QList<VPuzzleLayer *> GetLayers();
/**
* @brief GetSelectedPieces Returns the list of the selected pieces
* @return the selected pieces
*/
QList<VPuzzlePiece *> GetSelectedPieces();
/**
* @brief SetUnit Sets the unit of the layout to the given unit
* @param unit the new unit
*/
void SetUnit(Unit unit);
/**
* @brief GetUnit Returns the current unit of the layout
* @return the unit
*/
Unit GetUnit() const;
/**
* @brief SetLayoutSize sets the size of the layout, the values have to be in Unit::Px
* @param width layout width
* @param height layout height
*/
void SetLayoutSize(qreal width, qreal height);
/**
* @brief SetLayoutSize sets the size of the layout, the values have to be in the layout's unit
* @param width layout width
* @param height layout height
*/
void SetLayoutSizeConverted(qreal width, qreal height);
/**
* @brief SetLayoutSize sets the size of the layout, the values have to be in Unit::Px
* @param size layout size
*/
void SetLayoutSize(const QSizeF &size);
/**
* @brief SetLayoutSizeConverted sets the size of the layout, the values have to be in the layout's unit
* @param size layout size
*/
void SetLayoutSizeConverted(const QSizeF &size);
/**
* @brief GetLayoutSize Returns the size in Unit::Px
* @return layout size in Unit::Px
*/
QSizeF GetLayoutSize() const;
/**
* @brief GetLayoutSizeConverted Returns the size in the layout's unit
* @return the size in the layout's unit
*/
QSizeF GetLayoutSizeConverted() const;
/**
* @brief SetLayoutMargins, set the margins of the layout, the values have to be in Unit::Px
* @param left in Unit::Px
* @param top in Unit::Px
* @param right in Unit::Px
* @param bottom in Unit::Px
*/
void SetLayoutMargins(qreal left, qreal top, qreal right, qreal bottom);
/**
* @brief SetLayoutMargins, set the margins of the layout, the values have to be in the unit of the layout
* @param left in Unit::Px
* @param top in Unit::Px
* @param right in Unit::Px
* @param bottom in Unit::Px
*/
void SetLayoutMarginsConverted(qreal left, qreal top, qreal right, qreal bottom);
/**
* @brief SetLayoutMargins set the margins of the layout, the values have to be in Unit::Px
* @param margins layout margins
*/
void SetLayoutMargins(const QMarginsF &margins);
/**
* @brief SetLayoutMargins set the margins of the layout, the values have to be in the unit of the layout
* @param margins layout margins
*/
void SetLayoutMarginsConverted(const QMarginsF &margins);
/**
* @brief GetLayoutMargins Returns the size in Unit::Px
* @return the size in Unit::Px
*/
QMarginsF GetLayoutMargins() const;
/**
* @brief GetLayoutMarginsConverted Returns the margins in the layout's unit
* @return the margins in the layout's unit
*/
QMarginsF GetLayoutMarginsConverted() const;
/**
* @brief SetFollowGrainline Sets the type of grainline for the pieces to follow
* @param state the type of grainline
*/
void SetFollowGrainline(FollowGrainline state);
/**
* @brief GetFollowGrainline Returns if the layout's pieces follow a grainline or not
* @return wether the pieces follow a grainline and if so, which grainline
*/
FollowGrainline GetFollowGrainline() const;
/**
* @brief SetPiecesGap sets the pieces gap to the given value, the unit has to be in Unit::Px
* @param value pieces gap
*/
void SetPiecesGap(qreal value);
/**
* @brief SetPiecesGapConverted sets the pieces gap to the given value, the unit has to be in the layout's unit
* @param value pieces gap
*/
void SetPiecesGapConverted(qreal value);
/**
* @brief GetPiecesGap returns the pieces gap in Unit::Px
* @return the pieces gap in Unit::Px
*/
qreal GetPiecesGap() const;
/**
* @brief GetPiecesGapConverted returns the pieces gap in the layout's unit
* @return the pieces gap in the layout's unit
*/
qreal GetPiecesGapConverted() const;
void SetWarningSuperpositionOfPieces(bool state);
bool GetWarningSuperpositionOfPieces() const;
void SetWarningPiecesOutOfBound(bool state);
bool GetWarningPiecesOutOfBound() const;
void SetStickyEdges(bool state);
bool GetStickyEdges() const;
/**
* @brief ClearSelection goes through the layers & pieces and calls
* SetIsSelected(false) for the pieces that were selected.
*/
void ClearSelection();
/**
* @brief SetFocusedLayer Sets the focused layer, to which pieces are added from the carrousel via drag
* and drop
* @param focusedLayer the new active layer. If nullptr, then it sets automaticaly the first layer from m_layers
*/
void SetFocusedLayer(VPuzzleLayer* focusedLayer = nullptr);
/**
* @brief GetFocusedLayer Returns the focused layer, to which pieces are added from the carrousel via drag
* and drop
* @return the focused layer
*/
VPuzzleLayer* GetFocusedLayer();
/**
* @brief MovePieceToLayer Moves the given piece to the given layer
* @param piece the piece to move
* @param layer the layer to move the piece to
*/
void MovePieceToLayer(VPuzzlePiece* piece, VPuzzleLayer* layer);
signals:
void PieceMovedToLayer(VPuzzlePiece *piece, VPuzzleLayer *layerBefore, VPuzzleLayer *layerAfter);
private:
Q_DISABLE_COPY(VPuzzleLayout)
VPuzzleLayer *m_unplacedPiecesLayer;
QList<VPuzzleLayer *> m_layers{};
/**
* @brief m_focusedLayer pointer the the focused layer, to which pieces will be
* added via drag and drop, or if no layer is defined.
*/
VPuzzleLayer *m_focusedLayer{nullptr};
// format
Unit m_unit{Unit::Cm};
/**
* @brief m_size the Size in Unit::Px
*/
QSizeF m_size{};
// margins
/**
* @brief m_margins the margins in Unit::Px
*/
QMarginsF m_margins{};
// control
FollowGrainline m_followGrainLine{FollowGrainline::No};
/**
* @brief m_piecesGap the pieces gap in Unit::Px
*/
qreal m_piecesGap{0};
bool m_warningSuperpositionOfPieces{false};
bool m_warningPiecesOutOfBound{false};
bool m_stickyEdges{false};
};
#endif // VPUZZLELAYOUT_H

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlelayoutfilereader.cpp ** @file vplayoutfilereader.cpp
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 18 4, 2020 ** @date 18 4, 2020
** **
@ -27,27 +27,27 @@
** *************************************************************************/ ** *************************************************************************/
#include <QXmlStreamAttributes> #include <QXmlStreamAttributes>
#include "vpuzzlelayoutfilereader.h" #include "vplayoutfilereader.h"
#include "vpuzzlelayoutfilewriter.h" #include "vplayoutfilewriter.h"
#include "layoutliterals.h" #include "vplayoutliterals.h"
#include "../ifc/exception/vexception.h" #include "../ifc/exception/vexception.h"
#include "../ifc/exception/vexceptionconversionerror.h" #include "../ifc/exception/vexceptionconversionerror.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleLayoutFileReader::VPuzzleLayoutFileReader() VPLayoutFileReader::VPLayoutFileReader()
{ {
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleLayoutFileReader::~VPuzzleLayoutFileReader() VPLayoutFileReader::~VPLayoutFileReader()
{ {
// TODO // TODO
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VPuzzleLayoutFileReader::ReadFile(VPuzzleLayout *layout, QFile *file) bool VPLayoutFileReader::ReadFile(VPLayout *layout, QFile *file)
{ {
setDevice(file); setDevice(file);
@ -60,7 +60,7 @@ bool VPuzzleLayoutFileReader::ReadFile(VPuzzleLayout *layout, QFile *file)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayoutFileReader::ReadLayout(VPuzzleLayout *layout) void VPLayoutFileReader::ReadLayout(VPLayout *layout)
{ {
SCASSERT(isStartElement() && name() == ML::TagLayout); SCASSERT(isStartElement() && name() == ML::TagLayout);
@ -70,9 +70,13 @@ void VPuzzleLayoutFileReader::ReadLayout(VPuzzleLayout *layout)
{ {
ReadProperties(layout); ReadProperties(layout);
} }
else if (name() == ML::TagLayers) else if (name() == ML::TagPieceLists)
{ {
ReadLayers(layout); ReadSheets(layout);
}
else if (name() == ML::TagUnplacedPieceList)
{
ReadUnplacedPieces(layout);
} }
else else
{ {
@ -82,7 +86,7 @@ void VPuzzleLayoutFileReader::ReadLayout(VPuzzleLayout *layout)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayoutFileReader::ReadProperties(VPuzzleLayout *layout) void VPLayoutFileReader::ReadProperties(VPLayout *layout)
{ {
SCASSERT(isStartElement() && name() == ML::TagProperties); SCASSERT(isStartElement() && name() == ML::TagProperties);
@ -94,8 +98,6 @@ void VPuzzleLayoutFileReader::ReadProperties(VPuzzleLayout *layout)
{ {
ML::TagUnit, ML::TagUnit,
ML::TagDescription, ML::TagDescription,
ML::TagSize,
ML::TagMargin,
ML::TagControl, ML::TagControl,
ML::TagTiles ML::TagTiles
}); });
@ -113,38 +115,17 @@ void VPuzzleLayoutFileReader::ReadProperties(VPuzzleLayout *layout)
// TODO read the description info // TODO read the description info
break; break;
} }
case 2:// size case 2:// control
{
qDebug("read size");
QSizeF size = ReadSize();
layout->SetLayoutSize(size);
readElementText();
break;
}
case 3:// margin
{
qDebug("read margin");
QMarginsF margins = ReadMargins();
layout->SetLayoutMargins(margins);
readElementText();
break;
}
case 4:// control
{ {
qDebug("read control"); qDebug("read control");
QXmlStreamAttributes attribs = attributes(); QXmlStreamAttributes attribs = attributes();
// attribs.value("followGrainLine"); // TODO
layout->SetWarningSuperpositionOfPieces(ReadAttributeBool(attribs, ML::AttrWarningSuperposition, trueStr)); layout->SetWarningSuperpositionOfPieces(ReadAttributeBool(attribs, ML::AttrWarningSuperposition, trueStr));
layout->SetWarningPiecesOutOfBound(ReadAttributeBool(attribs, ML::AttrWarningOutOfBound, trueStr)); layout->SetWarningPiecesOutOfBound(ReadAttributeBool(attribs, ML::AttrWarningOutOfBound, trueStr));
layout->SetStickyEdges(ReadAttributeBool(attribs, ML::AttrStickyEdges, trueStr));
layout->SetPiecesGap(ReadAttributeDouble(attribs, ML::AttrPiecesGap, QChar('0')));
readElementText(); readElementText();
break; break;
} }
case 5:// tiles case 3:// tiles
qDebug("read tiles"); qDebug("read tiles");
ReadTiles(layout); ReadTiles(layout);
readElementText(); readElementText();
@ -158,7 +139,13 @@ void VPuzzleLayoutFileReader::ReadProperties(VPuzzleLayout *layout)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayoutFileReader::ReadTiles(VPuzzleLayout *layout) void VPLayoutFileReader::ReadUnplacedPieces(VPLayout *layout)
{
ReadPieceList(layout->GetUnplacedPieceList());
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileReader::ReadTiles(VPLayout *layout)
{ {
Q_UNUSED(layout); // to be removed when used Q_UNUSED(layout); // to be removed when used
@ -193,20 +180,15 @@ void VPuzzleLayoutFileReader::ReadTiles(VPuzzleLayout *layout)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayoutFileReader::ReadLayers(VPuzzleLayout *layout) void VPLayoutFileReader::ReadSheets(VPLayout *layout)
{ {
SCASSERT(isStartElement() && name() == ML::TagLayers); SCASSERT(isStartElement() && name() == ML::TagSheets);
while (readNextStartElement()) while (readNextStartElement())
{ {
if (name() == ML::TagUnplacedPiecesLayer) if (name() == ML::TagSheet)
{ {
ReadLayer(layout->GetUnplacedPiecesLayer()); ReadSheet(layout);
}
else if (name() == ML::TagLayer)
{
VPuzzleLayer *layer = layout->AddLayer();
ReadLayer(layer);
} }
else else
{ {
@ -217,21 +199,29 @@ void VPuzzleLayoutFileReader::ReadLayers(VPuzzleLayout *layout)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayoutFileReader::ReadLayer(VPuzzleLayer *layer) void VPLayoutFileReader::ReadSheet(VPLayout *layout)
{ {
SCASSERT(isStartElement() && (name() == ML::TagLayer || name() == ML::TagUnplacedPiecesLayer)); Q_UNUSED(layout);
// TODO
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileReader::ReadPieceList(VPPieceList *pieceList)
{
SCASSERT(isStartElement() && (name() == ML::TagPieceList || name() == ML::TagUnplacedPieceList));
QXmlStreamAttributes attribs = attributes(); QXmlStreamAttributes attribs = attributes();
layer->SetName(ReadAttributeString(attribs, ML::AttrName, tr("Layer"))); pieceList->SetName(ReadAttributeString(attribs, ML::AttrName, tr("Piece List")));
layer->SetIsVisible(ReadAttributeBool(attribs, ML::AttrVisible, trueStr)); pieceList->SetIsVisible(ReadAttributeBool(attribs, ML::AttrVisible, trueStr));
while (readNextStartElement()) while (readNextStartElement())
{ {
if (name() == ML::TagPiece) if (name() == ML::TagPiece)
{ {
VPuzzlePiece *piece = new VPuzzlePiece(); VPPiece *piece = new VPPiece();
ReadPiece(piece); ReadPiece(piece);
layer->AddPiece(piece); pieceList->AddPiece(piece);
} }
else else
{ {
@ -242,7 +232,7 @@ void VPuzzleLayoutFileReader::ReadLayer(VPuzzleLayer *layer)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayoutFileReader::ReadPiece(VPuzzlePiece *piece) void VPLayoutFileReader::ReadPiece(VPPiece *piece)
{ {
Q_UNUSED(piece); Q_UNUSED(piece);
SCASSERT(isStartElement() && name() == ML::TagPiece); SCASSERT(isStartElement() && name() == ML::TagPiece);
@ -278,7 +268,7 @@ void VPuzzleLayoutFileReader::ReadPiece(VPuzzlePiece *piece)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QMarginsF VPuzzleLayoutFileReader::ReadMargins() QMarginsF VPLayoutFileReader::ReadMargins()
{ {
QMarginsF margins = QMarginsF(); QMarginsF margins = QMarginsF();
@ -292,7 +282,7 @@ QMarginsF VPuzzleLayoutFileReader::ReadMargins()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QSizeF VPuzzleLayoutFileReader::ReadSize() QSizeF VPLayoutFileReader::ReadSize()
{ {
QSizeF size = QSize(); QSizeF size = QSize();
@ -304,7 +294,7 @@ QSizeF VPuzzleLayoutFileReader::ReadSize()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VPuzzleLayoutFileReader::ReadAttributeString(const QXmlStreamAttributes &attribs, const QString &name, QString VPLayoutFileReader::ReadAttributeString(const QXmlStreamAttributes &attribs, const QString &name,
const QString &defValue) const QString &defValue)
{ {
const QString parameter = attribs.value(name).toString(); const QString parameter = attribs.value(name).toString();
@ -323,13 +313,13 @@ QString VPuzzleLayoutFileReader::ReadAttributeString(const QXmlStreamAttributes
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VPuzzleLayoutFileReader::ReadAttributeEmptyString(const QXmlStreamAttributes &attribs, const QString &name) QString VPLayoutFileReader::ReadAttributeEmptyString(const QXmlStreamAttributes &attribs, const QString &name)
{ {
return attribs.value(name).toString(); return attribs.value(name).toString();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VPuzzleLayoutFileReader::ReadAttributeBool(const QXmlStreamAttributes &attribs, const QString &name, bool VPLayoutFileReader::ReadAttributeBool(const QXmlStreamAttributes &attribs, const QString &name,
const QString &defValue) const QString &defValue)
{ {
QString parametr; QString parametr;
@ -366,7 +356,7 @@ bool VPuzzleLayoutFileReader::ReadAttributeBool(const QXmlStreamAttributes &attr
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VPuzzleLayoutFileReader::ReadAttributeDouble(const QXmlStreamAttributes &attribs, const QString &name, qreal VPLayoutFileReader::ReadAttributeDouble(const QXmlStreamAttributes &attribs, const QString &name,
const QString &defValue) const QString &defValue)
{ {
bool ok = false; bool ok = false;

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlelayoutfilereader.h ** @file vplayoutfilereader.h
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 18 4, 2020 ** @date 18 4, 2020
** **
@ -26,33 +26,35 @@
** **
** *************************************************************************/ ** *************************************************************************/
#ifndef VPUZZLELAYOUTFILEREADER_H #ifndef VPLAYOUTFILEREADER_H
#define VPUZZLELAYOUTFILEREADER_H #define VPLAYOUTFILEREADER_H
#include <QXmlStreamReader> #include <QXmlStreamReader>
#include "../ifc/xml/vabstractconverter.h" #include "../ifc/xml/vabstractconverter.h"
#include "vpuzzlelayout.h" #include "vplayout.h"
#include "vpuzzlelayer.h" #include "vppiecelist.h"
#include "vpuzzlepiece.h" #include "vppiece.h"
class VPuzzleLayoutFileReader : public QXmlStreamReader class VPLayoutFileReader : public QXmlStreamReader
{ {
Q_DECLARE_TR_FUNCTIONS(VPuzzleLayoutFileReader) Q_DECLARE_TR_FUNCTIONS(VPLayoutFileReader)
public: public:
VPuzzleLayoutFileReader(); VPLayoutFileReader();
~VPuzzleLayoutFileReader(); ~VPLayoutFileReader();
bool ReadFile(VPuzzleLayout *layout, QFile *file); bool ReadFile(VPLayout *layout, QFile *file);
private: private:
Q_DISABLE_COPY(VPuzzleLayoutFileReader) Q_DISABLE_COPY(VPLayoutFileReader)
void ReadLayout(VPuzzleLayout *layout); void ReadLayout(VPLayout *layout);
void ReadProperties(VPuzzleLayout *layout); void ReadProperties(VPLayout *layout);
void ReadTiles(VPuzzleLayout *layout); void ReadTiles(VPLayout *layout);
void ReadLayers(VPuzzleLayout *layout); void ReadUnplacedPieces(VPLayout *layout);
void ReadLayer(VPuzzleLayer *layer); void ReadSheets(VPLayout *layout);
void ReadPiece(VPuzzlePiece *piece); void ReadSheet(VPLayout *layout);
void ReadPieceList(VPPieceList *pieceList);
void ReadPiece(VPPiece *piece);
QMarginsF ReadMargins(); QMarginsF ReadMargins();
QSizeF ReadSize(); QSizeF ReadSize();
@ -65,4 +67,4 @@ private:
const QString &defValue); const QString &defValue);
}; };
#endif // VPUZZLELAYOUTFILEREADER_H #endif // VPLAYOUTFILEREADER_H

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlelayoutfilewriter.cpp ** @file vplayoutfilewriter.cpp
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 18 4, 2020 ** @date 18 4, 2020
** **
@ -26,27 +26,28 @@
** **
*************************************************************************/ *************************************************************************/
#include "vpuzzlelayoutfilewriter.h" #include "vplayoutfilewriter.h"
#include "vpuzzlelayout.h" #include "vplayout.h"
#include "vpuzzlelayer.h" #include "vpsheet.h"
#include "vpuzzlepiece.h" #include "vppiecelist.h"
#include "layoutliterals.h" #include "vppiece.h"
#include "vplayoutliterals.h"
#include "../ifc/xml/vlayoutconverter.h" #include "../ifc/xml/vlayoutconverter.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleLayoutFileWriter::VPuzzleLayoutFileWriter() VPLayoutFileWriter::VPLayoutFileWriter()
{ {
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleLayoutFileWriter::~VPuzzleLayoutFileWriter() VPLayoutFileWriter::~VPLayoutFileWriter()
{ {
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayoutFileWriter::WriteFile(VPuzzleLayout *layout, QFile *file) void VPLayoutFileWriter::WriteFile(VPLayout *layout, QFile *file)
{ {
setDevice(file); setDevice(file);
setAutoFormatting(true); setAutoFormatting(true);
@ -59,19 +60,19 @@ void VPuzzleLayoutFileWriter::WriteFile(VPuzzleLayout *layout, QFile *file)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayoutFileWriter::WriteLayout(VPuzzleLayout *layout) void VPLayoutFileWriter::WriteLayout(VPLayout *layout)
{ {
writeStartElement(ML::TagLayout); writeStartElement(ML::TagLayout);
SetAttribute(ML::AttrVersion, VLayoutConverter::LayoutMaxVerStr); SetAttribute(ML::AttrVersion, VLayoutConverter::LayoutMaxVerStr);
WriteProperties(layout); WriteProperties(layout);
WriteLayers(layout); WriteUnplacePiecesList(layout);
writeEndElement(); //layout writeEndElement(); //layout
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayoutFileWriter::WriteProperties(VPuzzleLayout *layout) void VPLayoutFileWriter::WriteProperties(VPLayout *layout)
{ {
writeStartElement(ML::TagProperties); writeStartElement(ML::TagProperties);
@ -79,16 +80,10 @@ void VPuzzleLayoutFileWriter::WriteProperties(VPuzzleLayout *layout)
writeTextElement(ML::TagDescription, QString()); // TODO : define the value in layout writeTextElement(ML::TagDescription, QString()); // TODO : define the value in layout
WriteSize(layout->GetLayoutSize());
WriteMargins(layout->GetLayoutMargins());
writeStartElement(ML::TagControl); writeStartElement(ML::TagControl);
SetAttribute(ML::AttrFollowGrainLine, "no"); // TODO / Fixme get the right value
SetAttribute(ML::AttrWarningSuperposition, layout->GetWarningSuperpositionOfPieces()); SetAttribute(ML::AttrWarningSuperposition, layout->GetWarningSuperpositionOfPieces());
SetAttribute(ML::AttrWarningOutOfBound, layout->GetWarningPiecesOutOfBound()); SetAttribute(ML::AttrWarningOutOfBound, layout->GetWarningPiecesOutOfBound());
SetAttribute(ML::AttrStickyEdges, layout->GetStickyEdges());
SetAttribute(ML::AttrPiecesGap, layout->GetPiecesGap());
writeEndElement(); // control writeEndElement(); // control
// WriteTiles(layout); TODO: when tile functionality implemented, then uncomment this line // WriteTiles(layout); TODO: when tile functionality implemented, then uncomment this line
@ -97,7 +92,33 @@ void VPuzzleLayoutFileWriter::WriteProperties(VPuzzleLayout *layout)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayoutFileWriter::WriteTiles(VPuzzleLayout *layout) void VPLayoutFileWriter::WriteUnplacePiecesList(VPLayout *layout)
{
Q_UNUSED(layout);
// TODO
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileWriter::WriteSheets(VPLayout *layout)
{
Q_UNUSED(layout);
// TODO
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileWriter::WriteSheet(VPSheet* sheet)
{
Q_UNUSED(sheet);
// TODO
// WritePieceList(pieceList);
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileWriter::WriteTiles(VPLayout *layout)
{ {
Q_UNUSED(layout); // to be removed Q_UNUSED(layout); // to be removed
@ -116,49 +137,32 @@ void VPuzzleLayoutFileWriter::WriteTiles(VPuzzleLayout *layout)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayoutFileWriter::WriteLayers(VPuzzleLayout *layout) void VPLayoutFileWriter::WritePieceList(VPPieceList *pieceList)
{ {
writeStartElement(ML::TagLayers); WritePieceList(pieceList, ML::TagPieceList);
WriteLayer(layout->GetUnplacedPiecesLayer(), ML::TagUnplacedPiecesLayer);
QList<VPuzzleLayer*> layers = layout->GetLayers();
for (auto layer : layers)
{
WriteLayer(layer);
}
writeEndElement(); // layers
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayoutFileWriter::WriteLayer(VPuzzleLayer *layer)
{
WriteLayer(layer, ML::TagLayer);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayoutFileWriter::WriteLayer(VPuzzleLayer *layer, const QString &tagName) void VPLayoutFileWriter::WritePieceList(VPPieceList *pieceList, const QString &tagName)
{ {
writeStartElement(tagName); // layer writeStartElement(tagName); // piece list
SetAttribute(ML::AttrName, layer->GetName()); SetAttribute(ML::AttrName, pieceList->GetName());
SetAttribute(ML::AttrVisible, layer->GetIsVisible()); SetAttribute(ML::AttrVisible, pieceList->GetIsVisible());
// TODO selected info. Not sure how it's saved yet // TODO selected info. Not sure how it's saved yet
//SetAttribute("selected", layer->GetIsSelected()); //SetAttribute("selected", pieceList->GetIsSelected());
QList<VPuzzlePiece*> pieces = layer->GetPieces(); QList<VPPiece*> pieces = pieceList->GetPieces();
for (auto piece : pieces) for (auto piece : pieces)
{ {
WritePiece(piece); WritePiece(piece);
} }
writeEndElement(); // layer writeEndElement(); // piece list
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayoutFileWriter::WritePiece(VPuzzlePiece *piece) void VPLayoutFileWriter::WritePiece(VPPiece *piece)
{ {
Q_UNUSED(piece); Q_UNUSED(piece);
@ -182,7 +186,7 @@ void VPuzzleLayoutFileWriter::WritePiece(VPuzzlePiece *piece)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayoutFileWriter::WriteMargins(const QMarginsF &margins) void VPLayoutFileWriter::WriteMargins(const QMarginsF &margins)
{ {
writeStartElement(ML::TagMargin); writeStartElement(ML::TagMargin);
SetAttribute(ML::AttrLeft, margins.left()); SetAttribute(ML::AttrLeft, margins.left());
@ -193,7 +197,7 @@ void VPuzzleLayoutFileWriter::WriteMargins(const QMarginsF &margins)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleLayoutFileWriter::WriteSize(QSizeF size) void VPLayoutFileWriter::WriteSize(QSizeF size)
{ {
// maybe not necessary to test this, the writer should "stupidly write", the application should take care of these tests // maybe not necessary to test this, the writer should "stupidly write", the application should take care of these tests
qreal width = size.width(); qreal width = size.width();

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlelayoutfilewriter.h ** @file vplayoutfilewriter.h
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 18 4, 2020 ** @date 18 4, 2020
** **
@ -26,37 +26,40 @@
** **
** *************************************************************************/ ** *************************************************************************/
#ifndef VPUZZLELAYOUTFILEWRITER_H #ifndef VPLAYOUTFILEWRITER_H
#define VPUZZLELAYOUTFILEWRITER_H #define VPLAYOUTFILEWRITER_H
#include <QLocale> #include <QLocale>
#include <QXmlStreamWriter> #include <QXmlStreamWriter>
#include "../vmisc/literals.h" #include "../vmisc/literals.h"
class VPuzzleLayout; class VPLayout;
class VPuzzleLayer; class VPSheet;
class VPuzzlePiece; class VPPieceList;
class VPPiece;
class QFile; class QFile;
class QMarginsF; class QMarginsF;
class VPuzzleLayoutFileWriter : public QXmlStreamWriter class VPLayoutFileWriter : public QXmlStreamWriter
{ {
public: public:
VPuzzleLayoutFileWriter(); VPLayoutFileWriter();
~VPuzzleLayoutFileWriter(); ~VPLayoutFileWriter();
void WriteFile(VPuzzleLayout *layout, QFile *file); void WriteFile(VPLayout *layout, QFile *file);
private: private:
void WriteLayout(VPuzzleLayout *layout); void WriteLayout(VPLayout *layout);
void WriteProperties(VPuzzleLayout *layout); void WriteProperties(VPLayout *layout);
void WriteTiles(VPuzzleLayout *layout); void WriteUnplacePiecesList(VPLayout *layout);
void WriteLayers(VPuzzleLayout *layout); void WriteSheets(VPLayout *layout);
void WriteLayer(VPuzzleLayer *layer); void WriteSheet(VPSheet* sheet);
void WriteLayer(VPuzzleLayer *layer, const QString &tagName); void WriteTiles(VPLayout *layout);
void WritePiece(VPuzzlePiece *piece); void WritePieceList(VPPieceList *pieceList);
void WritePieceList(VPPieceList *pieceList, const QString &tagName);
void WritePiece(VPPiece *piece);
void WriteMargins(const QMarginsF &margins); void WriteMargins(const QMarginsF &margins);
void WriteSize(QSizeF size); void WriteSize(QSizeF size);
@ -71,7 +74,7 @@ private:
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template<typename T> template<typename T>
void VPuzzleLayoutFileWriter::SetAttribute(const QString &name, const T &value) void VPLayoutFileWriter::SetAttribute(const QString &name, const T &value)
{ {
// See specification for xs:decimal // See specification for xs:decimal
const QLocale locale = QLocale::c(); const QLocale locale = QLocale::c();
@ -80,30 +83,30 @@ void VPuzzleLayoutFileWriter::SetAttribute(const QString &name, const T &value)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <> template <>
inline void VPuzzleLayoutFileWriter::SetAttribute<QString>(const QString &name, const QString &value) inline void VPLayoutFileWriter::SetAttribute<QString>(const QString &name, const QString &value)
{ {
writeAttribute(name, value); writeAttribute(name, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <> template <>
inline void VPuzzleLayoutFileWriter::SetAttribute<QChar>(const QString &name, const QChar &value) inline void VPLayoutFileWriter::SetAttribute<QChar>(const QString &name, const QChar &value)
{ {
writeAttribute(name, value); writeAttribute(name, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <> template <>
inline void VPuzzleLayoutFileWriter::SetAttribute<bool>(const QString &name, const bool &value) inline void VPLayoutFileWriter::SetAttribute<bool>(const QString &name, const bool &value)
{ {
writeAttribute(name, value ? trueStr : falseStr); writeAttribute(name, value ? trueStr : falseStr);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <size_t N> template <size_t N>
inline void VPuzzleLayoutFileWriter::SetAttribute(const QString &name, const char (&value)[N]) inline void VPLayoutFileWriter::SetAttribute(const QString &name, const char (&value)[N])
{ {
writeAttribute(name, QString(value)); writeAttribute(name, QString(value));
} }
#endif // VPUZZLELAYOUTFILEWRITER_H #endif // VPLAYOUTFILEWRITER_H

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file literals.cpp ** @file vplayoutliterals.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com> ** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 23 4, 2020 ** @date 23 4, 2020
** **
@ -25,22 +25,24 @@
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
*************************************************************************/ *************************************************************************/
#include "layoutliterals.h" #include "vplayoutliterals.h"
namespace ML namespace ML
{ {
const QString TagLayout = QStringLiteral("layout"); const QString TagLayout = QStringLiteral("layout");
const QString TagProperties = QStringLiteral("properties"); const QString TagProperties = QStringLiteral("properties");
const QString TagLayers = QStringLiteral("layers"); const QString TagPieceLists = QStringLiteral("pieceLists");
const QString TagUnit = QStringLiteral("unit"); const QString TagUnit = QStringLiteral("unit");
const QString TagDescription = QStringLiteral("description"); const QString TagDescription = QStringLiteral("description");
const QString TagSize = QStringLiteral("size"); const QString TagSize = QStringLiteral("size");
const QString TagMargin = QStringLiteral("margin"); const QString TagMargin = QStringLiteral("margin");
const QString TagControl = QStringLiteral("control"); const QString TagControl = QStringLiteral("control");
const QString TagTiles = QStringLiteral("tiles"); const QString TagTiles = QStringLiteral("tiles");
const QString TagUnplacedPiecesLayer = QStringLiteral("unplacedPiecesLayer"); const QString TagUnplacedPieceList = QStringLiteral("unplacedPieceList");
const QString TagLayer = QStringLiteral("layer"); const QString TagPieceList = QStringLiteral("pieceList");
const QString TagPiece = QStringLiteral("piece"); const QString TagPiece = QStringLiteral("piece");
const QString TagSheets = QStringLiteral("sheets");
const QString TagSheet = QStringLiteral("sheet");
const QString AttrVersion = QStringLiteral("version"); const QString AttrVersion = QStringLiteral("version");
const QString AttrWarningSuperposition = QStringLiteral("warningSuperposition"); const QString AttrWarningSuperposition = QStringLiteral("warningSuperposition");

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file literals.h ** @file vplayoutliterals.h
** @author Roman Telezhynskyi <dismine(at)gmail.com> ** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 23 4, 2020 ** @date 23 4, 2020
** **
@ -25,8 +25,8 @@
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
*************************************************************************/ *************************************************************************/
#ifndef LAYOUTLITERALS_H #ifndef VPLAYOUTLITERALS_H
#define LAYOUTLITERALS_H #define VPLAYOUTLITERALS_H
#include <QString> #include <QString>
@ -36,16 +36,18 @@ namespace ML
{ {
extern const QString TagLayout; extern const QString TagLayout;
extern const QString TagProperties; extern const QString TagProperties;
extern const QString TagLayers; extern const QString TagPieceLists;
extern const QString TagUnit; extern const QString TagUnit;
extern const QString TagDescription; extern const QString TagDescription;
extern const QString TagSize; extern const QString TagSize;
extern const QString TagMargin; extern const QString TagMargin;
extern const QString TagControl; extern const QString TagControl;
extern const QString TagTiles; extern const QString TagTiles;
extern const QString TagUnplacedPiecesLayer; extern const QString TagUnplacedPieceList;
extern const QString TagLayer; extern const QString TagPieceList;
extern const QString TagPiece; extern const QString TagPiece;
extern const QString TagSheets;
extern const QString TagSheet;
extern const QString AttrVersion; extern const QString AttrVersion;
extern const QString AttrWarningSuperposition; extern const QString AttrWarningSuperposition;
@ -69,4 +71,4 @@ extern const QString AttrShowSeamline;
} }
#endif // LAYOUTLITERALS_H #endif // VPLAYOUTLITERALS_H