From ed3022ae51e8e43e10b8c72122e8ef149065e821 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 13:10:25 +0200 Subject: [PATCH 01/28] isEmpty test of graphic piece --- src/app/puzzle/vpuzzlegraphicspiece.cpp | 28 ++++++++++++++++--------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/app/puzzle/vpuzzlegraphicspiece.cpp b/src/app/puzzle/vpuzzlegraphicspiece.cpp index 3d53423fe..30f1af656 100644 --- a/src/app/puzzle/vpuzzlegraphicspiece.cpp +++ b/src/app/puzzle/vpuzzlegraphicspiece.cpp @@ -74,22 +74,30 @@ void VPuzzleGraphicsPiece::Init() // initialises the seam line QVector seamLinePoints = m_piece->GetSeamLine(); - m_seamLine.moveTo(seamLinePoints.first()); - for (int i = 1; i < seamLinePoints.size(); ++i) - m_seamLine.lineTo(seamLinePoints.at(i)); + if(!seamLinePoints.isEmpty()) + { + m_seamLine.moveTo(seamLinePoints.first()); + for (int i = 1; i < seamLinePoints.size(); ++i) + m_seamLine.lineTo(seamLinePoints.at(i)); + } // initiliases the cutting line QVector cuttingLinepoints = m_piece->GetCuttingLine(); - m_cuttingLine.moveTo(cuttingLinepoints.first()); - for (int i = 1; i < cuttingLinepoints.size(); ++i) - m_cuttingLine.lineTo(cuttingLinepoints.at(i)); + if(!cuttingLinepoints.isEmpty()) + { + m_cuttingLine.moveTo(cuttingLinepoints.first()); + for (int i = 1; i < cuttingLinepoints.size(); ++i) + m_cuttingLine.lineTo(cuttingLinepoints.at(i)); + } // initialises the grainline QVector grainLinepoints = m_piece->GetGrainline(); - m_grainline.moveTo(grainLinepoints.first()); - for (int i = 1; i < grainLinepoints.size(); ++i) - m_grainline.lineTo(grainLinepoints.at(i)); - + if(!grainLinepoints.isEmpty()) + { + m_grainline.moveTo(grainLinepoints.first()); + for (int i = 1; i < grainLinepoints.size(); ++i) + m_grainline.lineTo(grainLinepoints.at(i)); + } // TODO : initialises the other elements labels, passmarks etc. From 213863ae983664a5a56f20da1948db8c8e01140e Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 13:49:38 +0200 Subject: [PATCH 02/28] refactoring dialog about --- ...ialogaboutpuzzle.cpp => vpdialogabout.cpp} | 22 +++++++++---------- .../{dialogaboutpuzzle.h => vpdialogabout.h} | 20 ++++++++--------- ...{dialogaboutpuzzle.ui => vpdialogabout.ui} | 5 +++-- src/app/puzzle/puzzle.pri | 6 ++--- src/app/puzzle/puzzlemainwindow.cpp | 5 +++-- 5 files changed, 30 insertions(+), 28 deletions(-) rename src/app/puzzle/dialogs/{dialogaboutpuzzle.cpp => vpdialogabout.cpp} (89%) rename src/app/puzzle/dialogs/{dialogaboutpuzzle.h => vpdialogabout.h} (80%) rename src/app/puzzle/dialogs/{dialogaboutpuzzle.ui => vpdialogabout.ui} (98%) diff --git a/src/app/puzzle/dialogs/dialogaboutpuzzle.cpp b/src/app/puzzle/dialogs/vpdialogabout.cpp similarity index 89% rename from src/app/puzzle/dialogs/dialogaboutpuzzle.cpp rename to src/app/puzzle/dialogs/vpdialogabout.cpp index 89328bfab..857c0b12e 100644 --- a/src/app/puzzle/dialogs/dialogaboutpuzzle.cpp +++ b/src/app/puzzle/dialogs/vpdialogabout.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file dialogaboutpuzzle.cpp + ** @file vpdialogabout.cpp ** @author Ronan Le Tiec ** @date 11 4, 2020 ** @@ -26,8 +26,8 @@ ** *************************************************************************/ -#include "dialogaboutpuzzle.h" -#include "ui_dialogaboutpuzzle.h" +#include "vpdialogabout.h" +#include "ui_vpdialogabout.h" #include "../version.h" #include "../vmisc/def.h" #include "../fervor/fvupdater.h" @@ -40,9 +40,9 @@ #include //--------------------------------------------------------------------------------------------------------------------- -DialogAboutPuzzle::DialogAboutPuzzle(QWidget *parent) +VPDialogAbout::VPDialogAbout(QWidget *parent) :QDialog(parent), - ui(new Ui::DialogAboutPuzzle), + ui(new Ui::VPDialogAbout), isInitialized(false) { ui->setupUi(this); @@ -57,7 +57,7 @@ DialogAboutPuzzle::DialogAboutPuzzle(QWidget *parent) 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, []() { // Set feed URL before doing anything else @@ -72,13 +72,13 @@ DialogAboutPuzzle::DialogAboutPuzzle(QWidget *parent) } //--------------------------------------------------------------------------------------------------------------------- -DialogAboutPuzzle::~DialogAboutPuzzle() +VPDialogAbout::~VPDialogAbout() { delete ui; } //--------------------------------------------------------------------------------------------------------------------- -void DialogAboutPuzzle::changeEvent(QEvent *event) +void VPDialogAbout::changeEvent(QEvent *event) { 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 ); 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) @@ -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->labelBuildRevision->setText(tr("Build revision: %1").arg(BUILD_REVISION)); diff --git a/src/app/puzzle/dialogs/dialogaboutpuzzle.h b/src/app/puzzle/dialogs/vpdialogabout.h similarity index 80% rename from src/app/puzzle/dialogs/dialogaboutpuzzle.h rename to src/app/puzzle/dialogs/vpdialogabout.h index 62d0d2498..fce48ca0e 100644 --- a/src/app/puzzle/dialogs/dialogaboutpuzzle.h +++ b/src/app/puzzle/dialogs/vpdialogabout.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file dialogaboutpuzzle.h + ** @file vpdialogabout.h ** @author Ronan Le Tiec ** @date 11 4, 2020 ** @@ -26,31 +26,31 @@ ** *************************************************************************/ -#ifndef DIALOGABOUTPUZZLE_H -#define DIALOGABOUTPUZZLE_H +#ifndef VPDIALOGABOUT_H +#define VPDIALOGABOUT_H #include namespace Ui { - class DialogAboutPuzzle; + class VPDialogAbout; } -class DialogAboutPuzzle : public QDialog +class VPDialogAbout : public QDialog { Q_OBJECT public: - explicit DialogAboutPuzzle(QWidget *parent = nullptr); - virtual ~DialogAboutPuzzle(); + explicit VPDialogAbout(QWidget *parent = nullptr); + virtual ~VPDialogAbout(); protected: virtual void changeEvent(QEvent* event) override; virtual void showEvent(QShowEvent *event) override; private: - Q_DISABLE_COPY(DialogAboutPuzzle) - Ui::DialogAboutPuzzle *ui; + Q_DISABLE_COPY(VPDialogAbout) + Ui::VPDialogAbout *ui; bool isInitialized; void FontPointSize(QWidget *w, int pointSize); @@ -58,4 +58,4 @@ private: void RetranslateUi(); }; -#endif // DIALOGABOUTPUZZLE_H +#endif // VPDIALOGABOUT_H diff --git a/src/app/puzzle/dialogs/dialogaboutpuzzle.ui b/src/app/puzzle/dialogs/vpdialogabout.ui similarity index 98% rename from src/app/puzzle/dialogs/dialogaboutpuzzle.ui rename to src/app/puzzle/dialogs/vpdialogabout.ui index 9b4344117..f98c73aa6 100644 --- a/src/app/puzzle/dialogs/dialogaboutpuzzle.ui +++ b/src/app/puzzle/dialogs/vpdialogabout.ui @@ -1,7 +1,7 @@ - DialogAboutPuzzle - + VPDialogAbout + 0 @@ -296,6 +296,7 @@ + diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index 5ed131c58..9405487ca 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -2,13 +2,13 @@ # This need for corect working file translations.pro SOURCES += \ + $$PWD/dialogs/vpdialogabout.cpp \ $$PWD/main.cpp \ $$PWD/puzzlecommands.cpp \ $$PWD/puzzlemainwindow.cpp \ $$PWD/puzzleapplication.cpp \ $$PWD/vpiececarrouselpiecepreview.cpp \ $$PWD/vpuzzlecommandline.cpp \ - $$PWD/dialogs/dialogaboutpuzzle.cpp \ $$PWD/vpiececarrousel.cpp \ $$PWD/vpuzzlegraphicslayout.cpp \ $$PWD/vpuzzlegraphicspiece.cpp \ @@ -27,13 +27,13 @@ SOURCES += \ *msvc*:SOURCES += $$PWD/stable.cpp HEADERS += \ + $$PWD/dialogs/vpdialogabout.h \ $$PWD/puzzlecommands.h \ $$PWD/puzzlemainwindow.h \ $$PWD/stable.h \ $$PWD/puzzleapplication.h \ $$PWD/vpiececarrouselpiecepreview.h \ $$PWD/vpuzzlecommandline.h \ - $$PWD/dialogs/dialogaboutpuzzle.h \ $$PWD/vpiececarrousel.h \ $$PWD/vpuzzlegraphicslayout.h \ $$PWD/vpuzzlegraphicspiece.h \ @@ -50,6 +50,6 @@ HEADERS += \ $$PWD/vpiececarrouselpiece.h FORMS += \ + $$PWD/dialogs/vpdialogabout.ui \ $$PWD/puzzlemainwindow.ui \ - $$PWD/dialogs/dialogaboutpuzzle.ui \ $$PWD/vpiececarrousel.ui diff --git a/src/app/puzzle/puzzlemainwindow.cpp b/src/app/puzzle/puzzlemainwindow.cpp index 874477d53..9a86fa91b 100644 --- a/src/app/puzzle/puzzlemainwindow.cpp +++ b/src/app/puzzle/puzzlemainwindow.cpp @@ -28,9 +28,10 @@ #include "puzzlemainwindow.h" #include +#include #include "ui_puzzlemainwindow.h" -#include "dialogs/dialogaboutpuzzle.h" +#include "dialogs/vpdialogabout.h" #include "xml/vpuzzlelayoutfilewriter.h" #include "xml/vpuzzlelayoutfilereader.h" #include "puzzleapplication.h" @@ -754,7 +755,7 @@ void PuzzleMainWindow::on_actionAboutQt_triggered() //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::on_actionAboutPuzzle_triggered() { - auto *aboutDialog = new DialogAboutPuzzle(this); + auto *aboutDialog = new VPDialogAbout(this); aboutDialog->setAttribute(Qt::WA_DeleteOnClose, true); aboutDialog->show(); } From 63d5ac0158f392f18a5b2c4b63706f555b195d40 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 13:51:57 +0200 Subject: [PATCH 03/28] refactoring layoutliterals --- src/app/puzzle/puzzle.pri | 4 ++-- .../puzzle/xml/{layoutliterals.cpp => vplayoutliterals.cpp} | 2 +- src/app/puzzle/xml/{layoutliterals.h => vplayoutliterals.h} | 6 +++--- src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp | 2 +- src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) rename src/app/puzzle/xml/{layoutliterals.cpp => vplayoutliterals.cpp} (99%) rename src/app/puzzle/xml/{layoutliterals.h => vplayoutliterals.h} (96%) diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index 9405487ca..1a0814b52 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -18,7 +18,7 @@ SOURCES += \ $$PWD/vpuzzlemimedatapiece.cpp \ $$PWD/vpuzzlepiece.cpp \ $$PWD/vpuzzlesettings.cpp \ - $$PWD/xml/layoutliterals.cpp \ + $$PWD/xml/vplayoutliterals.cpp \ $$PWD/xml/vpuzzlelayoutfilewriter.cpp \ $$PWD/xml/vpuzzlelayoutfilereader.cpp \ $$PWD/vpiececarrousellayer.cpp \ @@ -43,7 +43,7 @@ HEADERS += \ $$PWD/vpuzzlemimedatapiece.h \ $$PWD/vpuzzlepiece.h \ $$PWD/vpuzzlesettings.h \ - $$PWD/xml/layoutliterals.h \ + $$PWD/xml/vplayoutliterals.h \ $$PWD/xml/vpuzzlelayoutfilewriter.h \ $$PWD/xml/vpuzzlelayoutfilereader.h \ $$PWD/vpiececarrousellayer.h \ diff --git a/src/app/puzzle/xml/layoutliterals.cpp b/src/app/puzzle/xml/vplayoutliterals.cpp similarity index 99% rename from src/app/puzzle/xml/layoutliterals.cpp rename to src/app/puzzle/xml/vplayoutliterals.cpp index d73088fc8..3d64afd4a 100644 --- a/src/app/puzzle/xml/layoutliterals.cpp +++ b/src/app/puzzle/xml/vplayoutliterals.cpp @@ -25,7 +25,7 @@ ** along with Valentina. If not, see . ** *************************************************************************/ -#include "layoutliterals.h" +#include "vplayoutliterals.h" namespace ML { diff --git a/src/app/puzzle/xml/layoutliterals.h b/src/app/puzzle/xml/vplayoutliterals.h similarity index 96% rename from src/app/puzzle/xml/layoutliterals.h rename to src/app/puzzle/xml/vplayoutliterals.h index 82157f9bf..294097326 100644 --- a/src/app/puzzle/xml/layoutliterals.h +++ b/src/app/puzzle/xml/vplayoutliterals.h @@ -25,8 +25,8 @@ ** along with Valentina. If not, see . ** *************************************************************************/ -#ifndef LAYOUTLITERALS_H -#define LAYOUTLITERALS_H +#ifndef VPLAYOUTLITERALS_H +#define VPLAYOUTLITERALS_H #include @@ -69,4 +69,4 @@ extern const QString AttrShowSeamline; } -#endif // LAYOUTLITERALS_H +#endif // VPLAYOUTLITERALS_H diff --git a/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp b/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp index 31ab72691..1b7826fd2 100644 --- a/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp +++ b/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp @@ -29,7 +29,7 @@ #include #include "vpuzzlelayoutfilereader.h" #include "vpuzzlelayoutfilewriter.h" -#include "layoutliterals.h" +#include "vplayoutliterals.h" #include "../ifc/exception/vexception.h" #include "../ifc/exception/vexceptionconversionerror.h" diff --git a/src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp b/src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp index 6b8dced26..88baa5784 100644 --- a/src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp +++ b/src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp @@ -30,7 +30,7 @@ #include "vpuzzlelayout.h" #include "vpuzzlelayer.h" #include "vpuzzlepiece.h" -#include "layoutliterals.h" +#include "vplayoutliterals.h" #include "../ifc/xml/vlayoutconverter.h" //--------------------------------------------------------------------------------------------------------------------- From d9e3a08eac9946ee1719de2749e9149624b1c3cf Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 14:01:03 +0200 Subject: [PATCH 04/28] Refactoring VPuzzleLayoutFileReader --- src/app/puzzle/puzzle.pri | 4 +-- src/app/puzzle/puzzlemainwindow.cpp | 4 +-- ...tfilereader.cpp => vplayoutfilereader.cpp} | 32 +++++++++---------- ...ayoutfilereader.h => vplayoutfilereader.h} | 14 ++++---- 4 files changed, 27 insertions(+), 27 deletions(-) rename src/app/puzzle/xml/{vpuzzlelayoutfilereader.cpp => vplayoutfilereader.cpp} (91%) rename src/app/puzzle/xml/{vpuzzlelayoutfilereader.h => vplayoutfilereader.h} (89%) diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index 1a0814b52..0ebac1854 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -18,9 +18,9 @@ SOURCES += \ $$PWD/vpuzzlemimedatapiece.cpp \ $$PWD/vpuzzlepiece.cpp \ $$PWD/vpuzzlesettings.cpp \ + $$PWD/xml/vplayoutfilereader.cpp \ $$PWD/xml/vplayoutliterals.cpp \ $$PWD/xml/vpuzzlelayoutfilewriter.cpp \ - $$PWD/xml/vpuzzlelayoutfilereader.cpp \ $$PWD/vpiececarrousellayer.cpp \ $$PWD/vpiececarrouselpiece.cpp @@ -43,9 +43,9 @@ HEADERS += \ $$PWD/vpuzzlemimedatapiece.h \ $$PWD/vpuzzlepiece.h \ $$PWD/vpuzzlesettings.h \ + $$PWD/xml/vplayoutfilereader.h \ $$PWD/xml/vplayoutliterals.h \ $$PWD/xml/vpuzzlelayoutfilewriter.h \ - $$PWD/xml/vpuzzlelayoutfilereader.h \ $$PWD/vpiececarrousellayer.h \ $$PWD/vpiececarrouselpiece.h diff --git a/src/app/puzzle/puzzlemainwindow.cpp b/src/app/puzzle/puzzlemainwindow.cpp index 9a86fa91b..851c1eb12 100644 --- a/src/app/puzzle/puzzlemainwindow.cpp +++ b/src/app/puzzle/puzzlemainwindow.cpp @@ -33,7 +33,7 @@ #include "ui_puzzlemainwindow.h" #include "dialogs/vpdialogabout.h" #include "xml/vpuzzlelayoutfilewriter.h" -#include "xml/vpuzzlelayoutfilereader.h" +#include "xml/vplayoutfilereader.h" #include "puzzleapplication.h" #include "../vlayout/vrawlayout.h" #include "../vmisc/vsysexits.h" @@ -106,7 +106,7 @@ bool PuzzleMainWindow::LoadFile(QString path) QFile file(path); file.open(QIODevice::ReadOnly); - QScopedPointer fileReader(new VPuzzleLayoutFileReader()); + QScopedPointer fileReader(new VPLayoutFileReader()); if(m_layout == nullptr) { diff --git a/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp b/src/app/puzzle/xml/vplayoutfilereader.cpp similarity index 91% rename from src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp rename to src/app/puzzle/xml/vplayoutfilereader.cpp index 1b7826fd2..046805035 100644 --- a/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp +++ b/src/app/puzzle/xml/vplayoutfilereader.cpp @@ -27,27 +27,27 @@ ** *************************************************************************/ #include -#include "vpuzzlelayoutfilereader.h" +#include "vplayoutfilereader.h" #include "vpuzzlelayoutfilewriter.h" #include "vplayoutliterals.h" #include "../ifc/exception/vexception.h" #include "../ifc/exception/vexceptionconversionerror.h" //--------------------------------------------------------------------------------------------------------------------- -VPuzzleLayoutFileReader::VPuzzleLayoutFileReader() +VPLayoutFileReader::VPLayoutFileReader() { } //--------------------------------------------------------------------------------------------------------------------- -VPuzzleLayoutFileReader::~VPuzzleLayoutFileReader() +VPLayoutFileReader::~VPLayoutFileReader() { // TODO } //--------------------------------------------------------------------------------------------------------------------- -bool VPuzzleLayoutFileReader::ReadFile(VPuzzleLayout *layout, QFile *file) +bool VPLayoutFileReader::ReadFile(VPuzzleLayout *layout, QFile *file) { setDevice(file); @@ -60,7 +60,7 @@ bool VPuzzleLayoutFileReader::ReadFile(VPuzzleLayout *layout, QFile *file) } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayoutFileReader::ReadLayout(VPuzzleLayout *layout) +void VPLayoutFileReader::ReadLayout(VPuzzleLayout *layout) { SCASSERT(isStartElement() && name() == ML::TagLayout); @@ -82,7 +82,7 @@ void VPuzzleLayoutFileReader::ReadLayout(VPuzzleLayout *layout) } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayoutFileReader::ReadProperties(VPuzzleLayout *layout) +void VPLayoutFileReader::ReadProperties(VPuzzleLayout *layout) { SCASSERT(isStartElement() && name() == ML::TagProperties); @@ -158,7 +158,7 @@ void VPuzzleLayoutFileReader::ReadProperties(VPuzzleLayout *layout) } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayoutFileReader::ReadTiles(VPuzzleLayout *layout) +void VPLayoutFileReader::ReadTiles(VPuzzleLayout *layout) { Q_UNUSED(layout); // to be removed when used @@ -193,7 +193,7 @@ void VPuzzleLayoutFileReader::ReadTiles(VPuzzleLayout *layout) } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayoutFileReader::ReadLayers(VPuzzleLayout *layout) +void VPLayoutFileReader::ReadLayers(VPuzzleLayout *layout) { SCASSERT(isStartElement() && name() == ML::TagLayers); @@ -217,7 +217,7 @@ void VPuzzleLayoutFileReader::ReadLayers(VPuzzleLayout *layout) } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayoutFileReader::ReadLayer(VPuzzleLayer *layer) +void VPLayoutFileReader::ReadLayer(VPuzzleLayer *layer) { SCASSERT(isStartElement() && (name() == ML::TagLayer || name() == ML::TagUnplacedPiecesLayer)); @@ -242,7 +242,7 @@ void VPuzzleLayoutFileReader::ReadLayer(VPuzzleLayer *layer) } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayoutFileReader::ReadPiece(VPuzzlePiece *piece) +void VPLayoutFileReader::ReadPiece(VPuzzlePiece *piece) { Q_UNUSED(piece); SCASSERT(isStartElement() && name() == ML::TagPiece); @@ -278,7 +278,7 @@ void VPuzzleLayoutFileReader::ReadPiece(VPuzzlePiece *piece) } //--------------------------------------------------------------------------------------------------------------------- -QMarginsF VPuzzleLayoutFileReader::ReadMargins() +QMarginsF VPLayoutFileReader::ReadMargins() { QMarginsF margins = QMarginsF(); @@ -292,7 +292,7 @@ QMarginsF VPuzzleLayoutFileReader::ReadMargins() } //--------------------------------------------------------------------------------------------------------------------- -QSizeF VPuzzleLayoutFileReader::ReadSize() +QSizeF VPLayoutFileReader::ReadSize() { QSizeF size = QSize(); @@ -304,7 +304,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 parameter = attribs.value(name).toString(); @@ -323,13 +323,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(); } //--------------------------------------------------------------------------------------------------------------------- -bool VPuzzleLayoutFileReader::ReadAttributeBool(const QXmlStreamAttributes &attribs, const QString &name, +bool VPLayoutFileReader::ReadAttributeBool(const QXmlStreamAttributes &attribs, const QString &name, const QString &defValue) { QString parametr; @@ -366,7 +366,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) { bool ok = false; diff --git a/src/app/puzzle/xml/vpuzzlelayoutfilereader.h b/src/app/puzzle/xml/vplayoutfilereader.h similarity index 89% rename from src/app/puzzle/xml/vpuzzlelayoutfilereader.h rename to src/app/puzzle/xml/vplayoutfilereader.h index 7f4c00e1a..668bbec62 100644 --- a/src/app/puzzle/xml/vpuzzlelayoutfilereader.h +++ b/src/app/puzzle/xml/vplayoutfilereader.h @@ -26,8 +26,8 @@ ** ** *************************************************************************/ -#ifndef VPUZZLELAYOUTFILEREADER_H -#define VPUZZLELAYOUTFILEREADER_H +#ifndef VPLAYOUTFILEREADER_H +#define VPLAYOUTFILEREADER_H #include #include "../ifc/xml/vabstractconverter.h" @@ -35,17 +35,17 @@ #include "vpuzzlelayer.h" #include "vpuzzlepiece.h" -class VPuzzleLayoutFileReader : public QXmlStreamReader +class VPLayoutFileReader : public QXmlStreamReader { Q_DECLARE_TR_FUNCTIONS(VPuzzleLayoutFileReader) public: - VPuzzleLayoutFileReader(); - ~VPuzzleLayoutFileReader(); + VPLayoutFileReader(); + ~VPLayoutFileReader(); bool ReadFile(VPuzzleLayout *layout, QFile *file); private: - Q_DISABLE_COPY(VPuzzleLayoutFileReader) + Q_DISABLE_COPY(VPLayoutFileReader) void ReadLayout(VPuzzleLayout *layout); void ReadProperties(VPuzzleLayout *layout); @@ -65,4 +65,4 @@ private: const QString &defValue); }; -#endif // VPUZZLELAYOUTFILEREADER_H +#endif // VPLAYOUTFILEREADER_H From 13c060f2fc17c21c4a29f19ee521a91914110412 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 14:02:39 +0200 Subject: [PATCH 05/28] Refactoring VPuzzleLayoutFileWriter --- src/app/puzzle/puzzle.pri | 4 +-- src/app/puzzle/puzzlemainwindow.cpp | 4 +-- src/app/puzzle/xml/vplayoutfilereader.cpp | 2 +- ...tfilewriter.cpp => vplayoutfilewriter.cpp} | 26 +++++++++---------- ...ayoutfilewriter.h => vplayoutfilewriter.h} | 22 ++++++++-------- 5 files changed, 29 insertions(+), 29 deletions(-) rename src/app/puzzle/xml/{vpuzzlelayoutfilewriter.cpp => vplayoutfilewriter.cpp} (89%) rename src/app/puzzle/xml/{vpuzzlelayoutfilewriter.h => vplayoutfilewriter.h} (81%) diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index 0ebac1854..410a04e1b 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -19,8 +19,8 @@ SOURCES += \ $$PWD/vpuzzlepiece.cpp \ $$PWD/vpuzzlesettings.cpp \ $$PWD/xml/vplayoutfilereader.cpp \ + $$PWD/xml/vplayoutfilewriter.cpp \ $$PWD/xml/vplayoutliterals.cpp \ - $$PWD/xml/vpuzzlelayoutfilewriter.cpp \ $$PWD/vpiececarrousellayer.cpp \ $$PWD/vpiececarrouselpiece.cpp @@ -44,8 +44,8 @@ HEADERS += \ $$PWD/vpuzzlepiece.h \ $$PWD/vpuzzlesettings.h \ $$PWD/xml/vplayoutfilereader.h \ + $$PWD/xml/vplayoutfilewriter.h \ $$PWD/xml/vplayoutliterals.h \ - $$PWD/xml/vpuzzlelayoutfilewriter.h \ $$PWD/vpiececarrousellayer.h \ $$PWD/vpiececarrouselpiece.h diff --git a/src/app/puzzle/puzzlemainwindow.cpp b/src/app/puzzle/puzzlemainwindow.cpp index 851c1eb12..78414ef41 100644 --- a/src/app/puzzle/puzzlemainwindow.cpp +++ b/src/app/puzzle/puzzlemainwindow.cpp @@ -32,7 +32,7 @@ #include "ui_puzzlemainwindow.h" #include "dialogs/vpdialogabout.h" -#include "xml/vpuzzlelayoutfilewriter.h" +#include "xml/vplayoutfilewriter.h" #include "xml/vplayoutfilereader.h" #include "puzzleapplication.h" #include "../vlayout/vrawlayout.h" @@ -126,7 +126,7 @@ bool PuzzleMainWindow::SaveFile(const QString &path) QFile file(path); file.open(QIODevice::WriteOnly); - VPuzzleLayoutFileWriter *fileWriter = new VPuzzleLayoutFileWriter(); + VPLayoutFileWriter *fileWriter = new VPLayoutFileWriter(); fileWriter->WriteFile(m_layout, &file); // TODO / FIXME : better return value and error handling diff --git a/src/app/puzzle/xml/vplayoutfilereader.cpp b/src/app/puzzle/xml/vplayoutfilereader.cpp index 046805035..1fac4bb55 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.cpp +++ b/src/app/puzzle/xml/vplayoutfilereader.cpp @@ -28,7 +28,7 @@ #include #include "vplayoutfilereader.h" -#include "vpuzzlelayoutfilewriter.h" +#include "vplayoutfilewriter.h" #include "vplayoutliterals.h" #include "../ifc/exception/vexception.h" #include "../ifc/exception/vexceptionconversionerror.h" diff --git a/src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp b/src/app/puzzle/xml/vplayoutfilewriter.cpp similarity index 89% rename from src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp rename to src/app/puzzle/xml/vplayoutfilewriter.cpp index 88baa5784..92650b61b 100644 --- a/src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp +++ b/src/app/puzzle/xml/vplayoutfilewriter.cpp @@ -26,7 +26,7 @@ ** *************************************************************************/ -#include "vpuzzlelayoutfilewriter.h" +#include "vplayoutfilewriter.h" #include "vpuzzlelayout.h" #include "vpuzzlelayer.h" #include "vpuzzlepiece.h" @@ -34,19 +34,19 @@ #include "../ifc/xml/vlayoutconverter.h" //--------------------------------------------------------------------------------------------------------------------- -VPuzzleLayoutFileWriter::VPuzzleLayoutFileWriter() +VPLayoutFileWriter::VPLayoutFileWriter() { } //--------------------------------------------------------------------------------------------------------------------- -VPuzzleLayoutFileWriter::~VPuzzleLayoutFileWriter() +VPLayoutFileWriter::~VPLayoutFileWriter() { } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayoutFileWriter::WriteFile(VPuzzleLayout *layout, QFile *file) +void VPLayoutFileWriter::WriteFile(VPuzzleLayout *layout, QFile *file) { setDevice(file); setAutoFormatting(true); @@ -59,7 +59,7 @@ void VPuzzleLayoutFileWriter::WriteFile(VPuzzleLayout *layout, QFile *file) } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayoutFileWriter::WriteLayout(VPuzzleLayout *layout) +void VPLayoutFileWriter::WriteLayout(VPuzzleLayout *layout) { writeStartElement(ML::TagLayout); SetAttribute(ML::AttrVersion, VLayoutConverter::LayoutMaxVerStr); @@ -71,7 +71,7 @@ void VPuzzleLayoutFileWriter::WriteLayout(VPuzzleLayout *layout) } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayoutFileWriter::WriteProperties(VPuzzleLayout *layout) +void VPLayoutFileWriter::WriteProperties(VPuzzleLayout *layout) { writeStartElement(ML::TagProperties); @@ -97,7 +97,7 @@ void VPuzzleLayoutFileWriter::WriteProperties(VPuzzleLayout *layout) } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayoutFileWriter::WriteTiles(VPuzzleLayout *layout) +void VPLayoutFileWriter::WriteTiles(VPuzzleLayout *layout) { Q_UNUSED(layout); // to be removed @@ -116,7 +116,7 @@ void VPuzzleLayoutFileWriter::WriteTiles(VPuzzleLayout *layout) //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayoutFileWriter::WriteLayers(VPuzzleLayout *layout) +void VPLayoutFileWriter::WriteLayers(VPuzzleLayout *layout) { writeStartElement(ML::TagLayers); @@ -133,13 +133,13 @@ void VPuzzleLayoutFileWriter::WriteLayers(VPuzzleLayout *layout) //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayoutFileWriter::WriteLayer(VPuzzleLayer *layer) +void VPLayoutFileWriter::WriteLayer(VPuzzleLayer *layer) { WriteLayer(layer, ML::TagLayer); } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayoutFileWriter::WriteLayer(VPuzzleLayer *layer, const QString &tagName) +void VPLayoutFileWriter::WriteLayer(VPuzzleLayer *layer, const QString &tagName) { writeStartElement(tagName); // layer SetAttribute(ML::AttrName, layer->GetName()); @@ -158,7 +158,7 @@ void VPuzzleLayoutFileWriter::WriteLayer(VPuzzleLayer *layer, const QString &tag } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayoutFileWriter::WritePiece(VPuzzlePiece *piece) +void VPLayoutFileWriter::WritePiece(VPuzzlePiece *piece) { Q_UNUSED(piece); @@ -182,7 +182,7 @@ void VPuzzleLayoutFileWriter::WritePiece(VPuzzlePiece *piece) } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayoutFileWriter::WriteMargins(const QMarginsF &margins) +void VPLayoutFileWriter::WriteMargins(const QMarginsF &margins) { writeStartElement(ML::TagMargin); SetAttribute(ML::AttrLeft, margins.left()); @@ -193,7 +193,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 qreal width = size.width(); diff --git a/src/app/puzzle/xml/vpuzzlelayoutfilewriter.h b/src/app/puzzle/xml/vplayoutfilewriter.h similarity index 81% rename from src/app/puzzle/xml/vpuzzlelayoutfilewriter.h rename to src/app/puzzle/xml/vplayoutfilewriter.h index abbc7377f..e3c23373b 100644 --- a/src/app/puzzle/xml/vpuzzlelayoutfilewriter.h +++ b/src/app/puzzle/xml/vplayoutfilewriter.h @@ -26,8 +26,8 @@ ** ** *************************************************************************/ -#ifndef VPUZZLELAYOUTFILEWRITER_H -#define VPUZZLELAYOUTFILEWRITER_H +#ifndef VPLAYOUTFILEWRITER_H +#define VPLAYOUTFILEWRITER_H #include #include @@ -40,11 +40,11 @@ class VPuzzlePiece; class QFile; class QMarginsF; -class VPuzzleLayoutFileWriter : public QXmlStreamWriter +class VPLayoutFileWriter : public QXmlStreamWriter { public: - VPuzzleLayoutFileWriter(); - ~VPuzzleLayoutFileWriter(); + VPLayoutFileWriter(); + ~VPLayoutFileWriter(); void WriteFile(VPuzzleLayout *layout, QFile *file); @@ -71,7 +71,7 @@ private: //--------------------------------------------------------------------------------------------------------------------- template -void VPuzzleLayoutFileWriter::SetAttribute(const QString &name, const T &value) +void VPLayoutFileWriter::SetAttribute(const QString &name, const T &value) { // See specification for xs:decimal const QLocale locale = QLocale::c(); @@ -80,30 +80,30 @@ void VPuzzleLayoutFileWriter::SetAttribute(const QString &name, const T &value) //--------------------------------------------------------------------------------------------------------------------- template <> -inline void VPuzzleLayoutFileWriter::SetAttribute(const QString &name, const QString &value) +inline void VPLayoutFileWriter::SetAttribute(const QString &name, const QString &value) { writeAttribute(name, value); } //--------------------------------------------------------------------------------------------------------------------- template <> -inline void VPuzzleLayoutFileWriter::SetAttribute(const QString &name, const QChar &value) +inline void VPLayoutFileWriter::SetAttribute(const QString &name, const QChar &value) { writeAttribute(name, value); } //--------------------------------------------------------------------------------------------------------------------- template <> -inline void VPuzzleLayoutFileWriter::SetAttribute(const QString &name, const bool &value) +inline void VPLayoutFileWriter::SetAttribute(const QString &name, const bool &value) { writeAttribute(name, value ? trueStr : falseStr); } //--------------------------------------------------------------------------------------------------------------------- template -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)); } -#endif // VPUZZLELAYOUTFILEWRITER_H +#endif // VPLAYOUTFILEWRITER_H From 04e97b6e744f7585a26e9b526b44cb67416f33e5 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 14:04:39 +0200 Subject: [PATCH 06/28] Refactoring class comments --- src/app/puzzle/xml/vplayoutfilereader.cpp | 2 +- src/app/puzzle/xml/vplayoutfilereader.h | 2 +- src/app/puzzle/xml/vplayoutfilewriter.cpp | 2 +- src/app/puzzle/xml/vplayoutfilewriter.h | 2 +- src/app/puzzle/xml/vplayoutliterals.cpp | 2 +- src/app/puzzle/xml/vplayoutliterals.h | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/puzzle/xml/vplayoutfilereader.cpp b/src/app/puzzle/xml/vplayoutfilereader.cpp index 1fac4bb55..155fad029 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.cpp +++ b/src/app/puzzle/xml/vplayoutfilereader.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlelayoutfilereader.cpp + ** @file vplayoutfilereader.cpp ** @author Ronan Le Tiec ** @date 18 4, 2020 ** diff --git a/src/app/puzzle/xml/vplayoutfilereader.h b/src/app/puzzle/xml/vplayoutfilereader.h index 668bbec62..5c8984338 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.h +++ b/src/app/puzzle/xml/vplayoutfilereader.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlelayoutfilereader.h + ** @file vplayoutfilereader.h ** @author Ronan Le Tiec ** @date 18 4, 2020 ** diff --git a/src/app/puzzle/xml/vplayoutfilewriter.cpp b/src/app/puzzle/xml/vplayoutfilewriter.cpp index 92650b61b..33d7b0bdf 100644 --- a/src/app/puzzle/xml/vplayoutfilewriter.cpp +++ b/src/app/puzzle/xml/vplayoutfilewriter.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlelayoutfilewriter.cpp + ** @file vplayoutfilewriter.cpp ** @author Ronan Le Tiec ** @date 18 4, 2020 ** diff --git a/src/app/puzzle/xml/vplayoutfilewriter.h b/src/app/puzzle/xml/vplayoutfilewriter.h index e3c23373b..b41c58aff 100644 --- a/src/app/puzzle/xml/vplayoutfilewriter.h +++ b/src/app/puzzle/xml/vplayoutfilewriter.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlelayoutfilewriter.h + ** @file vplayoutfilewriter.h ** @author Ronan Le Tiec ** @date 18 4, 2020 ** diff --git a/src/app/puzzle/xml/vplayoutliterals.cpp b/src/app/puzzle/xml/vplayoutliterals.cpp index 3d64afd4a..13f0938a1 100644 --- a/src/app/puzzle/xml/vplayoutliterals.cpp +++ b/src/app/puzzle/xml/vplayoutliterals.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file literals.cpp + ** @file vplayoutliterals.cpp ** @author Roman Telezhynskyi ** @date 23 4, 2020 ** diff --git a/src/app/puzzle/xml/vplayoutliterals.h b/src/app/puzzle/xml/vplayoutliterals.h index 294097326..7359e5fef 100644 --- a/src/app/puzzle/xml/vplayoutliterals.h +++ b/src/app/puzzle/xml/vplayoutliterals.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file literals.h + ** @file vplayoutliterals.h ** @author Roman Telezhynskyi ** @date 23 4, 2020 ** From 5bd695b646d9f56b49e26ed0ff2ac6ec0f6b9634 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 14:10:05 +0200 Subject: [PATCH 07/28] Refactoring PuzzleApplication --- src/app/puzzle/main.cpp | 6 +-- src/app/puzzle/puzzle.pri | 4 +- src/app/puzzle/puzzlemainwindow.cpp | 2 +- ...uzzleapplication.cpp => vpapplication.cpp} | 48 +++++++++---------- .../{puzzleapplication.h => vpapplication.h} | 20 ++++---- src/app/puzzle/vpuzzlecommandline.h | 4 +- 6 files changed, 42 insertions(+), 42 deletions(-) rename src/app/puzzle/{puzzleapplication.cpp => vpapplication.cpp} (94%) rename src/app/puzzle/{puzzleapplication.h => vpapplication.h} (85%) diff --git a/src/app/puzzle/main.cpp b/src/app/puzzle/main.cpp index 86d126b18..16fc44d55 100644 --- a/src/app/puzzle/main.cpp +++ b/src/app/puzzle/main.cpp @@ -29,7 +29,7 @@ #include // For QT_REQUIRE_VERSION #include -#include "puzzleapplication.h" +#include "vpapplication.h" #include "../fervor/fvupdater.h" #include "../vmisc/vsysexits.h" #include "../vmisc/def.h" @@ -64,7 +64,7 @@ int main(int argc, char *argv[]) InitHighDpiScaling(argc, argv); #endif //Q_OS_MAC - PuzzleApplication app(argc, argv); + VPApplication app(argc, argv); app.InitOptions(); if (FvUpdater::IsStaledTestBuild()) @@ -78,7 +78,7 @@ int main(int argc, char *argv[]) return V_EX_UNAVAILABLE; } - QTimer::singleShot(0, &app, &PuzzleApplication::ProcessCMD); + QTimer::singleShot(0, &app, &VPApplication::ProcessCMD); #if defined(APPIMAGE) && defined(Q_OS_LINUX) if (exe_dir) diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index 410a04e1b..c3e29b9c4 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -6,7 +6,7 @@ SOURCES += \ $$PWD/main.cpp \ $$PWD/puzzlecommands.cpp \ $$PWD/puzzlemainwindow.cpp \ - $$PWD/puzzleapplication.cpp \ + $$PWD/vpapplication.cpp \ $$PWD/vpiececarrouselpiecepreview.cpp \ $$PWD/vpuzzlecommandline.cpp \ $$PWD/vpiececarrousel.cpp \ @@ -31,7 +31,7 @@ HEADERS += \ $$PWD/puzzlecommands.h \ $$PWD/puzzlemainwindow.h \ $$PWD/stable.h \ - $$PWD/puzzleapplication.h \ + $$PWD/vpapplication.h \ $$PWD/vpiececarrouselpiecepreview.h \ $$PWD/vpuzzlecommandline.h \ $$PWD/vpiececarrousel.h \ diff --git a/src/app/puzzle/puzzlemainwindow.cpp b/src/app/puzzle/puzzlemainwindow.cpp index 78414ef41..3dd805964 100644 --- a/src/app/puzzle/puzzlemainwindow.cpp +++ b/src/app/puzzle/puzzlemainwindow.cpp @@ -34,7 +34,7 @@ #include "dialogs/vpdialogabout.h" #include "xml/vplayoutfilewriter.h" #include "xml/vplayoutfilereader.h" -#include "puzzleapplication.h" +#include "vpapplication.h" #include "../vlayout/vrawlayout.h" #include "../vmisc/vsysexits.h" #include "../vmisc/projectversion.h" diff --git a/src/app/puzzle/puzzleapplication.cpp b/src/app/puzzle/vpapplication.cpp similarity index 94% rename from src/app/puzzle/puzzleapplication.cpp rename to src/app/puzzle/vpapplication.cpp index 32e84e1bd..d4d36602b 100644 --- a/src/app/puzzle/puzzleapplication.cpp +++ b/src/app/puzzle/vpapplication.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file puzzleapplication.cpp + ** @file vpapplication.cpp ** @author Roman Telezhynskyi ** @date 16 2, 2020 ** @@ -26,7 +26,7 @@ ** *************************************************************************/ -#include "puzzleapplication.h" +#include "vpapplication.h" #include "version.h" #include "puzzlemainwindow.h" #include "../ifc/exception/vexceptionobjecterror.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), mainWindows(), localServer(nullptr) @@ -250,7 +250,7 @@ PuzzleApplication::PuzzleApplication(int &argc, char **argv) } //--------------------------------------------------------------------------------------------------------------------- -PuzzleApplication::~PuzzleApplication() +VPApplication::~VPApplication() { qDeleteAll(mainWindows); } @@ -263,7 +263,7 @@ PuzzleApplication::~PuzzleApplication() * @return value that is returned from the receiver's event handler. */ // 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 { @@ -324,13 +324,13 @@ bool PuzzleApplication::notify(QObject *receiver, QEvent *event) /** * @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(); } //--------------------------------------------------------------------------------------------------------------------- -PuzzleMainWindow *PuzzleApplication::MainWindow() +PuzzleMainWindow *VPApplication::MainWindow() { Clean(); if (mainWindows.isEmpty()) @@ -343,7 +343,7 @@ PuzzleMainWindow *PuzzleApplication::MainWindow() } //--------------------------------------------------------------------------------------------------------------------- -QList PuzzleApplication::MainWindows() +QList VPApplication::MainWindows() { Clean(); QList list; @@ -355,7 +355,7 @@ QList PuzzleApplication::MainWindows() } //--------------------------------------------------------------------------------------------------------------------- -PuzzleMainWindow *PuzzleApplication::NewMainWindow(const VPuzzleCommandLinePtr &cmd) +PuzzleMainWindow *VPApplication::NewMainWindow(const VPuzzleCommandLinePtr &cmd) { PuzzleMainWindow *puzzle = new PuzzleMainWindow(cmd); mainWindows.prepend(puzzle); @@ -367,7 +367,7 @@ PuzzleMainWindow *PuzzleApplication::NewMainWindow(const VPuzzleCommandLinePtr & } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleApplication::InitOptions() +void VPApplication::InitOptions() { qInstallMessageHandler(noisyFailureMsgHandler); @@ -397,27 +397,27 @@ void PuzzleApplication::InitOptions() } //--------------------------------------------------------------------------------------------------------------------- -const VTranslateVars *PuzzleApplication::TrVars() +const VTranslateVars *VPApplication::TrVars() { return nullptr; } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleApplication::OpenSettings() +void VPApplication::OpenSettings() { settings = new VPuzzleSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), QCoreApplication::applicationName(), this); } //--------------------------------------------------------------------------------------------------------------------- -VPuzzleSettings *PuzzleApplication::PuzzleSettings() +VPuzzleSettings *VPApplication::PuzzleSettings() { SCASSERT(settings != nullptr) return qobject_cast(settings); } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleApplication::ActivateDarkMode() +void VPApplication::ActivateDarkMode() { VPuzzleSettings *settings = qApp->PuzzleSettings(); if (settings->GetDarkMode()) @@ -437,7 +437,7 @@ void PuzzleApplication::ActivateDarkMode() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleApplication::ParseCommandLine(const SocketConnection &connection, const QStringList &arguments) +void VPApplication::ParseCommandLine(const SocketConnection &connection, const QStringList &arguments) { VPuzzleCommandLinePtr cmd; VPuzzleCommandLine::ProcessInstance(cmd, arguments); @@ -461,7 +461,7 @@ void PuzzleApplication::ParseCommandLine(const SocketConnection &connection, con qCDebug(mApp, "Can't establish connection to the server '%s'", qUtf8Printable(serverName)); localServer = new QLocalServer(this); - connect(localServer, &QLocalServer::newConnection, this, &PuzzleApplication::NewLocalSocketConnection); + connect(localServer, &QLocalServer::newConnection, this, &VPApplication::NewLocalSocketConnection); if (not localServer->listen(serverName)) { 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 VPuzzleCommandLinePtr &cmd) { const QStringList rawLayouts = cmd->OptionRawLayouts(); 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()); } //--------------------------------------------------------------------------------------------------------------------- -bool PuzzleApplication::event(QEvent *e) +bool VPApplication::event(QEvent *e) { switch(e->type()) { @@ -591,13 +591,13 @@ bool PuzzleApplication::event(QEvent *e) } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleApplication::InitTrVars() +void VPApplication::InitTrVars() { // 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 // instance. Solution is to call sync() before quit. @@ -606,7 +606,7 @@ void PuzzleApplication::AboutToQuit() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleApplication::NewLocalSocketConnection() +void VPApplication::NewLocalSocketConnection() { QScopedPointersocket(localServer->nextPendingConnection()); if (socket.isNull()) @@ -625,7 +625,7 @@ void PuzzleApplication::NewLocalSocketConnection() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleApplication::Clean() +void VPApplication::Clean() { // cleanup any deleted main windows first for (int i = mainWindows.count() - 1; i >= 0; --i) @@ -638,7 +638,7 @@ void PuzzleApplication::Clean() } //-------------------------------------------------------------------------------------------- -VPuzzleCommandLinePtr PuzzleApplication::CommandLine() const +VPuzzleCommandLinePtr VPApplication::CommandLine() const { return VPuzzleCommandLine::instance; } diff --git a/src/app/puzzle/puzzleapplication.h b/src/app/puzzle/vpapplication.h similarity index 85% rename from src/app/puzzle/puzzleapplication.h rename to src/app/puzzle/vpapplication.h index 0b7b2ac84..f66385d79 100644 --- a/src/app/puzzle/puzzleapplication.h +++ b/src/app/puzzle/vpapplication.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file puzzleapplication.h + ** @file vpapplication.h ** @author Roman Telezhynskyi ** @date 16 2, 2020 ** @@ -25,8 +25,8 @@ ** along with Valentina. If not, see . ** *************************************************************************/ -#ifndef PUZZLEAPPLICATION_H -#define PUZZLEAPPLICATION_H +#ifndef VPAPPLICATION_H +#define VPAPPLICATION_H #include "../vmisc/def.h" #include "vpuzzlesettings.h" @@ -35,23 +35,23 @@ #include -class PuzzleApplication;// use in define +class VPApplication;// use in define class PuzzleMainWindow; class QLocalServer; #if defined(qApp) #undef qApp #endif -#define qApp (static_cast(VAbstractApplication::instance())) +#define qApp (static_cast(VAbstractApplication::instance())) enum class SocketConnection : bool {Client = false, Server = true}; -class PuzzleApplication : public VAbstractApplication +class VPApplication : public VAbstractApplication { Q_OBJECT public: - PuzzleApplication(int &argc, char **argv); - virtual ~PuzzleApplication() override; + VPApplication(int &argc, char **argv); + virtual ~VPApplication() override; virtual bool notify(QObject * receiver, QEvent * event) override; @@ -85,11 +85,11 @@ private slots: void NewLocalSocketConnection(); private: - Q_DISABLE_COPY(PuzzleApplication) + Q_DISABLE_COPY(VPApplication) QList > mainWindows; QLocalServer *localServer; void Clean(); }; -#endif // PUZZLEAPPLICATION_H +#endif // VPAPPLICATION_H diff --git a/src/app/puzzle/vpuzzlecommandline.h b/src/app/puzzle/vpuzzlecommandline.h index 0bd64c8e2..4440f6c31 100644 --- a/src/app/puzzle/vpuzzlecommandline.h +++ b/src/app/puzzle/vpuzzlecommandline.h @@ -66,7 +66,7 @@ public: protected: VPuzzleCommandLine(); - /** @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 void ProcessInstance(VPuzzleCommandLinePtr &instance, const QStringList &arguments); private: @@ -74,7 +74,7 @@ private: static VPuzzleCommandLinePtr instance; QCommandLineParser parser; bool isGuiEnabled; - friend class PuzzleApplication; + friend class VPApplication; /** @brief add options to the QCommandLineParser that there are in the cmd can be */ void InitCommandLineOptions(); From e816e4d5a1ffd8fd688429d4e95f634498656640 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 14:12:07 +0200 Subject: [PATCH 08/28] Refactoring puzzlecommands --- src/app/puzzle/puzzle.pri | 4 ++-- src/app/puzzle/{puzzlecommands.cpp => vpcommands.cpp} | 4 ++-- src/app/puzzle/{puzzlecommands.h => vpcommands.h} | 8 ++++---- src/app/puzzle/vpuzzlecommandline.cpp | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) rename src/app/puzzle/{puzzlecommands.cpp => vpcommands.cpp} (98%) rename src/app/puzzle/{puzzlecommands.h => vpcommands.h} (95%) diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index c3e29b9c4..03b05a5f8 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -4,9 +4,9 @@ SOURCES += \ $$PWD/dialogs/vpdialogabout.cpp \ $$PWD/main.cpp \ - $$PWD/puzzlecommands.cpp \ $$PWD/puzzlemainwindow.cpp \ $$PWD/vpapplication.cpp \ + $$PWD/vpcommands.cpp \ $$PWD/vpiececarrouselpiecepreview.cpp \ $$PWD/vpuzzlecommandline.cpp \ $$PWD/vpiececarrousel.cpp \ @@ -28,10 +28,10 @@ SOURCES += \ HEADERS += \ $$PWD/dialogs/vpdialogabout.h \ - $$PWD/puzzlecommands.h \ $$PWD/puzzlemainwindow.h \ $$PWD/stable.h \ $$PWD/vpapplication.h \ + $$PWD/vpcommands.h \ $$PWD/vpiececarrouselpiecepreview.h \ $$PWD/vpuzzlecommandline.h \ $$PWD/vpiececarrousel.h \ diff --git a/src/app/puzzle/puzzlecommands.cpp b/src/app/puzzle/vpcommands.cpp similarity index 98% rename from src/app/puzzle/puzzlecommands.cpp rename to src/app/puzzle/vpcommands.cpp index 57134ad2d..b10c0d1d3 100644 --- a/src/app/puzzle/puzzlecommands.cpp +++ b/src/app/puzzle/vpcommands.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file commands.cpp + ** @file vpcommands.cpp ** @author Roman Telezhynskyi ** @date 13 4, 2020 ** @@ -25,7 +25,7 @@ ** along with Valentina. If not, see . ** *************************************************************************/ -#include "puzzlecommands.h" +#include "vpcommands.h" #include diff --git a/src/app/puzzle/puzzlecommands.h b/src/app/puzzle/vpcommands.h similarity index 95% rename from src/app/puzzle/puzzlecommands.h rename to src/app/puzzle/vpcommands.h index ae362b032..4db42b939 100644 --- a/src/app/puzzle/puzzlecommands.h +++ b/src/app/puzzle/vpcommands.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file commands.h + ** @file vpcommands.h ** @author Roman Telezhynskyi ** @date 13 4, 2020 ** @@ -25,8 +25,8 @@ ** along with Valentina. If not, see . ** *************************************************************************/ -#ifndef COMMANDS_H -#define COMMANDS_H +#ifndef VPCOMMANDS_H +#define VPCOMMANDS_H #include @@ -60,4 +60,4 @@ extern const QString LONG_OPTION_TILED_PDF_LANDSCAPE; QStringList AllKeys(); -#endif // COMMANDS_H +#endif // VPCOMMANDS_H diff --git a/src/app/puzzle/vpuzzlecommandline.cpp b/src/app/puzzle/vpuzzlecommandline.cpp index bc08399eb..9eaeadda1 100644 --- a/src/app/puzzle/vpuzzlecommandline.cpp +++ b/src/app/puzzle/vpuzzlecommandline.cpp @@ -26,7 +26,7 @@ ** *************************************************************************/ #include "vpuzzlecommandline.h" -#include "puzzlecommands.h" +#include "vpcommands.h" #include "../vmisc/vsysexits.h" #include "../vmisc/literals.h" #include From 1079ef2addebc0107ac7bf3ecdd924c375e395ac Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 14:17:20 +0200 Subject: [PATCH 09/28] Refactoring PuzzleMainWindow --- src/app/puzzle/puzzle.pri | 8 +- src/app/puzzle/vpapplication.cpp | 16 +- src/app/puzzle/vpapplication.h | 10 +- ...{puzzlemainwindow.cpp => vpmainwindow.cpp} | 164 +++++++++--------- .../{puzzlemainwindow.h => vpmainwindow.h} | 20 +-- .../{puzzlemainwindow.ui => vpmainwindow.ui} | 4 +- 6 files changed, 111 insertions(+), 111 deletions(-) rename src/app/puzzle/{puzzlemainwindow.cpp => vpmainwindow.cpp} (86%) rename src/app/puzzle/{puzzlemainwindow.h => vpmainwindow.h} (96%) rename src/app/puzzle/{puzzlemainwindow.ui => vpmainwindow.ui} (99%) diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index 03b05a5f8..58cf1ea8c 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -4,10 +4,10 @@ SOURCES += \ $$PWD/dialogs/vpdialogabout.cpp \ $$PWD/main.cpp \ - $$PWD/puzzlemainwindow.cpp \ $$PWD/vpapplication.cpp \ $$PWD/vpcommands.cpp \ $$PWD/vpiececarrouselpiecepreview.cpp \ + $$PWD/vpmainwindow.cpp \ $$PWD/vpuzzlecommandline.cpp \ $$PWD/vpiececarrousel.cpp \ $$PWD/vpuzzlegraphicslayout.cpp \ @@ -28,11 +28,11 @@ SOURCES += \ HEADERS += \ $$PWD/dialogs/vpdialogabout.h \ - $$PWD/puzzlemainwindow.h \ $$PWD/stable.h \ $$PWD/vpapplication.h \ $$PWD/vpcommands.h \ $$PWD/vpiececarrouselpiecepreview.h \ + $$PWD/vpmainwindow.h \ $$PWD/vpuzzlecommandline.h \ $$PWD/vpiececarrousel.h \ $$PWD/vpuzzlegraphicslayout.h \ @@ -51,5 +51,5 @@ HEADERS += \ FORMS += \ $$PWD/dialogs/vpdialogabout.ui \ - $$PWD/puzzlemainwindow.ui \ - $$PWD/vpiececarrousel.ui + $$PWD/vpiececarrousel.ui \ + $$PWD/vpmainwindow.ui diff --git a/src/app/puzzle/vpapplication.cpp b/src/app/puzzle/vpapplication.cpp index d4d36602b..848dd0b4c 100644 --- a/src/app/puzzle/vpapplication.cpp +++ b/src/app/puzzle/vpapplication.cpp @@ -28,7 +28,7 @@ #include "vpapplication.h" #include "version.h" -#include "puzzlemainwindow.h" +#include "vpmainwindow.h" #include "../ifc/exception/vexceptionobjecterror.h" #include "../ifc/exception/vexceptionbadid.h" #include "../ifc/exception/vexceptionconversionerror.h" @@ -330,7 +330,7 @@ bool VPApplication::IsAppInGUIMode() const } //--------------------------------------------------------------------------------------------------------------------- -PuzzleMainWindow *VPApplication::MainWindow() +VPMainWindow *VPApplication::MainWindow() { Clean(); if (mainWindows.isEmpty()) @@ -343,10 +343,10 @@ PuzzleMainWindow *VPApplication::MainWindow() } //--------------------------------------------------------------------------------------------------------------------- -QList VPApplication::MainWindows() +QList VPApplication::MainWindows() { Clean(); - QList list; + QList list; for (auto &w : mainWindows) { list.append(w); @@ -355,9 +355,9 @@ QList VPApplication::MainWindows() } //--------------------------------------------------------------------------------------------------------------------- -PuzzleMainWindow *VPApplication::NewMainWindow(const VPuzzleCommandLinePtr &cmd) +VPMainWindow *VPApplication::NewMainWindow(const VPuzzleCommandLinePtr &cmd) { - PuzzleMainWindow *puzzle = new PuzzleMainWindow(cmd); + VPMainWindow *puzzle = new VPMainWindow(cmd); mainWindows.prepend(puzzle); if (cmd->IsGuiEnabled()) { @@ -563,7 +563,7 @@ bool VPApplication::event(QEvent *e) const QString macFileOpen = fileOpenEvent->file(); if(not macFileOpen.isEmpty()) { - PuzzleMainWindow *mw = MainWindow(); + VPMainWindow *mw = MainWindow(); if (mw) { mw->LoadFile(macFileOpen); // open file in existing window @@ -576,7 +576,7 @@ bool VPApplication::event(QEvent *e) case QEvent::ApplicationActivate: { Clean(); - PuzzleMainWindow *mw = MainWindow(); + VPMainWindow *mw = MainWindow(); if (mw && not mw->isMinimized()) { mw->show(); diff --git a/src/app/puzzle/vpapplication.h b/src/app/puzzle/vpapplication.h index f66385d79..9e66620c0 100644 --- a/src/app/puzzle/vpapplication.h +++ b/src/app/puzzle/vpapplication.h @@ -36,7 +36,7 @@ #include class VPApplication;// use in define -class PuzzleMainWindow; +class VPMainWindow; class QLocalServer; #if defined(qApp) @@ -56,9 +56,9 @@ public: virtual bool notify(QObject * receiver, QEvent * event) override; virtual bool IsAppInGUIMode() const override; - PuzzleMainWindow *MainWindow(); - QList MainWindows(); - PuzzleMainWindow *NewMainWindow(const VPuzzleCommandLinePtr &cmd); + VPMainWindow *MainWindow(); + QList MainWindows(); + VPMainWindow *NewMainWindow(const VPuzzleCommandLinePtr &cmd); void InitOptions(); @@ -86,7 +86,7 @@ private slots: private: Q_DISABLE_COPY(VPApplication) - QList > mainWindows; + QList > mainWindows; QLocalServer *localServer; void Clean(); diff --git a/src/app/puzzle/puzzlemainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp similarity index 86% rename from src/app/puzzle/puzzlemainwindow.cpp rename to src/app/puzzle/vpmainwindow.cpp index 3dd805964..728167c8d 100644 --- a/src/app/puzzle/puzzlemainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file puzzlemainwindow.cpp + ** @file vpmainwindow.cpp ** @author Roman Telezhynskyi ** @date 16 2, 2020 ** @@ -25,12 +25,12 @@ ** along with Valentina. If not, see . ** *************************************************************************/ -#include "puzzlemainwindow.h" +#include "vpmainwindow.h" #include #include -#include "ui_puzzlemainwindow.h" +#include "ui_vpmainwindow.h" #include "dialogs/vpdialogabout.h" #include "xml/vplayoutfilewriter.h" #include "xml/vplayoutfilereader.h" @@ -52,9 +52,9 @@ Q_LOGGING_CATEGORY(pWindow, "p.window") QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- -PuzzleMainWindow::PuzzleMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *parent) : +VPMainWindow::VPMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *parent) : QMainWindow(parent), - ui(new Ui::PuzzleMainWindow), + ui(new Ui::VPMainWindow), m_cmd(cmd) { @@ -82,14 +82,14 @@ PuzzleMainWindow::PuzzleMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *pa } //--------------------------------------------------------------------------------------------------------------------- -PuzzleMainWindow::~PuzzleMainWindow() +VPMainWindow::~VPMainWindow() { delete ui; delete m_pieceCarrousel; } //--------------------------------------------------------------------------------------------------------------------- -bool PuzzleMainWindow::LoadFile(QString path) +bool VPMainWindow::LoadFile(QString path) { try { @@ -121,7 +121,7 @@ bool PuzzleMainWindow::LoadFile(QString path) } //--------------------------------------------------------------------------------------------------------------------- -bool PuzzleMainWindow::SaveFile(const QString &path) +bool VPMainWindow::SaveFile(const QString &path) { QFile file(path); file.open(QIODevice::WriteOnly); @@ -135,7 +135,7 @@ bool PuzzleMainWindow::SaveFile(const QString &path) } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::ImportRawLayouts(const QStringList &rawLayouts) +void VPMainWindow::ImportRawLayouts(const QStringList &rawLayouts) { VRawLayout rawLayoutReader; @@ -183,7 +183,7 @@ void PuzzleMainWindow::ImportRawLayouts(const QStringList &rawLayouts) } //--------------------------------------------------------------------------------------------------------------------- -VPuzzlePiece* PuzzleMainWindow::CreatePiece(const VLayoutPiece &rawPiece) +VPuzzlePiece* VPMainWindow::CreatePiece(const VLayoutPiece &rawPiece) { VPuzzlePiece *piece = new VPuzzlePiece(); piece->SetName(rawPiece.GetName()); @@ -202,22 +202,22 @@ VPuzzlePiece* PuzzleMainWindow::CreatePiece(const VLayoutPiece &rawPiece) // TODO : set all the information we need for the piece! // - connect(piece, &VPuzzlePiece::SelectionChanged, this, &PuzzleMainWindow::on_PieceSelectionChanged); - connect(piece, &VPuzzlePiece::PositionChanged, this, &PuzzleMainWindow::on_PiecePositionChanged); - connect(piece, &VPuzzlePiece::RotationChanged, this, &PuzzleMainWindow::on_PieceRotationChanged); + connect(piece, &VPuzzlePiece::SelectionChanged, this, &VPMainWindow::on_PieceSelectionChanged); + connect(piece, &VPuzzlePiece::PositionChanged, this, &VPMainWindow::on_PiecePositionChanged); + connect(piece, &VPuzzlePiece::RotationChanged, this, &VPMainWindow::on_PieceRotationChanged); return piece; } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::InitMenuBar() +void VPMainWindow::InitMenuBar() { // most of the actions are connected through name convention (auto-connection) // -------------------- 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 // TODO : initialise the undo / redo @@ -232,7 +232,7 @@ void PuzzleMainWindow::InitMenuBar() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::InitProperties() +void VPMainWindow::InitProperties() { InitPropertyTabCurrentPiece(); InitPropertyTabLayout(); @@ -241,19 +241,19 @@ void PuzzleMainWindow::InitProperties() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::InitPropertyTabCurrentPiece() +void VPMainWindow::InitPropertyTabCurrentPiece() { // ------------------------------ placement ----------------------------------- connect(ui->doubleSpinBoxCurrentPieceBoxPositionX, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &PuzzleMainWindow::on_CurrentPiecePositionEdited); + &VPMainWindow::on_CurrentPiecePositionEdited); connect(ui->doubleSpinBoxCurrentPieceBoxPositionY, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &PuzzleMainWindow::on_CurrentPiecePositionEdited); + &VPMainWindow::on_CurrentPiecePositionEdited); } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::InitPropertyTabLayout() +void VPMainWindow::InitPropertyTabLayout() { // -------------------- init the unit combobox --------------------- ui->comboBoxLayoutUnit->addItem(tr("Centimeters"), QVariant(UnitsToStr(Unit::Cm))); @@ -272,31 +272,31 @@ void PuzzleMainWindow::InitPropertyTabLayout() // -------------------- layout width, length, orientation ------------------------ connect(ui->doubleSpinBoxLayoutWidth, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &PuzzleMainWindow::on_LayoutSizeChanged); + &VPMainWindow::on_LayoutSizeChanged); connect(ui->doubleSpinBoxLayoutLength, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &PuzzleMainWindow::on_LayoutSizeChanged); + &VPMainWindow::on_LayoutSizeChanged); connect(ui->radioButtonLayoutPortrait, QOverload::of(&QRadioButton::clicked), this, - &PuzzleMainWindow::on_LayoutOrientationChanged); + &VPMainWindow::on_LayoutOrientationChanged); connect(ui->radioButtonLayoutLandscape, QOverload::of(&QRadioButton::clicked), this, - &PuzzleMainWindow::on_LayoutOrientationChanged); + &VPMainWindow::on_LayoutOrientationChanged); // -------------------- margins ------------------------ connect(ui->doubleSpinBoxLayoutMarginTop, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &PuzzleMainWindow::on_LayoutMarginChanged); + &VPMainWindow::on_LayoutMarginChanged); connect(ui->doubleSpinBoxLayoutMarginRight, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &PuzzleMainWindow::on_LayoutMarginChanged); + &VPMainWindow::on_LayoutMarginChanged); connect(ui->doubleSpinBoxLayoutMarginBottom, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &PuzzleMainWindow::on_LayoutMarginChanged); + &VPMainWindow::on_LayoutMarginChanged); connect(ui->doubleSpinBoxLayoutMarginLeft, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &PuzzleMainWindow::on_LayoutMarginChanged); + &VPMainWindow::on_LayoutMarginChanged); // ------------------- follow grainline ----------------------- connect(ui->radioButtonLayoutFollowGrainlineNo, QOverload::of(&QRadioButton::clicked), this, - &PuzzleMainWindow::on_LayoutFollowGrainlineChanged); + &VPMainWindow::on_LayoutFollowGrainlineChanged); connect(ui->radioButtonLayoutFollowGrainlineVertical, QOverload::of(&QRadioButton::clicked), this, - &PuzzleMainWindow::on_LayoutFollowGrainlineChanged); + &VPMainWindow::on_LayoutFollowGrainlineChanged); connect(ui->radioButtonLayoutFollowGrainlineHorizontal, QOverload::of(&QRadioButton::clicked), this, - &PuzzleMainWindow::on_LayoutFollowGrainlineChanged); + &VPMainWindow::on_LayoutFollowGrainlineChanged); // -------------------- export --------------------------- @@ -305,7 +305,7 @@ void PuzzleMainWindow::InitPropertyTabLayout() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::InitPropertyTabTiles() +void VPMainWindow::InitPropertyTabTiles() { // for the MVP we don't want the tiles tab. // we remove it. As soon as we need it, update this code @@ -313,7 +313,7 @@ void PuzzleMainWindow::InitPropertyTabTiles() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::InitPropertyTabLayers() +void VPMainWindow::InitPropertyTabLayers() { // for the MVP we don't want the layers tab. // we remove it. As soon as we need it, update this code @@ -321,18 +321,18 @@ void PuzzleMainWindow::InitPropertyTabLayers() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::InitPieceCarrousel() +void VPMainWindow::InitPieceCarrousel() { m_pieceCarrousel = new VPieceCarrousel(m_layout, ui->dockWidgetPieceCarrousel); ui->dockWidgetPieceCarrousel->setWidget(m_pieceCarrousel); connect(ui->dockWidgetPieceCarrousel, QOverload::of(&QDockWidget::dockLocationChanged), this, - &PuzzleMainWindow::on_PieceCarrouselLocationChanged); + &VPMainWindow::on_PieceCarrouselLocationChanged); } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::SetPropertiesData() +void VPMainWindow::SetPropertiesData() { if(m_layout == nullptr) { @@ -348,7 +348,7 @@ void PuzzleMainWindow::SetPropertiesData() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::SetPropertyTabCurrentPieceData() +void VPMainWindow::SetPropertyTabCurrentPieceData() { if(m_selectedPieces.count() == 0) { @@ -395,7 +395,7 @@ void PuzzleMainWindow::SetPropertyTabCurrentPieceData() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::SetPropertyTabLayoutData() +void VPMainWindow::SetPropertyTabLayoutData() { // set Unit int index = ui->comboBoxLayoutUnit->findData(QVariant(UnitsToStr(m_layout->GetUnit()))); @@ -438,19 +438,19 @@ void PuzzleMainWindow::SetPropertyTabLayoutData() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::SetPropertyTabTilesData() +void VPMainWindow::SetPropertyTabTilesData() { } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::SetPropertyTabLayersData() +void VPMainWindow::SetPropertyTabLayersData() { } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::InitMainGraphics() +void VPMainWindow::InitMainGraphics() { m_graphicsView = new VPuzzleMainGraphicsView(m_layout, this); ui->centralWidget->layout()->addWidget(m_graphicsView); @@ -460,7 +460,7 @@ void PuzzleMainWindow::InitMainGraphics() //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::SetDoubleSpinBoxValue(QDoubleSpinBox *spinBox, qreal value) +void VPMainWindow::SetDoubleSpinBoxValue(QDoubleSpinBox *spinBox, qreal value) { spinBox->blockSignals(true); spinBox->setValue(value); @@ -468,7 +468,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->setChecked(value); @@ -476,7 +476,7 @@ void PuzzleMainWindow::SetCheckBoxValue(QCheckBox *checkbox, bool value) } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::ReadSettings() +void VPMainWindow::ReadSettings() { qCDebug(pWindow, "Reading settings."); const VPuzzleSettings *settings = qApp->PuzzleSettings(); @@ -503,7 +503,7 @@ void PuzzleMainWindow::ReadSettings() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::WriteSettings() +void VPMainWindow::WriteSettings() { VPuzzleSettings *settings = qApp->PuzzleSettings(); settings->SetGeometry(saveGeometry()); @@ -521,7 +521,7 @@ void PuzzleMainWindow::WriteSettings() } //--------------------------------------------------------------------------------------------------------------------- -bool PuzzleMainWindow::MaybeSave() +bool VPMainWindow::MaybeSave() { // TODO: Implement maybe save check // if (this->isWindowModified()) @@ -569,11 +569,11 @@ bool PuzzleMainWindow::MaybeSave() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::on_actionNew_triggered() +void VPMainWindow::on_actionNew_triggered() { // just for test purpuses, to be removed: QMessageBox msgBox; - msgBox.setText("TODO PuzzleMainWindow::New"); + msgBox.setText("TODO VPMainWindow::New"); int ret = msgBox.exec(); Q_UNUSED(ret); @@ -584,7 +584,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) // Workaround for Qt bug https://bugreports.qt.io/browse/QTBUG-43344 @@ -608,7 +608,7 @@ void PuzzleMainWindow::closeEvent(QCloseEvent *event) } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::on_actionOpen_triggered() +void VPMainWindow::on_actionOpen_triggered() { qCDebug(pWindow, "Openning puzzle layout file."); @@ -662,11 +662,11 @@ void PuzzleMainWindow::on_actionOpen_triggered() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::on_actionSave_triggered() +void VPMainWindow::on_actionSave_triggered() { // just for test purpuses, to be removed: QMessageBox msgBox; - msgBox.setText("TODO PuzzleMainWindow::Save"); + msgBox.setText("TODO VPMainWindow::Save"); int ret = msgBox.exec(); Q_UNUSED(ret); @@ -675,7 +675,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. @@ -705,7 +705,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 @@ -734,11 +734,11 @@ void PuzzleMainWindow::on_actionImportRawLayout_triggered() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::on_actionCloseLayout_triggered() +void VPMainWindow::on_actionCloseLayout_triggered() { // just for test purpuses, to be removed: QMessageBox msgBox; - msgBox.setText("TODO PuzzleMainWindow::CloseLayout"); + msgBox.setText("TODO VPMainWindow::CloseLayout"); int ret = msgBox.exec(); Q_UNUSED(ret); @@ -747,13 +747,13 @@ void PuzzleMainWindow::on_actionCloseLayout_triggered() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::on_actionAboutQt_triggered() +void VPMainWindow::on_actionAboutQt_triggered() { QMessageBox::aboutQt(this, tr("About Qt")); } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::on_actionAboutPuzzle_triggered() +void VPMainWindow::on_actionAboutPuzzle_triggered() { auto *aboutDialog = new VPDialogAbout(this); aboutDialog->setAttribute(Qt::WA_DeleteOnClose, true); @@ -761,7 +761,7 @@ void PuzzleMainWindow::on_actionAboutPuzzle_triggered() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::on_comboBoxLayoutUnit_currentIndexChanged(int index) +void VPMainWindow::on_comboBoxLayoutUnit_currentIndexChanged(int index) { Q_UNUSED(index); QVariant comboBoxValue = ui->comboBoxLayoutUnit->currentData(); @@ -784,11 +784,11 @@ void PuzzleMainWindow::on_comboBoxLayoutUnit_currentIndexChanged(int index) } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::on_comboBoxLayoutTemplate_currentIndexChanged(int index) +void VPMainWindow::on_comboBoxLayoutTemplate_currentIndexChanged(int index) { // just for test purpuses, to be removed: QMessageBox msgBox; - msgBox.setText("TODO PuzzleMainWindow::LayoutTemplateChanged"); + msgBox.setText("TODO VPMainWindow::LayoutTemplateChanged"); int ret = msgBox.exec(); Q_UNUSED(index); @@ -799,7 +799,7 @@ void PuzzleMainWindow::on_comboBoxLayoutTemplate_currentIndexChanged(int index) } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::on_LayoutSizeChanged() +void VPMainWindow::on_LayoutSizeChanged() { m_layout->SetLayoutSizeConverted(ui->doubleSpinBoxLayoutWidth->value(), ui->doubleSpinBoxLayoutLength->value()); @@ -821,7 +821,7 @@ void PuzzleMainWindow::on_LayoutSizeChanged() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::on_LayoutOrientationChanged() +void VPMainWindow::on_LayoutOrientationChanged() { // swap the width and length qreal width_before = ui->doubleSpinBoxLayoutWidth->value(); @@ -838,11 +838,11 @@ void PuzzleMainWindow::on_LayoutOrientationChanged() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::on_pushButtonLayoutRemoveUnusedLength_clicked() +void VPMainWindow::on_pushButtonLayoutRemoveUnusedLength_clicked() { // just for test purpuses, to be removed: QMessageBox msgBox; - msgBox.setText("TODO PuzzleMainWindow::LayoutRemoveUnusedLength"); + msgBox.setText("TODO VPMainWindow::LayoutRemoveUnusedLength"); int ret = msgBox.exec(); Q_UNUSED(ret); @@ -852,7 +852,7 @@ void PuzzleMainWindow::on_pushButtonLayoutRemoveUnusedLength_clicked() //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::on_LayoutMarginChanged() +void VPMainWindow::on_LayoutMarginChanged() { m_layout->SetLayoutMarginsConverted( ui->doubleSpinBoxLayoutMarginLeft->value(), @@ -868,11 +868,11 @@ void PuzzleMainWindow::on_LayoutMarginChanged() //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::on_LayoutFollowGrainlineChanged() +void VPMainWindow::on_LayoutFollowGrainlineChanged() { // just for test purpuses, to be removed: QMessageBox msgBox; - msgBox.setText("TODO PuzzleMainWindow::LayoutFollowGrainlineChanged"); + msgBox.setText("TODO VPMainWindow::LayoutFollowGrainlineChanged"); int ret = msgBox.exec(); Q_UNUSED(ret); @@ -882,7 +882,7 @@ void PuzzleMainWindow::on_LayoutFollowGrainlineChanged() //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::on_doubleSpinBoxLayoutPiecesGap_valueChanged(double value) +void VPMainWindow::on_doubleSpinBoxLayoutPiecesGap_valueChanged(double value) { m_layout->SetPiecesGapConverted(value); @@ -891,7 +891,7 @@ void PuzzleMainWindow::on_doubleSpinBoxLayoutPiecesGap_valueChanged(double value } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::on_checkBoxLayoutWarningPiecesSuperposition_toggled(bool checked) +void VPMainWindow::on_checkBoxLayoutWarningPiecesSuperposition_toggled(bool checked) { m_layout->SetWarningSuperpositionOfPieces(checked); @@ -900,7 +900,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); @@ -909,7 +909,7 @@ void PuzzleMainWindow::on_checkBoxLayoutWarningPiecesOutOfBound_toggled(bool che } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::on_checkBoxLayoutStickyEdges_toggled(bool checked) +void VPMainWindow::on_checkBoxLayoutStickyEdges_toggled(bool checked) { m_layout->SetStickyEdges(checked); @@ -918,11 +918,11 @@ void PuzzleMainWindow::on_checkBoxLayoutStickyEdges_toggled(bool checked) } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::on_pushButtonLayoutExport_clicked() +void VPMainWindow::on_pushButtonLayoutExport_clicked() { // just for test purpuses, to be removed: QMessageBox msgBox; - msgBox.setText("TODO PuzzleMainWindow::LayoutExport"); + msgBox.setText("TODO VPMainWindow::LayoutExport"); int ret = msgBox.exec(); Q_UNUSED(ret); @@ -932,7 +932,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) { @@ -941,7 +941,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) { @@ -950,7 +950,7 @@ 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) { @@ -961,7 +961,7 @@ void PuzzleMainWindow::on_doubleSpinBoxCurrentPieceAngle_valueChanged(double val //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::on_CurrentPiecePositionEdited() +void VPMainWindow::on_CurrentPiecePositionEdited() { if(m_selectedPieces.count() == 1) { @@ -973,7 +973,7 @@ void PuzzleMainWindow::on_CurrentPiecePositionEdited() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::on_PieceCarrouselLocationChanged(Qt::DockWidgetArea area) +void VPMainWindow::on_PieceCarrouselLocationChanged(Qt::DockWidgetArea area) { if(area == Qt::BottomDockWidgetArea || area == Qt::TopDockWidgetArea) { @@ -986,7 +986,7 @@ void PuzzleMainWindow::on_PieceCarrouselLocationChanged(Qt::DockWidgetArea area) } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::on_PieceSelectionChanged() +void VPMainWindow::on_PieceSelectionChanged() { m_selectedPieces = m_layout->GetSelectedPieces(); @@ -996,7 +996,7 @@ void PuzzleMainWindow::on_PieceSelectionChanged() //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::on_PiecePositionChanged() +void VPMainWindow::on_PiecePositionChanged() { if(m_selectedPieces.count() == 1) { @@ -1011,7 +1011,7 @@ void PuzzleMainWindow::on_PiecePositionChanged() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::on_PieceRotationChanged() +void VPMainWindow::on_PieceRotationChanged() { if(m_selectedPieces.count() == 1) { diff --git a/src/app/puzzle/puzzlemainwindow.h b/src/app/puzzle/vpmainwindow.h similarity index 96% rename from src/app/puzzle/puzzlemainwindow.h rename to src/app/puzzle/vpmainwindow.h index 00abf3c7f..0cf94046b 100644 --- a/src/app/puzzle/puzzlemainwindow.h +++ b/src/app/puzzle/vpmainwindow.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file puzzlemainwindow.h + ** @file vpmainwindow.h ** @author Roman Telezhynskyi ** @date 16 2, 2020 ** @@ -25,8 +25,8 @@ ** along with Valentina. If not, see . ** *************************************************************************/ -#ifndef PUZZLEMAINWINDOW_H -#define PUZZLEMAINWINDOW_H +#ifndef VPMAINWINDOW_H +#define VPMAINWINDOW_H #include #include @@ -42,16 +42,16 @@ namespace Ui { - class PuzzleMainWindow; + class VPMainWindow; } -class PuzzleMainWindow : public QMainWindow +class VPMainWindow : public QMainWindow { Q_OBJECT public: - explicit PuzzleMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *parent = nullptr); - virtual ~PuzzleMainWindow(); + explicit VPMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *parent = nullptr); + virtual ~VPMainWindow(); /** * @brief LoadFile Loads the layout file of given path in m_layout. @@ -87,8 +87,8 @@ protected: virtual void closeEvent(QCloseEvent *event) override; private: - Q_DISABLE_COPY(PuzzleMainWindow) - Ui::PuzzleMainWindow *ui; + Q_DISABLE_COPY(VPMainWindow) + Ui::VPMainWindow *ui; VPieceCarrousel *m_pieceCarrousel{nullptr}; VPuzzleMainGraphicsView *m_graphicsView{nullptr}; @@ -387,4 +387,4 @@ private slots: }; -#endif // PUZZLEMAINWINDOW_H +#endif // VPMAINWINDOW_H diff --git a/src/app/puzzle/puzzlemainwindow.ui b/src/app/puzzle/vpmainwindow.ui similarity index 99% rename from src/app/puzzle/puzzlemainwindow.ui rename to src/app/puzzle/vpmainwindow.ui index 79ed17157..ccb74e72e 100644 --- a/src/app/puzzle/puzzlemainwindow.ui +++ b/src/app/puzzle/vpmainwindow.ui @@ -1,7 +1,7 @@ - PuzzleMainWindow - + VPMainWindow + 0 From 74112a43ace8f8000d16b96cab129923d38cbb36 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 14:19:12 +0200 Subject: [PATCH 10/28] Refactoring stable --- src/app/puzzle/puzzle.pri | 7 +++++-- src/app/puzzle/{stable.cpp => vpstable.cpp} | 4 ++-- src/app/puzzle/{stable.h => vpstable.h} | 8 ++++---- 3 files changed, 11 insertions(+), 8 deletions(-) rename src/app/puzzle/{stable.cpp => vpstable.cpp} (96%) rename src/app/puzzle/{stable.h => vpstable.h} (96%) diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index 58cf1ea8c..924a5db00 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -24,15 +24,15 @@ SOURCES += \ $$PWD/vpiececarrousellayer.cpp \ $$PWD/vpiececarrouselpiece.cpp -*msvc*:SOURCES += $$PWD/stable.cpp +*msvc*:SOURCES += HEADERS += \ $$PWD/dialogs/vpdialogabout.h \ - $$PWD/stable.h \ $$PWD/vpapplication.h \ $$PWD/vpcommands.h \ $$PWD/vpiececarrouselpiecepreview.h \ $$PWD/vpmainwindow.h \ + $$PWD/vpstable.h \ $$PWD/vpuzzlecommandline.h \ $$PWD/vpiececarrousel.h \ $$PWD/vpuzzlegraphicslayout.h \ @@ -53,3 +53,6 @@ FORMS += \ $$PWD/dialogs/vpdialogabout.ui \ $$PWD/vpiececarrousel.ui \ $$PWD/vpmainwindow.ui + +SOURCES += \ + $$PWD/vpstable.cpp diff --git a/src/app/puzzle/stable.cpp b/src/app/puzzle/vpstable.cpp similarity index 96% rename from src/app/puzzle/stable.cpp rename to src/app/puzzle/vpstable.cpp index 460b5cb9c..3db0e2a5d 100644 --- a/src/app/puzzle/stable.cpp +++ b/src/app/puzzle/vpstable.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file stable.cpp + ** @file vpstable.cpp ** @author Roman Telezhynskyi ** @date November 15, 2013 ** @@ -27,4 +27,4 @@ *************************************************************************/ // Build the precompiled headers. -#include "stable.h" +#include "vpstable.h" diff --git a/src/app/puzzle/stable.h b/src/app/puzzle/vpstable.h similarity index 96% rename from src/app/puzzle/stable.h rename to src/app/puzzle/vpstable.h index 22e9d4702..b986a6f7c 100644 --- a/src/app/puzzle/stable.h +++ b/src/app/puzzle/vpstable.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file stable.h + ** @file vpstable.h ** @author Roman Telezhynskyi ** @date November 15, 2013 ** @@ -26,8 +26,8 @@ ** *************************************************************************/ -#ifndef STABLE_H -#define STABLE_H +#ifndef VPSTABLE_H +#define VPSTABLE_H /* 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") @@ -69,4 +69,4 @@ #endif /*__cplusplus*/ -#endif // STABLE_H +#endif // VPSTABLE_H From 690606b4e597be0716bffb3e550116ce0b79b6a9 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 14:29:18 +0200 Subject: [PATCH 11/28] Refactoring VPieceCarrousel --- src/app/puzzle/puzzle.pri | 6 ++--- .../{vpiececarrousel.cpp => vpcarrousel.cpp} | 24 +++++++++---------- .../{vpiececarrousel.h => vpcarrousel.h} | 20 ++++++++-------- .../{vpiececarrousel.ui => vpcarrousel.ui} | 6 ++--- src/app/puzzle/vpiececarrousellayer.cpp | 6 ++--- src/app/puzzle/vpiececarrousellayer.h | 8 +++---- src/app/puzzle/vpiececarrouselpiece.cpp | 2 +- src/app/puzzle/vpmainwindow.cpp | 22 ++++++++--------- src/app/puzzle/vpmainwindow.h | 12 +++++----- src/app/puzzle/vpmainwindow.ui | 4 ++-- 10 files changed, 55 insertions(+), 55 deletions(-) rename src/app/puzzle/{vpiececarrousel.cpp => vpcarrousel.cpp} (90%) rename src/app/puzzle/{vpiececarrousel.h => vpcarrousel.h} (86%) rename src/app/puzzle/{vpiececarrousel.ui => vpcarrousel.ui} (93%) diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index 924a5db00..cbb2dc364 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -5,11 +5,11 @@ SOURCES += \ $$PWD/dialogs/vpdialogabout.cpp \ $$PWD/main.cpp \ $$PWD/vpapplication.cpp \ + $$PWD/vpcarrousel.cpp \ $$PWD/vpcommands.cpp \ $$PWD/vpiececarrouselpiecepreview.cpp \ $$PWD/vpmainwindow.cpp \ $$PWD/vpuzzlecommandline.cpp \ - $$PWD/vpiececarrousel.cpp \ $$PWD/vpuzzlegraphicslayout.cpp \ $$PWD/vpuzzlegraphicspiece.cpp \ $$PWD/vpuzzlelayout.cpp \ @@ -29,12 +29,12 @@ SOURCES += \ HEADERS += \ $$PWD/dialogs/vpdialogabout.h \ $$PWD/vpapplication.h \ + $$PWD/vpcarrousel.h \ $$PWD/vpcommands.h \ $$PWD/vpiececarrouselpiecepreview.h \ $$PWD/vpmainwindow.h \ $$PWD/vpstable.h \ $$PWD/vpuzzlecommandline.h \ - $$PWD/vpiececarrousel.h \ $$PWD/vpuzzlegraphicslayout.h \ $$PWD/vpuzzlegraphicspiece.h \ $$PWD/vpuzzlelayout.h \ @@ -51,7 +51,7 @@ HEADERS += \ FORMS += \ $$PWD/dialogs/vpdialogabout.ui \ - $$PWD/vpiececarrousel.ui \ + $$PWD/vpcarrousel.ui \ $$PWD/vpmainwindow.ui SOURCES += \ diff --git a/src/app/puzzle/vpiececarrousel.cpp b/src/app/puzzle/vpcarrousel.cpp similarity index 90% rename from src/app/puzzle/vpiececarrousel.cpp rename to src/app/puzzle/vpcarrousel.cpp index 5b0abe3b8..2f2f8d00f 100644 --- a/src/app/puzzle/vpiececarrousel.cpp +++ b/src/app/puzzle/vpcarrousel.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpiececarrousel.cpp + ** @file vpcarrousel.cpp ** @author Ronan Le Tiec ** @date 13 4, 2020 ** @@ -25,8 +25,8 @@ ** along with Valentina. If not, see . ** *************************************************************************/ -#include "vpiececarrousel.h" -#include "ui_vpiececarrousel.h" +#include "vpcarrousel.h" +#include "ui_vpcarrousel.h" #include #include #include @@ -41,16 +41,16 @@ Q_LOGGING_CATEGORY(pCarrousel, "p.carrousel") //--------------------------------------------------------------------------------------------------------------------- -VPieceCarrousel::VPieceCarrousel(VPuzzleLayout *layout, QWidget *parent) : +VPCarrousel::VPCarrousel(VPuzzleLayout *layout, QWidget *parent) : QWidget(parent), - ui(new Ui::VPieceCarrousel), + ui(new Ui::VPCarrousel), m_layout(layout) { ui->setupUi(this); // init the combo box connect(ui->comboBoxLayer, QOverload::of(&QComboBox::currentIndexChanged), this, - &VPieceCarrousel::on_ActiveLayerChanged); + &VPCarrousel::on_ActiveLayerChanged); ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu); @@ -59,7 +59,7 @@ VPieceCarrousel::VPieceCarrousel(VPuzzleLayout *layout, QWidget *parent) : } //--------------------------------------------------------------------------------------------------------------------- -void VPieceCarrousel::Refresh() +void VPCarrousel::Refresh() { // NOTE: alternative to clearing the carrousel and adding things again, we could make comparision @@ -85,7 +85,7 @@ void VPieceCarrousel::Refresh() } //--------------------------------------------------------------------------------------------------------------------- -void VPieceCarrousel::Clear() +void VPCarrousel::Clear() { // remove the combobox entries ui->comboBoxLayer->clear(); @@ -94,7 +94,7 @@ void VPieceCarrousel::Clear() } //--------------------------------------------------------------------------------------------------------------------- -void VPieceCarrousel::on_ActiveLayerChanged(int index) +void VPCarrousel::on_ActiveLayerChanged(int index) { qCDebug(pCarrousel, "index changed %i", index); @@ -117,14 +117,14 @@ void VPieceCarrousel::on_ActiveLayerChanged(int index) } //--------------------------------------------------------------------------------------------------------------------- -void VPieceCarrousel::SetOrientation(Qt::Orientation orientation) +void VPCarrousel::SetOrientation(Qt::Orientation orientation) { m_orientation = orientation; RefreshOrientation(); } //--------------------------------------------------------------------------------------------------------------------- -void VPieceCarrousel::RefreshOrientation() +void VPCarrousel::RefreshOrientation() { // then update the scrollarea min height / width and scrollbar behaviour if(m_orientation == Qt::Horizontal) @@ -150,7 +150,7 @@ void VPieceCarrousel::RefreshOrientation() } //--------------------------------------------------------------------------------------------------------------------- -void VPieceCarrousel::ClearSelection() +void VPCarrousel::ClearSelection() { m_layout->ClearSelection(); } diff --git a/src/app/puzzle/vpiececarrousel.h b/src/app/puzzle/vpcarrousel.h similarity index 86% rename from src/app/puzzle/vpiececarrousel.h rename to src/app/puzzle/vpcarrousel.h index 569ffc3ac..abb2162c4 100644 --- a/src/app/puzzle/vpiececarrousel.h +++ b/src/app/puzzle/vpcarrousel.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpiececarrousel.h + ** @file vpcarrousel.h ** @author Ronan Le Tiec ** @date 13 04, 2020 ** @@ -26,8 +26,8 @@ ** *************************************************************************/ -#ifndef VPIECECARROUSEL_H -#define VPIECECARROUSEL_H +#ifndef VPCARROUSEL_H +#define VPCARROUSEL_H #include #include @@ -37,15 +37,15 @@ namespace Ui { -class VPieceCarrousel; +class VPCarrousel; } -class VPieceCarrousel : public QWidget +class VPCarrousel : public QWidget { Q_OBJECT public: - explicit VPieceCarrousel(VPuzzleLayout *layout, QWidget *parent = nullptr); - virtual ~VPieceCarrousel() = default; + explicit VPCarrousel(VPuzzleLayout *layout, QWidget *parent = nullptr); + virtual ~VPCarrousel() = default; /** * @brief SetOrientation Sets the orientation to the given value and refreshes @@ -76,8 +76,8 @@ public: void ClearSelection(); private: - Q_DISABLE_COPY(VPieceCarrousel) - Ui::VPieceCarrousel *ui; + Q_DISABLE_COPY(VPCarrousel) + Ui::VPCarrousel *ui; VPuzzleLayout *m_layout; QList m_layers{}; @@ -94,4 +94,4 @@ private slots: void on_ActiveLayerChanged(int index); }; -#endif // VPIECECARROUSEL_H +#endif // VPCARROUSEL_H diff --git a/src/app/puzzle/vpiececarrousel.ui b/src/app/puzzle/vpcarrousel.ui similarity index 93% rename from src/app/puzzle/vpiececarrousel.ui rename to src/app/puzzle/vpcarrousel.ui index 511853607..57bc16afc 100644 --- a/src/app/puzzle/vpiececarrousel.ui +++ b/src/app/puzzle/vpcarrousel.ui @@ -1,7 +1,7 @@ - VPieceCarrousel - + VPCarrousel + 0 @@ -42,7 +42,7 @@ Qt::ScrollBarAlwaysOn - QAbstractItemView::DragOnly + QAbstractItemView::NoDragDrop diff --git a/src/app/puzzle/vpiececarrousellayer.cpp b/src/app/puzzle/vpiececarrousellayer.cpp index b784a6c52..d7b432bb0 100644 --- a/src/app/puzzle/vpiececarrousellayer.cpp +++ b/src/app/puzzle/vpiececarrousellayer.cpp @@ -27,7 +27,7 @@ *************************************************************************/ #include "vpiececarrousellayer.h" -#include "vpiececarrousel.h" +#include "vpcarrousel.h" #include "../vmisc/backport/qoverload.h" #include @@ -37,7 +37,7 @@ Q_LOGGING_CATEGORY(pCarrouselLayer, "p.carrouselLayer") //--------------------------------------------------------------------------------------------------------------------- -VPieceCarrouselLayer::VPieceCarrouselLayer(VPuzzleLayer *layer, VPieceCarrousel *carrousel) : +VPieceCarrouselLayer::VPieceCarrouselLayer(VPuzzleLayer *layer, VPCarrousel *carrousel) : m_layer(layer), m_carrousel(carrousel), m_carrouselPieces(QList()) @@ -117,7 +117,7 @@ QList VPieceCarrouselLayer::GetCarrouselPieces() } //--------------------------------------------------------------------------------------------------------------------- -VPieceCarrousel* VPieceCarrouselLayer::GetCarrousel() +VPCarrousel* VPieceCarrouselLayer::GetCarrousel() { return m_carrousel; } diff --git a/src/app/puzzle/vpiececarrousellayer.h b/src/app/puzzle/vpiececarrousellayer.h index 4c65455ae..b2122d0d4 100644 --- a/src/app/puzzle/vpiececarrousellayer.h +++ b/src/app/puzzle/vpiececarrousellayer.h @@ -33,13 +33,13 @@ #include "vpuzzlelayer.h" #include "vpiececarrouselpiece.h" -class VPieceCarrousel; +class VPCarrousel; class VPieceCarrouselLayer : public QWidget { Q_OBJECT public: - VPieceCarrouselLayer(VPuzzleLayer *layer, VPieceCarrousel *carrousel); + VPieceCarrouselLayer(VPuzzleLayer *layer, VPCarrousel *carrousel); ~VPieceCarrouselLayer(); void Init(); @@ -52,7 +52,7 @@ public: QList GetCarrouselPieces(); - VPieceCarrousel* GetCarrousel(); + VPCarrousel* GetCarrousel(); /** * @brief GetPuzzleLayer Returns the corresponding VPuzzleLayer @@ -64,7 +64,7 @@ private: Q_DISABLE_COPY(VPieceCarrouselLayer) VPuzzleLayer *m_layer; - VPieceCarrousel *m_carrousel; + VPCarrousel *m_carrousel; QList m_carrouselPieces; private slots: diff --git a/src/app/puzzle/vpiececarrouselpiece.cpp b/src/app/puzzle/vpiececarrouselpiece.cpp index 85958ab63..8f4e76e96 100644 --- a/src/app/puzzle/vpiececarrouselpiece.cpp +++ b/src/app/puzzle/vpiececarrouselpiece.cpp @@ -39,7 +39,7 @@ #include "vpuzzlemimedatapiece.h" #include "vpiececarrousellayer.h" -#include "vpiececarrousel.h" +#include "vpcarrousel.h" #include diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index 728167c8d..59ba207ab 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -72,7 +72,7 @@ VPMainWindow::VPMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *parent) : InitMenuBar(); InitProperties(); - InitPieceCarrousel(); + InitCarrousel(); InitMainGraphics(); @@ -85,7 +85,7 @@ VPMainWindow::VPMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *parent) : VPMainWindow::~VPMainWindow() { delete ui; - delete m_pieceCarrousel; + delete m_carrousel; } //--------------------------------------------------------------------------------------------------------------------- @@ -168,7 +168,7 @@ void VPMainWindow::ImportRawLayouts(const QStringList &rawLayouts) m_layout->GetUnplacedPiecesLayer()->AddPiece(piece); } - m_pieceCarrousel->Refresh(); + m_carrousel->Refresh(); } else { @@ -321,13 +321,13 @@ void VPMainWindow::InitPropertyTabLayers() } //--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::InitPieceCarrousel() +void VPMainWindow::InitCarrousel() { - m_pieceCarrousel = new VPieceCarrousel(m_layout, ui->dockWidgetPieceCarrousel); - ui->dockWidgetPieceCarrousel->setWidget(m_pieceCarrousel); + m_carrousel = new VPCarrousel(m_layout, ui->dockWidgetCarrousel); + ui->dockWidgetCarrousel->setWidget(m_carrousel); - connect(ui->dockWidgetPieceCarrousel, QOverload::of(&QDockWidget::dockLocationChanged), this, - &VPMainWindow::on_PieceCarrouselLocationChanged); + connect(ui->dockWidgetCarrousel, QOverload::of(&QDockWidget::dockLocationChanged), this, + &VPMainWindow::on_CarrouselLocationChanged); } @@ -973,15 +973,15 @@ void VPMainWindow::on_CurrentPiecePositionEdited() } //--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_PieceCarrouselLocationChanged(Qt::DockWidgetArea area) +void VPMainWindow::on_CarrouselLocationChanged(Qt::DockWidgetArea area) { 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) { - m_pieceCarrousel->SetOrientation(Qt::Vertical); + m_carrousel->SetOrientation(Qt::Vertical); } } diff --git a/src/app/puzzle/vpmainwindow.h b/src/app/puzzle/vpmainwindow.h index 0cf94046b..463ae5fe3 100644 --- a/src/app/puzzle/vpmainwindow.h +++ b/src/app/puzzle/vpmainwindow.h @@ -33,7 +33,7 @@ #include #include "../vmisc/def.h" -#include "vpiececarrousel.h" +#include "vpcarrousel.h" #include "vpuzzlemaingraphicsview.h" #include "vpuzzlelayout.h" #include "vpuzzlepiece.h" @@ -90,7 +90,7 @@ private: Q_DISABLE_COPY(VPMainWindow) Ui::VPMainWindow *ui; - VPieceCarrousel *m_pieceCarrousel{nullptr}; + VPCarrousel *m_carrousel{nullptr}; VPuzzleMainGraphicsView *m_graphicsView{nullptr}; VPuzzleCommandLinePtr m_cmd; @@ -135,9 +135,9 @@ private: void InitPropertyTabLayers(); /** - * @brief InitPieceCarrousel Inits the piece carrousel + * @brief InitCarrousel Inits the carrousel */ - void InitPieceCarrousel(); + void InitCarrousel(); /** * @brief InitMainGraphics Initialises the puzzle main graphics @@ -364,11 +364,11 @@ private slots: void on_CurrentPiecePositionEdited(); /** - * @brief PieceCarrouselLocationChanged When the piece carrousel's location + * @brief CarrouselLocationChanged When the piece carrousel's location * has been changed * @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 diff --git a/src/app/puzzle/vpmainwindow.ui b/src/app/puzzle/vpmainwindow.ui index ccb74e72e..ccefd273b 100644 --- a/src/app/puzzle/vpmainwindow.ui +++ b/src/app/puzzle/vpmainwindow.ui @@ -82,7 +82,7 @@ - + 0 @@ -110,7 +110,7 @@ 1 - + 0 From 8ca77baef07557350c3a211dea76c8e915c3433d Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 14:33:02 +0200 Subject: [PATCH 12/28] Refactoring VPieceCarrouselLayer --- src/app/puzzle/puzzle.pri | 4 +-- ...usellayer.cpp => vpcarrouselpiecelist.cpp} | 28 +++++++++---------- ...arrousellayer.h => vpcarrouselpiecelist.h} | 16 +++++------ src/app/puzzle/vpiececarrouselpiece.cpp | 4 +-- src/app/puzzle/vpiececarrouselpiece.h | 6 ++-- 5 files changed, 29 insertions(+), 29 deletions(-) rename src/app/puzzle/{vpiececarrousellayer.cpp => vpcarrouselpiecelist.cpp} (85%) rename src/app/puzzle/{vpiececarrousellayer.h => vpcarrouselpiecelist.h} (87%) diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index cbb2dc364..222583850 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -6,6 +6,7 @@ SOURCES += \ $$PWD/main.cpp \ $$PWD/vpapplication.cpp \ $$PWD/vpcarrousel.cpp \ + $$PWD/vpcarrouselpiecelist.cpp \ $$PWD/vpcommands.cpp \ $$PWD/vpiececarrouselpiecepreview.cpp \ $$PWD/vpmainwindow.cpp \ @@ -21,7 +22,6 @@ SOURCES += \ $$PWD/xml/vplayoutfilereader.cpp \ $$PWD/xml/vplayoutfilewriter.cpp \ $$PWD/xml/vplayoutliterals.cpp \ - $$PWD/vpiececarrousellayer.cpp \ $$PWD/vpiececarrouselpiece.cpp *msvc*:SOURCES += @@ -30,6 +30,7 @@ HEADERS += \ $$PWD/dialogs/vpdialogabout.h \ $$PWD/vpapplication.h \ $$PWD/vpcarrousel.h \ + $$PWD/vpcarrouselpiecelist.h \ $$PWD/vpcommands.h \ $$PWD/vpiececarrouselpiecepreview.h \ $$PWD/vpmainwindow.h \ @@ -46,7 +47,6 @@ HEADERS += \ $$PWD/xml/vplayoutfilereader.h \ $$PWD/xml/vplayoutfilewriter.h \ $$PWD/xml/vplayoutliterals.h \ - $$PWD/vpiececarrousellayer.h \ $$PWD/vpiececarrouselpiece.h FORMS += \ diff --git a/src/app/puzzle/vpiececarrousellayer.cpp b/src/app/puzzle/vpcarrouselpiecelist.cpp similarity index 85% rename from src/app/puzzle/vpiececarrousellayer.cpp rename to src/app/puzzle/vpcarrouselpiecelist.cpp index d7b432bb0..d461dd648 100644 --- a/src/app/puzzle/vpiececarrousellayer.cpp +++ b/src/app/puzzle/vpcarrouselpiecelist.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpiececarrousellayer.cpp + ** @file vpcarrouselpiecelist.cpp ** @author Ronan Le Tiec ** @date 25 4, 2020 ** @@ -26,7 +26,7 @@ ** *************************************************************************/ -#include "vpiececarrousellayer.h" +#include "vpcarrouselpiecelist.h" #include "vpcarrousel.h" #include "../vmisc/backport/qoverload.h" @@ -37,7 +37,7 @@ Q_LOGGING_CATEGORY(pCarrouselLayer, "p.carrouselLayer") //--------------------------------------------------------------------------------------------------------------------- -VPieceCarrouselLayer::VPieceCarrouselLayer(VPuzzleLayer *layer, VPCarrousel *carrousel) : +VPCarrouselPieceList::VPCarrouselPieceList(VPuzzleLayer *layer, VPCarrousel *carrousel) : m_layer(layer), m_carrousel(carrousel), m_carrouselPieces(QList()) @@ -46,13 +46,13 @@ VPieceCarrouselLayer::VPieceCarrouselLayer(VPuzzleLayer *layer, VPCarrousel *car } //--------------------------------------------------------------------------------------------------------------------- -VPieceCarrouselLayer::~VPieceCarrouselLayer() +VPCarrouselPieceList::~VPCarrouselPieceList() { Clear(); } //--------------------------------------------------------------------------------------------------------------------- -void VPieceCarrouselLayer::Init() +void VPCarrouselPieceList::Init() { // initiales the structure QVBoxLayout *layoutPiecesLayout = new QVBoxLayout(); @@ -63,12 +63,12 @@ void VPieceCarrouselLayer::Init() Refresh(); // add the connections - connect(m_layer, &VPuzzleLayer::PieceAdded, this, &VPieceCarrouselLayer::on_PieceAdded); - connect(m_layer, &VPuzzleLayer::PieceRemoved, this, &VPieceCarrouselLayer::on_PieceRemoved); + connect(m_layer, &VPuzzleLayer::PieceAdded, this, &VPCarrouselPieceList::on_PieceAdded); + connect(m_layer, &VPuzzleLayer::PieceRemoved, this, &VPCarrouselPieceList::on_PieceRemoved); } //--------------------------------------------------------------------------------------------------------------------- -void VPieceCarrouselLayer::Refresh() +void VPCarrouselPieceList::Refresh() { Clear(); @@ -94,7 +94,7 @@ void VPieceCarrouselLayer::Refresh() } //--------------------------------------------------------------------------------------------------------------------- -void VPieceCarrouselLayer::Clear() +void VPCarrouselPieceList::Clear() { // Removes and deletes the carrousel pieces from the layer while (!m_carrouselPieces.isEmpty()) @@ -111,25 +111,25 @@ void VPieceCarrouselLayer::Clear() } //--------------------------------------------------------------------------------------------------------------------- -QList VPieceCarrouselLayer::GetCarrouselPieces() +QList VPCarrouselPieceList::GetCarrouselPieces() { return m_carrouselPieces; } //--------------------------------------------------------------------------------------------------------------------- -VPCarrousel* VPieceCarrouselLayer::GetCarrousel() +VPCarrousel* VPCarrouselPieceList::GetCarrousel() { return m_carrousel; } //--------------------------------------------------------------------------------------------------------------------- -VPuzzleLayer* VPieceCarrouselLayer::GetLayer() +VPuzzleLayer* VPCarrouselPieceList::GetLayer() { return m_layer; } //--------------------------------------------------------------------------------------------------------------------- -void VPieceCarrouselLayer::on_PieceAdded(VPuzzlePiece* piece) +void VPCarrouselPieceList::on_PieceAdded(VPuzzlePiece* piece) { Q_UNUSED(piece) @@ -139,7 +139,7 @@ void VPieceCarrouselLayer::on_PieceAdded(VPuzzlePiece* piece) } //--------------------------------------------------------------------------------------------------------------------- -void VPieceCarrouselLayer::on_PieceRemoved(VPuzzlePiece* piece) +void VPCarrouselPieceList::on_PieceRemoved(VPuzzlePiece* piece) { for (auto carrouselPiece : m_carrouselPieces) { diff --git a/src/app/puzzle/vpiececarrousellayer.h b/src/app/puzzle/vpcarrouselpiecelist.h similarity index 87% rename from src/app/puzzle/vpiececarrousellayer.h rename to src/app/puzzle/vpcarrouselpiecelist.h index b2122d0d4..0e51aa756 100644 --- a/src/app/puzzle/vpiececarrousellayer.h +++ b/src/app/puzzle/vpcarrouselpiecelist.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpiececarrousellayer.h + ** @file vpcarrouselpiecelist.h ** @author Ronan Le Tiec ** @date 25 4, 2020 ** @@ -26,8 +26,8 @@ ** *************************************************************************/ -#ifndef VPIECECARROUSELLAYER_H -#define VPIECECARROUSELLAYER_H +#ifndef VPCARROUSELPIECELIST_H +#define VPCARROUSELPIECELIST_H #include #include "vpuzzlelayer.h" @@ -35,12 +35,12 @@ class VPCarrousel; -class VPieceCarrouselLayer : public QWidget +class VPCarrouselPieceList : public QWidget { Q_OBJECT public: - VPieceCarrouselLayer(VPuzzleLayer *layer, VPCarrousel *carrousel); - ~VPieceCarrouselLayer(); + VPCarrouselPieceList(VPuzzleLayer *layer, VPCarrousel *carrousel); + ~VPCarrouselPieceList(); void Init(); void Refresh(); @@ -61,7 +61,7 @@ public: VPuzzleLayer* GetLayer(); private: - Q_DISABLE_COPY(VPieceCarrouselLayer) + Q_DISABLE_COPY(VPCarrouselPieceList) VPuzzleLayer *m_layer; VPCarrousel *m_carrousel; @@ -81,4 +81,4 @@ private slots: }; -#endif // VPIECECARROUSELLAYER_H +#endif // VPCARROUSELPIECELIST_H diff --git a/src/app/puzzle/vpiececarrouselpiece.cpp b/src/app/puzzle/vpiececarrouselpiece.cpp index 8f4e76e96..78a8b1999 100644 --- a/src/app/puzzle/vpiececarrouselpiece.cpp +++ b/src/app/puzzle/vpiececarrouselpiece.cpp @@ -38,7 +38,7 @@ #include #include "vpuzzlemimedatapiece.h" -#include "vpiececarrousellayer.h" +#include "vpcarrouselpiecelist.h" #include "vpcarrousel.h" #include @@ -47,7 +47,7 @@ Q_LOGGING_CATEGORY(pCarrouselPiece, "p.carrouselPiece") //--------------------------------------------------------------------------------------------------------------------- -VPieceCarrouselPiece::VPieceCarrouselPiece(VPuzzlePiece *piece, VPieceCarrouselLayer *carrouselLayer) : +VPieceCarrouselPiece::VPieceCarrouselPiece(VPuzzlePiece *piece, VPCarrouselPieceList *carrouselLayer) : m_piece(piece), m_carrouselLayer(carrouselLayer), m_dragStart(QPoint()) diff --git a/src/app/puzzle/vpiececarrouselpiece.h b/src/app/puzzle/vpiececarrouselpiece.h index 96264e0d0..4f2ad2a8b 100644 --- a/src/app/puzzle/vpiececarrouselpiece.h +++ b/src/app/puzzle/vpiececarrouselpiece.h @@ -37,13 +37,13 @@ #include "vpiececarrouselpiecepreview.h" -class VPieceCarrouselLayer; +class VPCarrouselPieceList; class VPieceCarrouselPiece : public QFrame { Q_OBJECT public: - explicit VPieceCarrouselPiece(VPuzzlePiece *piece, VPieceCarrouselLayer *carrouselLayer); + explicit VPieceCarrouselPiece(VPuzzlePiece *piece, VPCarrouselPieceList *carrouselLayer); ~VPieceCarrouselPiece(); void Init(); @@ -82,7 +82,7 @@ private: VPuzzlePiece *m_piece; - VPieceCarrouselLayer *m_carrouselLayer; + VPCarrouselPieceList *m_carrouselLayer; QLabel *m_label{nullptr}; VPieceCarrouselPiecePreview *m_piecePreview{nullptr}; From 510d1bd9318cef0b4560e97f1f0ceed420270a4f Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 14:36:35 +0200 Subject: [PATCH 13/28] Refactoring VPieceCarrouselPiece --- src/app/puzzle/puzzle.pri | 8 ++--- ...arrouselpiece.cpp => vpcarrouselpiece.cpp} | 32 +++++++++---------- ...ececarrouselpiece.h => vpcarrouselpiece.h} | 18 +++++------ src/app/puzzle/vpcarrouselpiecelist.cpp | 8 ++--- src/app/puzzle/vpcarrouselpiecelist.h | 8 ++--- 5 files changed, 37 insertions(+), 37 deletions(-) rename src/app/puzzle/{vpiececarrouselpiece.cpp => vpcarrouselpiece.cpp} (89%) rename src/app/puzzle/{vpiececarrouselpiece.h => vpcarrouselpiece.h} (85%) diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index 222583850..e110dcc4c 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -6,6 +6,7 @@ SOURCES += \ $$PWD/main.cpp \ $$PWD/vpapplication.cpp \ $$PWD/vpcarrousel.cpp \ + $$PWD/vpcarrouselpiece.cpp \ $$PWD/vpcarrouselpiecelist.cpp \ $$PWD/vpcommands.cpp \ $$PWD/vpiececarrouselpiecepreview.cpp \ @@ -21,8 +22,7 @@ SOURCES += \ $$PWD/vpuzzlesettings.cpp \ $$PWD/xml/vplayoutfilereader.cpp \ $$PWD/xml/vplayoutfilewriter.cpp \ - $$PWD/xml/vplayoutliterals.cpp \ - $$PWD/vpiececarrouselpiece.cpp + $$PWD/xml/vplayoutliterals.cpp *msvc*:SOURCES += @@ -30,6 +30,7 @@ HEADERS += \ $$PWD/dialogs/vpdialogabout.h \ $$PWD/vpapplication.h \ $$PWD/vpcarrousel.h \ + $$PWD/vpcarrouselpiece.h \ $$PWD/vpcarrouselpiecelist.h \ $$PWD/vpcommands.h \ $$PWD/vpiececarrouselpiecepreview.h \ @@ -46,8 +47,7 @@ HEADERS += \ $$PWD/vpuzzlesettings.h \ $$PWD/xml/vplayoutfilereader.h \ $$PWD/xml/vplayoutfilewriter.h \ - $$PWD/xml/vplayoutliterals.h \ - $$PWD/vpiececarrouselpiece.h + $$PWD/xml/vplayoutliterals.h FORMS += \ $$PWD/dialogs/vpdialogabout.ui \ diff --git a/src/app/puzzle/vpiececarrouselpiece.cpp b/src/app/puzzle/vpcarrouselpiece.cpp similarity index 89% rename from src/app/puzzle/vpiececarrouselpiece.cpp rename to src/app/puzzle/vpcarrouselpiece.cpp index 78a8b1999..8d4754c07 100644 --- a/src/app/puzzle/vpiececarrouselpiece.cpp +++ b/src/app/puzzle/vpcarrouselpiece.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpiececarrouselpiece.cpp + ** @file vpcarrouselpiece.cpp ** @author Ronan Le Tiec ** @date 25 4, 2020 ** @@ -26,7 +26,7 @@ ** *************************************************************************/ -#include "vpiececarrouselpiece.h" +#include "vpcarrouselpiece.h" #include #include @@ -47,7 +47,7 @@ Q_LOGGING_CATEGORY(pCarrouselPiece, "p.carrouselPiece") //--------------------------------------------------------------------------------------------------------------------- -VPieceCarrouselPiece::VPieceCarrouselPiece(VPuzzlePiece *piece, VPCarrouselPieceList *carrouselLayer) : +VPCarrouselPiece::VPCarrouselPiece(VPuzzlePiece *piece, VPCarrouselPieceList *carrouselLayer) : m_piece(piece), m_carrouselLayer(carrouselLayer), m_dragStart(QPoint()) @@ -57,13 +57,13 @@ VPieceCarrouselPiece::VPieceCarrouselPiece(VPuzzlePiece *piece, VPCarrouselPiece //--------------------------------------------------------------------------------------------------------------------- -VPieceCarrouselPiece::~VPieceCarrouselPiece() +VPCarrouselPiece::~VPCarrouselPiece() { delete m_piecePreview; } //--------------------------------------------------------------------------------------------------------------------- -void VPieceCarrouselPiece::Init() +void VPCarrouselPiece::Init() { // Define the structure setFixedSize(124,128); @@ -98,20 +98,20 @@ void VPieceCarrouselPiece::Init() // connect the signals - connect(m_piece, &VPuzzlePiece::SelectionChanged, this, &VPieceCarrouselPiece::on_PieceSelectionChanged); + connect(m_piece, &VPuzzlePiece::SelectionChanged, this, &VPCarrouselPiece::on_PieceSelectionChanged); // then refresh the data Refresh(); } //--------------------------------------------------------------------------------------------------------------------- -void VPieceCarrouselPiece::CleanPreview() +void VPCarrouselPiece::CleanPreview() { m_piecePreview->fitInView(m_piecePreview->scene()->sceneRect(), Qt::KeepAspectRatio); } //--------------------------------------------------------------------------------------------------------------------- -void VPieceCarrouselPiece::Refresh() +void VPCarrouselPiece::Refresh() { // update the graphic view / the scene @@ -147,13 +147,13 @@ void VPieceCarrouselPiece::Refresh() } //--------------------------------------------------------------------------------------------------------------------- -VPuzzlePiece * VPieceCarrouselPiece::GetPiece() +VPuzzlePiece * VPCarrouselPiece::GetPiece() { return m_piece; } //--------------------------------------------------------------------------------------------------------------------- -void VPieceCarrouselPiece::on_PieceSelectionChanged() +void VPCarrouselPiece::on_PieceSelectionChanged() { if(m_piece->GetIsSelected()) { @@ -166,7 +166,7 @@ void VPieceCarrouselPiece::on_PieceSelectionChanged() } //--------------------------------------------------------------------------------------------------------------------- -void VPieceCarrouselPiece::mousePressEvent(QMouseEvent *event) +void VPCarrouselPiece::mousePressEvent(QMouseEvent *event) { qCDebug(pCarrouselPiece, "mouse pressed"); @@ -189,7 +189,7 @@ void VPieceCarrouselPiece::mousePressEvent(QMouseEvent *event) //--------------------------------------------------------------------------------------------------------------------- -void VPieceCarrouselPiece::mouseMoveEvent(QMouseEvent *event) +void VPCarrouselPiece::mouseMoveEvent(QMouseEvent *event) { if (!(event->buttons() & Qt::LeftButton)) { @@ -235,7 +235,7 @@ void VPieceCarrouselPiece::mouseMoveEvent(QMouseEvent *event) //--------------------------------------------------------------------------------------------------------------------- -void VPieceCarrouselPiece::contextMenuEvent(QContextMenuEvent *event) +void VPCarrouselPiece::contextMenuEvent(QContextMenuEvent *event) { QMenu contextMenu; @@ -256,7 +256,7 @@ void VPieceCarrouselPiece::contextMenuEvent(QContextMenuEvent *event) QVariant data = QVariant::fromValue(layer); moveToLayer->setData(data); - connect(moveToLayer, &QAction::triggered, this, &VPieceCarrouselPiece::on_ActionPieceMovedToLayer); + connect(moveToLayer, &QAction::triggered, this, &VPCarrouselPiece::on_ActionPieceMovedToLayer); } } @@ -266,14 +266,14 @@ void VPieceCarrouselPiece::contextMenuEvent(QContextMenuEvent *event) 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); + connect(removeAction, &QAction::triggered, this, &VPCarrouselPiece::on_ActionPieceMovedToLayer); } contextMenu.exec(event->globalPos()); } //--------------------------------------------------------------------------------------------------------------------- -void VPieceCarrouselPiece::on_ActionPieceMovedToLayer() +void VPCarrouselPiece::on_ActionPieceMovedToLayer() { QAction *act = qobject_cast(sender()); QVariant v = act->data(); diff --git a/src/app/puzzle/vpiececarrouselpiece.h b/src/app/puzzle/vpcarrouselpiece.h similarity index 85% rename from src/app/puzzle/vpiececarrouselpiece.h rename to src/app/puzzle/vpcarrouselpiece.h index 4f2ad2a8b..452a25774 100644 --- a/src/app/puzzle/vpiececarrouselpiece.h +++ b/src/app/puzzle/vpcarrouselpiece.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpiececarrouselpiece.h + ** @file vpcarrouselpiece.h ** @author Ronan Le Tiec ** @date 25 4, 2020 ** @@ -25,8 +25,8 @@ ** along with Valentina. If not, see . ** *************************************************************************/ -#ifndef VPIECECARROUSELPIECE_H -#define VPIECECARROUSELPIECE_H +#ifndef VPCARROUSELPIECE_H +#define VPCARROUSELPIECE_H #include #include @@ -39,12 +39,12 @@ class VPCarrouselPieceList; -class VPieceCarrouselPiece : public QFrame +class VPCarrouselPiece : public QFrame { Q_OBJECT public: - explicit VPieceCarrouselPiece(VPuzzlePiece *piece, VPCarrouselPieceList *carrouselLayer); - ~VPieceCarrouselPiece(); + explicit VPCarrouselPiece(VPuzzlePiece *piece, VPCarrouselPieceList *carrouselLayer); + ~VPCarrouselPiece(); void Init(); void Refresh(); @@ -55,7 +55,7 @@ public: void CleanPreview(); /** - * @brief GetLayoutPiece Returns the corresponding layout piece + * @brief GetPiece Returns the corresponding layout piece * @return the corresponding layout piece */ VPuzzlePiece * GetPiece(); @@ -78,7 +78,7 @@ private slots: void on_ActionPieceMovedToLayer(); private: - Q_DISABLE_COPY(VPieceCarrouselPiece) + Q_DISABLE_COPY(VPCarrouselPiece) VPuzzlePiece *m_piece; @@ -93,4 +93,4 @@ private slots: }; -#endif // VPIECECARROUSELPIECE_H +#endif // VPCARROUSELPIECE_H diff --git a/src/app/puzzle/vpcarrouselpiecelist.cpp b/src/app/puzzle/vpcarrouselpiecelist.cpp index d461dd648..dc7e58937 100644 --- a/src/app/puzzle/vpcarrouselpiecelist.cpp +++ b/src/app/puzzle/vpcarrouselpiecelist.cpp @@ -40,7 +40,7 @@ Q_LOGGING_CATEGORY(pCarrouselLayer, "p.carrouselLayer") VPCarrouselPieceList::VPCarrouselPieceList(VPuzzleLayer *layer, VPCarrousel *carrousel) : m_layer(layer), m_carrousel(carrousel), - m_carrouselPieces(QList()) + m_carrouselPieces(QList()) { Init(); } @@ -85,7 +85,7 @@ void VPCarrouselPieceList::Refresh() setVisible(true); for (auto piece : pieces) { - VPieceCarrouselPiece *carrouselPiece = new VPieceCarrouselPiece(piece, this); + VPCarrouselPiece *carrouselPiece = new VPCarrouselPiece(piece, this); m_carrouselPieces.append(carrouselPiece); layout()->addWidget(carrouselPiece); carrouselPiece->CleanPreview(); // fitInView only works if the widget is displayed. @@ -99,7 +99,7 @@ void VPCarrouselPieceList::Clear() // Removes and deletes the carrousel pieces from the layer while (!m_carrouselPieces.isEmpty()) { - VPieceCarrouselPiece *carrouselPiece = m_carrouselPieces.takeLast(); + VPCarrouselPiece *carrouselPiece = m_carrouselPieces.takeLast(); if(carrouselPiece != nullptr) { @@ -111,7 +111,7 @@ void VPCarrouselPieceList::Clear() } //--------------------------------------------------------------------------------------------------------------------- -QList VPCarrouselPieceList::GetCarrouselPieces() +QList VPCarrouselPieceList::GetCarrouselPieces() { return m_carrouselPieces; } diff --git a/src/app/puzzle/vpcarrouselpiecelist.h b/src/app/puzzle/vpcarrouselpiecelist.h index 0e51aa756..f488db2d8 100644 --- a/src/app/puzzle/vpcarrouselpiecelist.h +++ b/src/app/puzzle/vpcarrouselpiecelist.h @@ -31,7 +31,7 @@ #include #include "vpuzzlelayer.h" -#include "vpiececarrouselpiece.h" +#include "vpcarrouselpiece.h" class VPCarrousel; @@ -46,11 +46,11 @@ public: void Refresh(); /** - * @brief Clear it clears the carrousel layer from its pieces + * @brief Clear it clears the carrousel pieceList from its pieces */ void Clear(); - QList GetCarrouselPieces(); + QList GetCarrouselPieces(); VPCarrousel* GetCarrousel(); @@ -65,7 +65,7 @@ private: VPuzzleLayer *m_layer; VPCarrousel *m_carrousel; - QList m_carrouselPieces; + QList m_carrouselPieces; private slots: From fb78189d297591a30f8a3c6ba400d62ce55033ef Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 14:39:31 +0200 Subject: [PATCH 14/28] Refactoring VPieceCarrouselPiecePreview --- src/app/puzzle/puzzle.pri | 4 ++-- src/app/puzzle/vpcarrouselpiece.cpp | 8 ++++---- src/app/puzzle/vpcarrouselpiece.h | 6 +++--- ...iecepreview.cpp => vpcarrouselpiecepreview.cpp} | 12 ++++++------ ...selpiecepreview.h => vpcarrouselpiecepreview.h} | 14 +++++++------- 5 files changed, 22 insertions(+), 22 deletions(-) rename src/app/puzzle/{vpiececarrouselpiecepreview.cpp => vpcarrouselpiecepreview.cpp} (82%) rename src/app/puzzle/{vpiececarrouselpiecepreview.h => vpcarrouselpiecepreview.h} (80%) diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index e110dcc4c..81d208244 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -8,8 +8,8 @@ SOURCES += \ $$PWD/vpcarrousel.cpp \ $$PWD/vpcarrouselpiece.cpp \ $$PWD/vpcarrouselpiecelist.cpp \ + $$PWD/vpcarrouselpiecepreview.cpp \ $$PWD/vpcommands.cpp \ - $$PWD/vpiececarrouselpiecepreview.cpp \ $$PWD/vpmainwindow.cpp \ $$PWD/vpuzzlecommandline.cpp \ $$PWD/vpuzzlegraphicslayout.cpp \ @@ -32,8 +32,8 @@ HEADERS += \ $$PWD/vpcarrousel.h \ $$PWD/vpcarrouselpiece.h \ $$PWD/vpcarrouselpiecelist.h \ + $$PWD/vpcarrouselpiecepreview.h \ $$PWD/vpcommands.h \ - $$PWD/vpiececarrouselpiecepreview.h \ $$PWD/vpmainwindow.h \ $$PWD/vpstable.h \ $$PWD/vpuzzlecommandline.h \ diff --git a/src/app/puzzle/vpcarrouselpiece.cpp b/src/app/puzzle/vpcarrouselpiece.cpp index 8d4754c07..7cc6c7173 100644 --- a/src/app/puzzle/vpcarrouselpiece.cpp +++ b/src/app/puzzle/vpcarrouselpiece.cpp @@ -49,7 +49,7 @@ Q_LOGGING_CATEGORY(pCarrouselPiece, "p.carrouselPiece") //--------------------------------------------------------------------------------------------------------------------- VPCarrouselPiece::VPCarrouselPiece(VPuzzlePiece *piece, VPCarrouselPieceList *carrouselLayer) : m_piece(piece), - m_carrouselLayer(carrouselLayer), + m_carrouselPieceList(carrouselLayer), m_dragStart(QPoint()) { Init(); @@ -75,7 +75,7 @@ void VPCarrouselPiece::Init() setStyleSheet("background-color:white; border: 2px solid transparent;"); // define the preview of the piece - m_piecePreview = new VPieceCarrouselPiecePreview(this); + m_piecePreview = new VPCarrouselPiecePreview(this); // m_graphicsView = new VMainGraphicsView(this); // --> undefined reference to 'VMainGraphicsView::VMainGraphicView(QWidget*)' @@ -175,7 +175,7 @@ void VPCarrouselPiece::mousePressEvent(QMouseEvent *event) { if(!(event->modifiers() & Qt::ControlModifier)) { - m_carrouselLayer->GetCarrousel()->ClearSelection(); + m_carrouselPieceList->GetCarrousel()->ClearSelection(); m_piece->SetIsSelected(true); } else @@ -207,7 +207,7 @@ void VPCarrouselPiece::mouseMoveEvent(QMouseEvent *event) } // make sure the multiple selection is removed - m_carrouselLayer->GetCarrousel()->ClearSelection(); + m_carrouselPieceList->GetCarrousel()->ClearSelection(); m_piece->SetIsSelected(true); // starts the dragging diff --git a/src/app/puzzle/vpcarrouselpiece.h b/src/app/puzzle/vpcarrouselpiece.h index 452a25774..403df3aab 100644 --- a/src/app/puzzle/vpcarrouselpiece.h +++ b/src/app/puzzle/vpcarrouselpiece.h @@ -34,7 +34,7 @@ #include #include "vpuzzlepiece.h" -#include "vpiececarrouselpiecepreview.h" +#include "vpcarrouselpiecepreview.h" class VPCarrouselPieceList; @@ -82,10 +82,10 @@ private: VPuzzlePiece *m_piece; - VPCarrouselPieceList *m_carrouselLayer; + VPCarrouselPieceList *m_carrouselPieceList; QLabel *m_label{nullptr}; - VPieceCarrouselPiecePreview *m_piecePreview{nullptr}; + VPCarrouselPiecePreview *m_piecePreview{nullptr}; QPoint m_dragStart; diff --git a/src/app/puzzle/vpiececarrouselpiecepreview.cpp b/src/app/puzzle/vpcarrouselpiecepreview.cpp similarity index 82% rename from src/app/puzzle/vpiececarrouselpiecepreview.cpp rename to src/app/puzzle/vpcarrouselpiecepreview.cpp index f68af933f..5c7182b43 100644 --- a/src/app/puzzle/vpiececarrouselpiecepreview.cpp +++ b/src/app/puzzle/vpcarrouselpiecepreview.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpiececarrouselpiecepreview.cpp + ** @file vpcarrouselpiecepreview.cpp ** @author Ronan Le Tiec ** @date 3 5, 2020 ** @@ -26,29 +26,29 @@ ** *************************************************************************/ -#include "vpiececarrouselpiecepreview.h" +#include "vpcarrouselpiecepreview.h" #include //--------------------------------------------------------------------------------------------------------------------- -VPieceCarrouselPiecePreview::VPieceCarrouselPiecePreview(QWidget *parent): +VPCarrouselPiecePreview::VPCarrouselPiecePreview(QWidget *parent): QGraphicsView(parent) { } //--------------------------------------------------------------------------------------------------------------------- -VPieceCarrouselPiecePreview::~VPieceCarrouselPiecePreview() +VPCarrouselPiecePreview::~VPCarrouselPiecePreview() { } //--------------------------------------------------------------------------------------------------------------------- -void VPieceCarrouselPiecePreview::mousePressEvent(QMouseEvent *event) +void VPCarrouselPiecePreview::mousePressEvent(QMouseEvent *event) { event->ignore(); } //--------------------------------------------------------------------------------------------------------------------- -void VPieceCarrouselPiecePreview::mouseMoveEvent(QMouseEvent *event) +void VPCarrouselPiecePreview::mouseMoveEvent(QMouseEvent *event) { event->ignore(); } diff --git a/src/app/puzzle/vpiececarrouselpiecepreview.h b/src/app/puzzle/vpcarrouselpiecepreview.h similarity index 80% rename from src/app/puzzle/vpiececarrouselpiecepreview.h rename to src/app/puzzle/vpcarrouselpiecepreview.h index 9e3049de1..4e31c80f3 100644 --- a/src/app/puzzle/vpiececarrouselpiecepreview.h +++ b/src/app/puzzle/vpcarrouselpiecepreview.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpiececarrouselpiecepreview.h + ** @file vpcarrouselpiecepreview.h ** @author Ronan Le Tiec ** @date 3 5, 2020 ** @@ -26,20 +26,20 @@ ** *************************************************************************/ -#ifndef VPUZZLEPIECECARROUSELPIECEPREVIEW_H -#define VPUZZLEPIECECARROUSELPIECEPREVIEW_H +#ifndef VPCARROUSELPIECEPREVIEW_H +#define VPCARROUSELPIECEPREVIEW_H #include -class VPieceCarrouselPiecePreview: public QGraphicsView +class VPCarrouselPiecePreview: public QGraphicsView { public: - VPieceCarrouselPiecePreview(QWidget *parent = nullptr); - ~VPieceCarrouselPiecePreview(); + VPCarrouselPiecePreview(QWidget *parent = nullptr); + ~VPCarrouselPiecePreview(); protected: void mousePressEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; }; -#endif // VPUZZLEPIECECARROUSELPIECEPREVIEW_H +#endif // VPCARROUSELPIECEPREVIEW_H From 9e532edc1acee38fe93eae8247c633525d425825 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 14:43:57 +0200 Subject: [PATCH 15/28] Refactoring VPuzzleCommandLine --- src/app/puzzle/puzzle.pri | 4 +- src/app/puzzle/vpapplication.cpp | 20 ++++----- src/app/puzzle/vpapplication.h | 8 ++-- src/app/puzzle/vpcarrouselpiece.h | 6 +-- ...uzzlecommandline.cpp => vpcommandline.cpp} | 44 +++++++++---------- .../{vpuzzlecommandline.h => vpcommandline.h} | 26 +++++------ 6 files changed, 54 insertions(+), 54 deletions(-) rename src/app/puzzle/{vpuzzlecommandline.cpp => vpcommandline.cpp} (86%) rename src/app/puzzle/{vpuzzlecommandline.h => vpcommandline.h} (80%) diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index 81d208244..7727db3bb 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -9,9 +9,9 @@ SOURCES += \ $$PWD/vpcarrouselpiece.cpp \ $$PWD/vpcarrouselpiecelist.cpp \ $$PWD/vpcarrouselpiecepreview.cpp \ + $$PWD/vpcommandline.cpp \ $$PWD/vpcommands.cpp \ $$PWD/vpmainwindow.cpp \ - $$PWD/vpuzzlecommandline.cpp \ $$PWD/vpuzzlegraphicslayout.cpp \ $$PWD/vpuzzlegraphicspiece.cpp \ $$PWD/vpuzzlelayout.cpp \ @@ -33,10 +33,10 @@ HEADERS += \ $$PWD/vpcarrouselpiece.h \ $$PWD/vpcarrouselpiecelist.h \ $$PWD/vpcarrouselpiecepreview.h \ + $$PWD/vpcommandline.h \ $$PWD/vpcommands.h \ $$PWD/vpmainwindow.h \ $$PWD/vpstable.h \ - $$PWD/vpuzzlecommandline.h \ $$PWD/vpuzzlegraphicslayout.h \ $$PWD/vpuzzlegraphicspiece.h \ $$PWD/vpuzzlelayout.h \ diff --git a/src/app/puzzle/vpapplication.cpp b/src/app/puzzle/vpapplication.cpp index 848dd0b4c..0c492e3d9 100644 --- a/src/app/puzzle/vpapplication.cpp +++ b/src/app/puzzle/vpapplication.cpp @@ -335,9 +335,9 @@ VPMainWindow *VPApplication::MainWindow() Clean(); if (mainWindows.isEmpty()) { - VPuzzleCommandLinePtr cmd; - VPuzzleCommandLine::ProcessInstance(cmd, QStringList()); - NewMainWindow(VPuzzleCommandLinePtr()); + VPCommandLinePtr cmd; + VPCommandLine::ProcessInstance(cmd, QStringList()); + NewMainWindow(VPCommandLinePtr()); } return mainWindows[0]; } @@ -355,7 +355,7 @@ QList VPApplication::MainWindows() } //--------------------------------------------------------------------------------------------------------------------- -VPMainWindow *VPApplication::NewMainWindow(const VPuzzleCommandLinePtr &cmd) +VPMainWindow *VPApplication::NewMainWindow(const VPCommandLinePtr &cmd) { VPMainWindow *puzzle = new VPMainWindow(cmd); mainWindows.prepend(puzzle); @@ -382,7 +382,7 @@ void VPApplication::InitOptions() 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"; if (QIcon::hasThemeIcon(GENERIC_ICON_TO_CHECK) == false) @@ -439,8 +439,8 @@ void VPApplication::ActivateDarkMode() //--------------------------------------------------------------------------------------------------------------------- void VPApplication::ParseCommandLine(const SocketConnection &connection, const QStringList &arguments) { - VPuzzleCommandLinePtr cmd; - VPuzzleCommandLine::ProcessInstance(cmd, arguments); + VPCommandLinePtr cmd; + VPCommandLine::ProcessInstance(cmd, arguments); if (cmd->IsGuiEnabled() && connection == SocketConnection::Client) { @@ -484,7 +484,7 @@ void VPApplication::ParseCommandLine(const SocketConnection &connection, const Q } //--------------------------------------------------------------------------------------------------------------------- -void VPApplication::ProcessArguments(const VPuzzleCommandLinePtr &cmd) +void VPApplication::ProcessArguments(const VPCommandLinePtr &cmd) { const QStringList rawLayouts = cmd->OptionRawLayouts(); const QStringList args = cmd->OptionFileNames(); @@ -638,7 +638,7 @@ void VPApplication::Clean() } //-------------------------------------------------------------------------------------------- -VPuzzleCommandLinePtr VPApplication::CommandLine() const +VPCommandLinePtr VPApplication::CommandLine() const { - return VPuzzleCommandLine::instance; + return VPCommandLine::instance; } diff --git a/src/app/puzzle/vpapplication.h b/src/app/puzzle/vpapplication.h index 9e66620c0..94fe99786 100644 --- a/src/app/puzzle/vpapplication.h +++ b/src/app/puzzle/vpapplication.h @@ -31,7 +31,7 @@ #include "../vmisc/def.h" #include "vpuzzlesettings.h" #include "../vmisc/vabstractapplication.h" -#include "vpuzzlecommandline.h" +#include "vpcommandline.h" #include @@ -58,7 +58,7 @@ public: virtual bool IsAppInGUIMode() const override; VPMainWindow *MainWindow(); QList MainWindows(); - VPMainWindow *NewMainWindow(const VPuzzleCommandLinePtr &cmd); + VPMainWindow *NewMainWindow(const VPCommandLinePtr &cmd); void InitOptions(); @@ -69,8 +69,8 @@ public: void ActivateDarkMode(); void ParseCommandLine(const SocketConnection &connection, const QStringList &arguments); - void ProcessArguments(const VPuzzleCommandLinePtr &cmd); - VPuzzleCommandLinePtr CommandLine() const; + void ProcessArguments(const VPCommandLinePtr &cmd); + VPCommandLinePtr CommandLine() const; public slots: void ProcessCMD(); diff --git a/src/app/puzzle/vpcarrouselpiece.h b/src/app/puzzle/vpcarrouselpiece.h index 403df3aab..160ac8fa4 100644 --- a/src/app/puzzle/vpcarrouselpiece.h +++ b/src/app/puzzle/vpcarrouselpiece.h @@ -72,10 +72,10 @@ protected: private slots: /** - * @brief on_ActionPieceMovedToLayer Slot called when the piece is moved via the - * context menu to anoter layer + * @brief on_ActionPieceMovedToPieceList Slot called when the piece is moved via the + * context menu to anoter piece list */ - void on_ActionPieceMovedToLayer(); + void on_ActionPieceMovedToPieceList(); private: Q_DISABLE_COPY(VPCarrouselPiece) diff --git a/src/app/puzzle/vpuzzlecommandline.cpp b/src/app/puzzle/vpcommandline.cpp similarity index 86% rename from src/app/puzzle/vpuzzlecommandline.cpp rename to src/app/puzzle/vpcommandline.cpp index 9eaeadda1..ca94b76d1 100644 --- a/src/app/puzzle/vpuzzlecommandline.cpp +++ b/src/app/puzzle/vpcommandline.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlecommandline.cpp + ** @file vpcommandline.cpp ** @author Roman Telezhynskyi ** @date 12 4, 2020 ** @@ -25,31 +25,31 @@ ** along with Valentina. If not, see . ** *************************************************************************/ -#include "vpuzzlecommandline.h" +#include "vpcommandline.h" #include "vpcommands.h" #include "../vmisc/vsysexits.h" #include "../vmisc/literals.h" #include -std::shared_ptr VPuzzleCommandLine::instance = nullptr; +std::shared_ptr VPCommandLine::instance = nullptr; #define translate(context, source) QCoreApplication::translate((context), source) //------------------------------------------------------------------------------------------------ -bool VPuzzleCommandLine::IsExportEnabled() const +bool VPCommandLine::IsExportEnabled() const { const bool result = IsOptionSet(LONG_OPTION_EXPORT_FILE); int argSize = parser.positionalArguments().size(); if (result && argSize != 1) { qCritical() << translate("Puzzle", "Export options can be used with single input file only.") << "/n"; - const_cast(this)->parser.showHelp(V_EX_USAGE); + const_cast(this)->parser.showHelp(V_EX_USAGE); } return result; } //---------------------------------------------------------------------------------------------- -QString VPuzzleCommandLine::OptionExportFile() const +QString VPCommandLine::OptionExportFile() const { QString path; if (IsExportEnabled()) @@ -61,49 +61,49 @@ QString VPuzzleCommandLine::OptionExportFile() const } //--------------------------------------------------------------------------------------------------------------------- -QStringList VPuzzleCommandLine::OptionRawLayouts() const +QStringList VPCommandLine::OptionRawLayouts() const { return OptionValues(LONG_OPTION_RAW_LAYOUT); } //-------------------------------------------------------------------------------------------- -bool VPuzzleCommandLine::IsTestModeEnabled() const +bool VPCommandLine::IsTestModeEnabled() const { const bool r = IsOptionSet(LONG_OPTION_TEST); if (r && parser.positionalArguments().size() != 1) { qCritical() << translate("VCommandLine", "Test option can be used with single input file only.") << "/n"; - const_cast(this)->parser.showHelp(V_EX_USAGE); + const_cast(this)->parser.showHelp(V_EX_USAGE); } return r; } //-------------------------------------------------------------------------------------------- -bool VPuzzleCommandLine::IsGuiEnabled() const +bool VPCommandLine::IsGuiEnabled() const { return isGuiEnabled; } //-------------------------------------------------------------------------------------------- -QStringList VPuzzleCommandLine::OptionFileNames() const +QStringList VPCommandLine::OptionFileNames() const { return parser.positionalArguments(); } //------------------------------------------------------------------------------------------- -bool VPuzzleCommandLine::IsNoScalingEnabled() const +bool VPCommandLine::IsNoScalingEnabled() const { return IsOptionSet(LONG_OPTION_NO_HDPI_SCALING); } //---------------------------------------------------------------------------------------------------------------------- -void VPuzzleCommandLine::ShowHelp(int exitCode) +void VPCommandLine::ShowHelp(int exitCode) { parser.showHelp(exitCode); } //---------------------------------------------------------------------------------------------- -VPuzzleCommandLine::VPuzzleCommandLine(): +VPCommandLine::VPCommandLine(): parser(), 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; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleCommandLine::ProcessInstance(VPuzzleCommandLinePtr &instance, const QStringList &arguments) +void VPCommandLine::ProcessInstance(VPCommandLinePtr &instance, const QStringList &arguments) { if (instance == nullptr) { - instance.reset(new VPuzzleCommandLine); + instance.reset(new VPCommandLine); } 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 //================================================================================================================= @@ -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); } //------------------------------------------------------------------------------------------- -QString VPuzzleCommandLine::OptionValue(const QString &option) const +QString VPCommandLine::OptionValue(const QString &option) const { return parser.value(option); } //-------------------------------------------------------------------------------------------- -QStringList VPuzzleCommandLine::OptionValues(const QString &option) const +QStringList VPCommandLine::OptionValues(const QString &option) const { return parser.values(option); } diff --git a/src/app/puzzle/vpuzzlecommandline.h b/src/app/puzzle/vpcommandline.h similarity index 80% rename from src/app/puzzle/vpuzzlecommandline.h rename to src/app/puzzle/vpcommandline.h index 4440f6c31..5cc1f3444 100644 --- a/src/app/puzzle/vpuzzlecommandline.h +++ b/src/app/puzzle/vpcommandline.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlecommandline.h + ** @file vpcommandline.h ** @author Dmytro Hladkykh ** @date 12 4, 2020 ** @@ -25,21 +25,21 @@ ** along with Valentina. If not, see . ** *************************************************************************/ -#ifndef VPUZZLECOMMANDLINE_H -#define VPUZZLECOMMANDLINE_H +#ifndef VPCOMMANDLINE_H +#define VPCOMMANDLINE_H #include #include #include -class VPuzzleCommandLine; -using VPuzzleCommandLinePtr = std::shared_ptr; +class VPCommandLine; +using VPCommandLinePtr = std::shared_ptr; -class VPuzzleCommandLine: public QObject +class VPCommandLine: public QObject { Q_OBJECT public: - virtual ~VPuzzleCommandLine() = default; + virtual ~VPCommandLine() = default; /** @brief if user enabled export from cmd */ bool IsExportEnabled() const; @@ -64,14 +64,14 @@ public: Q_NORETURN void ShowHelp(int exitCode = 0); protected: - VPuzzleCommandLine(); + VPCommandLine(); /** @brief create the single instance of the class inside vpapplication */ - static VPuzzleCommandLinePtr Instance(const QCoreApplication &app); - static void ProcessInstance(VPuzzleCommandLinePtr &instance, const QStringList &arguments); + static VPCommandLinePtr Instance(const QCoreApplication &app); + static void ProcessInstance(VPCommandLinePtr &instance, const QStringList &arguments); private: - Q_DISABLE_COPY(VPuzzleCommandLine) - static VPuzzleCommandLinePtr instance; + Q_DISABLE_COPY(VPCommandLine) + static VPCommandLinePtr instance; QCommandLineParser parser; bool isGuiEnabled; friend class VPApplication; @@ -84,4 +84,4 @@ private: QStringList OptionValues(const QString &option) const; }; -#endif // VPUZZLECOMMANDLINE_H +#endif // VPCOMMANDLINE_H From e43f970ea8a1c19ce8eaccb82eeccb2ddd39b516 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 14:48:31 +0200 Subject: [PATCH 16/28] Refactoring VPuzzleGraphicsLayout --- src/app/puzzle/puzzle.pri | 4 ++-- src/app/puzzle/vpcarrouselpiece.cpp | 6 +++--- ...zlegraphicslayout.cpp => vpgraphicssheet.cpp} | 16 ++++++++-------- ...vpuzzlegraphicslayout.h => vpgraphicssheet.h} | 16 ++++++++-------- src/app/puzzle/vpmainwindow.cpp | 2 +- src/app/puzzle/vpmainwindow.h | 6 +++--- src/app/puzzle/vpuzzlemaingraphicsview.cpp | 8 ++++---- src/app/puzzle/vpuzzlemaingraphicsview.h | 4 ++-- 8 files changed, 31 insertions(+), 31 deletions(-) rename src/app/puzzle/{vpuzzlegraphicslayout.cpp => vpgraphicssheet.cpp} (85%) rename src/app/puzzle/{vpuzzlegraphicslayout.h => vpgraphicssheet.h} (81%) diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index 7727db3bb..2b0317e0b 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -11,8 +11,8 @@ SOURCES += \ $$PWD/vpcarrouselpiecepreview.cpp \ $$PWD/vpcommandline.cpp \ $$PWD/vpcommands.cpp \ + $$PWD/vpgraphicssheet.cpp \ $$PWD/vpmainwindow.cpp \ - $$PWD/vpuzzlegraphicslayout.cpp \ $$PWD/vpuzzlegraphicspiece.cpp \ $$PWD/vpuzzlelayout.cpp \ $$PWD/vpuzzlelayer.cpp \ @@ -35,9 +35,9 @@ HEADERS += \ $$PWD/vpcarrouselpiecepreview.h \ $$PWD/vpcommandline.h \ $$PWD/vpcommands.h \ + $$PWD/vpgraphicssheet.h \ $$PWD/vpmainwindow.h \ $$PWD/vpstable.h \ - $$PWD/vpuzzlegraphicslayout.h \ $$PWD/vpuzzlegraphicspiece.h \ $$PWD/vpuzzlelayout.h \ $$PWD/vpuzzlelayer.h \ diff --git a/src/app/puzzle/vpcarrouselpiece.cpp b/src/app/puzzle/vpcarrouselpiece.cpp index 7cc6c7173..d96d39e02 100644 --- a/src/app/puzzle/vpcarrouselpiece.cpp +++ b/src/app/puzzle/vpcarrouselpiece.cpp @@ -256,7 +256,7 @@ void VPCarrouselPiece::contextMenuEvent(QContextMenuEvent *event) QVariant data = QVariant::fromValue(layer); moveToLayer->setData(data); - connect(moveToLayer, &QAction::triggered, this, &VPCarrouselPiece::on_ActionPieceMovedToLayer); + connect(moveToLayer, &QAction::triggered, this, &VPCarrouselPiece::on_ActionPieceMovedToPieceList); } } @@ -266,14 +266,14 @@ void VPCarrouselPiece::contextMenuEvent(QContextMenuEvent *event) 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, &VPCarrouselPiece::on_ActionPieceMovedToLayer); + connect(removeAction, &QAction::triggered, this, &VPCarrouselPiece::on_ActionPieceMovedToPieceList); } contextMenu.exec(event->globalPos()); } //--------------------------------------------------------------------------------------------------------------------- -void VPCarrouselPiece::on_ActionPieceMovedToLayer() +void VPCarrouselPiece::on_ActionPieceMovedToPieceList() { QAction *act = qobject_cast(sender()); QVariant v = act->data(); diff --git a/src/app/puzzle/vpuzzlegraphicslayout.cpp b/src/app/puzzle/vpgraphicssheet.cpp similarity index 85% rename from src/app/puzzle/vpuzzlegraphicslayout.cpp rename to src/app/puzzle/vpgraphicssheet.cpp index 00185b9b5..e8ca73e16 100644 --- a/src/app/puzzle/vpuzzlegraphicslayout.cpp +++ b/src/app/puzzle/vpgraphicssheet.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlegraphicslayout.cpp + ** @file vpgraphicssheet.cpp ** @author Ronan Le Tiec ** @date 3 5, 2020 ** @@ -26,10 +26,10 @@ ** *************************************************************************/ -#include "vpuzzlegraphicslayout.h" +#include "vpgraphicssheet.h" //--------------------------------------------------------------------------------------------------------------------- -VPuzzleGraphicsLayout::VPuzzleGraphicsLayout(VPuzzleLayout *layout, QGraphicsItem *parent): +VPGraphicsSheet::VPGraphicsSheet(VPuzzleLayout *layout, QGraphicsItem *parent): QGraphicsItem(parent), m_layout(layout), m_boundingRect(GetLayoutRect()) @@ -38,13 +38,13 @@ VPuzzleGraphicsLayout::VPuzzleGraphicsLayout(VPuzzleLayout *layout, QGraphicsIte } //--------------------------------------------------------------------------------------------------------------------- -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(option); @@ -66,14 +66,14 @@ void VPuzzleGraphicsLayout::paint(QPainter *painter, const QStyleOptionGraphicsI } //--------------------------------------------------------------------------------------------------------------------- -QRectF VPuzzleGraphicsLayout::GetLayoutRect() const +QRectF VPGraphicsSheet::GetLayoutRect() const { QRectF rect = QRectF(QPointF(0,0), m_layout->GetLayoutSize()); return rect; } //--------------------------------------------------------------------------------------------------------------------- -QRectF VPuzzleGraphicsLayout::GetMarginsRect() const +QRectF VPGraphicsSheet::GetMarginsRect() const { QMarginsF margins = m_layout->GetLayoutMargins(); QSizeF size = m_layout->GetLayoutSize(); @@ -86,7 +86,7 @@ QRectF VPuzzleGraphicsLayout::GetMarginsRect() const //--------------------------------------------------------------------------------------------------------------------- -QRectF VPuzzleGraphicsLayout::boundingRect() const +QRectF VPGraphicsSheet::boundingRect() const { return m_boundingRect; } diff --git a/src/app/puzzle/vpuzzlegraphicslayout.h b/src/app/puzzle/vpgraphicssheet.h similarity index 81% rename from src/app/puzzle/vpuzzlegraphicslayout.h rename to src/app/puzzle/vpgraphicssheet.h index a8c2c509e..b57d7001c 100644 --- a/src/app/puzzle/vpuzzlegraphicslayout.h +++ b/src/app/puzzle/vpgraphicssheet.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlegraphicslayout.h + ** @file vpgraphicssheet.h ** @author Ronan Le Tiec ** @date 3 5, 2020 ** @@ -26,19 +26,19 @@ ** *************************************************************************/ -#ifndef VPUZZLEGRAPHICSLAYOUT_H -#define VPUZZLEGRAPHICSLAYOUT_H +#ifndef VPGRAPHICSSHEET_H +#define VPGRAPHICSSHEET_H #include #include #include "vpuzzlelayout.h" -class VPuzzleGraphicsLayout : public QGraphicsItem +class VPGraphicsSheet : public QGraphicsItem { public: - explicit VPuzzleGraphicsLayout(VPuzzleLayout *layout, QGraphicsItem *parent = nullptr); - ~VPuzzleGraphicsLayout(); + explicit VPGraphicsSheet(VPuzzleLayout *layout, QGraphicsItem *parent = nullptr); + ~VPGraphicsSheet(); QRectF boundingRect() const override; void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget) override; @@ -49,10 +49,10 @@ public: private: - Q_DISABLE_COPY(VPuzzleGraphicsLayout) + Q_DISABLE_COPY(VPGraphicsSheet) VPuzzleLayout *m_layout{nullptr}; QRectF m_boundingRect; }; -#endif // VPUZZLEGRAPHICSLAYOUT_H +#endif // VPGRAPHICSSHEET_H diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index 59ba207ab..02defa906 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -52,7 +52,7 @@ Q_LOGGING_CATEGORY(pWindow, "p.window") QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- -VPMainWindow::VPMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *parent) : +VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) : QMainWindow(parent), ui(new Ui::VPMainWindow), m_cmd(cmd) diff --git a/src/app/puzzle/vpmainwindow.h b/src/app/puzzle/vpmainwindow.h index 463ae5fe3..1e3fb3cd5 100644 --- a/src/app/puzzle/vpmainwindow.h +++ b/src/app/puzzle/vpmainwindow.h @@ -38,7 +38,7 @@ #include "vpuzzlelayout.h" #include "vpuzzlepiece.h" #include "../vlayout/vlayoutpiece.h" -#include "vpuzzlecommandline.h" +#include "vpcommandline.h" namespace Ui { @@ -50,7 +50,7 @@ class VPMainWindow : public QMainWindow Q_OBJECT public: - explicit VPMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *parent = nullptr); + explicit VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent = nullptr); virtual ~VPMainWindow(); /** @@ -93,7 +93,7 @@ private: VPCarrousel *m_carrousel{nullptr}; VPuzzleMainGraphicsView *m_graphicsView{nullptr}; - VPuzzleCommandLinePtr m_cmd; + VPCommandLinePtr m_cmd; VPuzzleLayout *m_layout{nullptr}; QListm_selectedPieces{QList()}; diff --git a/src/app/puzzle/vpuzzlemaingraphicsview.cpp b/src/app/puzzle/vpuzzlemaingraphicsview.cpp index 4be5cf375..da3589dc8 100644 --- a/src/app/puzzle/vpuzzlemaingraphicsview.cpp +++ b/src/app/puzzle/vpuzzlemaingraphicsview.cpp @@ -49,9 +49,9 @@ VPuzzleMainGraphicsView::VPuzzleMainGraphicsView(VPuzzleLayout *layout, QWidget m_scene = new VMainGraphicsScene(this); setScene(m_scene); - m_graphicsLayout = new VPuzzleGraphicsLayout(layout); - m_graphicsLayout->setPos(0, 0); - m_scene->addItem(m_graphicsLayout); + m_graphicsSheet = new VPGraphicsSheet(layout); + m_graphicsSheet->setPos(0, 0); + m_scene->addItem(m_graphicsSheet); setAcceptDrops(true); @@ -66,7 +66,7 @@ void VPuzzleMainGraphicsView::RefreshLayout() { // FIXME: Is that the way to go? - m_graphicsLayout->update(); + m_graphicsSheet->update(); m_scene->update(); } diff --git a/src/app/puzzle/vpuzzlemaingraphicsview.h b/src/app/puzzle/vpuzzlemaingraphicsview.h index bccff359c..e138f4cae 100644 --- a/src/app/puzzle/vpuzzlemaingraphicsview.h +++ b/src/app/puzzle/vpuzzlemaingraphicsview.h @@ -29,7 +29,7 @@ #ifndef VPUZZLEMAINGRAPHICSVIEW_H #define VPUZZLEMAINGRAPHICSVIEW_H -#include "vpuzzlegraphicslayout.h" +#include "vpgraphicssheet.h" #include "vpuzzlegraphicspiece.h" #include "../vwidgets/vmaingraphicsview.h" @@ -76,7 +76,7 @@ private: VMainGraphicsScene *m_scene{nullptr}; - VPuzzleGraphicsLayout *m_graphicsLayout{nullptr}; + VPGraphicsSheet *m_graphicsSheet{nullptr}; VPuzzleLayout *m_layout{nullptr}; QList m_graphicsPieces{}; From 45be7271bb5dff80b06329b6f7d36dd64475b94a Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 14:50:22 +0200 Subject: [PATCH 17/28] Refactoring VPuzzleGraphicsPiece --- src/app/puzzle/puzzle.pri | 4 +- ...egraphicspiece.cpp => vpgraphicspiece.cpp} | 48 +++++++++---------- ...uzzlegraphicspiece.h => vpgraphicspiece.h} | 16 +++---- src/app/puzzle/vpuzzlemaingraphicsview.cpp | 6 +-- src/app/puzzle/vpuzzlemaingraphicsview.h | 4 +- 5 files changed, 39 insertions(+), 39 deletions(-) rename src/app/puzzle/{vpuzzlegraphicspiece.cpp => vpgraphicspiece.cpp} (86%) rename src/app/puzzle/{vpuzzlegraphicspiece.h => vpgraphicspiece.h} (89%) diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index 2b0317e0b..53d116bb4 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -11,9 +11,9 @@ SOURCES += \ $$PWD/vpcarrouselpiecepreview.cpp \ $$PWD/vpcommandline.cpp \ $$PWD/vpcommands.cpp \ + $$PWD/vpgraphicspiece.cpp \ $$PWD/vpgraphicssheet.cpp \ $$PWD/vpmainwindow.cpp \ - $$PWD/vpuzzlegraphicspiece.cpp \ $$PWD/vpuzzlelayout.cpp \ $$PWD/vpuzzlelayer.cpp \ $$PWD/vpuzzlemaingraphicsview.cpp \ @@ -35,10 +35,10 @@ HEADERS += \ $$PWD/vpcarrouselpiecepreview.h \ $$PWD/vpcommandline.h \ $$PWD/vpcommands.h \ + $$PWD/vpgraphicspiece.h \ $$PWD/vpgraphicssheet.h \ $$PWD/vpmainwindow.h \ $$PWD/vpstable.h \ - $$PWD/vpuzzlegraphicspiece.h \ $$PWD/vpuzzlelayout.h \ $$PWD/vpuzzlelayer.h \ $$PWD/vpuzzlemaingraphicsview.h \ diff --git a/src/app/puzzle/vpuzzlegraphicspiece.cpp b/src/app/puzzle/vpgraphicspiece.cpp similarity index 86% rename from src/app/puzzle/vpuzzlegraphicspiece.cpp rename to src/app/puzzle/vpgraphicspiece.cpp index 30f1af656..25faf76af 100644 --- a/src/app/puzzle/vpuzzlegraphicspiece.cpp +++ b/src/app/puzzle/vpgraphicspiece.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlegraphicspiece.cpp + ** @file vpgraphicspiece.cpp ** @author Ronan Le Tiec ** @date 4 5, 2020 ** @@ -26,7 +26,7 @@ ** *************************************************************************/ -#include "vpuzzlegraphicspiece.h" +#include "vpgraphicspiece.h" #include #include @@ -47,7 +47,7 @@ Q_LOGGING_CATEGORY(pGraphicsPiece, "p.graphicsPiece") //--------------------------------------------------------------------------------------------------------------------- -VPuzzleGraphicsPiece::VPuzzleGraphicsPiece(VPuzzlePiece *piece, QGraphicsItem *parent) : +VPGraphicsPiece::VPGraphicsPiece(VPuzzlePiece *piece, QGraphicsItem *parent) : QGraphicsObject(parent), m_piece(piece), m_cuttingLine(QPainterPath()), @@ -59,13 +59,13 @@ VPuzzleGraphicsPiece::VPuzzleGraphicsPiece(VPuzzlePiece *piece, QGraphicsItem *p } //--------------------------------------------------------------------------------------------------------------------- -VPuzzleGraphicsPiece::~VPuzzleGraphicsPiece() +VPGraphicsPiece::~VPGraphicsPiece() { } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleGraphicsPiece::Init() +void VPGraphicsPiece::Init() { // set some infos setFlags(ItemIsSelectable | ItemIsMovable | ItemSendsGeometryChanges); @@ -102,19 +102,19 @@ void VPuzzleGraphicsPiece::Init() // TODO : initialises the other elements labels, passmarks etc. // Initialises the connectors - connect(m_piece, &VPuzzlePiece::SelectionChanged, this, &VPuzzleGraphicsPiece::on_PieceSelectionChanged); - connect(m_piece, &VPuzzlePiece::PositionChanged, this, &VPuzzleGraphicsPiece::on_PiecePositionChanged); - connect(m_piece, &VPuzzlePiece::RotationChanged, this, &VPuzzleGraphicsPiece::on_PieceRotationChanged); + connect(m_piece, &VPuzzlePiece::SelectionChanged, this, &VPGraphicsPiece::on_PieceSelectionChanged); + connect(m_piece, &VPuzzlePiece::PositionChanged, this, &VPGraphicsPiece::on_PiecePositionChanged); + connect(m_piece, &VPuzzlePiece::RotationChanged, this, &VPGraphicsPiece::on_PieceRotationChanged); } //--------------------------------------------------------------------------------------------------------------------- -VPuzzlePiece* VPuzzleGraphicsPiece::GetPiece() +VPuzzlePiece* VPGraphicsPiece::GetPiece() { return m_piece; } //--------------------------------------------------------------------------------------------------------------------- -QRectF VPuzzleGraphicsPiece::boundingRect() const +QRectF VPGraphicsPiece::boundingRect() const { if(!m_cuttingLine.isEmpty()) { @@ -125,7 +125,7 @@ QRectF VPuzzleGraphicsPiece::boundingRect() const } //--------------------------------------------------------------------------------------------------------------------- -QPainterPath VPuzzleGraphicsPiece::shape() const +QPainterPath VPGraphicsPiece::shape() const { if(!m_cuttingLine.isEmpty()) { @@ -136,7 +136,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(option); @@ -179,7 +179,7 @@ void VPuzzleGraphicsPiece::paint(QPainter *painter, const QStyleOptionGraphicsIt } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleGraphicsPiece::mousePressEvent(QGraphicsSceneMouseEvent *event) +void VPGraphicsPiece::mousePressEvent(QGraphicsSceneMouseEvent *event) { bool selectionState = isSelected(); //perform the default behaviour @@ -214,7 +214,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)) { @@ -245,7 +245,7 @@ void VPuzzleGraphicsPiece::mouseMoveEvent(QGraphicsSceneMouseEvent * event) //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleGraphicsPiece::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +void VPGraphicsPiece::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { bool selectionState = isSelected(); @@ -272,7 +272,7 @@ void VPuzzleGraphicsPiece::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleGraphicsPiece::hoverMoveEvent(QGraphicsSceneHoverEvent *event) +void VPGraphicsPiece::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { if(event->modifiers() & Qt::AltModifier) @@ -292,7 +292,7 @@ void VPuzzleGraphicsPiece::hoverMoveEvent(QGraphicsSceneHoverEvent *event) } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleGraphicsPiece::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +void VPGraphicsPiece::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { QMenu contextMenu; @@ -312,7 +312,7 @@ void VPuzzleGraphicsPiece::contextMenuEvent(QGraphicsSceneContextMenuEvent *even QVariant data = QVariant::fromValue(layer); moveToLayer->setData(data); - connect(moveToLayer, &QAction::triggered, this, &VPuzzleGraphicsPiece::on_ActionPieceMovedToLayer); + connect(moveToLayer, &QAction::triggered, this, &VPGraphicsPiece::on_ActionPieceMovedToLayer); } } @@ -320,13 +320,13 @@ void VPuzzleGraphicsPiece::contextMenuEvent(QGraphicsSceneContextMenuEvent *even 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, &VPuzzleGraphicsPiece::on_ActionPieceMovedToLayer); + connect(removeAction, &QAction::triggered, this, &VPGraphicsPiece::on_ActionPieceMovedToLayer); contextMenu.exec(event->screenPos()); } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleGraphicsPiece::on_ActionPieceMovedToLayer() +void VPGraphicsPiece::on_ActionPieceMovedToLayer() { QAction *act = qobject_cast(sender()); QVariant v = act->data(); @@ -339,26 +339,26 @@ void VPuzzleGraphicsPiece::on_ActionPieceMovedToLayer() //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleGraphicsPiece::on_PieceSelectionChanged() +void VPGraphicsPiece::on_PieceSelectionChanged() { setSelected(m_piece->GetIsSelected()); } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleGraphicsPiece::on_PiecePositionChanged() +void VPGraphicsPiece::on_PiecePositionChanged() { setPos(m_piece->GetPosition()); } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleGraphicsPiece::on_PieceRotationChanged() +void VPGraphicsPiece::on_PieceRotationChanged() { setTransformOriginPoint(boundingRect().center()); setRotation(-m_piece->GetRotation()); } //--------------------------------------------------------------------------------------------------------------------- -QVariant VPuzzleGraphicsPiece::itemChange(GraphicsItemChange change, const QVariant &value) +QVariant VPGraphicsPiece::itemChange(GraphicsItemChange change, const QVariant &value) { if (scene()) { diff --git a/src/app/puzzle/vpuzzlegraphicspiece.h b/src/app/puzzle/vpgraphicspiece.h similarity index 89% rename from src/app/puzzle/vpuzzlegraphicspiece.h rename to src/app/puzzle/vpgraphicspiece.h index fee04892f..718687c87 100644 --- a/src/app/puzzle/vpuzzlegraphicspiece.h +++ b/src/app/puzzle/vpgraphicspiece.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlegraphicspiece.h + ** @file vpgraphicspiece.h ** @author Ronan Le Tiec ** @date 4 5, 2020 ** @@ -26,19 +26,19 @@ ** *************************************************************************/ -#ifndef VPUZZLEGRAPHICSPIECE_H -#define VPUZZLEGRAPHICSPIECE_H +#ifndef VPGRAPHICSPIECE_H +#define VPGRAPHICSPIECE_H #include class VPuzzlePiece; -class VPuzzleGraphicsPiece : public QGraphicsObject +class VPGraphicsPiece : public QGraphicsObject { Q_OBJECT public: - VPuzzleGraphicsPiece(VPuzzlePiece *piece, QGraphicsItem *parent = nullptr); - ~VPuzzleGraphicsPiece(); + VPGraphicsPiece(VPuzzlePiece *piece, QGraphicsItem *parent = nullptr); + ~VPGraphicsPiece(); void Init(); /** @@ -86,7 +86,7 @@ private slots: void on_ActionPieceMovedToLayer(); private: - Q_DISABLE_COPY(VPuzzleGraphicsPiece) + Q_DISABLE_COPY(VPGraphicsPiece) VPuzzlePiece *m_piece; QPainterPath m_cuttingLine; @@ -97,4 +97,4 @@ private: }; -#endif // VPUZZLEGRAPHICSPIECE_H +#endif // VPGRAPHICSPIECE_H diff --git a/src/app/puzzle/vpuzzlemaingraphicsview.cpp b/src/app/puzzle/vpuzzlemaingraphicsview.cpp index da3589dc8..3045f719a 100644 --- a/src/app/puzzle/vpuzzlemaingraphicsview.cpp +++ b/src/app/puzzle/vpuzzlemaingraphicsview.cpp @@ -137,7 +137,7 @@ void VPuzzleMainGraphicsView::keyPressEvent(QKeyEvent *event) { if(event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete) { - QList tmpGraphicsPieces = m_graphicsPieces; + QList tmpGraphicsPieces = m_graphicsPieces; for(auto graphicsPiece : tmpGraphicsPieces) { @@ -157,7 +157,7 @@ void VPuzzleMainGraphicsView::on_PieceMovedToLayer(VPuzzlePiece *piece, VPuzzleL { Q_UNUSED(layerBefore) - VPuzzleGraphicsPiece *_graphicsPiece = nullptr; + VPGraphicsPiece *_graphicsPiece = nullptr; for(auto graphicPiece : m_graphicsPieces) { if(graphicPiece->GetPiece() == piece) @@ -175,7 +175,7 @@ void VPuzzleMainGraphicsView::on_PieceMovedToLayer(VPuzzlePiece *piece, VPuzzleL { if(_graphicsPiece == nullptr) { - _graphicsPiece = new VPuzzleGraphicsPiece(piece); + _graphicsPiece = new VPGraphicsPiece(piece); m_graphicsPieces.append(_graphicsPiece); } diff --git a/src/app/puzzle/vpuzzlemaingraphicsview.h b/src/app/puzzle/vpuzzlemaingraphicsview.h index e138f4cae..100356361 100644 --- a/src/app/puzzle/vpuzzlemaingraphicsview.h +++ b/src/app/puzzle/vpuzzlemaingraphicsview.h @@ -30,7 +30,7 @@ #define VPUZZLEMAINGRAPHICSVIEW_H #include "vpgraphicssheet.h" -#include "vpuzzlegraphicspiece.h" +#include "vpgraphicspiece.h" #include "../vwidgets/vmaingraphicsview.h" class VMainGraphicsScene; @@ -79,7 +79,7 @@ private: VPGraphicsSheet *m_graphicsSheet{nullptr}; VPuzzleLayout *m_layout{nullptr}; - QList m_graphicsPieces{}; + QList m_graphicsPieces{}; }; From 34b67cc6e3cb5d57681d7bcc3c79ffe858efc4ca Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 15:29:57 +0200 Subject: [PATCH 18/28] Refactoring VPuzzleLayer --- src/app/puzzle/puzzle.pri | 4 +- src/app/puzzle/vpcarrousel.cpp | 38 ++++----- src/app/puzzle/vpcarrousel.h | 6 +- src/app/puzzle/vpcarrousel.ui | 2 +- src/app/puzzle/vpcarrouselpiece.cpp | 38 ++++----- src/app/puzzle/vpcarrouselpiece.h | 5 +- src/app/puzzle/vpcarrouselpiecelist.cpp | 18 ++-- src/app/puzzle/vpcarrouselpiecelist.h | 12 +-- src/app/puzzle/vpgraphicspiece.cpp | 32 +++---- src/app/puzzle/vpgraphicspiece.h | 6 +- src/app/puzzle/vpmainwindow.cpp | 18 +--- src/app/puzzle/vpmainwindow.h | 11 --- src/app/puzzle/vpmainwindow.ui | 83 +------------------ .../{vpuzzlelayer.cpp => vppiecelist.cpp} | 34 ++++---- .../puzzle/{vpuzzlelayer.h => vppiecelist.h} | 22 ++--- src/app/puzzle/vpuzzlelayout.cpp | 82 +++++++++--------- src/app/puzzle/vpuzzlelayout.h | 46 +++++----- src/app/puzzle/vpuzzlemaingraphicsview.cpp | 24 +++--- src/app/puzzle/vpuzzlemaingraphicsview.h | 10 +-- src/app/puzzle/vpuzzlepiece.cpp | 12 +-- src/app/puzzle/vpuzzlepiece.h | 16 ++-- src/app/puzzle/xml/vplayoutfilereader.cpp | 28 +++---- src/app/puzzle/xml/vplayoutfilereader.h | 6 +- src/app/puzzle/xml/vplayoutfilewriter.cpp | 36 ++++---- src/app/puzzle/xml/vplayoutfilewriter.h | 8 +- src/app/puzzle/xml/vplayoutliterals.cpp | 6 +- src/app/puzzle/xml/vplayoutliterals.h | 6 +- 27 files changed, 253 insertions(+), 356 deletions(-) rename src/app/puzzle/{vpuzzlelayer.cpp => vppiecelist.cpp} (79%) rename src/app/puzzle/{vpuzzlelayer.h => vppiecelist.h} (86%) diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index 53d116bb4..c94dea9cd 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -14,8 +14,8 @@ SOURCES += \ $$PWD/vpgraphicspiece.cpp \ $$PWD/vpgraphicssheet.cpp \ $$PWD/vpmainwindow.cpp \ + $$PWD/vppiecelist.cpp \ $$PWD/vpuzzlelayout.cpp \ - $$PWD/vpuzzlelayer.cpp \ $$PWD/vpuzzlemaingraphicsview.cpp \ $$PWD/vpuzzlemimedatapiece.cpp \ $$PWD/vpuzzlepiece.cpp \ @@ -38,9 +38,9 @@ HEADERS += \ $$PWD/vpgraphicspiece.h \ $$PWD/vpgraphicssheet.h \ $$PWD/vpmainwindow.h \ + $$PWD/vppiecelist.h \ $$PWD/vpstable.h \ $$PWD/vpuzzlelayout.h \ - $$PWD/vpuzzlelayer.h \ $$PWD/vpuzzlemaingraphicsview.h \ $$PWD/vpuzzlemimedatapiece.h \ $$PWD/vpuzzlepiece.h \ diff --git a/src/app/puzzle/vpcarrousel.cpp b/src/app/puzzle/vpcarrousel.cpp index 2f2f8d00f..f3d8df3aa 100644 --- a/src/app/puzzle/vpcarrousel.cpp +++ b/src/app/puzzle/vpcarrousel.cpp @@ -32,7 +32,7 @@ #include #include "../vmisc/backport/qoverload.h" -#include "vpuzzlelayer.h" +#include "vppiecelist.h" #include #include @@ -49,8 +49,8 @@ VPCarrousel::VPCarrousel(VPuzzleLayout *layout, QWidget *parent) : ui->setupUi(this); // init the combo box - connect(ui->comboBoxLayer, QOverload::of(&QComboBox::currentIndexChanged), this, - &VPCarrousel::on_ActiveLayerChanged); + connect(ui->comboBoxPieceList, QOverload::of(&QComboBox::currentIndexChanged), this, + &VPCarrousel::on_ActivePieceListChanged); ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu); @@ -68,18 +68,18 @@ void VPCarrousel::Refresh() // --- add the content saved in the layout to the carrousel. // Do not rely on m_layout because we do not control it. - m_layers = m_layout->GetLayers(); - m_layers.prepend(m_layout->GetUnplacedPiecesLayer()); + m_pieceLists = m_layout->GetPiecesLists(); + m_pieceLists.prepend(m_layout->GetUnplacedPieceList()); - for (auto layer : m_layers) + for (auto pieceList : m_pieceLists) { - // add layer name to combo - ui->comboBoxLayer->blockSignals(true); - ui->comboBoxLayer->addItem(layer->GetName()); - ui->comboBoxLayer->blockSignals(false); + // add piece list name to combo + ui->comboBoxPieceList->blockSignals(true); + ui->comboBoxPieceList->addItem(pieceList->GetName()); + ui->comboBoxPieceList->blockSignals(false); } - on_ActiveLayerChanged(0); + on_ActivePieceListChanged(0); RefreshOrientation(); } @@ -88,25 +88,25 @@ void VPCarrousel::Refresh() void VPCarrousel::Clear() { // remove the combobox entries - ui->comboBoxLayer->clear(); + ui->comboBoxPieceList->clear(); ui->listWidget->clear(); } //--------------------------------------------------------------------------------------------------------------------- -void VPCarrousel::on_ActiveLayerChanged(int index) +void VPCarrousel::on_ActivePieceListChanged(int index) { qCDebug(pCarrousel, "index changed %i", index); ui->listWidget->clear(); - if (index >= 0 && index < m_layers.size()) + if (index >= 0 && index < m_pieceLists.size()) { - VPuzzleLayer *layer = m_layers.at(index); + VPPieceList *pieceList = m_pieceLists.at(index); - if (layer) + if (pieceList) { - QList pieces = layer->GetPieces(); + QList pieces = pieceList->GetPieces(); for (auto piece : pieces) { @@ -129,7 +129,7 @@ void VPCarrousel::RefreshOrientation() // then update the scrollarea min height / width and scrollbar behaviour 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 ui->listWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); @@ -139,7 +139,7 @@ void VPCarrousel::RefreshOrientation() } else // Qt::Vertical { - ui->comboBoxLayer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + ui->comboBoxPieceList->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); // scroll bar policy of scroll area ui->listWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); diff --git a/src/app/puzzle/vpcarrousel.h b/src/app/puzzle/vpcarrousel.h index abb2162c4..6e6b72520 100644 --- a/src/app/puzzle/vpcarrousel.h +++ b/src/app/puzzle/vpcarrousel.h @@ -80,7 +80,7 @@ private: Ui::VPCarrousel *ui; VPuzzleLayout *m_layout; - QList m_layers{}; + QList m_pieceLists{}; Qt::Orientation m_orientation{Qt::Vertical}; @@ -88,10 +88,10 @@ private: 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 */ - void on_ActiveLayerChanged(int index); + void on_ActivePieceListChanged(int index); }; #endif // VPCARROUSEL_H diff --git a/src/app/puzzle/vpcarrousel.ui b/src/app/puzzle/vpcarrousel.ui index 57bc16afc..c3669feb5 100644 --- a/src/app/puzzle/vpcarrousel.ui +++ b/src/app/puzzle/vpcarrousel.ui @@ -27,7 +27,7 @@ 6 - + 0 diff --git a/src/app/puzzle/vpcarrouselpiece.cpp b/src/app/puzzle/vpcarrouselpiece.cpp index d96d39e02..3eec52e79 100644 --- a/src/app/puzzle/vpcarrouselpiece.cpp +++ b/src/app/puzzle/vpcarrouselpiece.cpp @@ -47,9 +47,9 @@ Q_LOGGING_CATEGORY(pCarrouselPiece, "p.carrouselPiece") //--------------------------------------------------------------------------------------------------------------------- -VPCarrouselPiece::VPCarrouselPiece(VPuzzlePiece *piece, VPCarrouselPieceList *carrouselLayer) : +VPCarrouselPiece::VPCarrouselPiece(VPuzzlePiece *piece, VPCarrouselPieceList *carrouselPieceList) : m_piece(piece), - m_carrouselPieceList(carrouselLayer), + m_carrouselPieceList(carrouselPieceList), m_dragStart(QPoint()) { Init(); @@ -196,7 +196,7 @@ void VPCarrouselPiece::mouseMoveEvent(QMouseEvent *event) return; } - if(m_piece->GetLayer() != m_piece->GetLayer()->GetLayout()->GetUnplacedPiecesLayer()) + if(m_piece->GetPieceList() != m_piece->GetPieceList()->GetLayout()->GetUnplacedPieceList()) { return; } @@ -239,32 +239,32 @@ void VPCarrouselPiece::contextMenuEvent(QContextMenuEvent *event) { QMenu contextMenu; - VPuzzleLayer* unplacedLayer = m_piece->GetLayer()->GetLayout()->GetUnplacedPiecesLayer(); - QList layers = m_piece->GetLayer()->GetLayout()->GetLayers(); + VPPieceList* unplacedPieces = m_piece->GetPieceList()->GetLayout()->GetUnplacedPieceList(); + QList pieceLists = m_piece->GetPieceList()->GetLayout()->GetPiecesLists(); - // move to layer actions -- TODO : To be tested properly when we have several layers - layers.removeAll(m_piece->GetLayer()); - if(layers.count() > 0) + // move to piece list actions -- TODO : To be tested properly when we have several piece lists + pieceLists.removeAll(m_piece->GetPieceList()); + if(pieceLists.count() > 0) { QMenu *moveMenu = contextMenu.addMenu(tr("Move to")); // TODO order in alphabetical order - for (auto layer : layers) + for (auto pieceList : pieceLists) { - QAction* moveToLayer = moveMenu->addAction(layer->GetName()); - QVariant data = QVariant::fromValue(layer); - moveToLayer->setData(data); + QAction* moveToPieceList = moveMenu->addAction(pieceList->GetName()); + QVariant data = QVariant::fromValue(pieceList); + moveToPieceList->setData(data); - connect(moveToLayer, &QAction::triggered, this, &VPCarrouselPiece::on_ActionPieceMovedToPieceList); + connect(moveToPieceList, &QAction::triggered, this, &VPCarrouselPiece::on_ActionPieceMovedToPieceList); } } - // remove from layout action - if(m_piece->GetLayer() != unplacedLayer) + // remove from piece list action + if(m_piece->GetPieceList() != unplacedPieces) { QAction *removeAction = contextMenu.addAction(tr("Remove from Layout")); - QVariant data = QVariant::fromValue(m_piece->GetLayer()->GetLayout()->GetUnplacedPiecesLayer()); + QVariant data = QVariant::fromValue(m_piece->GetPieceList()->GetLayout()->GetUnplacedPieceList()); removeAction->setData(data); connect(removeAction, &QAction::triggered, this, &VPCarrouselPiece::on_ActionPieceMovedToPieceList); } @@ -277,9 +277,9 @@ void VPCarrouselPiece::on_ActionPieceMovedToPieceList() { QAction *act = qobject_cast(sender()); QVariant v = act->data(); - VPuzzleLayer *layer = v.value(); - if(layer != nullptr) + VPPieceList *pieceList = v.value(); + if(pieceList != nullptr) { - layer->GetLayout()->MovePieceToLayer(m_piece, layer); + pieceList->GetLayout()->MovePieceToPieceList(m_piece, pieceList); } } diff --git a/src/app/puzzle/vpcarrouselpiece.h b/src/app/puzzle/vpcarrouselpiece.h index 160ac8fa4..4ef95083d 100644 --- a/src/app/puzzle/vpcarrouselpiece.h +++ b/src/app/puzzle/vpcarrouselpiece.h @@ -43,14 +43,15 @@ class VPCarrouselPiece : public QFrame { Q_OBJECT public: - explicit VPCarrouselPiece(VPuzzlePiece *piece, VPCarrouselPieceList *carrouselLayer); + explicit VPCarrouselPiece(VPuzzlePiece *piece, VPCarrouselPieceList *carrouselPieceList); ~VPCarrouselPiece(); 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. + * only when the piece is in place in the piece list and we call it from the piece list. */ void CleanPreview(); diff --git a/src/app/puzzle/vpcarrouselpiecelist.cpp b/src/app/puzzle/vpcarrouselpiecelist.cpp index dc7e58937..5d3044ed8 100644 --- a/src/app/puzzle/vpcarrouselpiecelist.cpp +++ b/src/app/puzzle/vpcarrouselpiecelist.cpp @@ -34,11 +34,11 @@ #include -Q_LOGGING_CATEGORY(pCarrouselLayer, "p.carrouselLayer") +Q_LOGGING_CATEGORY(pCarrouselPieceList, "p.carrouselPieceList") //--------------------------------------------------------------------------------------------------------------------- -VPCarrouselPieceList::VPCarrouselPieceList(VPuzzleLayer *layer, VPCarrousel *carrousel) : - m_layer(layer), +VPCarrouselPieceList::VPCarrouselPieceList(VPPieceList *pieceList, VPCarrousel *carrousel) : + m_pieceList(pieceList), m_carrousel(carrousel), m_carrouselPieces(QList()) { @@ -63,8 +63,8 @@ void VPCarrouselPieceList::Init() Refresh(); // add the connections - connect(m_layer, &VPuzzleLayer::PieceAdded, this, &VPCarrouselPieceList::on_PieceAdded); - connect(m_layer, &VPuzzleLayer::PieceRemoved, this, &VPCarrouselPieceList::on_PieceRemoved); + connect(m_pieceList, &VPPieceList::PieceAdded, this, &VPCarrouselPieceList::on_PieceAdded); + connect(m_pieceList, &VPPieceList::PieceRemoved, this, &VPCarrouselPieceList::on_PieceRemoved); } //--------------------------------------------------------------------------------------------------------------------- @@ -73,7 +73,7 @@ void VPCarrouselPieceList::Refresh() Clear(); // Updates the carrousel pieces from the pieces list - QList pieces = m_layer->GetPieces(); + QList pieces = m_pieceList->GetPieces(); // sort the pieces in alphabetical order std::sort(pieces.begin(), pieces.end(), @@ -96,7 +96,7 @@ void VPCarrouselPieceList::Refresh() //--------------------------------------------------------------------------------------------------------------------- void VPCarrouselPieceList::Clear() { - // Removes and deletes the carrousel pieces from the layer + // Removes and deletes the carrousel pieces from the piece list while (!m_carrouselPieces.isEmpty()) { VPCarrouselPiece *carrouselPiece = m_carrouselPieces.takeLast(); @@ -123,9 +123,9 @@ VPCarrousel* VPCarrouselPieceList::GetCarrousel() } //--------------------------------------------------------------------------------------------------------------------- -VPuzzleLayer* VPCarrouselPieceList::GetLayer() +VPPieceList* VPCarrouselPieceList::GetPieceList() { - return m_layer; + return m_pieceList; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/puzzle/vpcarrouselpiecelist.h b/src/app/puzzle/vpcarrouselpiecelist.h index f488db2d8..735b98c1c 100644 --- a/src/app/puzzle/vpcarrouselpiecelist.h +++ b/src/app/puzzle/vpcarrouselpiecelist.h @@ -30,7 +30,7 @@ #define VPCARROUSELPIECELIST_H #include -#include "vpuzzlelayer.h" +#include "vppiecelist.h" #include "vpcarrouselpiece.h" class VPCarrousel; @@ -39,7 +39,7 @@ class VPCarrouselPieceList : public QWidget { Q_OBJECT public: - VPCarrouselPieceList(VPuzzleLayer *layer, VPCarrousel *carrousel); + VPCarrouselPieceList(VPPieceList *pieceList, VPCarrousel *carrousel); ~VPCarrouselPieceList(); void Init(); @@ -55,15 +55,15 @@ public: VPCarrousel* GetCarrousel(); /** - * @brief GetPuzzleLayer Returns the corresponding VPuzzleLayer - * @return the VPuzzleLayer + * @brief GetPieceList Returns the corresponding VPPieceList + * @return the VPPieceList */ - VPuzzleLayer* GetLayer(); + VPPieceList* GetPieceList(); private: Q_DISABLE_COPY(VPCarrouselPieceList) - VPuzzleLayer *m_layer; + VPPieceList *m_pieceList; VPCarrousel *m_carrousel; QList m_carrouselPieces; diff --git a/src/app/puzzle/vpgraphicspiece.cpp b/src/app/puzzle/vpgraphicspiece.cpp index 25faf76af..970e5a1dd 100644 --- a/src/app/puzzle/vpgraphicspiece.cpp +++ b/src/app/puzzle/vpgraphicspiece.cpp @@ -40,7 +40,7 @@ #include #include "vpuzzlepiece.h" -#include "vpuzzlelayer.h" +#include "vppiecelist.h" #include "vpuzzlelayout.h" #include @@ -296,44 +296,44 @@ void VPGraphicsPiece::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { QMenu contextMenu; - // move to layer actions -- TODO : To be tested properly when we have several layers - QList layers = m_piece->GetLayer()->GetLayout()->GetLayers(); - layers.removeAll(m_piece->GetLayer()); + // move to piece list actions -- TODO : To be tested properly when we have several piece lists + QList pieceLists = m_piece->GetPieceList()->GetLayout()->GetPiecesLists(); + pieceLists.removeAll(m_piece->GetPieceList()); - if(layers.count() > 0) + if(pieceLists.count() > 0) { QMenu *moveMenu = contextMenu.addMenu(tr("Move to")); // TODO order in alphabetical order - for (auto layer : layers) + for (auto pieceList : pieceLists) { - QAction* moveToLayer = moveMenu->addAction(layer->GetName()); - QVariant data = QVariant::fromValue(layer); - moveToLayer->setData(data); + QAction* moveToPieceList = moveMenu->addAction(pieceList->GetName()); + QVariant data = QVariant::fromValue(pieceList); + moveToPieceList->setData(data); - connect(moveToLayer, &QAction::triggered, this, &VPGraphicsPiece::on_ActionPieceMovedToLayer); + connect(moveToPieceList, &QAction::triggered, this, &VPGraphicsPiece::on_ActionPieceMovedToPieceList); } } // remove from layout action QAction *removeAction = contextMenu.addAction(tr("Remove from Layout")); - QVariant data = QVariant::fromValue(m_piece->GetLayer()->GetLayout()->GetUnplacedPiecesLayer()); + QVariant data = QVariant::fromValue(m_piece->GetPieceList()->GetLayout()->GetUnplacedPieceList()); removeAction->setData(data); - connect(removeAction, &QAction::triggered, this, &VPGraphicsPiece::on_ActionPieceMovedToLayer); + connect(removeAction, &QAction::triggered, this, &VPGraphicsPiece::on_ActionPieceMovedToPieceList); contextMenu.exec(event->screenPos()); } //--------------------------------------------------------------------------------------------------------------------- -void VPGraphicsPiece::on_ActionPieceMovedToLayer() +void VPGraphicsPiece::on_ActionPieceMovedToPieceList() { QAction *act = qobject_cast(sender()); QVariant v = act->data(); - VPuzzleLayer *layer = v.value(); - if(layer != nullptr) + VPPieceList *pieceList = v.value(); + if(pieceList != nullptr) { - layer->GetLayout()->MovePieceToLayer(m_piece, layer); + pieceList->GetLayout()->MovePieceToPieceList(m_piece, pieceList); } } diff --git a/src/app/puzzle/vpgraphicspiece.h b/src/app/puzzle/vpgraphicspiece.h index 718687c87..954fcd195 100644 --- a/src/app/puzzle/vpgraphicspiece.h +++ b/src/app/puzzle/vpgraphicspiece.h @@ -80,10 +80,10 @@ protected: private slots: /** - * @brief on_ActionPieceMovedToLayer Slot called when the piece is moved via the - * context menu to anoter layer + * @brief on_ActionPieceMovedToPieceList Slot called when the piece is moved via the + * context menu to anoter piece list */ - void on_ActionPieceMovedToLayer(); + void on_ActionPieceMovedToPieceList(); private: Q_DISABLE_COPY(VPGraphicsPiece) diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index 02defa906..db79905f7 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -165,7 +165,7 @@ void VPMainWindow::ImportRawLayouts(const QStringList &rawLayouts) // TODO for feature "Update piece" : CreateOrUpdate() function indstead of CreatePiece() VPuzzlePiece *piece = CreatePiece(rawPiece); - m_layout->GetUnplacedPiecesLayer()->AddPiece(piece); + m_layout->GetUnplacedPieceList()->AddPiece(piece); } m_carrousel->Refresh(); @@ -236,7 +236,6 @@ void VPMainWindow::InitProperties() { InitPropertyTabCurrentPiece(); InitPropertyTabLayout(); - InitPropertyTabLayers(); InitPropertyTabTiles(); } @@ -312,14 +311,6 @@ void VPMainWindow::InitPropertyTabTiles() ui->tabWidgetProperties->removeTab(2); // remove tiles } -//--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::InitPropertyTabLayers() -{ - // for the MVP we don't want the layers tab. - // we remove it. As soon as we need it, update this code - ui->tabWidgetProperties->removeTab(3); // remove layers -} - //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::InitCarrousel() { @@ -343,7 +334,6 @@ void VPMainWindow::SetPropertiesData() SetPropertyTabCurrentPieceData(); SetPropertyTabLayoutData(); SetPropertyTabTilesData(); - SetPropertyTabLayersData(); } } @@ -443,12 +433,6 @@ void VPMainWindow::SetPropertyTabTilesData() } -//--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::SetPropertyTabLayersData() -{ - -} - //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::InitMainGraphics() { diff --git a/src/app/puzzle/vpmainwindow.h b/src/app/puzzle/vpmainwindow.h index 1e3fb3cd5..1824b960f 100644 --- a/src/app/puzzle/vpmainwindow.h +++ b/src/app/puzzle/vpmainwindow.h @@ -129,11 +129,6 @@ private: */ void InitPropertyTabTiles(); - /** - * @brief InitPropertyTabLayers Inits the layers tab in the properties - */ - void InitPropertyTabLayers(); - /** * @brief InitCarrousel Inits the carrousel */ @@ -168,12 +163,6 @@ private: */ void SetPropertyTabTilesData(); - /** - * @brief SetPropertyTabLayersData Sets the values of UI elements - * in the Layers Tab to the values saved in m_layout - */ - void SetPropertyTabLayersData(); - /** * @brief SetDoubleSpinBoxValue sets the given spinbox to the given value. * the signals are blocked before changing the value and unblocked after diff --git a/src/app/puzzle/vpmainwindow.ui b/src/app/puzzle/vpmainwindow.ui index ccefd273b..677c1286d 100644 --- a/src/app/puzzle/vpmainwindow.ui +++ b/src/app/puzzle/vpmainwindow.ui @@ -172,7 +172,7 @@ QTabWidget::Rounded - 0 + 2 @@ -955,86 +955,6 @@ - - - - :/puzzleicon/64x64/iconLayers.png:/puzzleicon/64x64/iconLayers.png - - - - - - Layers properties - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QFrame::NoFrame - - - QFrame::Plain - - - 0 - - - true - - - - - 0 - 0 - 356 - 760 - - - - - - - font-weight:bold; - - - Layers - - - Qt::AlignCenter - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - @@ -1126,7 +1046,6 @@ doubleSpinBoxLayoutMarginLeft doubleSpinBoxLayoutMarginRight doubleSpinBoxLayoutMarginBottom - scrollAreaLayers scrollAreaTiles diff --git a/src/app/puzzle/vpuzzlelayer.cpp b/src/app/puzzle/vppiecelist.cpp similarity index 79% rename from src/app/puzzle/vpuzzlelayer.cpp rename to src/app/puzzle/vppiecelist.cpp index efe1ce0dd..ee43ad220 100644 --- a/src/app/puzzle/vpuzzlelayer.cpp +++ b/src/app/puzzle/vppiecelist.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlelayer.cpp + ** @file vppiecelist.cpp ** @author Ronan Le Tiec ** @date 13 4, 2020 ** @@ -25,42 +25,42 @@ ** along with Valentina. If not, see . ** *************************************************************************/ -#include "vpuzzlelayer.h" +#include "vppiecelist.h" #include "vpuzzlelayout.h" #include -Q_LOGGING_CATEGORY(pLayer, "p.layer") +Q_LOGGING_CATEGORY(pPieceList, "p.pieceList") //--------------------------------------------------------------------------------------------------------------------- -VPuzzleLayer::VPuzzleLayer(VPuzzleLayout *layout): +VPPieceList::VPPieceList(VPuzzleLayout *layout): m_layout(layout) { } //--------------------------------------------------------------------------------------------------------------------- -VPuzzleLayer::~VPuzzleLayer() +VPPieceList::~VPPieceList() { } //--------------------------------------------------------------------------------------------------------------------- -VPuzzleLayout* VPuzzleLayer::GetLayout() +VPuzzleLayout* VPPieceList::GetLayout() { return m_layout; } //--------------------------------------------------------------------------------------------------------------------- -QList VPuzzleLayer::GetPieces() +QList VPPieceList::GetPieces() { return m_pieces; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayer::ClearSelection() +void VPPieceList::ClearSelection() { for (auto piece: m_pieces) { @@ -69,45 +69,45 @@ void VPuzzleLayer::ClearSelection() } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayer::AddPiece(VPuzzlePiece *piece) +void VPPieceList::AddPiece(VPuzzlePiece *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); - piece->SetLayer(this); + piece->SetPieceList(this); emit PieceAdded(piece); } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayer::RemovePiece(VPuzzlePiece *piece) +void VPPieceList::RemovePiece(VPuzzlePiece *piece) { m_pieces.removeAll(piece); - piece->SetLayer(nullptr); + piece->SetPieceList(nullptr); emit PieceRemoved(piece); } //--------------------------------------------------------------------------------------------------------------------- -QString VPuzzleLayer::GetName() const +QString VPPieceList::GetName() const { return m_name; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayer::SetName(const QString &name) +void VPPieceList::SetName(const QString &name) { m_name = name; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayer::SetIsVisible(bool value) +void VPPieceList::SetIsVisible(bool value) { m_isVisible = value; } //--------------------------------------------------------------------------------------------------------------------- -bool VPuzzleLayer::GetIsVisible() const +bool VPPieceList::GetIsVisible() const { return m_isVisible; } diff --git a/src/app/puzzle/vpuzzlelayer.h b/src/app/puzzle/vppiecelist.h similarity index 86% rename from src/app/puzzle/vpuzzlelayer.h rename to src/app/puzzle/vppiecelist.h index 435701eff..9c6043f3b 100644 --- a/src/app/puzzle/vpuzzlelayer.h +++ b/src/app/puzzle/vppiecelist.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlelayer.h + ** @file vppiecelist.h ** @author Ronan Le Tiec ** @date 13 4, 2020 ** @@ -25,20 +25,20 @@ ** along with Valentina. If not, see . ** *************************************************************************/ -#ifndef VPUZZLELAYER_H -#define VPUZZLELAYER_H +#ifndef VPPIECELIST_H +#define VPPIECELIST_H #include #include "vpuzzlepiece.h" class VPuzzleLayout; -class VPuzzleLayer : public QObject +class VPPieceList : public QObject { Q_OBJECT public: - VPuzzleLayer(VPuzzleLayout *layout); - ~VPuzzleLayer(); + VPPieceList(VPuzzleLayout *layout); + ~VPPieceList(); QList GetPieces(); void AddPiece(VPuzzlePiece *piece); @@ -54,13 +54,13 @@ public: bool GetIsVisible() const; /** - * @brief GetLayout Returns the layout in which this layer is - * @return the layout of this layer + * @brief GetLayout Returns the layout in which this piece list is + * @return the layout of this piece list */ VPuzzleLayout* GetLayout(); /** - * @brief ClearSelection Clears the selection of the pieces in this layer + * @brief ClearSelection Clears the selection of the pieces in this piece list */ void ClearSelection(); @@ -76,7 +76,7 @@ signals: void PieceRemoved(VPuzzlePiece *piece); private: - Q_DISABLE_COPY(VPuzzleLayer) + Q_DISABLE_COPY(VPPieceList) QString m_name{}; QList m_pieces{}; @@ -88,4 +88,4 @@ private: }; -#endif // VPUZZLELAYER_H +#endif // VPPIECELIST_H diff --git a/src/app/puzzle/vpuzzlelayout.cpp b/src/app/puzzle/vpuzzlelayout.cpp index 9020f3dac..e57daf39f 100644 --- a/src/app/puzzle/vpuzzlelayout.cpp +++ b/src/app/puzzle/vpuzzlelayout.cpp @@ -26,56 +26,56 @@ ** *************************************************************************/ #include "vpuzzlelayout.h" -#include "vpuzzlelayer.h" +#include "vppiecelist.h" #include "vpuzzlepiece.h" //--------------------------------------------------------------------------------------------------------------------- VPuzzleLayout::VPuzzleLayout() : - m_unplacedPiecesLayer(new VPuzzleLayer(this)) + m_unplacedPieceList(new VPPieceList(this)) { - m_unplacedPiecesLayer->SetName(QObject::tr("Unplaced pieces")); + m_unplacedPieceList->SetName(QObject::tr("Unplaced pieces")); - // create a standard default layer: - VPuzzleLayer *layer = new VPuzzleLayer(this); - layer->SetName(QObject::tr("Layout")); - AddLayer(layer); + // create a standard default piecelist: + VPPieceList *pieceList = new VPPieceList(this); + pieceList->SetName(QObject::tr("Layout")); + AddPieceList(pieceList); - // sets the default active layer - SetFocusedLayer(); + // sets the default active piece list + SetFocusedPieceList(); } //--------------------------------------------------------------------------------------------------------------------- VPuzzleLayout::~VPuzzleLayout() { - qDeleteAll(m_layers); - delete m_unplacedPiecesLayer; + qDeleteAll(m_pieceLists); + delete m_unplacedPieceList; } //--------------------------------------------------------------------------------------------------------------------- -VPuzzleLayer* VPuzzleLayout::GetUnplacedPiecesLayer() +VPPieceList* VPuzzleLayout::GetUnplacedPieceList() { - return m_unplacedPiecesLayer; + return m_unplacedPieceList; } //--------------------------------------------------------------------------------------------------------------------- -VPuzzleLayer* VPuzzleLayout::AddLayer() +VPPieceList* VPuzzleLayout::AddPieceList() { - VPuzzleLayer *newLayer = new VPuzzleLayer(this); - m_layers.append(newLayer); - return newLayer; + VPPieceList *newPieceList = new VPPieceList(this); + m_pieceLists.append(newPieceList); + return newPieceList; } //--------------------------------------------------------------------------------------------------------------------- -VPuzzleLayer* VPuzzleLayout::AddLayer(VPuzzleLayer *layer) +VPPieceList* VPuzzleLayout::AddPieceList(VPPieceList *pieceList) { - m_layers.append(layer); - return layer; + m_pieceLists.append(pieceList); + return pieceList; } //--------------------------------------------------------------------------------------------------------------------- -QList VPuzzleLayout::GetLayers() +QList VPuzzleLayout::GetPiecesLists() { - return m_layers; + return m_pieceLists; } //--------------------------------------------------------------------------------------------------------------------- @@ -83,12 +83,12 @@ QList VPuzzleLayout::GetSelectedPieces() { QList result = QList(); - QList layers = m_layers; - layers.prepend(m_unplacedPiecesLayer); + QList pieceLists = m_pieceLists; + pieceLists.prepend(m_unplacedPieceList); - for (auto layer : layers) + for (auto pieceList : pieceLists) { - for (auto piece : layer->GetPieces()) + for (auto piece : pieceList->GetPieces()) { if(piece->GetIsSelected()) { @@ -275,44 +275,44 @@ bool VPuzzleLayout::GetStickyEdges() const //--------------------------------------------------------------------------------------------------------------------- void VPuzzleLayout::ClearSelection() { - m_unplacedPiecesLayer->ClearSelection(); + m_unplacedPieceList->ClearSelection(); - for (auto layer : m_layers) + for (auto pieceList : m_pieceLists) { - layer->ClearSelection(); + pieceList->ClearSelection(); } } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayout::SetFocusedLayer(VPuzzleLayer* focusedLayer) +void VPuzzleLayout::SetFocusedPieceList(VPPieceList* focusedPieceList) { - if(focusedLayer == nullptr) + if(focusedPieceList == nullptr) { - m_focusedLayer = m_layers.first(); + m_focusedPieceList = m_pieceLists.first(); } else { - m_focusedLayer = focusedLayer; + m_focusedPieceList = focusedPieceList; } } //--------------------------------------------------------------------------------------------------------------------- -VPuzzleLayer* VPuzzleLayout::GetFocusedLayer() +VPPieceList* VPuzzleLayout::GetFocusedPieceList() { - return m_focusedLayer; + return m_focusedPieceList; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayout::MovePieceToLayer(VPuzzlePiece* piece, VPuzzleLayer* layer) +void VPuzzleLayout::MovePieceToPieceList(VPuzzlePiece* piece, VPPieceList* pieceList) { - VPuzzleLayer* layerBefore = piece->GetLayer(); + VPPieceList* pieceListBefore = piece->GetPieceList(); - if(layerBefore != nullptr) + if(pieceListBefore != nullptr) { - piece->GetLayer()->RemovePiece(piece); + piece->GetPieceList()->RemovePiece(piece); } - layer->AddPiece(piece); + pieceList->AddPiece(piece); // signal, that a piece was moved - emit PieceMovedToLayer(piece, layerBefore,layer); + emit PieceMovedToPieceList(piece, pieceListBefore,pieceList); } diff --git a/src/app/puzzle/vpuzzlelayout.h b/src/app/puzzle/vpuzzlelayout.h index 26ab1da3f..33ef12b8e 100644 --- a/src/app/puzzle/vpuzzlelayout.h +++ b/src/app/puzzle/vpuzzlelayout.h @@ -34,7 +34,7 @@ #include "def.h" -class VPuzzleLayer; +class VPPieceList; class VPuzzlePiece; // is this the right place for the definition? @@ -47,11 +47,15 @@ public: VPuzzleLayout(); virtual ~VPuzzleLayout(); - VPuzzleLayer* GetUnplacedPiecesLayer(); + /** + * @brief GetUnplacedPieceList Returns the piece list of unplaced pieces + * @return the unplaced pieces list + */ + VPPieceList* GetUnplacedPieceList(); - VPuzzleLayer* AddLayer(); - VPuzzleLayer* AddLayer(VPuzzleLayer *layer); - QList GetLayers(); + VPPieceList* AddPieceList(); + VPPieceList* AddPieceList(VPPieceList *pieceList); + QList GetPiecesLists(); /** * @brief GetSelectedPieces Returns the list of the selected pieces @@ -196,47 +200,47 @@ public: bool GetStickyEdges() const; /** - * @brief ClearSelection goes through the layers & pieces and calls + * @brief ClearSelection goes through the piece list and 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 + * @brief SetFocusedPieceList Sets the focused piece klist, 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 + * @param focusedPieceList the new active piece list. If nullptr, then it sets automaticaly the first piece list from m_pieceLists */ - void SetFocusedLayer(VPuzzleLayer* focusedLayer = nullptr); + void SetFocusedPieceList(VPPieceList* focusedPieceList = nullptr); /** - * @brief GetFocusedLayer Returns the focused layer, to which pieces are added from the carrousel via drag + * @brief GetFocusedPieceList Returns the focused piece list, to which pieces are added from the carrousel via drag * and drop - * @return the focused layer + * @return the focused piece list */ - VPuzzleLayer* GetFocusedLayer(); + VPPieceList* GetFocusedPieceList(); /** - * @brief MovePieceToLayer Moves the given piece to the given layer + * @brief MovePieceToPieceList Moves the given piece to the given piece list * @param piece the piece to move - * @param layer the layer to move the piece to + * @param pieceList the piece list to move the piece to */ - void MovePieceToLayer(VPuzzlePiece* piece, VPuzzleLayer* layer); + void MovePieceToPieceList(VPuzzlePiece* piece, VPPieceList* pieceList); signals: - void PieceMovedToLayer(VPuzzlePiece *piece, VPuzzleLayer *layerBefore, VPuzzleLayer *layerAfter); + void PieceMovedToPieceList(VPuzzlePiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter); private: Q_DISABLE_COPY(VPuzzleLayout) - VPuzzleLayer *m_unplacedPiecesLayer; - QList m_layers{}; + VPPieceList *m_unplacedPieceList; + QList m_pieceLists{}; /** - * @brief m_focusedLayer pointer the the focused layer, to which pieces will be - * added via drag and drop, or if no layer is defined. + * @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. */ - VPuzzleLayer *m_focusedLayer{nullptr}; + VPPieceList *m_focusedPieceList{nullptr}; // format Unit m_unit{Unit::Cm}; diff --git a/src/app/puzzle/vpuzzlemaingraphicsview.cpp b/src/app/puzzle/vpuzzlemaingraphicsview.cpp index 3045f719a..4b1fc57f1 100644 --- a/src/app/puzzle/vpuzzlemaingraphicsview.cpp +++ b/src/app/puzzle/vpuzzlemaingraphicsview.cpp @@ -33,7 +33,7 @@ #include #include "vpuzzlemimedatapiece.h" -#include "vpuzzlelayer.h" +#include "vppiecelist.h" #include "../vwidgets/vmaingraphicsscene.h" #include @@ -56,7 +56,7 @@ VPuzzleMainGraphicsView::VPuzzleMainGraphicsView(VPuzzleLayout *layout, QWidget setAcceptDrops(true); // add the connections - connect(m_layout, &VPuzzleLayout::PieceMovedToLayer, this, &VPuzzleMainGraphicsView::on_PieceMovedToLayer); + connect(m_layout, &VPuzzleLayout::PieceMovedToPieceList, this, &VPuzzleMainGraphicsView::on_PieceMovedToPieceList); connect(m_scene, &VMainGraphicsScene::selectionChanged, this, &VPuzzleMainGraphicsView::on_SceneSelectionChanged); } @@ -122,11 +122,11 @@ void VPuzzleMainGraphicsView::dropEvent(QDropEvent *event) QPoint point = event->pos(); piece->SetPosition(mapToScene(point)); - // change the layer of the piece - VPuzzleLayer *focusedLayer = m_layout->GetFocusedLayer(); - if(focusedLayer != nullptr) + // change the piecelist of the piece + VPPieceList *focusedPieceList = m_layout->GetFocusedPieceList(); + if(focusedPieceList != nullptr) { - m_layout->MovePieceToLayer(piece, focusedLayer); + m_layout->MovePieceToPieceList(piece, focusedPieceList); } } } @@ -146,16 +146,16 @@ void VPuzzleMainGraphicsView::keyPressEvent(QKeyEvent *event) if(piece->GetIsSelected()) { 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 VPuzzleMainGraphicsView::on_PieceMovedToPieceList(VPuzzlePiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter) { - Q_UNUSED(layerBefore) + Q_UNUSED(pieceListBefore) VPGraphicsPiece *_graphicsPiece = nullptr; for(auto graphicPiece : m_graphicsPieces) @@ -166,12 +166,12 @@ void VPuzzleMainGraphicsView::on_PieceMovedToLayer(VPuzzlePiece *piece, VPuzzleL } } - if(layerAfter == m_layout->GetUnplacedPiecesLayer() && _graphicsPiece != nullptr) + if(pieceListAfter == m_layout->GetUnplacedPieceList() && _graphicsPiece != nullptr) { scene()->removeItem(_graphicsPiece); m_graphicsPieces.removeAll(_graphicsPiece); } - else if(layerAfter != m_layout->GetUnplacedPiecesLayer()) + else if(pieceListAfter != m_layout->GetUnplacedPieceList()) { if(_graphicsPiece == nullptr) { @@ -194,5 +194,5 @@ void VPuzzleMainGraphicsView::on_SceneSelectionChanged() // 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 - m_layout->GetUnplacedPiecesLayer()->ClearSelection(); + m_layout->GetUnplacedPieceList()->ClearSelection(); } diff --git a/src/app/puzzle/vpuzzlemaingraphicsview.h b/src/app/puzzle/vpuzzlemaingraphicsview.h index 100356361..ce181ec04 100644 --- a/src/app/puzzle/vpuzzlemaingraphicsview.h +++ b/src/app/puzzle/vpuzzlemaingraphicsview.h @@ -58,13 +58,13 @@ protected: private slots: /** - * @brief on_PieceMovedToLayer The slot is called when the given piece was moved from the given layer to the other - * given layer + * @brief on_PieceMovedToPieceList The slot is called when the given piece was moved from the given piece list to the other + * given piece list * @param piece the piece that was moved - * @param layerBefore the layer before the move - * @param layerAfter the layer after the move + * @param pieceListBefore the piece list before the move + * @param pieceListAfter the piece list after the move */ - void on_PieceMovedToLayer(VPuzzlePiece *piece, VPuzzleLayer *layerBefore, VPuzzleLayer *layerAfter); + void on_PieceMovedToPieceList(VPuzzlePiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter); /** * @brief on_SceneSelectionChanged Slot is called when the scene selection has changed diff --git a/src/app/puzzle/vpuzzlepiece.cpp b/src/app/puzzle/vpuzzlepiece.cpp index dc11f77ca..02c000465 100644 --- a/src/app/puzzle/vpuzzlepiece.cpp +++ b/src/app/puzzle/vpuzzlepiece.cpp @@ -29,7 +29,7 @@ #include -#include "vpuzzlelayer.h" +#include "vppiecelist.h" #include "../vmisc/def.h" #include @@ -242,17 +242,17 @@ QVector VPuzzlePiece::GetGrainline() } //--------------------------------------------------------------------------------------------------------------------- -VPuzzleLayer* VPuzzlePiece::GetLayer() +VPPieceList* VPuzzlePiece::GetPieceList() { - return m_layer; + return m_pieceList; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetLayer(VPuzzleLayer* layer) +void VPuzzlePiece::SetPieceList(VPPieceList* pieceList) { - if(layer != m_layer) + if(pieceList != m_pieceList) { - m_layer = layer; + m_pieceList = pieceList; } } diff --git a/src/app/puzzle/vpuzzlepiece.h b/src/app/puzzle/vpuzzlepiece.h index c859de99e..a1536c224 100644 --- a/src/app/puzzle/vpuzzlepiece.h +++ b/src/app/puzzle/vpuzzlepiece.h @@ -33,7 +33,7 @@ #include #include -class VPuzzleLayer; +class VPPieceList; class VPuzzlePiece : public QObject { @@ -187,16 +187,16 @@ public: bool GetIsSelected(); /** - * @brief GetLayer Returns the layer in which the piece is. - * @return layer of the piece + * @brief GetPieceList Returns the piecelist in which the piece is. + * @return pieceList of the piece */ - VPuzzleLayer* GetLayer(); + VPPieceList* GetPieceList(); /** - * @brief SetLayer Sets the layer of the piece to the given layer - * @param layer + * @brief SetPieceList Sets the pieceList of the piece to the given pieceList + * @param pieceList */ - void SetLayer(VPuzzleLayer* layer); + void SetPieceList(VPPieceList* pieceList); QIcon PieceIcon(const QSize &size) const; @@ -244,7 +244,7 @@ private: bool m_mirrorPiece{false}; bool m_isSelected{false}; - VPuzzleLayer *m_layer{nullptr}; + VPPieceList *m_pieceList{nullptr}; }; #endif // VPUZZLEPIECE_H diff --git a/src/app/puzzle/xml/vplayoutfilereader.cpp b/src/app/puzzle/xml/vplayoutfilereader.cpp index 155fad029..fc41231d8 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.cpp +++ b/src/app/puzzle/xml/vplayoutfilereader.cpp @@ -70,9 +70,9 @@ void VPLayoutFileReader::ReadLayout(VPuzzleLayout *layout) { ReadProperties(layout); } - else if (name() == ML::TagLayers) + else if (name() == ML::TagPieceLists) { - ReadLayers(layout); + ReadPieceLists(layout); } else { @@ -193,20 +193,20 @@ void VPLayoutFileReader::ReadTiles(VPuzzleLayout *layout) } //--------------------------------------------------------------------------------------------------------------------- -void VPLayoutFileReader::ReadLayers(VPuzzleLayout *layout) +void VPLayoutFileReader::ReadPieceLists(VPuzzleLayout *layout) { - SCASSERT(isStartElement() && name() == ML::TagLayers); + SCASSERT(isStartElement() && name() == ML::TagPieceLists); while (readNextStartElement()) { - if (name() == ML::TagUnplacedPiecesLayer) + if (name() == ML::TagUnplacedPieceList) { - ReadLayer(layout->GetUnplacedPiecesLayer()); + ReadPieceList(layout->GetUnplacedPieceList()); } - else if (name() == ML::TagLayer) + else if (name() == ML::TagPieceList) { - VPuzzleLayer *layer = layout->AddLayer(); - ReadLayer(layer); + VPPieceList *pieceList = layout->AddPieceList(); + ReadPieceList(pieceList); } else { @@ -217,13 +217,13 @@ void VPLayoutFileReader::ReadLayers(VPuzzleLayout *layout) } //--------------------------------------------------------------------------------------------------------------------- -void VPLayoutFileReader::ReadLayer(VPuzzleLayer *layer) +void VPLayoutFileReader::ReadPieceList(VPPieceList *pieceList) { - SCASSERT(isStartElement() && (name() == ML::TagLayer || name() == ML::TagUnplacedPiecesLayer)); + SCASSERT(isStartElement() && (name() == ML::TagPieceList || name() == ML::TagUnplacedPieceList)); QXmlStreamAttributes attribs = attributes(); - layer->SetName(ReadAttributeString(attribs, ML::AttrName, tr("Layer"))); - layer->SetIsVisible(ReadAttributeBool(attribs, ML::AttrVisible, trueStr)); + pieceList->SetName(ReadAttributeString(attribs, ML::AttrName, tr("Piece List"))); + pieceList->SetIsVisible(ReadAttributeBool(attribs, ML::AttrVisible, trueStr)); while (readNextStartElement()) { @@ -231,7 +231,7 @@ void VPLayoutFileReader::ReadLayer(VPuzzleLayer *layer) { VPuzzlePiece *piece = new VPuzzlePiece(); ReadPiece(piece); - layer->AddPiece(piece); + pieceList->AddPiece(piece); } else { diff --git a/src/app/puzzle/xml/vplayoutfilereader.h b/src/app/puzzle/xml/vplayoutfilereader.h index 5c8984338..a161bc5e6 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.h +++ b/src/app/puzzle/xml/vplayoutfilereader.h @@ -32,7 +32,7 @@ #include #include "../ifc/xml/vabstractconverter.h" #include "vpuzzlelayout.h" -#include "vpuzzlelayer.h" +#include "vppiecelist.h" #include "vpuzzlepiece.h" class VPLayoutFileReader : public QXmlStreamReader @@ -50,8 +50,8 @@ private: void ReadLayout(VPuzzleLayout *layout); void ReadProperties(VPuzzleLayout *layout); void ReadTiles(VPuzzleLayout *layout); - void ReadLayers(VPuzzleLayout *layout); - void ReadLayer(VPuzzleLayer *layer); + void ReadPieceLists(VPuzzleLayout *layout); + void ReadPieceList(VPPieceList *pieceList); void ReadPiece(VPuzzlePiece *piece); QMarginsF ReadMargins(); diff --git a/src/app/puzzle/xml/vplayoutfilewriter.cpp b/src/app/puzzle/xml/vplayoutfilewriter.cpp index 33d7b0bdf..bd6a05202 100644 --- a/src/app/puzzle/xml/vplayoutfilewriter.cpp +++ b/src/app/puzzle/xml/vplayoutfilewriter.cpp @@ -28,7 +28,7 @@ #include "vplayoutfilewriter.h" #include "vpuzzlelayout.h" -#include "vpuzzlelayer.h" +#include "vppiecelist.h" #include "vpuzzlepiece.h" #include "vplayoutliterals.h" #include "../ifc/xml/vlayoutconverter.h" @@ -65,7 +65,7 @@ void VPLayoutFileWriter::WriteLayout(VPuzzleLayout *layout) SetAttribute(ML::AttrVersion, VLayoutConverter::LayoutMaxVerStr); WriteProperties(layout); - WriteLayers(layout); + WritePieceLists(layout); writeEndElement(); //layout } @@ -116,45 +116,45 @@ void VPLayoutFileWriter::WriteTiles(VPuzzleLayout *layout) //--------------------------------------------------------------------------------------------------------------------- -void VPLayoutFileWriter::WriteLayers(VPuzzleLayout *layout) +void VPLayoutFileWriter::WritePieceLists(VPuzzleLayout *layout) { - writeStartElement(ML::TagLayers); + writeStartElement(ML::TagPieceLists); - WriteLayer(layout->GetUnplacedPiecesLayer(), ML::TagUnplacedPiecesLayer); + WritePieceList(layout->GetUnplacedPieceList(), ML::TagUnplacedPieceList); - QList layers = layout->GetLayers(); - for (auto layer : layers) + QList pieceLists = layout->GetPiecesLists(); + for (auto pieceList : pieceLists) { - WriteLayer(layer); + WritePieceList(pieceList); } - writeEndElement(); // layers + writeEndElement(); // piece list } //--------------------------------------------------------------------------------------------------------------------- -void VPLayoutFileWriter::WriteLayer(VPuzzleLayer *layer) +void VPLayoutFileWriter::WritePieceList(VPPieceList *pieceList) { - WriteLayer(layer, ML::TagLayer); + WritePieceList(pieceList, ML::TagPieceList); } //--------------------------------------------------------------------------------------------------------------------- -void VPLayoutFileWriter::WriteLayer(VPuzzleLayer *layer, const QString &tagName) +void VPLayoutFileWriter::WritePieceList(VPPieceList *pieceList, const QString &tagName) { - writeStartElement(tagName); // layer - SetAttribute(ML::AttrName, layer->GetName()); - SetAttribute(ML::AttrVisible, layer->GetIsVisible()); + writeStartElement(tagName); // piece list + SetAttribute(ML::AttrName, pieceList->GetName()); + SetAttribute(ML::AttrVisible, pieceList->GetIsVisible()); // TODO selected info. Not sure how it's saved yet - //SetAttribute("selected", layer->GetIsSelected()); + //SetAttribute("selected", pieceList->GetIsSelected()); - QList pieces = layer->GetPieces(); + QList pieces = pieceList->GetPieces(); for (auto piece : pieces) { WritePiece(piece); } - writeEndElement(); // layer + writeEndElement(); // piece list } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/puzzle/xml/vplayoutfilewriter.h b/src/app/puzzle/xml/vplayoutfilewriter.h index b41c58aff..4fc4f646b 100644 --- a/src/app/puzzle/xml/vplayoutfilewriter.h +++ b/src/app/puzzle/xml/vplayoutfilewriter.h @@ -35,7 +35,7 @@ #include "../vmisc/literals.h" class VPuzzleLayout; -class VPuzzleLayer; +class VPPieceList; class VPuzzlePiece; class QFile; class QMarginsF; @@ -53,9 +53,9 @@ private: void WriteLayout(VPuzzleLayout *layout); void WriteProperties(VPuzzleLayout *layout); void WriteTiles(VPuzzleLayout *layout); - void WriteLayers(VPuzzleLayout *layout); - void WriteLayer(VPuzzleLayer *layer); - void WriteLayer(VPuzzleLayer *layer, const QString &tagName); + void WritePieceLists(VPuzzleLayout *layout); + void WritePieceList(VPPieceList *pieceList); + void WritePieceList(VPPieceList *pieceList, const QString &tagName); void WritePiece(VPuzzlePiece *piece); void WriteMargins(const QMarginsF &margins); diff --git a/src/app/puzzle/xml/vplayoutliterals.cpp b/src/app/puzzle/xml/vplayoutliterals.cpp index 13f0938a1..2421577e2 100644 --- a/src/app/puzzle/xml/vplayoutliterals.cpp +++ b/src/app/puzzle/xml/vplayoutliterals.cpp @@ -31,15 +31,15 @@ namespace ML { const QString TagLayout = QStringLiteral("layout"); const QString TagProperties = QStringLiteral("properties"); -const QString TagLayers = QStringLiteral("layers"); +const QString TagPieceLists = QStringLiteral("pieceLists"); const QString TagUnit = QStringLiteral("unit"); const QString TagDescription = QStringLiteral("description"); const QString TagSize = QStringLiteral("size"); const QString TagMargin = QStringLiteral("margin"); const QString TagControl = QStringLiteral("control"); const QString TagTiles = QStringLiteral("tiles"); -const QString TagUnplacedPiecesLayer = QStringLiteral("unplacedPiecesLayer"); -const QString TagLayer = QStringLiteral("layer"); +const QString TagUnplacedPieceList = QStringLiteral("unplacedPieceList"); +const QString TagPieceList = QStringLiteral("pieceList"); const QString TagPiece = QStringLiteral("piece"); const QString AttrVersion = QStringLiteral("version"); diff --git a/src/app/puzzle/xml/vplayoutliterals.h b/src/app/puzzle/xml/vplayoutliterals.h index 7359e5fef..b0b2c970f 100644 --- a/src/app/puzzle/xml/vplayoutliterals.h +++ b/src/app/puzzle/xml/vplayoutliterals.h @@ -36,15 +36,15 @@ namespace ML { extern const QString TagLayout; extern const QString TagProperties; -extern const QString TagLayers; +extern const QString TagPieceLists; extern const QString TagUnit; extern const QString TagDescription; extern const QString TagSize; extern const QString TagMargin; extern const QString TagControl; extern const QString TagTiles; -extern const QString TagUnplacedPiecesLayer; -extern const QString TagLayer; +extern const QString TagUnplacedPieceList; +extern const QString TagPieceList; extern const QString TagPiece; extern const QString AttrVersion; From 5e785bfa79a90d1114d013e04af38b655c0354ee Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 15:34:11 +0200 Subject: [PATCH 19/28] Refactoring VPuzzleLayout --- src/app/puzzle/puzzle.pri | 4 +- src/app/puzzle/vpcarrousel.cpp | 2 +- src/app/puzzle/vpcarrousel.h | 6 +- src/app/puzzle/vpgraphicspiece.cpp | 2 +- src/app/puzzle/vpgraphicssheet.cpp | 2 +- src/app/puzzle/vpgraphicssheet.h | 6 +- .../{vpuzzlelayout.cpp => vplayout.cpp} | 78 +++++++++---------- .../puzzle/{vpuzzlelayout.h => vplayout.h} | 16 ++-- src/app/puzzle/vpmainwindow.cpp | 4 +- src/app/puzzle/vpmainwindow.h | 4 +- src/app/puzzle/vppiecelist.cpp | 6 +- src/app/puzzle/vppiecelist.h | 8 +- src/app/puzzle/vpuzzlemaingraphicsview.cpp | 4 +- src/app/puzzle/vpuzzlemaingraphicsview.h | 4 +- src/app/puzzle/xml/vplayoutfilereader.cpp | 10 +-- src/app/puzzle/xml/vplayoutfilereader.h | 14 ++-- src/app/puzzle/xml/vplayoutfilewriter.cpp | 12 +-- src/app/puzzle/xml/vplayoutfilewriter.h | 12 +-- 18 files changed, 97 insertions(+), 97 deletions(-) rename src/app/puzzle/{vpuzzlelayout.cpp => vplayout.cpp} (81%) rename src/app/puzzle/{vpuzzlelayout.h => vplayout.h} (97%) diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index c94dea9cd..b7442b82a 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -13,9 +13,9 @@ SOURCES += \ $$PWD/vpcommands.cpp \ $$PWD/vpgraphicspiece.cpp \ $$PWD/vpgraphicssheet.cpp \ + $$PWD/vplayout.cpp \ $$PWD/vpmainwindow.cpp \ $$PWD/vppiecelist.cpp \ - $$PWD/vpuzzlelayout.cpp \ $$PWD/vpuzzlemaingraphicsview.cpp \ $$PWD/vpuzzlemimedatapiece.cpp \ $$PWD/vpuzzlepiece.cpp \ @@ -37,10 +37,10 @@ HEADERS += \ $$PWD/vpcommands.h \ $$PWD/vpgraphicspiece.h \ $$PWD/vpgraphicssheet.h \ + $$PWD/vplayout.h \ $$PWD/vpmainwindow.h \ $$PWD/vppiecelist.h \ $$PWD/vpstable.h \ - $$PWD/vpuzzlelayout.h \ $$PWD/vpuzzlemaingraphicsview.h \ $$PWD/vpuzzlemimedatapiece.h \ $$PWD/vpuzzlepiece.h \ diff --git a/src/app/puzzle/vpcarrousel.cpp b/src/app/puzzle/vpcarrousel.cpp index f3d8df3aa..8573ce873 100644 --- a/src/app/puzzle/vpcarrousel.cpp +++ b/src/app/puzzle/vpcarrousel.cpp @@ -41,7 +41,7 @@ Q_LOGGING_CATEGORY(pCarrousel, "p.carrousel") //--------------------------------------------------------------------------------------------------------------------- -VPCarrousel::VPCarrousel(VPuzzleLayout *layout, QWidget *parent) : +VPCarrousel::VPCarrousel(VPLayout *layout, QWidget *parent) : QWidget(parent), ui(new Ui::VPCarrousel), m_layout(layout) diff --git a/src/app/puzzle/vpcarrousel.h b/src/app/puzzle/vpcarrousel.h index 6e6b72520..e0ca7cfe6 100644 --- a/src/app/puzzle/vpcarrousel.h +++ b/src/app/puzzle/vpcarrousel.h @@ -32,7 +32,7 @@ #include #include #include -#include "vpuzzlelayout.h" +#include "vplayout.h" #include "vpuzzlepiece.h" namespace Ui @@ -44,7 +44,7 @@ class VPCarrousel : public QWidget { Q_OBJECT public: - explicit VPCarrousel(VPuzzleLayout *layout, QWidget *parent = nullptr); + explicit VPCarrousel(VPLayout *layout, QWidget *parent = nullptr); virtual ~VPCarrousel() = default; /** @@ -79,7 +79,7 @@ private: Q_DISABLE_COPY(VPCarrousel) Ui::VPCarrousel *ui; - VPuzzleLayout *m_layout; + VPLayout *m_layout; QList m_pieceLists{}; Qt::Orientation m_orientation{Qt::Vertical}; diff --git a/src/app/puzzle/vpgraphicspiece.cpp b/src/app/puzzle/vpgraphicspiece.cpp index 970e5a1dd..3908ae3e6 100644 --- a/src/app/puzzle/vpgraphicspiece.cpp +++ b/src/app/puzzle/vpgraphicspiece.cpp @@ -41,7 +41,7 @@ #include "vpuzzlepiece.h" #include "vppiecelist.h" -#include "vpuzzlelayout.h" +#include "vplayout.h" #include Q_LOGGING_CATEGORY(pGraphicsPiece, "p.graphicsPiece") diff --git a/src/app/puzzle/vpgraphicssheet.cpp b/src/app/puzzle/vpgraphicssheet.cpp index e8ca73e16..9919679b1 100644 --- a/src/app/puzzle/vpgraphicssheet.cpp +++ b/src/app/puzzle/vpgraphicssheet.cpp @@ -29,7 +29,7 @@ #include "vpgraphicssheet.h" //--------------------------------------------------------------------------------------------------------------------- -VPGraphicsSheet::VPGraphicsSheet(VPuzzleLayout *layout, QGraphicsItem *parent): +VPGraphicsSheet::VPGraphicsSheet(VPLayout *layout, QGraphicsItem *parent): QGraphicsItem(parent), m_layout(layout), m_boundingRect(GetLayoutRect()) diff --git a/src/app/puzzle/vpgraphicssheet.h b/src/app/puzzle/vpgraphicssheet.h index b57d7001c..01183d97c 100644 --- a/src/app/puzzle/vpgraphicssheet.h +++ b/src/app/puzzle/vpgraphicssheet.h @@ -32,12 +32,12 @@ #include #include -#include "vpuzzlelayout.h" +#include "vplayout.h" class VPGraphicsSheet : public QGraphicsItem { public: - explicit VPGraphicsSheet(VPuzzleLayout *layout, QGraphicsItem *parent = nullptr); + explicit VPGraphicsSheet(VPLayout *layout, QGraphicsItem *parent = nullptr); ~VPGraphicsSheet(); QRectF boundingRect() const override; @@ -51,7 +51,7 @@ public: private: Q_DISABLE_COPY(VPGraphicsSheet) - VPuzzleLayout *m_layout{nullptr}; + VPLayout *m_layout{nullptr}; QRectF m_boundingRect; }; diff --git a/src/app/puzzle/vpuzzlelayout.cpp b/src/app/puzzle/vplayout.cpp similarity index 81% rename from src/app/puzzle/vpuzzlelayout.cpp rename to src/app/puzzle/vplayout.cpp index e57daf39f..b823d45c8 100644 --- a/src/app/puzzle/vpuzzlelayout.cpp +++ b/src/app/puzzle/vplayout.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlelayout.cpp + ** @file vplayout.cpp ** @author Ronan Le Tiec ** @date 13 4, 2020 ** @@ -25,12 +25,12 @@ ** along with Valentina. If not, see . ** *************************************************************************/ -#include "vpuzzlelayout.h" +#include "vplayout.h" #include "vppiecelist.h" #include "vpuzzlepiece.h" //--------------------------------------------------------------------------------------------------------------------- -VPuzzleLayout::VPuzzleLayout() : +VPLayout::VPLayout() : m_unplacedPieceList(new VPPieceList(this)) { m_unplacedPieceList->SetName(QObject::tr("Unplaced pieces")); @@ -45,20 +45,20 @@ VPuzzleLayout::VPuzzleLayout() : } //--------------------------------------------------------------------------------------------------------------------- -VPuzzleLayout::~VPuzzleLayout() +VPLayout::~VPLayout() { qDeleteAll(m_pieceLists); delete m_unplacedPieceList; } //--------------------------------------------------------------------------------------------------------------------- -VPPieceList* VPuzzleLayout::GetUnplacedPieceList() +VPPieceList* VPLayout::GetUnplacedPieceList() { return m_unplacedPieceList; } //--------------------------------------------------------------------------------------------------------------------- -VPPieceList* VPuzzleLayout::AddPieceList() +VPPieceList* VPLayout::AddPieceList() { VPPieceList *newPieceList = new VPPieceList(this); m_pieceLists.append(newPieceList); @@ -66,20 +66,20 @@ VPPieceList* VPuzzleLayout::AddPieceList() } //--------------------------------------------------------------------------------------------------------------------- -VPPieceList* VPuzzleLayout::AddPieceList(VPPieceList *pieceList) +VPPieceList* VPLayout::AddPieceList(VPPieceList *pieceList) { m_pieceLists.append(pieceList); return pieceList; } //--------------------------------------------------------------------------------------------------------------------- -QList VPuzzleLayout::GetPiecesLists() +QList VPLayout::GetPiecesLists() { return m_pieceLists; } //--------------------------------------------------------------------------------------------------------------------- -QList VPuzzleLayout::GetSelectedPieces() +QList VPLayout::GetSelectedPieces() { QList result = QList(); @@ -102,39 +102,39 @@ QList VPuzzleLayout::GetSelectedPieces() //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayout::SetUnit(Unit unit) +void VPLayout::SetUnit(Unit unit) { m_unit = unit; } //--------------------------------------------------------------------------------------------------------------------- -Unit VPuzzleLayout::GetUnit() const +Unit VPLayout::GetUnit() const { return m_unit; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayout::SetLayoutSize(qreal width, qreal height) +void VPLayout::SetLayoutSize(qreal width, qreal height) { m_size.setWidth(width); m_size.setHeight(height); } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayout::SetLayoutSizeConverted(qreal width, qreal height) +void VPLayout::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) +void VPLayout::SetLayoutSize(const QSizeF &size) { m_size = size; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayout::SetLayoutSizeConverted(const QSizeF &size) +void VPLayout::SetLayoutSizeConverted(const QSizeF &size) { m_size = QSizeF( UnitConvertor(size.width(), m_unit, Unit::Px), @@ -143,13 +143,13 @@ void VPuzzleLayout::SetLayoutSizeConverted(const QSizeF &size) } //--------------------------------------------------------------------------------------------------------------------- -QSizeF VPuzzleLayout::GetLayoutSize() const +QSizeF VPLayout::GetLayoutSize() const { return m_size; } //--------------------------------------------------------------------------------------------------------------------- -QSizeF VPuzzleLayout::GetLayoutSizeConverted() const +QSizeF VPLayout::GetLayoutSizeConverted() const { QSizeF convertedSize = QSizeF( UnitConvertor(m_size.width(), Unit::Px, m_unit), @@ -160,7 +160,7 @@ QSizeF VPuzzleLayout::GetLayoutSizeConverted() const } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayout::SetLayoutMargins(qreal left, qreal top, qreal right, qreal bottom) +void VPLayout::SetLayoutMargins(qreal left, qreal top, qreal right, qreal bottom) { m_margins.setLeft(left); m_margins.setTop(top); @@ -168,7 +168,7 @@ void VPuzzleLayout::SetLayoutMargins(qreal left, qreal top, qreal right, qreal b m_margins.setBottom(bottom); } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayout::SetLayoutMarginsConverted(qreal left, qreal top, qreal right, qreal bottom) +void VPLayout::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)); @@ -177,103 +177,103 @@ void VPuzzleLayout::SetLayoutMarginsConverted(qreal left, qreal top, qreal right } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayout::SetLayoutMargins(const QMarginsF &margins) +void VPLayout::SetLayoutMargins(const QMarginsF &margins) { m_margins = margins; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayout::SetLayoutMarginsConverted(const QMarginsF &margins) +void VPLayout::SetLayoutMarginsConverted(const QMarginsF &margins) { m_margins = UnitConvertor(margins, m_unit, Unit::Px); } //--------------------------------------------------------------------------------------------------------------------- -QMarginsF VPuzzleLayout::GetLayoutMargins() const +QMarginsF VPLayout::GetLayoutMargins() const { return m_margins; } //--------------------------------------------------------------------------------------------------------------------- -QMarginsF VPuzzleLayout::GetLayoutMarginsConverted() const +QMarginsF VPLayout::GetLayoutMarginsConverted() const { return UnitConvertor(m_margins, Unit::Px, m_unit); } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayout::SetFollowGrainline(FollowGrainline state) +void VPLayout::SetFollowGrainline(FollowGrainline state) { m_followGrainLine = state; } //--------------------------------------------------------------------------------------------------------------------- -FollowGrainline VPuzzleLayout::GetFollowGrainline() const +FollowGrainline VPLayout::GetFollowGrainline() const { return m_followGrainLine; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayout::SetPiecesGap(qreal value) +void VPLayout::SetPiecesGap(qreal value) { m_piecesGap = value; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayout::SetPiecesGapConverted(qreal value) +void VPLayout::SetPiecesGapConverted(qreal value) { m_piecesGap = UnitConvertor(value, m_unit, Unit::Px); } //--------------------------------------------------------------------------------------------------------------------- -qreal VPuzzleLayout::GetPiecesGap() const +qreal VPLayout::GetPiecesGap() const { return m_piecesGap; } //--------------------------------------------------------------------------------------------------------------------- -qreal VPuzzleLayout::GetPiecesGapConverted() const +qreal VPLayout::GetPiecesGapConverted() const { return UnitConvertor(m_piecesGap, Unit::Px, m_unit); } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayout::SetWarningSuperpositionOfPieces(bool state) +void VPLayout::SetWarningSuperpositionOfPieces(bool state) { m_warningSuperpositionOfPieces = state; } //--------------------------------------------------------------------------------------------------------------------- -bool VPuzzleLayout::GetWarningSuperpositionOfPieces() const +bool VPLayout::GetWarningSuperpositionOfPieces() const { return m_warningSuperpositionOfPieces; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayout::SetWarningPiecesOutOfBound(bool state) +void VPLayout::SetWarningPiecesOutOfBound(bool state) { m_warningPiecesOutOfBound = state; } //--------------------------------------------------------------------------------------------------------------------- -bool VPuzzleLayout::GetWarningPiecesOutOfBound() const +bool VPLayout::GetWarningPiecesOutOfBound() const { return m_warningPiecesOutOfBound; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayout::SetStickyEdges(bool state) +void VPLayout::SetStickyEdges(bool state) { m_stickyEdges = state; } //--------------------------------------------------------------------------------------------------------------------- -bool VPuzzleLayout::GetStickyEdges() const +bool VPLayout::GetStickyEdges() const { return m_stickyEdges; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayout::ClearSelection() +void VPLayout::ClearSelection() { m_unplacedPieceList->ClearSelection(); @@ -284,7 +284,7 @@ void VPuzzleLayout::ClearSelection() } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayout::SetFocusedPieceList(VPPieceList* focusedPieceList) +void VPLayout::SetFocusedPieceList(VPPieceList* focusedPieceList) { if(focusedPieceList == nullptr) { @@ -297,13 +297,13 @@ void VPuzzleLayout::SetFocusedPieceList(VPPieceList* focusedPieceList) } //--------------------------------------------------------------------------------------------------------------------- -VPPieceList* VPuzzleLayout::GetFocusedPieceList() +VPPieceList* VPLayout::GetFocusedPieceList() { return m_focusedPieceList; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleLayout::MovePieceToPieceList(VPuzzlePiece* piece, VPPieceList* pieceList) +void VPLayout::MovePieceToPieceList(VPuzzlePiece* piece, VPPieceList* pieceList) { VPPieceList* pieceListBefore = piece->GetPieceList(); diff --git a/src/app/puzzle/vpuzzlelayout.h b/src/app/puzzle/vplayout.h similarity index 97% rename from src/app/puzzle/vpuzzlelayout.h rename to src/app/puzzle/vplayout.h index 33ef12b8e..7c45a29ff 100644 --- a/src/app/puzzle/vpuzzlelayout.h +++ b/src/app/puzzle/vplayout.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlelayout.h + ** @file vplayout.h ** @author Ronan Le Tiec ** @date 13 4, 2020 ** @@ -25,8 +25,8 @@ ** along with Valentina. If not, see . ** *************************************************************************/ -#ifndef VPUZZLELAYOUT_H -#define VPUZZLELAYOUT_H +#ifndef VPLAYOUT_H +#define VPLAYOUT_H #include #include @@ -40,12 +40,12 @@ class VPuzzlePiece; // is this the right place for the definition? enum class FollowGrainline : qint8 { No = 0, Follow90 = 1, Follow180 = 2}; -class VPuzzleLayout : public QObject +class VPLayout : public QObject { Q_OBJECT public: - VPuzzleLayout(); - virtual ~VPuzzleLayout(); + VPLayout(); + virtual ~VPLayout(); /** * @brief GetUnplacedPieceList Returns the piece list of unplaced pieces @@ -231,7 +231,7 @@ signals: void PieceMovedToPieceList(VPuzzlePiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter); private: - Q_DISABLE_COPY(VPuzzleLayout) + Q_DISABLE_COPY(VPLayout) VPPieceList *m_unplacedPieceList; QList m_pieceLists{}; @@ -268,4 +268,4 @@ private: }; -#endif // VPUZZLELAYOUT_H +#endif // VPLAYOUT_H diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index db79905f7..39c634f95 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -58,7 +58,7 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) : m_cmd(cmd) { - m_layout = new VPuzzleLayout(); + m_layout = new VPLayout(); // ----- for test purposes, to be removed------------------ m_layout->SetLayoutMarginsConverted(2, 2, 2, 2); @@ -110,7 +110,7 @@ bool VPMainWindow::LoadFile(QString path) if(m_layout == nullptr) { - m_layout = new VPuzzleLayout(); + m_layout = new VPLayout(); } fileReader->ReadFile(m_layout, &file); diff --git a/src/app/puzzle/vpmainwindow.h b/src/app/puzzle/vpmainwindow.h index 1824b960f..7ec2d1ac0 100644 --- a/src/app/puzzle/vpmainwindow.h +++ b/src/app/puzzle/vpmainwindow.h @@ -35,7 +35,7 @@ #include "../vmisc/def.h" #include "vpcarrousel.h" #include "vpuzzlemaingraphicsview.h" -#include "vpuzzlelayout.h" +#include "vplayout.h" #include "vpuzzlepiece.h" #include "../vlayout/vlayoutpiece.h" #include "vpcommandline.h" @@ -95,7 +95,7 @@ private: VPCommandLinePtr m_cmd; - VPuzzleLayout *m_layout{nullptr}; + VPLayout *m_layout{nullptr}; QListm_selectedPieces{QList()}; /** diff --git a/src/app/puzzle/vppiecelist.cpp b/src/app/puzzle/vppiecelist.cpp index ee43ad220..85c25454b 100644 --- a/src/app/puzzle/vppiecelist.cpp +++ b/src/app/puzzle/vppiecelist.cpp @@ -27,14 +27,14 @@ *************************************************************************/ #include "vppiecelist.h" -#include "vpuzzlelayout.h" +#include "vplayout.h" #include Q_LOGGING_CATEGORY(pPieceList, "p.pieceList") //--------------------------------------------------------------------------------------------------------------------- -VPPieceList::VPPieceList(VPuzzleLayout *layout): +VPPieceList::VPPieceList(VPLayout *layout): m_layout(layout) { @@ -47,7 +47,7 @@ VPPieceList::~VPPieceList() } //--------------------------------------------------------------------------------------------------------------------- -VPuzzleLayout* VPPieceList::GetLayout() +VPLayout* VPPieceList::GetLayout() { return m_layout; } diff --git a/src/app/puzzle/vppiecelist.h b/src/app/puzzle/vppiecelist.h index 9c6043f3b..384f1b81f 100644 --- a/src/app/puzzle/vppiecelist.h +++ b/src/app/puzzle/vppiecelist.h @@ -31,13 +31,13 @@ #include #include "vpuzzlepiece.h" -class VPuzzleLayout; +class VPLayout; class VPPieceList : public QObject { Q_OBJECT public: - VPPieceList(VPuzzleLayout *layout); + VPPieceList(VPLayout *layout); ~VPPieceList(); QList GetPieces(); @@ -57,7 +57,7 @@ public: * @brief GetLayout Returns the layout in which this piece list is * @return the layout of this piece list */ - VPuzzleLayout* GetLayout(); + VPLayout* GetLayout(); /** * @brief ClearSelection Clears the selection of the pieces in this piece list @@ -81,7 +81,7 @@ private: QString m_name{}; QList m_pieces{}; - VPuzzleLayout *m_layout{nullptr}; + VPLayout *m_layout{nullptr}; // control bool m_isVisible{true}; diff --git a/src/app/puzzle/vpuzzlemaingraphicsview.cpp b/src/app/puzzle/vpuzzlemaingraphicsview.cpp index 4b1fc57f1..53a80e1e4 100644 --- a/src/app/puzzle/vpuzzlemaingraphicsview.cpp +++ b/src/app/puzzle/vpuzzlemaingraphicsview.cpp @@ -42,7 +42,7 @@ Q_LOGGING_CATEGORY(pMainGraphicsView, "p.mainGraphicsView") //--------------------------------------------------------------------------------------------------------------------- -VPuzzleMainGraphicsView::VPuzzleMainGraphicsView(VPuzzleLayout *layout, QWidget *parent) : +VPuzzleMainGraphicsView::VPuzzleMainGraphicsView(VPLayout *layout, QWidget *parent) : VMainGraphicsView(parent), m_layout(layout) { @@ -56,7 +56,7 @@ VPuzzleMainGraphicsView::VPuzzleMainGraphicsView(VPuzzleLayout *layout, QWidget setAcceptDrops(true); // add the connections - connect(m_layout, &VPuzzleLayout::PieceMovedToPieceList, this, &VPuzzleMainGraphicsView::on_PieceMovedToPieceList); + connect(m_layout, &VPLayout::PieceMovedToPieceList, this, &VPuzzleMainGraphicsView::on_PieceMovedToPieceList); connect(m_scene, &VMainGraphicsScene::selectionChanged, this, &VPuzzleMainGraphicsView::on_SceneSelectionChanged); } diff --git a/src/app/puzzle/vpuzzlemaingraphicsview.h b/src/app/puzzle/vpuzzlemaingraphicsview.h index ce181ec04..7fc605d7c 100644 --- a/src/app/puzzle/vpuzzlemaingraphicsview.h +++ b/src/app/puzzle/vpuzzlemaingraphicsview.h @@ -40,7 +40,7 @@ class VPuzzleMainGraphicsView : public VMainGraphicsView { Q_OBJECT public: - VPuzzleMainGraphicsView(VPuzzleLayout *layout, QWidget *parent); + VPuzzleMainGraphicsView(VPLayout *layout, QWidget *parent); ~VPuzzleMainGraphicsView() = default; /** @@ -77,7 +77,7 @@ private: VMainGraphicsScene *m_scene{nullptr}; VPGraphicsSheet *m_graphicsSheet{nullptr}; - VPuzzleLayout *m_layout{nullptr}; + VPLayout *m_layout{nullptr}; QList m_graphicsPieces{}; diff --git a/src/app/puzzle/xml/vplayoutfilereader.cpp b/src/app/puzzle/xml/vplayoutfilereader.cpp index fc41231d8..722cb8c73 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.cpp +++ b/src/app/puzzle/xml/vplayoutfilereader.cpp @@ -47,7 +47,7 @@ VPLayoutFileReader::~VPLayoutFileReader() //--------------------------------------------------------------------------------------------------------------------- -bool VPLayoutFileReader::ReadFile(VPuzzleLayout *layout, QFile *file) +bool VPLayoutFileReader::ReadFile(VPLayout *layout, QFile *file) { setDevice(file); @@ -60,7 +60,7 @@ bool VPLayoutFileReader::ReadFile(VPuzzleLayout *layout, QFile *file) } //--------------------------------------------------------------------------------------------------------------------- -void VPLayoutFileReader::ReadLayout(VPuzzleLayout *layout) +void VPLayoutFileReader::ReadLayout(VPLayout *layout) { SCASSERT(isStartElement() && name() == ML::TagLayout); @@ -82,7 +82,7 @@ void VPLayoutFileReader::ReadLayout(VPuzzleLayout *layout) } //--------------------------------------------------------------------------------------------------------------------- -void VPLayoutFileReader::ReadProperties(VPuzzleLayout *layout) +void VPLayoutFileReader::ReadProperties(VPLayout *layout) { SCASSERT(isStartElement() && name() == ML::TagProperties); @@ -158,7 +158,7 @@ void VPLayoutFileReader::ReadProperties(VPuzzleLayout *layout) } //--------------------------------------------------------------------------------------------------------------------- -void VPLayoutFileReader::ReadTiles(VPuzzleLayout *layout) +void VPLayoutFileReader::ReadTiles(VPLayout *layout) { Q_UNUSED(layout); // to be removed when used @@ -193,7 +193,7 @@ void VPLayoutFileReader::ReadTiles(VPuzzleLayout *layout) } //--------------------------------------------------------------------------------------------------------------------- -void VPLayoutFileReader::ReadPieceLists(VPuzzleLayout *layout) +void VPLayoutFileReader::ReadPieceLists(VPLayout *layout) { SCASSERT(isStartElement() && name() == ML::TagPieceLists); diff --git a/src/app/puzzle/xml/vplayoutfilereader.h b/src/app/puzzle/xml/vplayoutfilereader.h index a161bc5e6..d340811b9 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.h +++ b/src/app/puzzle/xml/vplayoutfilereader.h @@ -31,26 +31,26 @@ #include #include "../ifc/xml/vabstractconverter.h" -#include "vpuzzlelayout.h" +#include "vplayout.h" #include "vppiecelist.h" #include "vpuzzlepiece.h" class VPLayoutFileReader : public QXmlStreamReader { - Q_DECLARE_TR_FUNCTIONS(VPuzzleLayoutFileReader) + Q_DECLARE_TR_FUNCTIONS(VPLayoutFileReader) public: VPLayoutFileReader(); ~VPLayoutFileReader(); - bool ReadFile(VPuzzleLayout *layout, QFile *file); + bool ReadFile(VPLayout *layout, QFile *file); private: Q_DISABLE_COPY(VPLayoutFileReader) - void ReadLayout(VPuzzleLayout *layout); - void ReadProperties(VPuzzleLayout *layout); - void ReadTiles(VPuzzleLayout *layout); - void ReadPieceLists(VPuzzleLayout *layout); + void ReadLayout(VPLayout *layout); + void ReadProperties(VPLayout *layout); + void ReadTiles(VPLayout *layout); + void ReadPieceLists(VPLayout *layout); void ReadPieceList(VPPieceList *pieceList); void ReadPiece(VPuzzlePiece *piece); diff --git a/src/app/puzzle/xml/vplayoutfilewriter.cpp b/src/app/puzzle/xml/vplayoutfilewriter.cpp index bd6a05202..97d738928 100644 --- a/src/app/puzzle/xml/vplayoutfilewriter.cpp +++ b/src/app/puzzle/xml/vplayoutfilewriter.cpp @@ -27,7 +27,7 @@ *************************************************************************/ #include "vplayoutfilewriter.h" -#include "vpuzzlelayout.h" +#include "vplayout.h" #include "vppiecelist.h" #include "vpuzzlepiece.h" #include "vplayoutliterals.h" @@ -46,7 +46,7 @@ VPLayoutFileWriter::~VPLayoutFileWriter() } //--------------------------------------------------------------------------------------------------------------------- -void VPLayoutFileWriter::WriteFile(VPuzzleLayout *layout, QFile *file) +void VPLayoutFileWriter::WriteFile(VPLayout *layout, QFile *file) { setDevice(file); setAutoFormatting(true); @@ -59,7 +59,7 @@ void VPLayoutFileWriter::WriteFile(VPuzzleLayout *layout, QFile *file) } //--------------------------------------------------------------------------------------------------------------------- -void VPLayoutFileWriter::WriteLayout(VPuzzleLayout *layout) +void VPLayoutFileWriter::WriteLayout(VPLayout *layout) { writeStartElement(ML::TagLayout); SetAttribute(ML::AttrVersion, VLayoutConverter::LayoutMaxVerStr); @@ -71,7 +71,7 @@ void VPLayoutFileWriter::WriteLayout(VPuzzleLayout *layout) } //--------------------------------------------------------------------------------------------------------------------- -void VPLayoutFileWriter::WriteProperties(VPuzzleLayout *layout) +void VPLayoutFileWriter::WriteProperties(VPLayout *layout) { writeStartElement(ML::TagProperties); @@ -97,7 +97,7 @@ void VPLayoutFileWriter::WriteProperties(VPuzzleLayout *layout) } //--------------------------------------------------------------------------------------------------------------------- -void VPLayoutFileWriter::WriteTiles(VPuzzleLayout *layout) +void VPLayoutFileWriter::WriteTiles(VPLayout *layout) { Q_UNUSED(layout); // to be removed @@ -116,7 +116,7 @@ void VPLayoutFileWriter::WriteTiles(VPuzzleLayout *layout) //--------------------------------------------------------------------------------------------------------------------- -void VPLayoutFileWriter::WritePieceLists(VPuzzleLayout *layout) +void VPLayoutFileWriter::WritePieceLists(VPLayout *layout) { writeStartElement(ML::TagPieceLists); diff --git a/src/app/puzzle/xml/vplayoutfilewriter.h b/src/app/puzzle/xml/vplayoutfilewriter.h index 4fc4f646b..522b2ad8a 100644 --- a/src/app/puzzle/xml/vplayoutfilewriter.h +++ b/src/app/puzzle/xml/vplayoutfilewriter.h @@ -34,7 +34,7 @@ #include "../vmisc/literals.h" -class VPuzzleLayout; +class VPLayout; class VPPieceList; class VPuzzlePiece; class QFile; @@ -46,14 +46,14 @@ public: VPLayoutFileWriter(); ~VPLayoutFileWriter(); - void WriteFile(VPuzzleLayout *layout, QFile *file); + void WriteFile(VPLayout *layout, QFile *file); private: - void WriteLayout(VPuzzleLayout *layout); - void WriteProperties(VPuzzleLayout *layout); - void WriteTiles(VPuzzleLayout *layout); - void WritePieceLists(VPuzzleLayout *layout); + void WriteLayout(VPLayout *layout); + void WriteProperties(VPLayout *layout); + void WriteTiles(VPLayout *layout); + void WritePieceLists(VPLayout *layout); void WritePieceList(VPPieceList *pieceList); void WritePieceList(VPPieceList *pieceList, const QString &tagName); void WritePiece(VPuzzlePiece *piece); From 2accd83d6bc7bde7aa95bdcf83505335d0a59ad1 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 15:36:46 +0200 Subject: [PATCH 20/28] Refactoring VPuzzleMainGraphicsView --- src/app/puzzle/puzzle.pri | 4 +-- ...raphicsview.cpp => vpmaingraphicsview.cpp} | 26 +++++++++---------- ...aingraphicsview.h => vpmaingraphicsview.h} | 16 ++++++------ src/app/puzzle/vpmainwindow.cpp | 2 +- src/app/puzzle/vpmainwindow.h | 4 +-- 5 files changed, 26 insertions(+), 26 deletions(-) rename src/app/puzzle/{vpuzzlemaingraphicsview.cpp => vpmaingraphicsview.cpp} (87%) rename src/app/puzzle/{vpuzzlemaingraphicsview.h => vpmaingraphicsview.h} (87%) diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index b7442b82a..8e111294e 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -14,9 +14,9 @@ SOURCES += \ $$PWD/vpgraphicspiece.cpp \ $$PWD/vpgraphicssheet.cpp \ $$PWD/vplayout.cpp \ + $$PWD/vpmaingraphicsview.cpp \ $$PWD/vpmainwindow.cpp \ $$PWD/vppiecelist.cpp \ - $$PWD/vpuzzlemaingraphicsview.cpp \ $$PWD/vpuzzlemimedatapiece.cpp \ $$PWD/vpuzzlepiece.cpp \ $$PWD/vpuzzlesettings.cpp \ @@ -38,10 +38,10 @@ HEADERS += \ $$PWD/vpgraphicspiece.h \ $$PWD/vpgraphicssheet.h \ $$PWD/vplayout.h \ + $$PWD/vpmaingraphicsview.h \ $$PWD/vpmainwindow.h \ $$PWD/vppiecelist.h \ $$PWD/vpstable.h \ - $$PWD/vpuzzlemaingraphicsview.h \ $$PWD/vpuzzlemimedatapiece.h \ $$PWD/vpuzzlepiece.h \ $$PWD/vpuzzlesettings.h \ diff --git a/src/app/puzzle/vpuzzlemaingraphicsview.cpp b/src/app/puzzle/vpmaingraphicsview.cpp similarity index 87% rename from src/app/puzzle/vpuzzlemaingraphicsview.cpp rename to src/app/puzzle/vpmaingraphicsview.cpp index 53a80e1e4..97d39ac57 100644 --- a/src/app/puzzle/vpuzzlemaingraphicsview.cpp +++ b/src/app/puzzle/vpmaingraphicsview.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlemaingraphicsview.cpp + ** @file vpmaingraphicsview.cpp ** @author Ronan Le Tiec ** @date 3 5, 2020 ** @@ -26,7 +26,7 @@ ** *************************************************************************/ -#include "vpuzzlemaingraphicsview.h" +#include "vpmaingraphicsview.h" #include #include @@ -42,7 +42,7 @@ Q_LOGGING_CATEGORY(pMainGraphicsView, "p.mainGraphicsView") //--------------------------------------------------------------------------------------------------------------------- -VPuzzleMainGraphicsView::VPuzzleMainGraphicsView(VPLayout *layout, QWidget *parent) : +VPMainGraphicsView::VPMainGraphicsView(VPLayout *layout, QWidget *parent) : VMainGraphicsView(parent), m_layout(layout) { @@ -56,13 +56,13 @@ VPuzzleMainGraphicsView::VPuzzleMainGraphicsView(VPLayout *layout, QWidget *pare setAcceptDrops(true); // add the connections - connect(m_layout, &VPLayout::PieceMovedToPieceList, this, &VPuzzleMainGraphicsView::on_PieceMovedToPieceList); + connect(m_layout, &VPLayout::PieceMovedToPieceList, this, &VPMainGraphicsView::on_PieceMovedToPieceList); 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? @@ -72,7 +72,7 @@ void VPuzzleMainGraphicsView::RefreshLayout() } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleMainGraphicsView::dragEnterEvent(QDragEnterEvent *event) +void VPMainGraphicsView::dragEnterEvent(QDragEnterEvent *event) { const QMimeData *mime = event->mimeData(); @@ -84,7 +84,7 @@ void VPuzzleMainGraphicsView::dragEnterEvent(QDragEnterEvent *event) } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleMainGraphicsView::dragMoveEvent(QDragMoveEvent *event) +void VPMainGraphicsView::dragMoveEvent(QDragMoveEvent *event) { const QMimeData *mime = event->mimeData(); @@ -95,7 +95,7 @@ void VPuzzleMainGraphicsView::dragMoveEvent(QDragMoveEvent *event) } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleMainGraphicsView::dragLeaveEvent(QDragLeaveEvent *event) +void VPMainGraphicsView::dragLeaveEvent(QDragLeaveEvent *event) { event->accept(); } @@ -103,7 +103,7 @@ void VPuzzleMainGraphicsView::dragLeaveEvent(QDragLeaveEvent *event) //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleMainGraphicsView::dropEvent(QDropEvent *event) +void VPMainGraphicsView::dropEvent(QDropEvent *event) { const QMimeData *mime = event->mimeData(); @@ -133,7 +133,7 @@ void VPuzzleMainGraphicsView::dropEvent(QDropEvent *event) } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleMainGraphicsView::keyPressEvent(QKeyEvent *event) +void VPMainGraphicsView::keyPressEvent(QKeyEvent *event) { if(event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete) { @@ -153,7 +153,7 @@ void VPuzzleMainGraphicsView::keyPressEvent(QKeyEvent *event) } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleMainGraphicsView::on_PieceMovedToPieceList(VPuzzlePiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter) +void VPMainGraphicsView::on_PieceMovedToPieceList(VPuzzlePiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter) { Q_UNUSED(pieceListBefore) @@ -188,7 +188,7 @@ void VPuzzleMainGraphicsView::on_PieceMovedToPieceList(VPuzzlePiece *piece, VPPi } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleMainGraphicsView::on_SceneSelectionChanged() +void VPMainGraphicsView::on_SceneSelectionChanged() { // 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 diff --git a/src/app/puzzle/vpuzzlemaingraphicsview.h b/src/app/puzzle/vpmaingraphicsview.h similarity index 87% rename from src/app/puzzle/vpuzzlemaingraphicsview.h rename to src/app/puzzle/vpmaingraphicsview.h index 7fc605d7c..ac802549d 100644 --- a/src/app/puzzle/vpuzzlemaingraphicsview.h +++ b/src/app/puzzle/vpmaingraphicsview.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlemaingraphicsview.h + ** @file vpmaingraphicsview.h ** @author Ronan Le Tiec ** @date 3 5, 2020 ** @@ -26,8 +26,8 @@ ** *************************************************************************/ -#ifndef VPUZZLEMAINGRAPHICSVIEW_H -#define VPUZZLEMAINGRAPHICSVIEW_H +#ifndef VPMAINGRAPHICSVIEW_H +#define VPMAINGRAPHICSVIEW_H #include "vpgraphicssheet.h" #include "vpgraphicspiece.h" @@ -36,12 +36,12 @@ class VMainGraphicsScene; -class VPuzzleMainGraphicsView : public VMainGraphicsView +class VPMainGraphicsView : public VMainGraphicsView { Q_OBJECT public: - VPuzzleMainGraphicsView(VPLayout *layout, QWidget *parent); - ~VPuzzleMainGraphicsView() = default; + VPMainGraphicsView(VPLayout *layout, QWidget *parent); + ~VPMainGraphicsView() = default; /** * @brief RefreshLayout Refreshes the rectangles for the layout border and the margin @@ -72,7 +72,7 @@ private slots: void on_SceneSelectionChanged(); private: - Q_DISABLE_COPY(VPuzzleMainGraphicsView) + Q_DISABLE_COPY(VPMainGraphicsView) VMainGraphicsScene *m_scene{nullptr}; @@ -83,4 +83,4 @@ private: }; -#endif // VPUZZLEMAINGRAPHICVIEW_H +#endif // VPMAINGRAPHICSVIEW_H diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index 39c634f95..24ce82e64 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -436,7 +436,7 @@ void VPMainWindow::SetPropertyTabTilesData() //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::InitMainGraphics() { - m_graphicsView = new VPuzzleMainGraphicsView(m_layout, this); + m_graphicsView = new VPMainGraphicsView(m_layout, this); ui->centralWidget->layout()->addWidget(m_graphicsView); m_graphicsView->RefreshLayout(); diff --git a/src/app/puzzle/vpmainwindow.h b/src/app/puzzle/vpmainwindow.h index 7ec2d1ac0..a2c7cd962 100644 --- a/src/app/puzzle/vpmainwindow.h +++ b/src/app/puzzle/vpmainwindow.h @@ -34,7 +34,7 @@ #include "../vmisc/def.h" #include "vpcarrousel.h" -#include "vpuzzlemaingraphicsview.h" +#include "vpmaingraphicsview.h" #include "vplayout.h" #include "vpuzzlepiece.h" #include "../vlayout/vlayoutpiece.h" @@ -91,7 +91,7 @@ private: Ui::VPMainWindow *ui; VPCarrousel *m_carrousel{nullptr}; - VPuzzleMainGraphicsView *m_graphicsView{nullptr}; + VPMainGraphicsView *m_graphicsView{nullptr}; VPCommandLinePtr m_cmd; From 6079d69c93d98a668754968d24c0279c6fd7a377 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 15:38:59 +0200 Subject: [PATCH 21/28] Refactoring VPuzzleMimeDataPiece --- src/app/puzzle/puzzle.pri | 4 ++-- src/app/puzzle/vpcarrouselpiece.cpp | 4 ++-- src/app/puzzle/vpmaingraphicsview.cpp | 4 ++-- ...zzlemimedatapiece.cpp => vpmimedatapiece.cpp} | 12 ++++++------ ...{vpuzzlemimedatapiece.h => vpmimedatapiece.h} | 16 ++++++++-------- 5 files changed, 20 insertions(+), 20 deletions(-) rename src/app/puzzle/{vpuzzlemimedatapiece.cpp => vpmimedatapiece.cpp} (85%) rename src/app/puzzle/{vpuzzlemimedatapiece.h => vpmimedatapiece.h} (85%) diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index 8e111294e..5fe7c72a1 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -16,8 +16,8 @@ SOURCES += \ $$PWD/vplayout.cpp \ $$PWD/vpmaingraphicsview.cpp \ $$PWD/vpmainwindow.cpp \ + $$PWD/vpmimedatapiece.cpp \ $$PWD/vppiecelist.cpp \ - $$PWD/vpuzzlemimedatapiece.cpp \ $$PWD/vpuzzlepiece.cpp \ $$PWD/vpuzzlesettings.cpp \ $$PWD/xml/vplayoutfilereader.cpp \ @@ -40,9 +40,9 @@ HEADERS += \ $$PWD/vplayout.h \ $$PWD/vpmaingraphicsview.h \ $$PWD/vpmainwindow.h \ + $$PWD/vpmimedatapiece.h \ $$PWD/vppiecelist.h \ $$PWD/vpstable.h \ - $$PWD/vpuzzlemimedatapiece.h \ $$PWD/vpuzzlepiece.h \ $$PWD/vpuzzlesettings.h \ $$PWD/xml/vplayoutfilereader.h \ diff --git a/src/app/puzzle/vpcarrouselpiece.cpp b/src/app/puzzle/vpcarrouselpiece.cpp index 3eec52e79..83ee455e6 100644 --- a/src/app/puzzle/vpcarrouselpiece.cpp +++ b/src/app/puzzle/vpcarrouselpiece.cpp @@ -37,7 +37,7 @@ #include #include -#include "vpuzzlemimedatapiece.h" +#include "vpmimedatapiece.h" #include "vpcarrouselpiecelist.h" #include "vpcarrousel.h" @@ -212,7 +212,7 @@ void VPCarrouselPiece::mouseMoveEvent(QMouseEvent *event) // starts the dragging QDrag *drag = new QDrag(this); - VPuzzleMimeDataPiece *mimeData = new VPuzzleMimeDataPiece(); + VPMimeDataPiece *mimeData = new VPMimeDataPiece(); mimeData->SetPiecePtr(m_piece); mimeData->setObjectName("piecePointer"); diff --git a/src/app/puzzle/vpmaingraphicsview.cpp b/src/app/puzzle/vpmaingraphicsview.cpp index 97d39ac57..2100a1e27 100644 --- a/src/app/puzzle/vpmaingraphicsview.cpp +++ b/src/app/puzzle/vpmaingraphicsview.cpp @@ -32,7 +32,7 @@ #include #include -#include "vpuzzlemimedatapiece.h" +#include "vpmimedatapiece.h" #include "vppiecelist.h" #include "../vwidgets/vmaingraphicsscene.h" @@ -111,7 +111,7 @@ void VPMainGraphicsView::dropEvent(QDropEvent *event) if(mime->objectName() == "piecePointer") { - const VPuzzleMimeDataPiece *mimePiece = qobject_cast (mime); + const VPMimeDataPiece *mimePiece = qobject_cast (mime); VPuzzlePiece *piece = mimePiece->GetPiecePtr(); if(piece != nullptr) diff --git a/src/app/puzzle/vpuzzlemimedatapiece.cpp b/src/app/puzzle/vpmimedatapiece.cpp similarity index 85% rename from src/app/puzzle/vpuzzlemimedatapiece.cpp rename to src/app/puzzle/vpmimedatapiece.cpp index 873d500c8..5f7cb6c4b 100644 --- a/src/app/puzzle/vpuzzlemimedatapiece.cpp +++ b/src/app/puzzle/vpmimedatapiece.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlemimedatapiece.cpp + ** @file vpmimedatapiece.cpp ** @author Ronan Le Tiec ** @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 +VPuzzlePiece* VPMimeDataPiece::GetPiecePtr() const { return m_piece; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleMimeDataPiece::SetPiecePtr(VPuzzlePiece* piece) +void VPMimeDataPiece::SetPiecePtr(VPuzzlePiece* piece) { m_piece = piece; } diff --git a/src/app/puzzle/vpuzzlemimedatapiece.h b/src/app/puzzle/vpmimedatapiece.h similarity index 85% rename from src/app/puzzle/vpuzzlemimedatapiece.h rename to src/app/puzzle/vpmimedatapiece.h index 8246c604b..f1bba271e 100644 --- a/src/app/puzzle/vpuzzlemimedatapiece.h +++ b/src/app/puzzle/vpmimedatapiece.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlemimedatapiece.h + ** @file vpmimedatapiece.h ** @author Ronan Le Tiec ** @date 4 5, 2020 ** @@ -26,21 +26,21 @@ ** *************************************************************************/ -#ifndef VPUZZLEMIMEDATAPIECE_H -#define VPUZZLEMIMEDATAPIECE_H +#ifndef VPMIMEDATAPIECE_H +#define VPMIMEDATAPIECE_H #include #include "vpuzzlepiece.h" -class VPuzzleMimeDataPiece : public QMimeData +class VPMimeDataPiece : public QMimeData { Q_OBJECT public: - VPuzzleMimeDataPiece(); - ~VPuzzleMimeDataPiece(); + VPMimeDataPiece(); + ~VPMimeDataPiece(); /** * @brief GetPiecePtr Returns the piece pointer of the mime data @@ -55,11 +55,11 @@ public: void SetPiecePtr(VPuzzlePiece* piece); private: - Q_DISABLE_COPY(VPuzzleMimeDataPiece) + Q_DISABLE_COPY(VPMimeDataPiece) VPuzzlePiece *m_piece{nullptr}; }; -#endif // VPUZZLEMIMEDATAPIECE_H +#endif // VPMIMEDATAPIECE_H From 83666c090f30db04e19ccb5b8eb164246b78f069 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 15:42:51 +0200 Subject: [PATCH 22/28] Refactoring VPuzzlePiece --- src/app/puzzle/puzzle.pri | 4 +- src/app/puzzle/vpcarrousel.cpp | 2 +- src/app/puzzle/vpcarrousel.h | 2 +- src/app/puzzle/vpcarrouselpiece.cpp | 6 +- src/app/puzzle/vpcarrouselpiece.h | 8 +-- src/app/puzzle/vpcarrouselpiecelist.cpp | 8 +-- src/app/puzzle/vpcarrouselpiecelist.h | 4 +- src/app/puzzle/vpgraphicspiece.cpp | 12 ++-- src/app/puzzle/vpgraphicspiece.h | 8 +-- src/app/puzzle/vplayout.cpp | 8 +-- src/app/puzzle/vplayout.h | 8 +-- src/app/puzzle/vpmaingraphicsview.cpp | 6 +- src/app/puzzle/vpmaingraphicsview.h | 2 +- src/app/puzzle/vpmainwindow.cpp | 22 +++---- src/app/puzzle/vpmainwindow.h | 6 +- src/app/puzzle/vpmimedatapiece.cpp | 4 +- src/app/puzzle/vpmimedatapiece.h | 8 +-- .../puzzle/{vpuzzlepiece.cpp => vppiece.cpp} | 62 +++++++++---------- src/app/puzzle/{vpuzzlepiece.h => vppiece.h} | 16 ++--- src/app/puzzle/vppiecelist.cpp | 6 +- src/app/puzzle/vppiecelist.h | 14 ++--- src/app/puzzle/xml/vplayoutfilereader.cpp | 4 +- src/app/puzzle/xml/vplayoutfilereader.h | 4 +- src/app/puzzle/xml/vplayoutfilewriter.cpp | 6 +- src/app/puzzle/xml/vplayoutfilewriter.h | 4 +- 25 files changed, 117 insertions(+), 117 deletions(-) rename src/app/puzzle/{vpuzzlepiece.cpp => vppiece.cpp} (85%) rename src/app/puzzle/{vpuzzlepiece.h => vppiece.h} (97%) diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index 5fe7c72a1..94b394f38 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -17,8 +17,8 @@ SOURCES += \ $$PWD/vpmaingraphicsview.cpp \ $$PWD/vpmainwindow.cpp \ $$PWD/vpmimedatapiece.cpp \ + $$PWD/vppiece.cpp \ $$PWD/vppiecelist.cpp \ - $$PWD/vpuzzlepiece.cpp \ $$PWD/vpuzzlesettings.cpp \ $$PWD/xml/vplayoutfilereader.cpp \ $$PWD/xml/vplayoutfilewriter.cpp \ @@ -41,9 +41,9 @@ HEADERS += \ $$PWD/vpmaingraphicsview.h \ $$PWD/vpmainwindow.h \ $$PWD/vpmimedatapiece.h \ + $$PWD/vppiece.h \ $$PWD/vppiecelist.h \ $$PWD/vpstable.h \ - $$PWD/vpuzzlepiece.h \ $$PWD/vpuzzlesettings.h \ $$PWD/xml/vplayoutfilereader.h \ $$PWD/xml/vplayoutfilewriter.h \ diff --git a/src/app/puzzle/vpcarrousel.cpp b/src/app/puzzle/vpcarrousel.cpp index 8573ce873..f57bf2cb9 100644 --- a/src/app/puzzle/vpcarrousel.cpp +++ b/src/app/puzzle/vpcarrousel.cpp @@ -106,7 +106,7 @@ void VPCarrousel::on_ActivePieceListChanged(int index) if (pieceList) { - QList pieces = pieceList->GetPieces(); + QList pieces = pieceList->GetPieces(); for (auto piece : pieces) { diff --git a/src/app/puzzle/vpcarrousel.h b/src/app/puzzle/vpcarrousel.h index e0ca7cfe6..f4aed9aff 100644 --- a/src/app/puzzle/vpcarrousel.h +++ b/src/app/puzzle/vpcarrousel.h @@ -33,7 +33,7 @@ #include #include #include "vplayout.h" -#include "vpuzzlepiece.h" +#include "vppiece.h" namespace Ui { diff --git a/src/app/puzzle/vpcarrouselpiece.cpp b/src/app/puzzle/vpcarrouselpiece.cpp index 83ee455e6..165553482 100644 --- a/src/app/puzzle/vpcarrouselpiece.cpp +++ b/src/app/puzzle/vpcarrouselpiece.cpp @@ -47,7 +47,7 @@ Q_LOGGING_CATEGORY(pCarrouselPiece, "p.carrouselPiece") //--------------------------------------------------------------------------------------------------------------------- -VPCarrouselPiece::VPCarrouselPiece(VPuzzlePiece *piece, VPCarrouselPieceList *carrouselPieceList) : +VPCarrouselPiece::VPCarrouselPiece(VPPiece *piece, VPCarrouselPieceList *carrouselPieceList) : m_piece(piece), m_carrouselPieceList(carrouselPieceList), m_dragStart(QPoint()) @@ -98,7 +98,7 @@ void VPCarrouselPiece::Init() // connect the signals - connect(m_piece, &VPuzzlePiece::SelectionChanged, this, &VPCarrouselPiece::on_PieceSelectionChanged); + connect(m_piece, &VPPiece::SelectionChanged, this, &VPCarrouselPiece::on_PieceSelectionChanged); // then refresh the data Refresh(); @@ -147,7 +147,7 @@ void VPCarrouselPiece::Refresh() } //--------------------------------------------------------------------------------------------------------------------- -VPuzzlePiece * VPCarrouselPiece::GetPiece() +VPPiece * VPCarrouselPiece::GetPiece() { return m_piece; } diff --git a/src/app/puzzle/vpcarrouselpiece.h b/src/app/puzzle/vpcarrouselpiece.h index 4ef95083d..8512abf54 100644 --- a/src/app/puzzle/vpcarrouselpiece.h +++ b/src/app/puzzle/vpcarrouselpiece.h @@ -33,7 +33,7 @@ #include #include -#include "vpuzzlepiece.h" +#include "vppiece.h" #include "vpcarrouselpiecepreview.h" @@ -43,7 +43,7 @@ class VPCarrouselPiece : public QFrame { Q_OBJECT public: - explicit VPCarrouselPiece(VPuzzlePiece *piece, VPCarrouselPieceList *carrouselPieceList); + explicit VPCarrouselPiece(VPPiece *piece, VPCarrouselPieceList *carrouselPieceList); ~VPCarrouselPiece(); void Init(); @@ -59,7 +59,7 @@ public: * @brief GetPiece Returns the corresponding layout piece * @return the corresponding layout piece */ - VPuzzlePiece * GetPiece(); + VPPiece * GetPiece(); public slots: void on_PieceSelectionChanged(); @@ -81,7 +81,7 @@ private slots: private: Q_DISABLE_COPY(VPCarrouselPiece) - VPuzzlePiece *m_piece; + VPPiece *m_piece; VPCarrouselPieceList *m_carrouselPieceList; diff --git a/src/app/puzzle/vpcarrouselpiecelist.cpp b/src/app/puzzle/vpcarrouselpiecelist.cpp index 5d3044ed8..00f23e8b6 100644 --- a/src/app/puzzle/vpcarrouselpiecelist.cpp +++ b/src/app/puzzle/vpcarrouselpiecelist.cpp @@ -73,11 +73,11 @@ void VPCarrouselPieceList::Refresh() Clear(); // Updates the carrousel pieces from the pieces list - QList pieces = m_pieceList->GetPieces(); + QList pieces = m_pieceList->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();}); + [](const VPPiece* a, const VPPiece* b) -> bool { return a->GetName() < b->GetName();}); // create the corresponding carrousel pieces @@ -129,7 +129,7 @@ VPPieceList* VPCarrouselPieceList::GetPieceList() } //--------------------------------------------------------------------------------------------------------------------- -void VPCarrouselPieceList::on_PieceAdded(VPuzzlePiece* piece) +void VPCarrouselPieceList::on_PieceAdded(VPPiece* piece) { Q_UNUSED(piece) @@ -139,7 +139,7 @@ void VPCarrouselPieceList::on_PieceAdded(VPuzzlePiece* piece) } //--------------------------------------------------------------------------------------------------------------------- -void VPCarrouselPieceList::on_PieceRemoved(VPuzzlePiece* piece) +void VPCarrouselPieceList::on_PieceRemoved(VPPiece* piece) { for (auto carrouselPiece : m_carrouselPieces) { diff --git a/src/app/puzzle/vpcarrouselpiecelist.h b/src/app/puzzle/vpcarrouselpiecelist.h index 735b98c1c..e32cf1ab4 100644 --- a/src/app/puzzle/vpcarrouselpiecelist.h +++ b/src/app/puzzle/vpcarrouselpiecelist.h @@ -72,12 +72,12 @@ private slots: /** * @brief on_PieceUpdated This slot is called when a piece was added */ - void on_PieceAdded(VPuzzlePiece* piece); + void on_PieceAdded(VPPiece* piece); /** * @brief on_PieceUpdated This slot is called when a piece was removed */ - void on_PieceRemoved(VPuzzlePiece* piece); + void on_PieceRemoved(VPPiece* piece); }; diff --git a/src/app/puzzle/vpgraphicspiece.cpp b/src/app/puzzle/vpgraphicspiece.cpp index 3908ae3e6..0fb07e083 100644 --- a/src/app/puzzle/vpgraphicspiece.cpp +++ b/src/app/puzzle/vpgraphicspiece.cpp @@ -39,7 +39,7 @@ #include #include -#include "vpuzzlepiece.h" +#include "vppiece.h" #include "vppiecelist.h" #include "vplayout.h" @@ -47,7 +47,7 @@ Q_LOGGING_CATEGORY(pGraphicsPiece, "p.graphicsPiece") //--------------------------------------------------------------------------------------------------------------------- -VPGraphicsPiece::VPGraphicsPiece(VPuzzlePiece *piece, QGraphicsItem *parent) : +VPGraphicsPiece::VPGraphicsPiece(VPPiece *piece, QGraphicsItem *parent) : QGraphicsObject(parent), m_piece(piece), m_cuttingLine(QPainterPath()), @@ -102,13 +102,13 @@ void VPGraphicsPiece::Init() // TODO : initialises the other elements labels, passmarks etc. // Initialises the connectors - connect(m_piece, &VPuzzlePiece::SelectionChanged, this, &VPGraphicsPiece::on_PieceSelectionChanged); - connect(m_piece, &VPuzzlePiece::PositionChanged, this, &VPGraphicsPiece::on_PiecePositionChanged); - connect(m_piece, &VPuzzlePiece::RotationChanged, this, &VPGraphicsPiece::on_PieceRotationChanged); + connect(m_piece, &VPPiece::SelectionChanged, this, &VPGraphicsPiece::on_PieceSelectionChanged); + connect(m_piece, &VPPiece::PositionChanged, this, &VPGraphicsPiece::on_PiecePositionChanged); + connect(m_piece, &VPPiece::RotationChanged, this, &VPGraphicsPiece::on_PieceRotationChanged); } //--------------------------------------------------------------------------------------------------------------------- -VPuzzlePiece* VPGraphicsPiece::GetPiece() +VPPiece* VPGraphicsPiece::GetPiece() { return m_piece; } diff --git a/src/app/puzzle/vpgraphicspiece.h b/src/app/puzzle/vpgraphicspiece.h index 954fcd195..66f49f401 100644 --- a/src/app/puzzle/vpgraphicspiece.h +++ b/src/app/puzzle/vpgraphicspiece.h @@ -31,13 +31,13 @@ #include -class VPuzzlePiece; +class VPPiece; class VPGraphicsPiece : public QGraphicsObject { Q_OBJECT public: - VPGraphicsPiece(VPuzzlePiece *piece, QGraphicsItem *parent = nullptr); + VPGraphicsPiece(VPPiece *piece, QGraphicsItem *parent = nullptr); ~VPGraphicsPiece(); void Init(); @@ -45,7 +45,7 @@ public: * @brief GetPiece Returns the piece that corresponds to the graphics piece * @return the piece */ - VPuzzlePiece* GetPiece(); + VPPiece* GetPiece(); public slots: /** @@ -87,7 +87,7 @@ private slots: private: Q_DISABLE_COPY(VPGraphicsPiece) - VPuzzlePiece *m_piece; + VPPiece *m_piece; QPainterPath m_cuttingLine; QPainterPath m_seamLine; diff --git a/src/app/puzzle/vplayout.cpp b/src/app/puzzle/vplayout.cpp index b823d45c8..1f9087836 100644 --- a/src/app/puzzle/vplayout.cpp +++ b/src/app/puzzle/vplayout.cpp @@ -27,7 +27,7 @@ *************************************************************************/ #include "vplayout.h" #include "vppiecelist.h" -#include "vpuzzlepiece.h" +#include "vppiece.h" //--------------------------------------------------------------------------------------------------------------------- VPLayout::VPLayout() : @@ -79,9 +79,9 @@ QList VPLayout::GetPiecesLists() } //--------------------------------------------------------------------------------------------------------------------- -QList VPLayout::GetSelectedPieces() +QList VPLayout::GetSelectedPieces() { - QList result = QList(); + QList result = QList(); QList pieceLists = m_pieceLists; pieceLists.prepend(m_unplacedPieceList); @@ -303,7 +303,7 @@ VPPieceList* VPLayout::GetFocusedPieceList() } //--------------------------------------------------------------------------------------------------------------------- -void VPLayout::MovePieceToPieceList(VPuzzlePiece* piece, VPPieceList* pieceList) +void VPLayout::MovePieceToPieceList(VPPiece* piece, VPPieceList* pieceList) { VPPieceList* pieceListBefore = piece->GetPieceList(); diff --git a/src/app/puzzle/vplayout.h b/src/app/puzzle/vplayout.h index 7c45a29ff..b03668685 100644 --- a/src/app/puzzle/vplayout.h +++ b/src/app/puzzle/vplayout.h @@ -35,7 +35,7 @@ #include "def.h" class VPPieceList; -class VPuzzlePiece; +class VPPiece; // is this the right place for the definition? enum class FollowGrainline : qint8 { No = 0, Follow90 = 1, Follow180 = 2}; @@ -61,7 +61,7 @@ public: * @brief GetSelectedPieces Returns the list of the selected pieces * @return the selected pieces */ - QList GetSelectedPieces(); + QList GetSelectedPieces(); /** * @brief SetUnit Sets the unit of the layout to the given unit @@ -224,11 +224,11 @@ public: * @param piece the piece to move * @param pieceList the piece list to move the piece to */ - void MovePieceToPieceList(VPuzzlePiece* piece, VPPieceList* pieceList); + void MovePieceToPieceList(VPPiece* piece, VPPieceList* pieceList); signals: - void PieceMovedToPieceList(VPuzzlePiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter); + void PieceMovedToPieceList(VPPiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter); private: Q_DISABLE_COPY(VPLayout) diff --git a/src/app/puzzle/vpmaingraphicsview.cpp b/src/app/puzzle/vpmaingraphicsview.cpp index 2100a1e27..17ec5ee48 100644 --- a/src/app/puzzle/vpmaingraphicsview.cpp +++ b/src/app/puzzle/vpmaingraphicsview.cpp @@ -113,7 +113,7 @@ void VPMainGraphicsView::dropEvent(QDropEvent *event) { const VPMimeDataPiece *mimePiece = qobject_cast (mime); - VPuzzlePiece *piece = mimePiece->GetPiecePtr(); + VPPiece *piece = mimePiece->GetPiecePtr(); if(piece != nullptr) { qCDebug(pMainGraphicsView(), "element dropped, %s", qUtf8Printable(piece->GetName())); @@ -141,7 +141,7 @@ void VPMainGraphicsView::keyPressEvent(QKeyEvent *event) for(auto graphicsPiece : tmpGraphicsPieces) { - VPuzzlePiece *piece = graphicsPiece->GetPiece(); + VPPiece *piece = graphicsPiece->GetPiece(); if(piece->GetIsSelected()) { @@ -153,7 +153,7 @@ void VPMainGraphicsView::keyPressEvent(QKeyEvent *event) } //--------------------------------------------------------------------------------------------------------------------- -void VPMainGraphicsView::on_PieceMovedToPieceList(VPuzzlePiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter) +void VPMainGraphicsView::on_PieceMovedToPieceList(VPPiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter) { Q_UNUSED(pieceListBefore) diff --git a/src/app/puzzle/vpmaingraphicsview.h b/src/app/puzzle/vpmaingraphicsview.h index ac802549d..15709c520 100644 --- a/src/app/puzzle/vpmaingraphicsview.h +++ b/src/app/puzzle/vpmaingraphicsview.h @@ -64,7 +64,7 @@ private slots: * @param pieceListBefore the piece list before the move * @param pieceListAfter the piece list after the move */ - void on_PieceMovedToPieceList(VPuzzlePiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter); + void on_PieceMovedToPieceList(VPPiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter); /** * @brief on_SceneSelectionChanged Slot is called when the scene selection has changed diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index 24ce82e64..3b39815f3 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -164,7 +164,7 @@ void VPMainWindow::ImportRawLayouts(const QStringList &rawLayouts) // TODO for feature "Update piece" : CreateOrUpdate() function indstead of CreatePiece() - VPuzzlePiece *piece = CreatePiece(rawPiece); + VPPiece *piece = CreatePiece(rawPiece); m_layout->GetUnplacedPieceList()->AddPiece(piece); } @@ -183,9 +183,9 @@ void VPMainWindow::ImportRawLayouts(const QStringList &rawLayouts) } //--------------------------------------------------------------------------------------------------------------------- -VPuzzlePiece* VPMainWindow::CreatePiece(const VLayoutPiece &rawPiece) +VPPiece* VPMainWindow::CreatePiece(const VLayoutPiece &rawPiece) { - VPuzzlePiece *piece = new VPuzzlePiece(); + VPPiece *piece = new VPPiece(); piece->SetName(rawPiece.GetName()); piece->SetUuid(rawPiece.GetUUID()); @@ -202,9 +202,9 @@ VPuzzlePiece* VPMainWindow::CreatePiece(const VLayoutPiece &rawPiece) // TODO : set all the information we need for the piece! // - connect(piece, &VPuzzlePiece::SelectionChanged, this, &VPMainWindow::on_PieceSelectionChanged); - connect(piece, &VPuzzlePiece::PositionChanged, this, &VPMainWindow::on_PiecePositionChanged); - connect(piece, &VPuzzlePiece::RotationChanged, this, &VPMainWindow::on_PieceRotationChanged); + connect(piece, &VPPiece::SelectionChanged, this, &VPMainWindow::on_PieceSelectionChanged); + connect(piece, &VPPiece::PositionChanged, this, &VPMainWindow::on_PiecePositionChanged); + connect(piece, &VPPiece::RotationChanged, this, &VPMainWindow::on_PieceRotationChanged); return piece; @@ -355,7 +355,7 @@ void VPMainWindow::SetPropertyTabCurrentPieceData() ui->containerCurrentPieceData->setVisible(true); ui->containerCurrentPieceMultipleData->setVisible(false); - VPuzzlePiece *selectedPiece = m_selectedPieces.first(); + VPPiece *selectedPiece = m_selectedPieces.first(); // set the value to the current piece ui->lineEditCurrentPieceName->setText(selectedPiece->GetName()); @@ -938,7 +938,7 @@ void VPMainWindow::on_doubleSpinBoxCurrentPieceAngle_valueChanged(double value) { if(m_selectedPieces.count() == 1) { - VPuzzlePiece *piece = m_selectedPieces.first(); + VPPiece *piece = m_selectedPieces.first(); piece->SetRotation(value); } } @@ -949,7 +949,7 @@ void VPMainWindow::on_CurrentPiecePositionEdited() { 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), UnitConvertor(ui->doubleSpinBoxCurrentPieceBoxPositionY->value(), m_layout->GetUnit(), Unit::Px)); piece->SetPosition(pos); @@ -984,7 +984,7 @@ void VPMainWindow::on_PiecePositionChanged() { if(m_selectedPieces.count() == 1) { - VPuzzlePiece *piece = m_selectedPieces.first(); + VPPiece *piece = m_selectedPieces.first(); QPointF pos = piece->GetPosition(); SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionX, @@ -999,7 +999,7 @@ void VPMainWindow::on_PieceRotationChanged() { if(m_selectedPieces.count() == 1) { - VPuzzlePiece *piece = m_selectedPieces.first(); + VPPiece *piece = m_selectedPieces.first(); qreal angle = piece->GetRotation(); SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceAngle, angle); diff --git a/src/app/puzzle/vpmainwindow.h b/src/app/puzzle/vpmainwindow.h index a2c7cd962..275f2fb00 100644 --- a/src/app/puzzle/vpmainwindow.h +++ b/src/app/puzzle/vpmainwindow.h @@ -36,7 +36,7 @@ #include "vpcarrousel.h" #include "vpmaingraphicsview.h" #include "vplayout.h" -#include "vpuzzlepiece.h" +#include "vppiece.h" #include "../vlayout/vlayoutpiece.h" #include "vpcommandline.h" @@ -96,13 +96,13 @@ private: VPCommandLinePtr m_cmd; VPLayout *m_layout{nullptr}; - QListm_selectedPieces{QList()}; + QListm_selectedPieces{QList()}; /** * @brief CreatePiece creates a piece from the given VLayoutPiece 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 ...) diff --git a/src/app/puzzle/vpmimedatapiece.cpp b/src/app/puzzle/vpmimedatapiece.cpp index 5f7cb6c4b..a92f724e5 100644 --- a/src/app/puzzle/vpmimedatapiece.cpp +++ b/src/app/puzzle/vpmimedatapiece.cpp @@ -41,13 +41,13 @@ VPMimeDataPiece::~VPMimeDataPiece() } //--------------------------------------------------------------------------------------------------------------------- -VPuzzlePiece* VPMimeDataPiece::GetPiecePtr() const +VPPiece* VPMimeDataPiece::GetPiecePtr() const { return m_piece; } //--------------------------------------------------------------------------------------------------------------------- -void VPMimeDataPiece::SetPiecePtr(VPuzzlePiece* piece) +void VPMimeDataPiece::SetPiecePtr(VPPiece* piece) { m_piece = piece; } diff --git a/src/app/puzzle/vpmimedatapiece.h b/src/app/puzzle/vpmimedatapiece.h index f1bba271e..cb5ba0ca7 100644 --- a/src/app/puzzle/vpmimedatapiece.h +++ b/src/app/puzzle/vpmimedatapiece.h @@ -31,7 +31,7 @@ #include -#include "vpuzzlepiece.h" +#include "vppiece.h" class VPMimeDataPiece : public QMimeData { @@ -46,18 +46,18 @@ public: * @brief GetPiecePtr Returns the piece pointer of the mime data * @return piece pointer */ - VPuzzlePiece* GetPiecePtr() const; + VPPiece* GetPiecePtr() const; /** * @brief SetPiecePtr sets the piece pointer to the given value * @param piece the piece pointer */ - void SetPiecePtr(VPuzzlePiece* piece); + void SetPiecePtr(VPPiece* piece); private: Q_DISABLE_COPY(VPMimeDataPiece) - VPuzzlePiece *m_piece{nullptr}; + VPPiece *m_piece{nullptr}; }; diff --git a/src/app/puzzle/vpuzzlepiece.cpp b/src/app/puzzle/vppiece.cpp similarity index 85% rename from src/app/puzzle/vpuzzlepiece.cpp rename to src/app/puzzle/vppiece.cpp index 02c000465..f0c7aa71e 100644 --- a/src/app/puzzle/vpuzzlepiece.cpp +++ b/src/app/puzzle/vppiece.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlepiece.cpp + ** @file vppiece.cpp ** @author Ronan Le Tiec ** @date 13 4, 2020 ** @@ -25,7 +25,7 @@ ** along with Valentina. If not, see . ** *************************************************************************/ -#include "vpuzzlepiece.h" +#include "vppiece.h" #include @@ -39,77 +39,77 @@ 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; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetName(const QString &name) +void VPPiece::SetName(const QString &name) { m_name = name; } //--------------------------------------------------------------------------------------------------------------------- -QUuid VPuzzlePiece::GetUuid() const +QUuid VPPiece::GetUuid() const { return m_uuid; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetUuid(const QUuid &uuid) +void VPPiece::SetUuid(const QUuid &uuid) { m_uuid = uuid; } //--------------------------------------------------------------------------------------------------------------------- -QVector VPuzzlePiece::GetCuttingLine() const +QVector VPPiece::GetCuttingLine() const { return m_cuttingLine; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetCuttingLine(const QVector &cuttingLine) +void VPPiece::SetCuttingLine(const QVector &cuttingLine) { m_cuttingLine = cuttingLine; } //--------------------------------------------------------------------------------------------------------------------- -QVector VPuzzlePiece::GetSeamLine() const +QVector VPPiece::GetSeamLine() const { return m_seamLine; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetSeamLine(const QVector &seamLine) +void VPPiece::SetSeamLine(const QVector &seamLine) { m_seamLine = seamLine; } //--------------------------------------------------------------------------------------------------------------------- -bool VPuzzlePiece::GetShowSeamLine() const +bool VPPiece::GetShowSeamLine() const { return m_showSeamline; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetShowSeamLine(bool value) +void VPPiece::SetShowSeamLine(bool value) { m_showSeamline = value; @@ -117,13 +117,13 @@ void VPuzzlePiece::SetShowSeamLine(bool value) } //--------------------------------------------------------------------------------------------------------------------- -bool VPuzzlePiece::GetPieceMirrored() const +bool VPPiece::GetPieceMirrored() const { return m_mirrorPiece; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetPieceMirrored(bool value) +void VPPiece::SetPieceMirrored(bool 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()); @@ -139,13 +139,13 @@ void VPuzzlePiece::SetPosition(QPointF point) } //--------------------------------------------------------------------------------------------------------------------- -QPointF VPuzzlePiece::GetPosition() +QPointF VPPiece::GetPosition() { return QPointF(m_transform.dx(), m_transform.dy()); } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetRotation(qreal angle) +void VPPiece::SetRotation(qreal angle) { // qreal currentAngle = GetRotation(); // qreal newAngle = angle - currentAngle; @@ -172,7 +172,7 @@ void VPuzzlePiece::SetRotation(qreal angle) } //--------------------------------------------------------------------------------------------------------------------- -qreal VPuzzlePiece::GetRotation() +qreal VPPiece::GetRotation() { return m_pieceAngle; @@ -191,7 +191,7 @@ qreal VPuzzlePiece::GetRotation() } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetIsSelected(bool value) +void VPPiece::SetIsSelected(bool value) { if(m_isSelected != value) { @@ -201,54 +201,54 @@ void VPuzzlePiece::SetIsSelected(bool value) } //--------------------------------------------------------------------------------------------------------------------- -bool VPuzzlePiece::GetIsSelected() +bool VPPiece::GetIsSelected() { return m_isSelected; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetIsGrainlineEnabled(bool value) +void VPPiece::SetIsGrainlineEnabled(bool value) { m_isGrainlineEnabled = value; } //--------------------------------------------------------------------------------------------------------------------- -bool VPuzzlePiece::GetIsGrainlineEnabled() +bool VPPiece::GetIsGrainlineEnabled() { return m_isGrainlineEnabled; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetGrainlineAngle(qreal value) +void VPPiece::SetGrainlineAngle(qreal value) { m_grainlineAngle = value; } //--------------------------------------------------------------------------------------------------------------------- -qreal VPuzzlePiece::GetGrainlineAngle() +qreal VPPiece::GetGrainlineAngle() { return m_grainlineAngle; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetGrainline(QVector grainline) +void VPPiece::SetGrainline(QVector grainline) { m_grainline = grainline; } //--------------------------------------------------------------------------------------------------------------------- -QVector VPuzzlePiece::GetGrainline() +QVector VPPiece::GetGrainline() { return m_grainline; } //--------------------------------------------------------------------------------------------------------------------- -VPPieceList* VPuzzlePiece::GetPieceList() +VPPieceList* VPPiece::GetPieceList() { return m_pieceList; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzlePiece::SetPieceList(VPPieceList* pieceList) +void VPPiece::SetPieceList(VPPieceList* pieceList) { if(pieceList != m_pieceList) { @@ -257,7 +257,7 @@ void VPuzzlePiece::SetPieceList(VPPieceList* pieceList) } //--------------------------------------------------------------------------------------------------------------------- -QIcon VPuzzlePiece::PieceIcon(const QSize &size) const +QIcon VPPiece::PieceIcon(const QSize &size) const { QVector points = GetSeamLine(); if(points.isEmpty()) diff --git a/src/app/puzzle/vpuzzlepiece.h b/src/app/puzzle/vppiece.h similarity index 97% rename from src/app/puzzle/vpuzzlepiece.h rename to src/app/puzzle/vppiece.h index a1536c224..759909631 100644 --- a/src/app/puzzle/vpuzzlepiece.h +++ b/src/app/puzzle/vppiece.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlepiece.h + ** @file vpiece.h ** @author Ronan Le Tiec ** @date 13 4, 2020 ** @@ -25,8 +25,8 @@ ** along with Valentina. If not, see . ** *************************************************************************/ -#ifndef VPUZZLEPIECE_H -#define VPUZZLEPIECE_H +#ifndef VPPIECE_H +#define VPPIECE_H #include #include @@ -35,12 +35,12 @@ class VPPieceList; -class VPuzzlePiece : public QObject +class VPPiece : public QObject { Q_OBJECT public: - VPuzzlePiece(); - ~VPuzzlePiece(); + VPPiece(); + ~VPPiece(); /** * @brief GetName Returns the name of the piece @@ -226,7 +226,7 @@ signals: void PropertiesChanged(); private: - Q_DISABLE_COPY(VPuzzlePiece) + Q_DISABLE_COPY(VPPiece) QUuid m_uuid{QUuid()}; QString m_name{QString()}; QVector m_cuttingLine{QVector()}; @@ -247,4 +247,4 @@ private: VPPieceList *m_pieceList{nullptr}; }; -#endif // VPUZZLEPIECE_H +#endif // VPPIECE_H diff --git a/src/app/puzzle/vppiecelist.cpp b/src/app/puzzle/vppiecelist.cpp index 85c25454b..f6d074797 100644 --- a/src/app/puzzle/vppiecelist.cpp +++ b/src/app/puzzle/vppiecelist.cpp @@ -53,7 +53,7 @@ VPLayout* VPPieceList::GetLayout() } //--------------------------------------------------------------------------------------------------------------------- -QList VPPieceList::GetPieces() +QList VPPieceList::GetPieces() { return m_pieces; } @@ -69,7 +69,7 @@ void VPPieceList::ClearSelection() } //--------------------------------------------------------------------------------------------------------------------- -void VPPieceList::AddPiece(VPuzzlePiece *piece) +void VPPieceList::AddPiece(VPPiece *piece) { qCDebug(pPieceList(), "piece -- %s -- added to %s", qUtf8Printable(piece->GetName()), qUtf8Printable(this->GetName())); @@ -80,7 +80,7 @@ void VPPieceList::AddPiece(VPuzzlePiece *piece) } //--------------------------------------------------------------------------------------------------------------------- -void VPPieceList::RemovePiece(VPuzzlePiece *piece) +void VPPieceList::RemovePiece(VPPiece *piece) { m_pieces.removeAll(piece); piece->SetPieceList(nullptr); diff --git a/src/app/puzzle/vppiecelist.h b/src/app/puzzle/vppiecelist.h index 384f1b81f..283a0d03e 100644 --- a/src/app/puzzle/vppiecelist.h +++ b/src/app/puzzle/vppiecelist.h @@ -29,7 +29,7 @@ #define VPPIECELIST_H #include -#include "vpuzzlepiece.h" +#include "vppiece.h" class VPLayout; @@ -40,9 +40,9 @@ public: VPPieceList(VPLayout *layout); ~VPPieceList(); - QList GetPieces(); - void AddPiece(VPuzzlePiece *piece); - void RemovePiece(VPuzzlePiece *piece); + QList GetPieces(); + void AddPiece(VPPiece *piece); + void RemovePiece(VPPiece *piece); // here add some more function if we want to add/move a piece at a // certain position in the list @@ -68,18 +68,18 @@ signals: /** * @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 */ - void PieceRemoved(VPuzzlePiece *piece); + void PieceRemoved(VPPiece *piece); private: Q_DISABLE_COPY(VPPieceList) QString m_name{}; - QList m_pieces{}; + QList m_pieces{}; VPLayout *m_layout{nullptr}; diff --git a/src/app/puzzle/xml/vplayoutfilereader.cpp b/src/app/puzzle/xml/vplayoutfilereader.cpp index 722cb8c73..59ce5d1ca 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.cpp +++ b/src/app/puzzle/xml/vplayoutfilereader.cpp @@ -229,7 +229,7 @@ void VPLayoutFileReader::ReadPieceList(VPPieceList *pieceList) { if (name() == ML::TagPiece) { - VPuzzlePiece *piece = new VPuzzlePiece(); + VPPiece *piece = new VPPiece(); ReadPiece(piece); pieceList->AddPiece(piece); } @@ -242,7 +242,7 @@ void VPLayoutFileReader::ReadPieceList(VPPieceList *pieceList) } //--------------------------------------------------------------------------------------------------------------------- -void VPLayoutFileReader::ReadPiece(VPuzzlePiece *piece) +void VPLayoutFileReader::ReadPiece(VPPiece *piece) { Q_UNUSED(piece); SCASSERT(isStartElement() && name() == ML::TagPiece); diff --git a/src/app/puzzle/xml/vplayoutfilereader.h b/src/app/puzzle/xml/vplayoutfilereader.h index d340811b9..db38265d6 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.h +++ b/src/app/puzzle/xml/vplayoutfilereader.h @@ -33,7 +33,7 @@ #include "../ifc/xml/vabstractconverter.h" #include "vplayout.h" #include "vppiecelist.h" -#include "vpuzzlepiece.h" +#include "vppiece.h" class VPLayoutFileReader : public QXmlStreamReader { @@ -52,7 +52,7 @@ private: void ReadTiles(VPLayout *layout); void ReadPieceLists(VPLayout *layout); void ReadPieceList(VPPieceList *pieceList); - void ReadPiece(VPuzzlePiece *piece); + void ReadPiece(VPPiece *piece); QMarginsF ReadMargins(); QSizeF ReadSize(); diff --git a/src/app/puzzle/xml/vplayoutfilewriter.cpp b/src/app/puzzle/xml/vplayoutfilewriter.cpp index 97d738928..92832f6c0 100644 --- a/src/app/puzzle/xml/vplayoutfilewriter.cpp +++ b/src/app/puzzle/xml/vplayoutfilewriter.cpp @@ -29,7 +29,7 @@ #include "vplayoutfilewriter.h" #include "vplayout.h" #include "vppiecelist.h" -#include "vpuzzlepiece.h" +#include "vppiece.h" #include "vplayoutliterals.h" #include "../ifc/xml/vlayoutconverter.h" @@ -148,7 +148,7 @@ void VPLayoutFileWriter::WritePieceList(VPPieceList *pieceList, const QString &t //SetAttribute("selected", pieceList->GetIsSelected()); - QList pieces = pieceList->GetPieces(); + QList pieces = pieceList->GetPieces(); for (auto piece : pieces) { WritePiece(piece); @@ -158,7 +158,7 @@ void VPLayoutFileWriter::WritePieceList(VPPieceList *pieceList, const QString &t } //--------------------------------------------------------------------------------------------------------------------- -void VPLayoutFileWriter::WritePiece(VPuzzlePiece *piece) +void VPLayoutFileWriter::WritePiece(VPPiece *piece) { Q_UNUSED(piece); diff --git a/src/app/puzzle/xml/vplayoutfilewriter.h b/src/app/puzzle/xml/vplayoutfilewriter.h index 522b2ad8a..a63ee4f0b 100644 --- a/src/app/puzzle/xml/vplayoutfilewriter.h +++ b/src/app/puzzle/xml/vplayoutfilewriter.h @@ -36,7 +36,7 @@ class VPLayout; class VPPieceList; -class VPuzzlePiece; +class VPPiece; class QFile; class QMarginsF; @@ -56,7 +56,7 @@ private: void WritePieceLists(VPLayout *layout); void WritePieceList(VPPieceList *pieceList); void WritePieceList(VPPieceList *pieceList, const QString &tagName); - void WritePiece(VPuzzlePiece *piece); + void WritePiece(VPPiece *piece); void WriteMargins(const QMarginsF &margins); void WriteSize(QSizeF size); From 22a5e2094c9edd75b20424a93c7bd578b6925c90 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 15:44:44 +0200 Subject: [PATCH 23/28] Refactoring VPuzzleSettings --- src/app/puzzle/puzzle.pri | 4 ++-- src/app/puzzle/vpapplication.cpp | 8 ++++---- src/app/puzzle/vpapplication.h | 4 ++-- src/app/puzzle/vpmainwindow.cpp | 4 ++-- .../{vpuzzlesettings.cpp => vpsettings.cpp} | 20 +++++++++---------- .../{vpuzzlesettings.h => vpsettings.h} | 16 +++++++-------- 6 files changed, 28 insertions(+), 28 deletions(-) rename src/app/puzzle/{vpuzzlesettings.cpp => vpsettings.cpp} (81%) rename src/app/puzzle/{vpuzzlesettings.h => vpsettings.h} (80%) diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index 94b394f38..f1ad4bdf2 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -19,7 +19,7 @@ SOURCES += \ $$PWD/vpmimedatapiece.cpp \ $$PWD/vppiece.cpp \ $$PWD/vppiecelist.cpp \ - $$PWD/vpuzzlesettings.cpp \ + $$PWD/vpsettings.cpp \ $$PWD/xml/vplayoutfilereader.cpp \ $$PWD/xml/vplayoutfilewriter.cpp \ $$PWD/xml/vplayoutliterals.cpp @@ -43,8 +43,8 @@ HEADERS += \ $$PWD/vpmimedatapiece.h \ $$PWD/vppiece.h \ $$PWD/vppiecelist.h \ + $$PWD/vpsettings.h \ $$PWD/vpstable.h \ - $$PWD/vpuzzlesettings.h \ $$PWD/xml/vplayoutfilereader.h \ $$PWD/xml/vplayoutfilewriter.h \ $$PWD/xml/vplayoutliterals.h diff --git a/src/app/puzzle/vpapplication.cpp b/src/app/puzzle/vpapplication.cpp index 0c492e3d9..afd0a559d 100644 --- a/src/app/puzzle/vpapplication.cpp +++ b/src/app/puzzle/vpapplication.cpp @@ -405,21 +405,21 @@ const VTranslateVars *VPApplication::TrVars() //--------------------------------------------------------------------------------------------------------------------- void VPApplication::OpenSettings() { - settings = new VPuzzleSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), + settings = new VPSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), QCoreApplication::applicationName(), this); } //--------------------------------------------------------------------------------------------------------------------- -VPuzzleSettings *VPApplication::PuzzleSettings() +VPSettings *VPApplication::PuzzleSettings() { SCASSERT(settings != nullptr) - return qobject_cast(settings); + return qobject_cast(settings); } //--------------------------------------------------------------------------------------------------------------------- void VPApplication::ActivateDarkMode() { - VPuzzleSettings *settings = qApp->PuzzleSettings(); + VPSettings *settings = qApp->PuzzleSettings(); if (settings->GetDarkMode()) { QFile f(":qdarkstyle/style.qss"); diff --git a/src/app/puzzle/vpapplication.h b/src/app/puzzle/vpapplication.h index 94fe99786..bc0ca4b6e 100644 --- a/src/app/puzzle/vpapplication.h +++ b/src/app/puzzle/vpapplication.h @@ -29,7 +29,7 @@ #define VPAPPLICATION_H #include "../vmisc/def.h" -#include "vpuzzlesettings.h" +#include "vpsettings.h" #include "../vmisc/vabstractapplication.h" #include "vpcommandline.h" @@ -65,7 +65,7 @@ public: virtual const VTranslateVars *TrVars() override; virtual void OpenSettings() override; - VPuzzleSettings *PuzzleSettings(); + VPSettings *PuzzleSettings(); void ActivateDarkMode(); void ParseCommandLine(const SocketConnection &connection, const QStringList &arguments); diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index 3b39815f3..e9afa30f4 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -463,7 +463,7 @@ void VPMainWindow::SetCheckBoxValue(QCheckBox *checkbox, bool value) void VPMainWindow::ReadSettings() { qCDebug(pWindow, "Reading settings."); - const VPuzzleSettings *settings = qApp->PuzzleSettings(); + const VPSettings *settings = qApp->PuzzleSettings(); if (settings->status() == QSettings::NoError) { @@ -489,7 +489,7 @@ void VPMainWindow::ReadSettings() //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::WriteSettings() { - VPuzzleSettings *settings = qApp->PuzzleSettings(); + VPSettings *settings = qApp->PuzzleSettings(); settings->SetGeometry(saveGeometry()); settings->SetWindowState(saveState()); settings->SetToolbarsState(saveState(APP_VERSION)); diff --git a/src/app/puzzle/vpuzzlesettings.cpp b/src/app/puzzle/vpsettings.cpp similarity index 81% rename from src/app/puzzle/vpuzzlesettings.cpp rename to src/app/puzzle/vpsettings.cpp index 6d4ad24d0..4d7360762 100644 --- a/src/app/puzzle/vpuzzlesettings.cpp +++ b/src/app/puzzle/vpsettings.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlesettings.cpp + ** @file vpsettings.cpp ** @author Roman Telezhynskyi ** @date 16 2, 2020 ** @@ -25,7 +25,7 @@ ** along with Valentina. If not, see . ** *************************************************************************/ -#include "vpuzzlesettings.h" +#include "vpsettings.h" 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) : 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) {} //--------------------------------------------------------------------------------------------------------------------- -bool VPuzzleSettings::IsDockWidgetPropertiesActive() const +bool VPSettings::IsDockWidgetPropertiesActive() const { return value(*settingDockWidgetPropertiesActive, GetDefDockWidgetPropertiesActive()).toBool(); } //--------------------------------------------------------------------------------------------------------------------- -bool VPuzzleSettings::GetDefDockWidgetPropertiesActive() +bool VPSettings::GetDefDockWidgetPropertiesActive() { return true; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleSettings::SetDockWidgetPropertiesActive(bool value) +void VPSettings::SetDockWidgetPropertiesActive(bool value) { setValue(*settingDockWidgetPropertiesActive, value); } //--------------------------------------------------------------------------------------------------------------------- -bool VPuzzleSettings::IsDockWidgetPropertiesContentsActive() const +bool VPSettings::IsDockWidgetPropertiesContentsActive() const { return value(*settingDockWidgetPropertiesActive, GetDefDockWidgetPropertiesActive()).toBool(); } //--------------------------------------------------------------------------------------------------------------------- -bool VPuzzleSettings::GetDefDockWidgetPropertiesContentsActive() +bool VPSettings::GetDefDockWidgetPropertiesContentsActive() { return true; } //--------------------------------------------------------------------------------------------------------------------- -void VPuzzleSettings::SetDockWidgetPropertiesContentsActive(bool value) +void VPSettings::SetDockWidgetPropertiesContentsActive(bool value) { setValue(*settingDockPropertiesContentsActive, value); } diff --git a/src/app/puzzle/vpuzzlesettings.h b/src/app/puzzle/vpsettings.h similarity index 80% rename from src/app/puzzle/vpuzzlesettings.h rename to src/app/puzzle/vpsettings.h index 97906df41..6d822042d 100644 --- a/src/app/puzzle/vpuzzlesettings.h +++ b/src/app/puzzle/vpsettings.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpuzzlesettings.h + ** @file vpsettings.h ** @author Roman Telezhynskyi ** @date 16 2, 2020 ** @@ -25,20 +25,20 @@ ** along with Valentina. If not, see . ** *************************************************************************/ -#ifndef VPUZZLESETTINGS_H -#define VPUZZLESETTINGS_H +#ifndef VPSETTINGS_H +#define VPSETTINGS_H #include #include "vcommonsettings.h" -class VPuzzleSettings : public VCommonSettings +class VPSettings : public VCommonSettings { Q_OBJECT 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); - VPuzzleSettings(const QString &fileName, Format format, QObject *parent = nullptr); + VPSettings(const QString &fileName, Format format, QObject *parent = nullptr); bool IsDockWidgetPropertiesActive() const; static bool GetDefDockWidgetPropertiesActive(); @@ -49,7 +49,7 @@ public: void SetDockWidgetPropertiesContentsActive(bool value); private: - Q_DISABLE_COPY(VPuzzleSettings) + Q_DISABLE_COPY(VPSettings) }; -#endif // VPUZZLESETTINGS_H +#endif // VPSETTINGS_H From 803a7b6caa49fbd2f28349eadbeb196f9aa887b5 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 17:46:46 +0200 Subject: [PATCH 24/28] Introducing VPSheet and refactoring --- src/app/puzzle/vpsheet.cpp | 6 ++++++ src/app/puzzle/vpsheet.h | 11 +++++++++++ 2 files changed, 17 insertions(+) create mode 100644 src/app/puzzle/vpsheet.cpp create mode 100644 src/app/puzzle/vpsheet.h diff --git a/src/app/puzzle/vpsheet.cpp b/src/app/puzzle/vpsheet.cpp new file mode 100644 index 000000000..a89e4227b --- /dev/null +++ b/src/app/puzzle/vpsheet.cpp @@ -0,0 +1,6 @@ +#include "vpsheet.h" + +VPSheet::VPSheet() +{ + +} diff --git a/src/app/puzzle/vpsheet.h b/src/app/puzzle/vpsheet.h new file mode 100644 index 000000000..c2cd9dffb --- /dev/null +++ b/src/app/puzzle/vpsheet.h @@ -0,0 +1,11 @@ +#ifndef VPSHEET_H +#define VPSHEET_H + + +class VPSheet +{ +public: + VPSheet(); +}; + +#endif // VPSHEET_H From 61a2e17a789837c3a4fcfdad815b2d7179a33294 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 17:47:04 +0200 Subject: [PATCH 25/28] Introducing VPSheet and refactoring part 2 --- src/app/puzzle/puzzle.pri | 2 + src/app/puzzle/vpcarrousel.cpp | 9 +- src/app/puzzle/vpcarrouselpiece.cpp | 8 +- src/app/puzzle/vpgraphicspiece.cpp | 12 +- src/app/puzzle/vpgraphicssheet.cpp | 18 +- src/app/puzzle/vpgraphicssheet.h | 8 +- src/app/puzzle/vplayout.cpp | 214 +++------------- src/app/puzzle/vplayout.h | 188 +++----------- src/app/puzzle/vpmaingraphicsview.cpp | 7 +- src/app/puzzle/vpmainwindow.cpp | 178 +++++++------ src/app/puzzle/vpmainwindow.h | 30 ++- src/app/puzzle/vpmainwindow.ui | 292 ++++++++++++++++------ src/app/puzzle/vppiece.h | 2 +- src/app/puzzle/vpsheet.cpp | 202 ++++++++++++++- src/app/puzzle/vpsheet.h | 218 +++++++++++++++- src/app/puzzle/xml/vplayoutfilereader.cpp | 60 ++--- src/app/puzzle/xml/vplayoutfilereader.h | 4 +- src/app/puzzle/xml/vplayoutfilewriter.cpp | 54 ++-- src/app/puzzle/xml/vplayoutfilewriter.h | 5 +- src/app/puzzle/xml/vplayoutliterals.cpp | 2 + src/app/puzzle/xml/vplayoutliterals.h | 2 + 21 files changed, 921 insertions(+), 594 deletions(-) diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index f1ad4bdf2..d3a03826c 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -20,6 +20,7 @@ SOURCES += \ $$PWD/vppiece.cpp \ $$PWD/vppiecelist.cpp \ $$PWD/vpsettings.cpp \ + $$PWD/vpsheet.cpp \ $$PWD/xml/vplayoutfilereader.cpp \ $$PWD/xml/vplayoutfilewriter.cpp \ $$PWD/xml/vplayoutliterals.cpp @@ -44,6 +45,7 @@ HEADERS += \ $$PWD/vppiece.h \ $$PWD/vppiecelist.h \ $$PWD/vpsettings.h \ + $$PWD/vpsheet.h \ $$PWD/vpstable.h \ $$PWD/xml/vplayoutfilereader.h \ $$PWD/xml/vplayoutfilewriter.h \ diff --git a/src/app/puzzle/vpcarrousel.cpp b/src/app/puzzle/vpcarrousel.cpp index f57bf2cb9..8423a67ab 100644 --- a/src/app/puzzle/vpcarrousel.cpp +++ b/src/app/puzzle/vpcarrousel.cpp @@ -33,6 +33,7 @@ #include "../vmisc/backport/qoverload.h" #include "vppiecelist.h" +#include "vpsheet.h" #include #include @@ -68,8 +69,12 @@ void VPCarrousel::Refresh() // --- add the content saved in the layout to the carrousel. // Do not rely on m_layout because we do not control it. - m_pieceLists = m_layout->GetPiecesLists(); - m_pieceLists.prepend(m_layout->GetUnplacedPieceList()); + m_pieceLists = QList(); + m_pieceLists.append(m_layout->GetUnplacedPieceList()); + for(auto sheet : m_layout->GetSheets()) + { + m_pieceLists.append(sheet->GetPieceList()); + } for (auto pieceList : m_pieceLists) { diff --git a/src/app/puzzle/vpcarrouselpiece.cpp b/src/app/puzzle/vpcarrouselpiece.cpp index 165553482..82b401cf8 100644 --- a/src/app/puzzle/vpcarrouselpiece.cpp +++ b/src/app/puzzle/vpcarrouselpiece.cpp @@ -40,6 +40,7 @@ #include "vpmimedatapiece.h" #include "vpcarrouselpiecelist.h" #include "vpcarrousel.h" +#include "vpsheet.h" #include @@ -240,7 +241,12 @@ void VPCarrouselPiece::contextMenuEvent(QContextMenuEvent *event) QMenu contextMenu; VPPieceList* unplacedPieces = m_piece->GetPieceList()->GetLayout()->GetUnplacedPieceList(); - QList pieceLists = m_piece->GetPieceList()->GetLayout()->GetPiecesLists(); + QList sheets = m_piece->GetPieceList()->GetLayout()->GetSheets(); + QList pieceLists = QList(); + for (auto sheet : sheets) + { + pieceLists.append(sheet->GetPieceList()); + } // move to piece list actions -- TODO : To be tested properly when we have several piece lists pieceLists.removeAll(m_piece->GetPieceList()); diff --git a/src/app/puzzle/vpgraphicspiece.cpp b/src/app/puzzle/vpgraphicspiece.cpp index 0fb07e083..7daa4f20e 100644 --- a/src/app/puzzle/vpgraphicspiece.cpp +++ b/src/app/puzzle/vpgraphicspiece.cpp @@ -42,6 +42,7 @@ #include "vppiece.h" #include "vppiecelist.h" #include "vplayout.h" +#include "vpsheet.h" #include Q_LOGGING_CATEGORY(pGraphicsPiece, "p.graphicsPiece") @@ -294,10 +295,19 @@ void VPGraphicsPiece::hoverMoveEvent(QGraphicsSceneHoverEvent *event) //--------------------------------------------------------------------------------------------------------------------- void VPGraphicsPiece::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { + + + // TODO/FIXME context menu needs to be refactored + QMenu contextMenu; // move to piece list actions -- TODO : To be tested properly when we have several piece lists - QList pieceLists = m_piece->GetPieceList()->GetLayout()->GetPiecesLists(); + QList pieceLists = QList(); + for(auto sheet : m_piece->GetPieceList()->GetLayout()->GetSheets()) + { + pieceLists.append(sheet->GetPieceList()); + } + pieceLists.removeAll(m_piece->GetPieceList()); if(pieceLists.count() > 0) diff --git a/src/app/puzzle/vpgraphicssheet.cpp b/src/app/puzzle/vpgraphicssheet.cpp index 9919679b1..77b496a4c 100644 --- a/src/app/puzzle/vpgraphicssheet.cpp +++ b/src/app/puzzle/vpgraphicssheet.cpp @@ -29,10 +29,10 @@ #include "vpgraphicssheet.h" //--------------------------------------------------------------------------------------------------------------------- -VPGraphicsSheet::VPGraphicsSheet(VPLayout *layout, QGraphicsItem *parent): +VPGraphicsSheet::VPGraphicsSheet(VPSheet *sheet, QGraphicsItem *parent): QGraphicsItem(parent), - m_layout(layout), - m_boundingRect(GetLayoutRect()) + m_sheet(sheet), + m_boundingRect(GetSheetRect()) { } @@ -60,23 +60,23 @@ void VPGraphicsSheet::paint(QPainter *painter, const QStyleOptionGraphicsItem *o pen.setColor(Qt::black); painter->setPen(pen); - painter->drawRect(GetLayoutRect()); + painter->drawRect(GetSheetRect()); - m_boundingRect = GetLayoutRect(); + m_boundingRect = GetSheetRect(); } //--------------------------------------------------------------------------------------------------------------------- -QRectF VPGraphicsSheet::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; } //--------------------------------------------------------------------------------------------------------------------- QRectF VPGraphicsSheet::GetMarginsRect() const { - QMarginsF margins = m_layout->GetLayoutMargins(); - QSizeF size = m_layout->GetLayoutSize(); + QMarginsF margins = m_sheet->GetSheetMargins(); + QSizeF size = m_sheet->GetSheetSize(); QRectF rect = QRectF( QPointF(margins.left(),margins.top()), QPointF(size.width()-margins.right(), size.height()-margins.bottom()) diff --git a/src/app/puzzle/vpgraphicssheet.h b/src/app/puzzle/vpgraphicssheet.h index 01183d97c..0c20ea2ec 100644 --- a/src/app/puzzle/vpgraphicssheet.h +++ b/src/app/puzzle/vpgraphicssheet.h @@ -32,26 +32,26 @@ #include #include -#include "vplayout.h" +#include "vpsheet.h" class VPGraphicsSheet : public QGraphicsItem { public: - explicit VPGraphicsSheet(VPLayout *layout, QGraphicsItem *parent = nullptr); + explicit VPGraphicsSheet(VPSheet *sheet, QGraphicsItem *parent = nullptr); ~VPGraphicsSheet(); QRectF boundingRect() const override; void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget) override; - QRectF GetLayoutRect() const; + QRectF GetSheetRect() const; QRectF GetMarginsRect() const; private: Q_DISABLE_COPY(VPGraphicsSheet) - VPLayout *m_layout{nullptr}; + VPSheet *m_sheet{nullptr}; QRectF m_boundingRect; }; diff --git a/src/app/puzzle/vplayout.cpp b/src/app/puzzle/vplayout.cpp index 1f9087836..5c7052d95 100644 --- a/src/app/puzzle/vplayout.cpp +++ b/src/app/puzzle/vplayout.cpp @@ -28,26 +28,19 @@ #include "vplayout.h" #include "vppiecelist.h" #include "vppiece.h" +#include "vpsheet.h" //--------------------------------------------------------------------------------------------------------------------- VPLayout::VPLayout() : m_unplacedPieceList(new VPPieceList(this)) { m_unplacedPieceList->SetName(QObject::tr("Unplaced pieces")); - - // create a standard default piecelist: - VPPieceList *pieceList = new VPPieceList(this); - pieceList->SetName(QObject::tr("Layout")); - AddPieceList(pieceList); - - // sets the default active piece list - SetFocusedPieceList(); } //--------------------------------------------------------------------------------------------------------------------- VPLayout::~VPLayout() { - qDeleteAll(m_pieceLists); + qDeleteAll(m_sheets); delete m_unplacedPieceList; } @@ -58,24 +51,24 @@ VPPieceList* VPLayout::GetUnplacedPieceList() } //--------------------------------------------------------------------------------------------------------------------- -VPPieceList* VPLayout::AddPieceList() +VPSheet* VPLayout::AddSheet() { - VPPieceList *newPieceList = new VPPieceList(this); - m_pieceLists.append(newPieceList); - return newPieceList; + VPSheet *newSheet = new VPSheet(this); + m_sheets.append(newSheet); + return newSheet; } //--------------------------------------------------------------------------------------------------------------------- -VPPieceList* VPLayout::AddPieceList(VPPieceList *pieceList) +VPSheet* VPLayout::AddSheet(VPSheet *sheet) { - m_pieceLists.append(pieceList); - return pieceList; + m_sheets.append(sheet); + return sheet; } //--------------------------------------------------------------------------------------------------------------------- -QList VPLayout::GetPiecesLists() +QList VPLayout::GetSheets() { - return m_pieceLists; + return m_sheets; } //--------------------------------------------------------------------------------------------------------------------- @@ -83,8 +76,12 @@ QList VPLayout::GetSelectedPieces() { QList result = QList(); - QList pieceLists = m_pieceLists; - pieceLists.prepend(m_unplacedPieceList); + QList pieceLists = QList(); + pieceLists.append(m_unplacedPieceList); + for (auto sheet : m_sheets) + { + pieceLists.append(sheet->GetPieceList()); + } for (auto pieceList : pieceLists) { @@ -113,128 +110,6 @@ Unit VPLayout::GetUnit() const return m_unit; } -//--------------------------------------------------------------------------------------------------------------------- -void VPLayout::SetLayoutSize(qreal width, qreal height) -{ - m_size.setWidth(width); - m_size.setHeight(height); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPLayout::SetLayoutSizeConverted(qreal width, qreal height) -{ - m_size.setWidth(UnitConvertor(width, m_unit, Unit::Px)); - m_size.setHeight(UnitConvertor(height, m_unit, Unit::Px)); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPLayout::SetLayoutSize(const QSizeF &size) -{ - m_size = size; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPLayout::SetLayoutSizeConverted(const QSizeF &size) -{ - m_size = QSizeF( - UnitConvertor(size.width(), m_unit, Unit::Px), - UnitConvertor(size.height(), m_unit, Unit::Px) - ); -} - -//--------------------------------------------------------------------------------------------------------------------- -QSizeF VPLayout::GetLayoutSize() const -{ - return m_size; -} - -//--------------------------------------------------------------------------------------------------------------------- -QSizeF VPLayout::GetLayoutSizeConverted() const -{ - QSizeF convertedSize = QSizeF( - UnitConvertor(m_size.width(), Unit::Px, m_unit), - UnitConvertor(m_size.height(), Unit::Px, m_unit) - ); - - return convertedSize; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPLayout::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 VPLayout::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 VPLayout::SetLayoutMargins(const QMarginsF &margins) -{ - m_margins = margins; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPLayout::SetLayoutMarginsConverted(const QMarginsF &margins) -{ - m_margins = UnitConvertor(margins, m_unit, Unit::Px); -} - -//--------------------------------------------------------------------------------------------------------------------- -QMarginsF VPLayout::GetLayoutMargins() const -{ - return m_margins; -} - -//--------------------------------------------------------------------------------------------------------------------- -QMarginsF VPLayout::GetLayoutMarginsConverted() const -{ - return UnitConvertor(m_margins, Unit::Px, m_unit); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPLayout::SetFollowGrainline(FollowGrainline state) -{ - m_followGrainLine = state; -} - -//--------------------------------------------------------------------------------------------------------------------- -FollowGrainline VPLayout::GetFollowGrainline() const -{ - return m_followGrainLine; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPLayout::SetPiecesGap(qreal value) -{ - m_piecesGap = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPLayout::SetPiecesGapConverted(qreal value) -{ - m_piecesGap = UnitConvertor(value, m_unit, Unit::Px); -} - -//--------------------------------------------------------------------------------------------------------------------- -qreal VPLayout::GetPiecesGap() const -{ - return m_piecesGap; -} - -//--------------------------------------------------------------------------------------------------------------------- -qreal VPLayout::GetPiecesGapConverted() const -{ - return UnitConvertor(m_piecesGap, Unit::Px, m_unit); -} //--------------------------------------------------------------------------------------------------------------------- void VPLayout::SetWarningSuperpositionOfPieces(bool state) @@ -260,48 +135,17 @@ bool VPLayout::GetWarningPiecesOutOfBound() const return m_warningPiecesOutOfBound; } -//--------------------------------------------------------------------------------------------------------------------- -void VPLayout::SetStickyEdges(bool state) -{ - m_stickyEdges = state; -} - -//--------------------------------------------------------------------------------------------------------------------- -bool VPLayout::GetStickyEdges() const -{ - return m_stickyEdges; -} - //--------------------------------------------------------------------------------------------------------------------- void VPLayout::ClearSelection() { m_unplacedPieceList->ClearSelection(); - for (auto pieceList : m_pieceLists) + for (auto sheet : m_sheets) { - pieceList->ClearSelection(); + sheet->ClearSelection(); } } -//--------------------------------------------------------------------------------------------------------------------- -void VPLayout::SetFocusedPieceList(VPPieceList* focusedPieceList) -{ - if(focusedPieceList == nullptr) - { - m_focusedPieceList = m_pieceLists.first(); - } - else - { - m_focusedPieceList = focusedPieceList; - } -} - -//--------------------------------------------------------------------------------------------------------------------- -VPPieceList* VPLayout::GetFocusedPieceList() -{ - return m_focusedPieceList; -} - //--------------------------------------------------------------------------------------------------------------------- void VPLayout::MovePieceToPieceList(VPPiece* piece, VPPieceList* pieceList) { @@ -316,3 +160,23 @@ void VPLayout::MovePieceToPieceList(VPPiece* piece, VPPieceList* pieceList) // 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; +} diff --git a/src/app/puzzle/vplayout.h b/src/app/puzzle/vplayout.h index b03668685..5d36fad93 100644 --- a/src/app/puzzle/vplayout.h +++ b/src/app/puzzle/vplayout.h @@ -28,17 +28,14 @@ #ifndef VPLAYOUT_H #define VPLAYOUT_H -#include -#include + #include #include "def.h" class VPPieceList; class VPPiece; - -// is this the right place for the definition? -enum class FollowGrainline : qint8 { No = 0, Follow90 = 1, Follow180 = 2}; +class VPSheet; class VPLayout : public QObject { @@ -53,9 +50,9 @@ public: */ VPPieceList* GetUnplacedPieceList(); - VPPieceList* AddPieceList(); - VPPieceList* AddPieceList(VPPieceList *pieceList); - QList GetPiecesLists(); + VPSheet* AddSheet(); + VPSheet* AddSheet(VPSheet *sheet); + QList GetSheets(); /** * @brief GetSelectedPieces Returns the list of the selected pieces @@ -75,150 +72,18 @@ public: */ 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 piece list and pieces and calls + * @brief ClearSelection goes through the unplaced pieces and through the sheets and calls * SetIsSelected(false) for the pieces that were selected. */ void ClearSelection(); - /** - * @brief SetFocusedPieceList Sets the focused piece klist, to which pieces are added from the carrousel via drag - * and drop - * @param focusedPieceList the new active piece list. If nullptr, then it sets automaticaly the first piece list from m_pieceLists - */ - void SetFocusedPieceList(VPPieceList* focusedPieceList = nullptr); - - /** - * @brief GetFocusedPieceList Returns the focused piece list, to which pieces are added from the carrousel via drag - * and drop - * @return the focused piece list - */ - VPPieceList* GetFocusedPieceList(); - /** * @brief MovePieceToPieceList Moves the given piece to the given piece list * @param piece the piece to move @@ -226,6 +91,21 @@ public: */ 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); @@ -234,37 +114,25 @@ private: Q_DISABLE_COPY(VPLayout) VPPieceList *m_unplacedPieceList; - QList m_pieceLists{}; + + QList 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}; - /** - * @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}; + }; diff --git a/src/app/puzzle/vpmaingraphicsview.cpp b/src/app/puzzle/vpmaingraphicsview.cpp index 17ec5ee48..a114a8ff0 100644 --- a/src/app/puzzle/vpmaingraphicsview.cpp +++ b/src/app/puzzle/vpmaingraphicsview.cpp @@ -34,6 +34,8 @@ #include "vpmimedatapiece.h" #include "vppiecelist.h" +#include "vplayout.h" +#include "vpsheet.h" #include "../vwidgets/vmaingraphicsscene.h" #include @@ -46,10 +48,11 @@ VPMainGraphicsView::VPMainGraphicsView(VPLayout *layout, QWidget *parent) : VMainGraphicsView(parent), m_layout(layout) { + // TODO : list of scenes m_scene = new VMainGraphicsScene(this); setScene(m_scene); - m_graphicsSheet = new VPGraphicsSheet(layout); + m_graphicsSheet = new VPGraphicsSheet(layout->GetFocusedSheet()); m_graphicsSheet->setPos(0, 0); m_scene->addItem(m_graphicsSheet); @@ -123,7 +126,7 @@ void VPMainGraphicsView::dropEvent(QDropEvent *event) piece->SetPosition(mapToScene(point)); // change the piecelist of the piece - VPPieceList *focusedPieceList = m_layout->GetFocusedPieceList(); + VPPieceList *focusedPieceList = m_layout->GetFocusedSheet()->GetPieceList(); if(focusedPieceList != nullptr) { m_layout->MovePieceToPieceList(piece, focusedPieceList); diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index e9afa30f4..c383074db 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -40,6 +40,7 @@ #include "../vmisc/projectversion.h" #include "../ifc/xml/vlayoutconverter.h" #include "../ifc/exception/vexception.h" +#include "vpsheet.h" #include @@ -57,13 +58,19 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) : ui(new Ui::VPMainWindow), m_cmd(cmd) { - m_layout = new VPLayout(); + // 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------------------ - m_layout->SetLayoutMarginsConverted(2, 2, 2, 2); - m_layout->SetLayoutSizeConverted(30.0, 45); - m_layout->SetPiecesGapConverted(1); + sheet->SetSheetMarginsConverted(2, 2, 2, 2); + sheet->SetSheetSizeConverted(30.0, 45); + sheet->SetPiecesGapConverted(1); + m_layout->SetUnit(Unit::Cm); m_layout->SetWarningSuperpositionOfPieces(true); // -------------------------------------------------------- @@ -270,32 +277,32 @@ void VPMainWindow::InitPropertyTabLayout() // see https://doc.qt.io/qt-5/designer-using-a-ui-file.html#widgets-and-dialogs-with-auto-connect // -------------------- layout width, length, orientation ------------------------ - connect(ui->doubleSpinBoxLayoutWidth, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &VPMainWindow::on_LayoutSizeChanged); - connect(ui->doubleSpinBoxLayoutLength, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &VPMainWindow::on_LayoutSizeChanged); - connect(ui->radioButtonLayoutPortrait, QOverload::of(&QRadioButton::clicked), this, - &VPMainWindow::on_LayoutOrientationChanged); - connect(ui->radioButtonLayoutLandscape, QOverload::of(&QRadioButton::clicked), this, - &VPMainWindow::on_LayoutOrientationChanged); + connect(ui->doubleSpinBoxSheetWidth, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &VPMainWindow::on_SheetSizeChanged); + connect(ui->doubleSpinBoxSheetLength, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &VPMainWindow::on_SheetSizeChanged); + connect(ui->radioButtonSheetPortrait, QOverload::of(&QRadioButton::clicked), this, + &VPMainWindow::on_SheetOrientationChanged); + connect(ui->radioButtonSheetLandscape, QOverload::of(&QRadioButton::clicked), this, + &VPMainWindow::on_SheetOrientationChanged); // -------------------- margins ------------------------ - connect(ui->doubleSpinBoxLayoutMarginTop, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &VPMainWindow::on_LayoutMarginChanged); - connect(ui->doubleSpinBoxLayoutMarginRight, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &VPMainWindow::on_LayoutMarginChanged); - connect(ui->doubleSpinBoxLayoutMarginBottom, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &VPMainWindow::on_LayoutMarginChanged); - connect(ui->doubleSpinBoxLayoutMarginLeft, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &VPMainWindow::on_LayoutMarginChanged); + connect(ui->doubleSpinBoxSheetMarginTop, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &VPMainWindow::on_SheetMarginChanged); + connect(ui->doubleSpinBoxSheetMarginRight, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &VPMainWindow::on_SheetMarginChanged); + connect(ui->doubleSpinBoxSheetMarginBottom, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &VPMainWindow::on_SheetMarginChanged); + connect(ui->doubleSpinBoxSheetMarginLeft, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &VPMainWindow::on_SheetMarginChanged); // ------------------- follow grainline ----------------------- - connect(ui->radioButtonLayoutFollowGrainlineNo, QOverload::of(&QRadioButton::clicked), this, - &VPMainWindow::on_LayoutFollowGrainlineChanged); - connect(ui->radioButtonLayoutFollowGrainlineVertical, QOverload::of(&QRadioButton::clicked), this, - &VPMainWindow::on_LayoutFollowGrainlineChanged); - connect(ui->radioButtonLayoutFollowGrainlineHorizontal, QOverload::of(&QRadioButton::clicked), this, - &VPMainWindow::on_LayoutFollowGrainlineChanged); + connect(ui->radioButtonSheetFollowGrainlineNo, QOverload::of(&QRadioButton::clicked), this, + &VPMainWindow::on_SheetFollowGrainlineChanged); + connect(ui->radioButtonSheetFollowGrainlineVertical, QOverload::of(&QRadioButton::clicked), this, + &VPMainWindow::on_SheetFollowGrainlineChanged); + connect(ui->radioButtonSheetFollowGrainlineHorizontal, QOverload::of(&QRadioButton::clicked), this, + &VPMainWindow::on_SheetFollowGrainlineChanged); // -------------------- export --------------------------- @@ -332,8 +339,9 @@ void VPMainWindow::SetPropertiesData() else { SetPropertyTabCurrentPieceData(); - SetPropertyTabLayoutData(); + SetPropertyTabSheetData(); SetPropertyTabTilesData(); + SetPropertyTabLayoutData(); } } @@ -384,9 +392,43 @@ void VPMainWindow::SetPropertyTabCurrentPieceData() } } +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::SetPropertyTabSheetData() +{ + // 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 int index = ui->comboBoxLayoutUnit->findData(QVariant(UnitsToStr(m_layout->GetUnit()))); if(index != -1) @@ -396,35 +438,9 @@ void VPMainWindow::SetPropertyTabLayoutData() ui->comboBoxLayoutUnit->blockSignals(false); } - // set Width / Length - 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 + // set controls SetCheckBoxValue(ui->checkBoxLayoutWarningPiecesOutOfBound, m_layout->GetWarningPiecesOutOfBound()); SetCheckBoxValue(ui->checkBoxLayoutWarningPiecesSuperposition, m_layout->GetWarningSuperpositionOfPieces()); - SetCheckBoxValue(ui->checkBoxLayoutStickyEdges, m_layout->GetStickyEdges()); } //--------------------------------------------------------------------------------------------------------------------- @@ -763,16 +779,16 @@ void VPMainWindow::on_comboBoxLayoutUnit_currentIndexChanged(int index) m_layout->SetUnit(Unit::Inch); } - SetPropertyTabLayoutData(); + SetPropertyTabSheetData(); SetPropertyTabCurrentPieceData(); } //--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_comboBoxLayoutTemplate_currentIndexChanged(int index) +void VPMainWindow::on_comboBoxSheetTemplate_currentIndexChanged(int index) { // just for test purpuses, to be removed: QMessageBox msgBox; - msgBox.setText("TODO VPMainWindow::LayoutTemplateChanged"); + msgBox.setText("TODO VPMainWindow::SheetTemplateChanged"); int ret = msgBox.exec(); Q_UNUSED(index); @@ -783,20 +799,20 @@ void VPMainWindow::on_comboBoxLayoutTemplate_currentIndexChanged(int index) } //--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::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" - if(ui->doubleSpinBoxLayoutWidth->value() <= ui->doubleSpinBoxLayoutLength->value()) + if(ui->doubleSpinBoxSheetWidth->value() <= ui->doubleSpinBoxSheetLength->value()) { //portrait - ui->radioButtonLayoutPortrait->setChecked(true); + ui->radioButtonSheetPortrait->setChecked(true); } else { //landscape - ui->radioButtonLayoutLandscape->setChecked(true); + ui->radioButtonSheetLandscape->setChecked(true); } // TODO Undo / Redo @@ -805,16 +821,16 @@ void VPMainWindow::on_LayoutSizeChanged() } //--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_LayoutOrientationChanged() +void VPMainWindow::on_SheetOrientationChanged() { // swap the width and length - qreal width_before = ui->doubleSpinBoxLayoutWidth->value(); - qreal length_before = ui->doubleSpinBoxLayoutLength->value(); + qreal width_before = ui->doubleSpinBoxSheetWidth->value(); + qreal length_before = ui->doubleSpinBoxSheetLength->value(); - SetDoubleSpinBoxValue(ui->doubleSpinBoxLayoutWidth, length_before); - SetDoubleSpinBoxValue(ui->doubleSpinBoxLayoutLength, width_before); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetWidth, length_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 @@ -822,7 +838,7 @@ void VPMainWindow::on_LayoutOrientationChanged() } //--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_pushButtonLayoutRemoveUnusedLength_clicked() +void VPMainWindow::on_pushButtonSheetRemoveUnusedLength_clicked() { // just for test purpuses, to be removed: QMessageBox msgBox; @@ -836,13 +852,13 @@ void VPMainWindow::on_pushButtonLayoutRemoveUnusedLength_clicked() //--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_LayoutMarginChanged() +void VPMainWindow::on_SheetMarginChanged() { - m_layout->SetLayoutMarginsConverted( - ui->doubleSpinBoxLayoutMarginLeft->value(), - ui->doubleSpinBoxLayoutMarginTop->value(), - ui->doubleSpinBoxLayoutMarginRight->value(), - ui->doubleSpinBoxLayoutMarginBottom->value() + m_layout->GetFocusedSheet()->SetSheetMarginsConverted( + ui->doubleSpinBoxSheetMarginLeft->value(), + ui->doubleSpinBoxSheetMarginTop->value(), + ui->doubleSpinBoxSheetMarginRight->value(), + ui->doubleSpinBoxSheetMarginBottom->value() ); // TODO Undo / Redo @@ -852,7 +868,7 @@ void VPMainWindow::on_LayoutMarginChanged() //--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_LayoutFollowGrainlineChanged() +void VPMainWindow::on_SheetFollowGrainlineChanged() { // just for test purpuses, to be removed: QMessageBox msgBox; @@ -866,9 +882,9 @@ void VPMainWindow::on_LayoutFollowGrainlineChanged() //--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::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 update the QGraphicView @@ -893,16 +909,16 @@ void VPMainWindow::on_checkBoxLayoutWarningPiecesOutOfBound_toggled(bool checked } //--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::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 update the QGraphicView } //--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_pushButtonLayoutExport_clicked() +void VPMainWindow::on_pushButtonSheetExport_clicked() { // just for test purpuses, to be removed: QMessageBox msgBox; diff --git a/src/app/puzzle/vpmainwindow.h b/src/app/puzzle/vpmainwindow.h index 275f2fb00..65380c4dc 100644 --- a/src/app/puzzle/vpmainwindow.h +++ b/src/app/puzzle/vpmainwindow.h @@ -152,10 +152,10 @@ private: void SetPropertyTabCurrentPieceData(); /** - * @brief SetPropertyTabLayoutData Sets the values of UI elements - * in the Layout Tab to the values saved in m_layout + * @brief SetPropertyTabSheetData Sets the values of UI elements + * in the Sheet Tab to the values saved in focused sheet */ - void SetPropertyTabLayoutData(); + void SetPropertyTabSheetData(); /** * @brief SetPropertyTabTilesData Sets the values of UI elements @@ -163,6 +163,12 @@ private: */ void SetPropertyTabTilesData(); + /** + * @brief SetPropertyTabLayoutData Sets the values of UI elements + * in the Layout Tab to the values saved in m_layout + */ + void SetPropertyTabLayoutData(); + /** * @brief SetDoubleSpinBoxValue sets the given spinbox to the given value. * the signals are blocked before changing the value and unblocked after @@ -248,38 +254,38 @@ private slots: * The slot is automatically connected through name convention. * @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 * the layout property tab */ - void on_LayoutSizeChanged(); + void on_SheetSizeChanged(); /** * @brief LayoutOrientationChanged When one of the radio boxes for the layout * orientation has been clicked */ - void on_LayoutOrientationChanged(); + void on_SheetOrientationChanged(); /** * @brief on_pushButtonLayoutRemoveUnusedLength_clicked When the button * "Remove unused length" in the layout property tab is clicked. * 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 * in the layout property tab. */ - void on_LayoutMarginChanged(); + void on_SheetMarginChanged(); /** * @brief LayoutFollowGrainlineChanged When one of the radio boxes for the * "Follow grainline" has been clicked in the layout property tab. */ - void on_LayoutFollowGrainlineChanged(); + void on_SheetFollowGrainlineChanged(); /** * @brief on_doubleSpinBoxLayoutPiecesGap_valueChanged When the "pieces gap" @@ -287,7 +293,7 @@ private slots: * The slot is automatically connected through name convention. * @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 @@ -313,14 +319,14 @@ private slots: * The slot is automatically connected through name convention. * @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 * "Export layout" in the layout property is clicked. * The slot is automatically connected through name convention. */ - void on_pushButtonLayoutExport_clicked(); + void on_pushButtonSheetExport_clicked(); /** * @brief on_checkBoxCurrentPieceShowSeamline_toggled When the diff --git a/src/app/puzzle/vpmainwindow.ui b/src/app/puzzle/vpmainwindow.ui index 677c1286d..927c80787 100644 --- a/src/app/puzzle/vpmainwindow.ui +++ b/src/app/puzzle/vpmainwindow.ui @@ -172,7 +172,7 @@ QTabWidget::Rounded - 2 + 1 @@ -458,7 +458,7 @@ - + :/puzzleicon/64x64/iconLayout.png:/puzzleicon/64x64/iconLayout.png @@ -483,7 +483,7 @@ 0 - + QFrame::NoFrame @@ -507,12 +507,12 @@ - + font-weight: bold; - Layout + Current sheet Qt::AlignCenter @@ -520,7 +520,7 @@ - + Format @@ -528,64 +528,54 @@ - - - Unit - - - - - - - - + Template - - + + - - + + Width - - + + 100000.000000000000000 - - + + + + Length + + + + + 100000.000000000000000 - - - Length - - - - - + Orientation - + - + Portrait @@ -608,7 +598,7 @@ - + Landscape @@ -632,7 +622,7 @@ - + Remove unused length @@ -642,13 +632,13 @@ - + Margins - + Right: @@ -658,7 +648,7 @@ - + Top: @@ -668,21 +658,21 @@ - + 0.100000000000000 - + 0.100000000000000 - + Left: @@ -692,7 +682,7 @@ - + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -702,14 +692,14 @@ - + 0.100000000000000 - + Bottom: @@ -722,7 +712,7 @@ - + Control @@ -730,7 +720,7 @@ - + Follow grainline @@ -739,7 +729,7 @@ - + No @@ -749,7 +739,7 @@ - + Vertical grainline @@ -769,7 +759,7 @@ - + Horizontal grainline @@ -791,33 +781,19 @@ - + Pieces gap - + - - - Warning superposition of pieces - - - - - - - Warning pieces out of bound - - - - - + Sticky edges @@ -827,7 +803,7 @@ - + Export @@ -835,21 +811,21 @@ - + Format - + - + - Export Layout + Export Sheet @@ -857,7 +833,7 @@ - + Qt::Vertical @@ -929,7 +905,7 @@ font-weight: bold; - Tiles + Tiles of current sheet Qt::AlignCenter @@ -955,6 +931,162 @@ + + + Prop. + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::NoFrame + + + QFrame::Plain + + + 0 + + + true + + + + + 0 + 0 + 356 + 760 + + + + + + + font-weight: bold; + + + Layout + + + Qt::AlignCenter + + + + + + + Infos + + + + + + + + Name + + + + + + + My layout + + + + + + + + + Description + + + + + + + + + + + + + Format + + + + + + + + Unit + + + + + + + + + + + + + + + Control + + + + + + Warning superposition of pieces + + + + + + + Warning pieces out of bound + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + @@ -1041,11 +1173,11 @@ - scrollAreaLayout - doubleSpinBoxLayoutMarginTop - doubleSpinBoxLayoutMarginLeft - doubleSpinBoxLayoutMarginRight - doubleSpinBoxLayoutMarginBottom + scrollAreaSheet + doubleSpinBoxSheetMarginTop + doubleSpinBoxSheetMarginLeft + doubleSpinBoxSheetMarginRight + doubleSpinBoxSheetMarginBottom scrollAreaTiles diff --git a/src/app/puzzle/vppiece.h b/src/app/puzzle/vppiece.h index 759909631..d536c569f 100644 --- a/src/app/puzzle/vppiece.h +++ b/src/app/puzzle/vppiece.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vpiece.h + ** @file vppiece.h ** @author Ronan Le Tiec ** @date 13 4, 2020 ** diff --git a/src/app/puzzle/vpsheet.cpp b/src/app/puzzle/vpsheet.cpp index a89e4227b..d61f586c7 100644 --- a/src/app/puzzle/vpsheet.cpp +++ b/src/app/puzzle/vpsheet.cpp @@ -1,6 +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 + ** 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 . + ** + *************************************************************************/ #include "vpsheet.h" -VPSheet::VPSheet() -{ +#include "vppiecelist.h" +#include "vplayout.h" +//--------------------------------------------------------------------------------------------------------------------- +VPSheet::VPSheet(VPLayout* layout) : + m_layout(layout) +{ + m_pieceList = new VPPieceList(layout); +} + +//--------------------------------------------------------------------------------------------------------------------- +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(); } diff --git a/src/app/puzzle/vpsheet.h b/src/app/puzzle/vpsheet.h index c2cd9dffb..ea9fb58f4 100644 --- a/src/app/puzzle/vpsheet.h +++ b/src/app/puzzle/vpsheet.h @@ -1,11 +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 + ** 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 . + ** + *************************************************************************/ #ifndef VPSHEET_H #define VPSHEET_H +#include +#include +#include +#include -class VPSheet +#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(); + 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 diff --git a/src/app/puzzle/xml/vplayoutfilereader.cpp b/src/app/puzzle/xml/vplayoutfilereader.cpp index 59ce5d1ca..233bf6c65 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.cpp +++ b/src/app/puzzle/xml/vplayoutfilereader.cpp @@ -72,7 +72,11 @@ void VPLayoutFileReader::ReadLayout(VPLayout *layout) } else if (name() == ML::TagPieceLists) { - ReadPieceLists(layout); + ReadSheets(layout); + } + else if (name() == ML::TagUnplacedPieceList) + { + ReadUnplacedPieces(layout); } else { @@ -94,8 +98,6 @@ void VPLayoutFileReader::ReadProperties(VPLayout *layout) { ML::TagUnit, ML::TagDescription, - ML::TagSize, - ML::TagMargin, ML::TagControl, ML::TagTiles }); @@ -113,38 +115,17 @@ void VPLayoutFileReader::ReadProperties(VPLayout *layout) // TODO read the description info break; } - case 2:// size - { - 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 + case 2:// control { qDebug("read control"); QXmlStreamAttributes attribs = attributes(); - - // attribs.value("followGrainLine"); // TODO - layout->SetWarningSuperpositionOfPieces(ReadAttributeBool(attribs, ML::AttrWarningSuperposition, trueStr)); layout->SetWarningPiecesOutOfBound(ReadAttributeBool(attribs, ML::AttrWarningOutOfBound, trueStr)); - layout->SetStickyEdges(ReadAttributeBool(attribs, ML::AttrStickyEdges, trueStr)); - layout->SetPiecesGap(ReadAttributeDouble(attribs, ML::AttrPiecesGap, QChar('0'))); readElementText(); break; } - case 5:// tiles + case 3:// tiles qDebug("read tiles"); ReadTiles(layout); readElementText(); @@ -157,6 +138,12 @@ void VPLayoutFileReader::ReadProperties(VPLayout *layout) } } +//--------------------------------------------------------------------------------------------------------------------- +void VPLayoutFileReader::ReadUnplacedPieces(VPLayout *layout) +{ + ReadPieceList(layout->GetUnplacedPieceList()); +} + //--------------------------------------------------------------------------------------------------------------------- void VPLayoutFileReader::ReadTiles(VPLayout *layout) { @@ -193,20 +180,15 @@ void VPLayoutFileReader::ReadTiles(VPLayout *layout) } //--------------------------------------------------------------------------------------------------------------------- -void VPLayoutFileReader::ReadPieceLists(VPLayout *layout) +void VPLayoutFileReader::ReadSheets(VPLayout *layout) { - SCASSERT(isStartElement() && name() == ML::TagPieceLists); + SCASSERT(isStartElement() && name() == ML::TagSheets); while (readNextStartElement()) { - if (name() == ML::TagUnplacedPieceList) + if (name() == ML::TagSheet) { - ReadPieceList(layout->GetUnplacedPieceList()); - } - else if (name() == ML::TagPieceList) - { - VPPieceList *pieceList = layout->AddPieceList(); - ReadPieceList(pieceList); + ReadSheet(layout); } else { @@ -216,6 +198,14 @@ void VPLayoutFileReader::ReadPieceLists(VPLayout *layout) } } +//--------------------------------------------------------------------------------------------------------------------- +void VPLayoutFileReader::ReadSheet(VPLayout *layout) +{ + Q_UNUSED(layout); + // TODO +} + + //--------------------------------------------------------------------------------------------------------------------- void VPLayoutFileReader::ReadPieceList(VPPieceList *pieceList) { diff --git a/src/app/puzzle/xml/vplayoutfilereader.h b/src/app/puzzle/xml/vplayoutfilereader.h index db38265d6..7ed40f1a8 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.h +++ b/src/app/puzzle/xml/vplayoutfilereader.h @@ -50,7 +50,9 @@ private: void ReadLayout(VPLayout *layout); void ReadProperties(VPLayout *layout); void ReadTiles(VPLayout *layout); - void ReadPieceLists(VPLayout *layout); + void ReadUnplacedPieces(VPLayout *layout); + void ReadSheets(VPLayout *layout); + void ReadSheet(VPLayout *layout); void ReadPieceList(VPPieceList *pieceList); void ReadPiece(VPPiece *piece); diff --git a/src/app/puzzle/xml/vplayoutfilewriter.cpp b/src/app/puzzle/xml/vplayoutfilewriter.cpp index 92832f6c0..327e01aaf 100644 --- a/src/app/puzzle/xml/vplayoutfilewriter.cpp +++ b/src/app/puzzle/xml/vplayoutfilewriter.cpp @@ -28,6 +28,7 @@ #include "vplayoutfilewriter.h" #include "vplayout.h" +#include "vpsheet.h" #include "vppiecelist.h" #include "vppiece.h" #include "vplayoutliterals.h" @@ -65,7 +66,7 @@ void VPLayoutFileWriter::WriteLayout(VPLayout *layout) SetAttribute(ML::AttrVersion, VLayoutConverter::LayoutMaxVerStr); WriteProperties(layout); - WritePieceLists(layout); + WriteUnplacePiecesList(layout); writeEndElement(); //layout } @@ -79,16 +80,10 @@ void VPLayoutFileWriter::WriteProperties(VPLayout *layout) writeTextElement(ML::TagDescription, QString()); // TODO : define the value in layout - WriteSize(layout->GetLayoutSize()); - - WriteMargins(layout->GetLayoutMargins()); - writeStartElement(ML::TagControl); - SetAttribute(ML::AttrFollowGrainLine, "no"); // TODO / Fixme get the right value + SetAttribute(ML::AttrWarningSuperposition, layout->GetWarningSuperpositionOfPieces()); SetAttribute(ML::AttrWarningOutOfBound, layout->GetWarningPiecesOutOfBound()); - SetAttribute(ML::AttrStickyEdges, layout->GetStickyEdges()); - SetAttribute(ML::AttrPiecesGap, layout->GetPiecesGap()); writeEndElement(); // control // WriteTiles(layout); TODO: when tile functionality implemented, then uncomment this line @@ -96,6 +91,32 @@ void VPLayoutFileWriter::WriteProperties(VPLayout *layout) writeEndElement(); // properties } +//--------------------------------------------------------------------------------------------------------------------- +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) { @@ -115,23 +136,6 @@ void VPLayoutFileWriter::WriteTiles(VPLayout *layout) } -//--------------------------------------------------------------------------------------------------------------------- -void VPLayoutFileWriter::WritePieceLists(VPLayout *layout) -{ - writeStartElement(ML::TagPieceLists); - - WritePieceList(layout->GetUnplacedPieceList(), ML::TagUnplacedPieceList); - - QList pieceLists = layout->GetPiecesLists(); - for (auto pieceList : pieceLists) - { - WritePieceList(pieceList); - } - - writeEndElement(); // piece list -} - - //--------------------------------------------------------------------------------------------------------------------- void VPLayoutFileWriter::WritePieceList(VPPieceList *pieceList) { diff --git a/src/app/puzzle/xml/vplayoutfilewriter.h b/src/app/puzzle/xml/vplayoutfilewriter.h index a63ee4f0b..4498277c4 100644 --- a/src/app/puzzle/xml/vplayoutfilewriter.h +++ b/src/app/puzzle/xml/vplayoutfilewriter.h @@ -35,6 +35,7 @@ #include "../vmisc/literals.h" class VPLayout; +class VPSheet; class VPPieceList; class VPPiece; class QFile; @@ -52,8 +53,10 @@ private: void WriteLayout(VPLayout *layout); void WriteProperties(VPLayout *layout); + void WriteUnplacePiecesList(VPLayout *layout); + void WriteSheets(VPLayout *layout); + void WriteSheet(VPSheet* sheet); void WriteTiles(VPLayout *layout); - void WritePieceLists(VPLayout *layout); void WritePieceList(VPPieceList *pieceList); void WritePieceList(VPPieceList *pieceList, const QString &tagName); void WritePiece(VPPiece *piece); diff --git a/src/app/puzzle/xml/vplayoutliterals.cpp b/src/app/puzzle/xml/vplayoutliterals.cpp index 2421577e2..ada2d2f37 100644 --- a/src/app/puzzle/xml/vplayoutliterals.cpp +++ b/src/app/puzzle/xml/vplayoutliterals.cpp @@ -41,6 +41,8 @@ const QString TagTiles = QStringLiteral("tiles"); const QString TagUnplacedPieceList = QStringLiteral("unplacedPieceList"); const QString TagPieceList = QStringLiteral("pieceList"); const QString TagPiece = QStringLiteral("piece"); +const QString TagSheets = QStringLiteral("sheets"); +const QString TagSheet = QStringLiteral("sheet"); const QString AttrVersion = QStringLiteral("version"); const QString AttrWarningSuperposition = QStringLiteral("warningSuperposition"); diff --git a/src/app/puzzle/xml/vplayoutliterals.h b/src/app/puzzle/xml/vplayoutliterals.h index b0b2c970f..0f1278b7d 100644 --- a/src/app/puzzle/xml/vplayoutliterals.h +++ b/src/app/puzzle/xml/vplayoutliterals.h @@ -46,6 +46,8 @@ extern const QString TagTiles; extern const QString TagUnplacedPieceList; extern const QString TagPieceList; extern const QString TagPiece; +extern const QString TagSheets; +extern const QString TagSheet; extern const QString AttrVersion; extern const QString AttrWarningSuperposition; From b4b77c4cdf5015c1394a7fed1b5437e8841c09fa Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 17:51:00 +0200 Subject: [PATCH 26/28] Introducing VPSheet and refactoring part 3 --- src/app/puzzle/vpmainwindow.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index c383074db..16d6437a5 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -842,7 +842,7 @@ void VPMainWindow::on_pushButtonSheetRemoveUnusedLength_clicked() { // just for test purpuses, to be removed: QMessageBox msgBox; - msgBox.setText("TODO VPMainWindow::LayoutRemoveUnusedLength"); + msgBox.setText("TODO VPMainWindow::on_pushButtonSheetRemoveUnusedLength_clicked"); int ret = msgBox.exec(); Q_UNUSED(ret); @@ -872,7 +872,7 @@ void VPMainWindow::on_SheetFollowGrainlineChanged() { // just for test purpuses, to be removed: QMessageBox msgBox; - msgBox.setText("TODO VPMainWindow::LayoutFollowGrainlineChanged"); + msgBox.setText("TODO VPMainWindow::on_SheetFollowGrainlineChanged"); int ret = msgBox.exec(); Q_UNUSED(ret); @@ -922,7 +922,7 @@ void VPMainWindow::on_pushButtonSheetExport_clicked() { // just for test purpuses, to be removed: QMessageBox msgBox; - msgBox.setText("TODO VPMainWindow::LayoutExport"); + msgBox.setText("TODO VPMainWindow::on_pushButtonSheetExport_clicked"); int ret = msgBox.exec(); Q_UNUSED(ret); From f00168e59bc03c12a89356e0985c868fd21e6d22 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sun, 24 May 2020 14:55:03 +0200 Subject: [PATCH 27/28] Refactoring Piece carrousel --- src/app/puzzle/puzzle.pri | 2 - src/app/puzzle/vpcarrousel.cpp | 15 +- src/app/puzzle/vpcarrousel.ui | 9 +- src/app/puzzle/vpcarrouselpiece.cpp | 275 +++++---------------- src/app/puzzle/vpcarrouselpiece.h | 43 +--- src/app/puzzle/vpcarrouselpiecelist.cpp | 210 +++++++++++----- src/app/puzzle/vpcarrouselpiecelist.h | 42 ++-- src/app/puzzle/vpcarrouselpiecepreview.cpp | 55 ----- src/app/puzzle/vpcarrouselpiecepreview.h | 45 ---- src/app/puzzle/vpgraphicspiece.cpp | 2 +- src/app/puzzle/vplayout.cpp | 3 +- src/app/puzzle/vppiece.cpp | 7 +- src/app/puzzle/vppiecelist.cpp | 9 +- src/app/puzzle/vppiecelist.h | 13 +- src/app/puzzle/vpsheet.cpp | 2 +- 15 files changed, 273 insertions(+), 459 deletions(-) delete mode 100644 src/app/puzzle/vpcarrouselpiecepreview.cpp delete mode 100644 src/app/puzzle/vpcarrouselpiecepreview.h diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index d3a03826c..5c90f52f5 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -8,7 +8,6 @@ SOURCES += \ $$PWD/vpcarrousel.cpp \ $$PWD/vpcarrouselpiece.cpp \ $$PWD/vpcarrouselpiecelist.cpp \ - $$PWD/vpcarrouselpiecepreview.cpp \ $$PWD/vpcommandline.cpp \ $$PWD/vpcommands.cpp \ $$PWD/vpgraphicspiece.cpp \ @@ -33,7 +32,6 @@ HEADERS += \ $$PWD/vpcarrousel.h \ $$PWD/vpcarrouselpiece.h \ $$PWD/vpcarrouselpiecelist.h \ - $$PWD/vpcarrouselpiecepreview.h \ $$PWD/vpcommandline.h \ $$PWD/vpcommands.h \ $$PWD/vpgraphicspiece.h \ diff --git a/src/app/puzzle/vpcarrousel.cpp b/src/app/puzzle/vpcarrousel.cpp index 8423a67ab..cf419a913 100644 --- a/src/app/puzzle/vpcarrousel.cpp +++ b/src/app/puzzle/vpcarrousel.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include "../vmisc/backport/qoverload.h" #include "vppiecelist.h" @@ -53,8 +54,6 @@ VPCarrousel::VPCarrousel(VPLayout *layout, QWidget *parent) : connect(ui->comboBoxPieceList, QOverload::of(&QComboBox::currentIndexChanged), this, &VPCarrousel::on_ActivePieceListChanged); - ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu); - // ------ then we fill the carrousel with the layout content Refresh(); } @@ -103,21 +102,11 @@ void VPCarrousel::on_ActivePieceListChanged(int index) { qCDebug(pCarrousel, "index changed %i", index); - ui->listWidget->clear(); - if (index >= 0 && index < m_pieceLists.size()) { VPPieceList *pieceList = m_pieceLists.at(index); - if (pieceList) - { - QList pieces = pieceList->GetPieces(); - - for (auto piece : pieces) - { - new QListWidgetItem(piece->PieceIcon(QSize(120, 120)) , piece->GetName(), ui->listWidget); - } - } + ui->listWidget->SetCurrentPieceList(pieceList); } } diff --git a/src/app/puzzle/vpcarrousel.ui b/src/app/puzzle/vpcarrousel.ui index c3669feb5..32e23095e 100644 --- a/src/app/puzzle/vpcarrousel.ui +++ b/src/app/puzzle/vpcarrousel.ui @@ -37,7 +37,7 @@ - + Qt::ScrollBarAlwaysOn @@ -72,6 +72,13 @@ + + + VPCarrouselPieceList + QListWidget +
vpcarrouselpiecelist.h
+
+
diff --git a/src/app/puzzle/vpcarrouselpiece.cpp b/src/app/puzzle/vpcarrouselpiece.cpp index 82b401cf8..a2ac6382a 100644 --- a/src/app/puzzle/vpcarrouselpiece.cpp +++ b/src/app/puzzle/vpcarrouselpiece.cpp @@ -28,12 +28,6 @@ #include "vpcarrouselpiece.h" -#include -#include -#include -#include -#include -#include #include #include @@ -48,103 +42,22 @@ Q_LOGGING_CATEGORY(pCarrouselPiece, "p.carrouselPiece") //--------------------------------------------------------------------------------------------------------------------- -VPCarrouselPiece::VPCarrouselPiece(VPPiece *piece, VPCarrouselPieceList *carrouselPieceList) : - m_piece(piece), - m_carrouselPieceList(carrouselPieceList), - m_dragStart(QPoint()) +VPCarrouselPiece::VPCarrouselPiece(VPPiece *piece, QListWidget* parent) : + QListWidgetItem(parent,1001), + m_piece(piece) { - Init(); + int width = 120 - 8; + QFontMetrics metrix = QFontMetrics(QFont()); + QString clippedText = metrix.elidedText(piece->GetName(), Qt::ElideRight, width); + setIcon(m_piece->PieceIcon(QSize(120, 120))); + setText(clippedText); } //--------------------------------------------------------------------------------------------------------------------- VPCarrouselPiece::~VPCarrouselPiece() { - delete m_piecePreview; -} -//--------------------------------------------------------------------------------------------------------------------- -void VPCarrouselPiece::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 VPCarrouselPiecePreview(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, &VPPiece::SelectionChanged, this, &VPCarrouselPiece::on_PieceSelectionChanged); - - // then refresh the data - Refresh(); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPCarrouselPiece::CleanPreview() -{ - m_piecePreview->fitInView(m_piecePreview->scene()->sceneRect(), Qt::KeepAspectRatio); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPCarrouselPiece::Refresh() -{ - // update the graphic view / the scene - - QVector 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(); } //--------------------------------------------------------------------------------------------------------------------- @@ -154,138 +67,62 @@ VPPiece * VPCarrouselPiece::GetPiece() } //--------------------------------------------------------------------------------------------------------------------- -void VPCarrouselPiece::on_PieceSelectionChanged() +void VPCarrouselPiece::RefreshSelection() { - if(m_piece->GetIsSelected()) - { - setStyleSheet("background-color:white; border: 2px solid red;"); - } - else - { - setStyleSheet("background-color:white; border: 2px solid transparent;"); - } + setSelected(m_piece->GetIsSelected()); } -//--------------------------------------------------------------------------------------------------------------------- -void VPCarrouselPiece::mousePressEvent(QMouseEvent *event) -{ - qCDebug(pCarrouselPiece, "mouse pressed"); +////--------------------------------------------------------------------------------------------------------------------- +//void VPCarrouselPiece::contextMenuEvent(QContextMenuEvent *event) +//{ +// QMenu contextMenu; +// VPPieceList* unplacedPieces = m_piece->GetPieceList()->GetLayout()->GetUnplacedPieceList(); +// QList sheets = m_piece->GetPieceList()->GetLayout()->GetSheets(); +// QList pieceLists = QList(); +// for (auto sheet : sheets) +// { +// pieceLists.append(sheet->GetPieceList()); +// } - if (event->button() == Qt::LeftButton) - { - if(!(event->modifiers() & Qt::ControlModifier)) - { - m_carrouselPieceList->GetCarrousel()->ClearSelection(); - m_piece->SetIsSelected(true); - } - else - { - m_piece->SetIsSelected(!m_piece->GetIsSelected()); - } +// // move to piece list actions -- TODO : To be tested properly when we have several piece lists +// pieceLists.removeAll(m_piece->GetPieceList()); +// if(pieceLists.count() > 0) +// { +// QMenu *moveMenu = contextMenu.addMenu(tr("Move to")); - m_dragStart = event->pos(); - } -} +// // TODO order in alphabetical order +// for (auto pieceList : pieceLists) +// { +// QAction* moveToPieceList = moveMenu->addAction(pieceList->GetName()); +// QVariant data = QVariant::fromValue(pieceList); +// moveToPieceList->setData(data); -//--------------------------------------------------------------------------------------------------------------------- -void VPCarrouselPiece::mouseMoveEvent(QMouseEvent *event) -{ - if (!(event->buttons() & Qt::LeftButton)) - { - return; - } +// connect(moveToPieceList, &QAction::triggered, this, &VPCarrouselPiece::on_ActionPieceMovedToPieceList); +// } +// } - if(m_piece->GetPieceList() != m_piece->GetPieceList()->GetLayout()->GetUnplacedPieceList()) - { - return; - } +// // remove from piece list action +// if(m_piece->GetPieceList() != unplacedPieces) +// { +// QAction *removeAction = contextMenu.addAction(tr("Remove from Sheet")); +// QVariant data = QVariant::fromValue(m_piece->GetPieceList()->GetLayout()->GetUnplacedPieceList()); +// removeAction->setData(data); +// connect(removeAction, &QAction::triggered, this, &VPCarrouselPiece::on_ActionPieceMovedToPieceList); +// } - if((event->pos() - m_dragStart).manhattanLength() < QApplication::startDragDistance()) - { - return; - } +// contextMenu.exec(event->globalPos()); +//} - // make sure the multiple selection is removed - m_carrouselPieceList->GetCarrousel()->ClearSelection(); - m_piece->SetIsSelected(true); - - // starts the dragging - QDrag *drag = new QDrag(this); - VPMimeDataPiece *mimeData = new VPMimeDataPiece(); - 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 VPCarrouselPiece::contextMenuEvent(QContextMenuEvent *event) -{ - QMenu contextMenu; - - VPPieceList* unplacedPieces = m_piece->GetPieceList()->GetLayout()->GetUnplacedPieceList(); - QList sheets = m_piece->GetPieceList()->GetLayout()->GetSheets(); - QList pieceLists = QList(); - for (auto sheet : sheets) - { - pieceLists.append(sheet->GetPieceList()); - } - - // move to piece list actions -- TODO : To be tested properly when we have several piece lists - pieceLists.removeAll(m_piece->GetPieceList()); - if(pieceLists.count() > 0) - { - QMenu *moveMenu = contextMenu.addMenu(tr("Move to")); - - // TODO order in alphabetical order - - for (auto pieceList : pieceLists) - { - QAction* moveToPieceList = moveMenu->addAction(pieceList->GetName()); - QVariant data = QVariant::fromValue(pieceList); - moveToPieceList->setData(data); - - connect(moveToPieceList, &QAction::triggered, this, &VPCarrouselPiece::on_ActionPieceMovedToPieceList); - } - } - - // remove from piece list action - if(m_piece->GetPieceList() != unplacedPieces) - { - QAction *removeAction = contextMenu.addAction(tr("Remove from Layout")); - QVariant data = QVariant::fromValue(m_piece->GetPieceList()->GetLayout()->GetUnplacedPieceList()); - removeAction->setData(data); - connect(removeAction, &QAction::triggered, this, &VPCarrouselPiece::on_ActionPieceMovedToPieceList); - } - - contextMenu.exec(event->globalPos()); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPCarrouselPiece::on_ActionPieceMovedToPieceList() -{ - QAction *act = qobject_cast(sender()); - QVariant v = act->data(); - VPPieceList *pieceList = v.value(); - if(pieceList != nullptr) - { - pieceList->GetLayout()->MovePieceToPieceList(m_piece, pieceList); - } -} +////--------------------------------------------------------------------------------------------------------------------- +//void VPCarrouselPiece::on_ActionPieceMovedToPieceList() +//{ +// QAction *act = qobject_cast(sender()); +// QVariant v = act->data(); +// VPPieceList *pieceList = v.value(); +// if(pieceList != nullptr) +// { +// pieceList->GetLayout()->MovePieceToPieceList(m_piece, pieceList); +// } +//} diff --git a/src/app/puzzle/vpcarrouselpiece.h b/src/app/puzzle/vpcarrouselpiece.h index 8512abf54..46f0afe2c 100644 --- a/src/app/puzzle/vpcarrouselpiece.h +++ b/src/app/puzzle/vpcarrouselpiece.h @@ -28,48 +28,28 @@ #ifndef VPCARROUSELPIECE_H #define VPCARROUSELPIECE_H -#include -#include -#include #include +#include #include "vppiece.h" -#include "vpcarrouselpiecepreview.h" -class VPCarrouselPieceList; - -class VPCarrouselPiece : public QFrame +class VPCarrouselPiece : public QListWidgetItem { - Q_OBJECT public: - explicit VPCarrouselPiece(VPPiece *piece, VPCarrouselPieceList *carrouselPieceList); + explicit VPCarrouselPiece(VPPiece *piece, QListWidget* parent); ~VPCarrouselPiece(); - void Init(); - void Refresh(); - - /** - * @brief CleanPiecesPreview fitInView of the qGraphicsView of the pieces works properly - * only when the piece is in place in the piece list and we call it from the piece list. - */ - void CleanPreview(); - /** * @brief GetPiece Returns the corresponding layout piece * @return the corresponding layout piece */ VPPiece * GetPiece(); -public slots: - void on_PieceSelectionChanged(); - -protected: - void mousePressEvent(QMouseEvent *event) override; - - void mouseMoveEvent(QMouseEvent *event) override; - - void contextMenuEvent(QContextMenuEvent *event) override; + /** + * @brief RefreshSelection refreshes the selection of the piece according to the selection information of m_piece + */ + void RefreshSelection(); private slots: /** @@ -79,17 +59,8 @@ private slots: void on_ActionPieceMovedToPieceList(); private: - Q_DISABLE_COPY(VPCarrouselPiece) - VPPiece *m_piece; - VPCarrouselPieceList *m_carrouselPieceList; - - QLabel *m_label{nullptr}; - VPCarrouselPiecePreview *m_piecePreview{nullptr}; - - QPoint m_dragStart; - private slots: }; diff --git a/src/app/puzzle/vpcarrouselpiecelist.cpp b/src/app/puzzle/vpcarrouselpiecelist.cpp index 00f23e8b6..63cfced52 100644 --- a/src/app/puzzle/vpcarrouselpiecelist.cpp +++ b/src/app/puzzle/vpcarrouselpiecelist.cpp @@ -25,107 +25,166 @@ ** along with Valentina. If not, see . ** *************************************************************************/ - #include "vpcarrouselpiecelist.h" -#include "vpcarrousel.h" -#include "../vmisc/backport/qoverload.h" -#include +#include +#include +#include +#include + +#include "vpcarrousel.h" +#include "vpcarrouselpiece.h" +#include "../vmisc/backport/qoverload.h" +#include "vpmimedatapiece.h" #include Q_LOGGING_CATEGORY(pCarrouselPieceList, "p.carrouselPieceList") //--------------------------------------------------------------------------------------------------------------------- -VPCarrouselPieceList::VPCarrouselPieceList(VPPieceList *pieceList, VPCarrousel *carrousel) : - m_pieceList(pieceList), - m_carrousel(carrousel), - m_carrouselPieces(QList()) +VPCarrouselPieceList::VPCarrouselPieceList(QWidget* parent) : + QListWidget(parent) { - Init(); +// Init(); + + setStyleSheet("QListWidget::item{background-color:transparent; border: 2px solid transparent; color: black;} QListWidget::item:selected {background-color:transparent; border: 2px solid red; color: black; selection-background-color: white;}"); + setContextMenuPolicy(Qt::CustomContextMenu); + setSelectionMode(QAbstractItemView::MultiSelection); + setViewMode(QListView::IconMode); + + connect(this, &VPCarrouselPieceList::itemSelectionChanged, this, &VPCarrouselPieceList::on_SelectionChangedInternal); } //--------------------------------------------------------------------------------------------------------------------- VPCarrouselPieceList::~VPCarrouselPieceList() { - Clear(); + } //--------------------------------------------------------------------------------------------------------------------- void VPCarrouselPieceList::Init() { - // initiales the structure - QVBoxLayout *layoutPiecesLayout = new QVBoxLayout(); - layoutPiecesLayout->setMargin(0); - setLayout(layoutPiecesLayout); - - // then refresh the content - Refresh(); - - // add the connections - connect(m_pieceList, &VPPieceList::PieceAdded, this, &VPCarrouselPieceList::on_PieceAdded); - connect(m_pieceList, &VPPieceList::PieceRemoved, this, &VPCarrouselPieceList::on_PieceRemoved); +// // add the connections +// connect(m_pieceList, &VPPieceList::PieceAdded, this, &VPCarrouselPieceList::on_PieceAdded); +// connect(m_pieceList, &VPPieceList::PieceRemoved, this, &VPCarrouselPieceList::on_PieceRemoved); } //--------------------------------------------------------------------------------------------------------------------- void VPCarrouselPieceList::Refresh() { - Clear(); + clear(); - // Updates the carrousel pieces from the pieces list - QList pieces = m_pieceList->GetPieces(); - - // sort the pieces in alphabetical order - std::sort(pieces.begin(), pieces.end(), - [](const VPPiece* a, const VPPiece* b) -> bool { return a->GetName() < b->GetName();}); - - // create the corresponding carrousel pieces - - bool _isVisible = isVisible(); - setVisible(true); - for (auto piece : pieces) + if(m_pieceList != nullptr) { - VPCarrouselPiece *carrouselPiece = new VPCarrouselPiece(piece, this); - m_carrouselPieces.append(carrouselPiece); - layout()->addWidget(carrouselPiece); - carrouselPiece->CleanPreview(); // fitInView only works if the widget is displayed. + // Updates the carrousel pieces from the pieces list + QList pieces = m_pieceList->GetPieces(); + + // sort the pieces in alphabetical order + std::sort(pieces.begin(), pieces.end(), + [](const VPPiece* a, const VPPiece* b) -> bool { return a->GetName() < b->GetName();}); + + // 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); + } } - setVisible(_isVisible); +} + + +//--------------------------------------------------------------------------------------------------------------------- +VPPieceList* VPCarrouselPieceList::GetCurrentPieceList() +{ + return m_pieceList; } //--------------------------------------------------------------------------------------------------------------------- -void VPCarrouselPieceList::Clear() +void VPCarrouselPieceList::SetCurrentPieceList(VPPieceList* pieceList) { - // Removes and deletes the carrousel pieces from the piece list - while (!m_carrouselPieces.isEmpty()) - { - VPCarrouselPiece *carrouselPiece = m_carrouselPieces.takeLast(); + m_pieceList = pieceList; - if(carrouselPiece != nullptr) + Refresh(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPCarrouselPieceList::mousePressEvent(QMouseEvent *event) +{ + qCDebug(pCarrouselPieceList, "mouse pressed"); + + 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()) { - layout()->removeWidget(carrouselPiece); - delete carrouselPiece; + item->setSelected(false); } } + QListWidget::mousePressEvent(event); } //--------------------------------------------------------------------------------------------------------------------- -QList VPCarrouselPieceList::GetCarrouselPieces() +void VPCarrouselPieceList::mouseMoveEvent(QMouseEvent *event) { - return m_carrouselPieces; + qCDebug(pCarrouselPieceList, "mouse moved"); + + if ((event->buttons() & Qt::LeftButton) && + ((event->pos() - m_dragStart).manhattanLength() >= QApplication::startDragDistance()) && + (m_pieceList->GetSheet() == nullptr)) // only if it's from unplaced pieces + { + startDrag(Qt::MoveAction); + } + else + { + QListWidget::mouseMoveEvent(event); + } +} + + +//--------------------------------------------------------------------------------------------------------------------- +void VPCarrouselPieceList::startDrag(Qt::DropActions supportedActions) +{ + + qCDebug(pCarrouselPieceList, "start drag"); + + QListWidgetItem* item = currentItem(); + if(item->type() == 1001) + { + VPCarrouselPiece *pieceItem = static_cast (item); + + // starts the dragging + QDrag *drag = new QDrag(this); + VPMimeDataPiece *mimeData = new VPMimeDataPiece(); + mimeData->SetPiecePtr(pieceItem->GetPiece()); //TODO + mimeData->setObjectName("piecePointer"); + + QPixmap pixmap = pieceItem->GetPiece()->PieceIcon(QSize(120,120)).pixmap(QSize(120,120)); + + drag->setPixmap(pixmap); + drag->setMimeData(mimeData); + if(drag->exec() == Qt::MoveAction) + { + delete takeItem(row(item)); + clearSelection(); + } + } } //--------------------------------------------------------------------------------------------------------------------- -VPCarrousel* VPCarrouselPieceList::GetCarrousel() +void VPCarrouselPieceList::dragMoveEvent(QDragMoveEvent* e) { - return m_carrousel; -} + qCDebug(pCarrouselPieceList, "drag move"); -//--------------------------------------------------------------------------------------------------------------------- -VPPieceList* VPCarrouselPieceList::GetPieceList() -{ - return m_pieceList; + + e->acceptProposedAction(); } //--------------------------------------------------------------------------------------------------------------------- @@ -141,15 +200,38 @@ void VPCarrouselPieceList::on_PieceAdded(VPPiece* piece) //--------------------------------------------------------------------------------------------------------------------- void VPCarrouselPieceList::on_PieceRemoved(VPPiece* piece) { - for (auto carrouselPiece : m_carrouselPieces) - { - if(carrouselPiece->GetPiece() == piece) - { - m_carrouselPieces.removeAll(carrouselPiece); - layout()->removeWidget(carrouselPiece); - delete carrouselPiece; + // TODO + Q_UNUSED(piece) +} - return; +//--------------------------------------------------------------------------------------------------------------------- +void VPCarrouselPieceList::on_SelectionChangedInternal() +{ + for(int i = 0; i < count(); ++i) + { + QListWidgetItem* _item = item(i); + if(_item->type() == 1001) + { + VPCarrouselPiece *itemPiece = static_cast (_item); + blockSignals(true); + itemPiece->GetPiece()->SetIsSelected(itemPiece->isSelected()); + blockSignals(false); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPCarrouselPieceList::on_SelectionChangedExternal() +{ + for(int i = 0; i < count(); ++i) + { + QListWidgetItem* _item = item(i); + if(_item->type() == 1001) + { + VPCarrouselPiece *itemPiece = static_cast (_item); + blockSignals(true); + itemPiece->RefreshSelection(); + blockSignals(false); } } } diff --git a/src/app/puzzle/vpcarrouselpiecelist.h b/src/app/puzzle/vpcarrouselpiecelist.h index e32cf1ab4..0af1870e8 100644 --- a/src/app/puzzle/vpcarrouselpiecelist.h +++ b/src/app/puzzle/vpcarrouselpiecelist.h @@ -29,43 +29,47 @@ #ifndef VPCARROUSELPIECELIST_H #define VPCARROUSELPIECELIST_H -#include +#include #include "vppiecelist.h" -#include "vpcarrouselpiece.h" -class VPCarrousel; -class VPCarrouselPieceList : public QWidget +class VPCarrouselPieceList : public QListWidget { Q_OBJECT public: - VPCarrouselPieceList(VPPieceList *pieceList, VPCarrousel *carrousel); + VPCarrouselPieceList(QWidget* parent); ~VPCarrouselPieceList(); void Init(); void Refresh(); - /** - * @brief Clear it clears the carrousel pieceList from its pieces - */ - void Clear(); - - QList GetCarrouselPieces(); - - VPCarrousel* GetCarrousel(); - /** * @brief GetPieceList Returns the corresponding VPPieceList * @return the VPPieceList */ - VPPieceList* GetPieceList(); + VPPieceList* GetCurrentPieceList(); + + /** + * @brief SetCurrentPieceList Sets the current piece list to the given piece list and redraw + * the carrousel. + */ + void SetCurrentPieceList(VPPieceList* pieceList); + +public slots: + 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; private: Q_DISABLE_COPY(VPCarrouselPieceList) - VPPieceList *m_pieceList; - VPCarrousel *m_carrousel; - QList m_carrouselPieces; + VPPieceList *m_pieceList{nullptr}; + QPoint m_dragStart; private slots: @@ -79,6 +83,8 @@ private slots: */ void on_PieceRemoved(VPPiece* piece); + void on_SelectionChangedInternal(); + }; #endif // VPCARROUSELPIECELIST_H diff --git a/src/app/puzzle/vpcarrouselpiecepreview.cpp b/src/app/puzzle/vpcarrouselpiecepreview.cpp deleted file mode 100644 index 5c7182b43..000000000 --- a/src/app/puzzle/vpcarrouselpiecepreview.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/************************************************************************ - ** - ** @file vpcarrouselpiecepreview.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 - ** 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 . - ** - *************************************************************************/ - -#include "vpcarrouselpiecepreview.h" - -#include - -//--------------------------------------------------------------------------------------------------------------------- -VPCarrouselPiecePreview::VPCarrouselPiecePreview(QWidget *parent): - QGraphicsView(parent) -{ - -} -//--------------------------------------------------------------------------------------------------------------------- -VPCarrouselPiecePreview::~VPCarrouselPiecePreview() -{ - -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPCarrouselPiecePreview::mousePressEvent(QMouseEvent *event) -{ - event->ignore(); -} -//--------------------------------------------------------------------------------------------------------------------- -void VPCarrouselPiecePreview::mouseMoveEvent(QMouseEvent *event) -{ - event->ignore(); -} - diff --git a/src/app/puzzle/vpcarrouselpiecepreview.h b/src/app/puzzle/vpcarrouselpiecepreview.h deleted file mode 100644 index 4e31c80f3..000000000 --- a/src/app/puzzle/vpcarrouselpiecepreview.h +++ /dev/null @@ -1,45 +0,0 @@ -/************************************************************************ - ** - ** @file vpcarrouselpiecepreview.h - ** @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 - ** 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 . - ** - *************************************************************************/ - -#ifndef VPCARROUSELPIECEPREVIEW_H -#define VPCARROUSELPIECEPREVIEW_H - -#include - -class VPCarrouselPiecePreview: public QGraphicsView -{ -public: - VPCarrouselPiecePreview(QWidget *parent = nullptr); - ~VPCarrouselPiecePreview(); - -protected: - void mousePressEvent(QMouseEvent *event) override; - void mouseMoveEvent(QMouseEvent *event) override; -}; - -#endif // VPCARROUSELPIECEPREVIEW_H diff --git a/src/app/puzzle/vpgraphicspiece.cpp b/src/app/puzzle/vpgraphicspiece.cpp index 7daa4f20e..4bf150701 100644 --- a/src/app/puzzle/vpgraphicspiece.cpp +++ b/src/app/puzzle/vpgraphicspiece.cpp @@ -327,7 +327,7 @@ void VPGraphicsPiece::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) } // 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->GetPieceList()->GetLayout()->GetUnplacedPieceList()); removeAction->setData(data); connect(removeAction, &QAction::triggered, this, &VPGraphicsPiece::on_ActionPieceMovedToPieceList); diff --git a/src/app/puzzle/vplayout.cpp b/src/app/puzzle/vplayout.cpp index 5c7052d95..3b06f0020 100644 --- a/src/app/puzzle/vplayout.cpp +++ b/src/app/puzzle/vplayout.cpp @@ -32,7 +32,8 @@ //--------------------------------------------------------------------------------------------------------------------- VPLayout::VPLayout() : - m_unplacedPieceList(new VPPieceList(this)) + m_unplacedPieceList(new VPPieceList(this)), + m_sheets(QList()) { m_unplacedPieceList->SetName(QObject::tr("Unplaced pieces")); } diff --git a/src/app/puzzle/vppiece.cpp b/src/app/puzzle/vppiece.cpp index f0c7aa71e..b1a3903e4 100644 --- a/src/app/puzzle/vppiece.cpp +++ b/src/app/puzzle/vppiece.cpp @@ -296,5 +296,10 @@ QIcon VPPiece::PieceIcon(const QSize &size) const painter.drawPolygon(shape); painter.end(); - return QIcon(pixmap); + QIcon icon; + + icon.addPixmap(pixmap,QIcon::Normal); + icon.addPixmap(pixmap,QIcon::Selected); + + return icon; } diff --git a/src/app/puzzle/vppiecelist.cpp b/src/app/puzzle/vppiecelist.cpp index f6d074797..65606f83c 100644 --- a/src/app/puzzle/vppiecelist.cpp +++ b/src/app/puzzle/vppiecelist.cpp @@ -34,7 +34,8 @@ Q_LOGGING_CATEGORY(pPieceList, "p.pieceList") //--------------------------------------------------------------------------------------------------------------------- -VPPieceList::VPPieceList(VPLayout *layout): +VPPieceList::VPPieceList(VPLayout *layout, VPSheet *sheet): + m_sheet(sheet), m_layout(layout) { @@ -52,6 +53,12 @@ VPLayout* VPPieceList::GetLayout() return m_layout; } +//--------------------------------------------------------------------------------------------------------------------- +VPSheet* VPPieceList::GetSheet() +{ + return m_sheet; +} + //--------------------------------------------------------------------------------------------------------------------- QList VPPieceList::GetPieces() { diff --git a/src/app/puzzle/vppiecelist.h b/src/app/puzzle/vppiecelist.h index 283a0d03e..c0e86b6fd 100644 --- a/src/app/puzzle/vppiecelist.h +++ b/src/app/puzzle/vppiecelist.h @@ -30,6 +30,7 @@ #include #include "vppiece.h" +#include "vpsheet.h" class VPLayout; @@ -37,7 +38,7 @@ class VPPieceList : public QObject { Q_OBJECT public: - VPPieceList(VPLayout *layout); + VPPieceList(VPLayout *layout, VPSheet *sheet = nullptr); ~VPPieceList(); QList GetPieces(); @@ -59,6 +60,14 @@ public: */ VPLayout* GetLayout(); + + /** + * @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 */ @@ -81,6 +90,8 @@ private: QString m_name{}; QList m_pieces{}; + VPSheet *m_sheet{nullptr}; + VPLayout *m_layout{nullptr}; // control diff --git a/src/app/puzzle/vpsheet.cpp b/src/app/puzzle/vpsheet.cpp index d61f586c7..13b5a2a89 100644 --- a/src/app/puzzle/vpsheet.cpp +++ b/src/app/puzzle/vpsheet.cpp @@ -34,7 +34,7 @@ VPSheet::VPSheet(VPLayout* layout) : m_layout(layout) { - m_pieceList = new VPPieceList(layout); + m_pieceList = new VPPieceList(layout, this); } //--------------------------------------------------------------------------------------------------------------------- From af40b52988262e8332f1a19da609032fe28371b9 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sun, 24 May 2020 19:53:51 +0200 Subject: [PATCH 28/28] Refactoring Piece carrousel part 2 --- src/app/puzzle/vpcarrousel.cpp | 31 ++--- src/app/puzzle/vpcarrousel.h | 9 +- src/app/puzzle/vpcarrouselpiece.cpp | 88 +++++++------- src/app/puzzle/vpcarrouselpiece.h | 9 +- src/app/puzzle/vpcarrouselpiecelist.cpp | 146 ++++++++++++++++++------ src/app/puzzle/vpcarrouselpiecelist.h | 28 ++++- src/app/puzzle/vplayout.cpp | 24 ++++ src/app/puzzle/vplayout.h | 8 ++ src/app/puzzle/vpmainwindow.cpp | 3 + src/app/puzzle/vpmainwindow.ui | 63 +++++++++- src/app/puzzle/vppiece.cpp | 46 -------- 11 files changed, 302 insertions(+), 153 deletions(-) diff --git a/src/app/puzzle/vpcarrousel.cpp b/src/app/puzzle/vpcarrousel.cpp index cf419a913..072b3a528 100644 --- a/src/app/puzzle/vpcarrousel.cpp +++ b/src/app/puzzle/vpcarrousel.cpp @@ -49,6 +49,7 @@ VPCarrousel::VPCarrousel(VPLayout *layout, QWidget *parent) : m_layout(layout) { ui->setupUi(this); + ui->listWidget->SetCarrousel(this); // init the combo box connect(ui->comboBoxPieceList, QOverload::of(&QComboBox::currentIndexChanged), this, @@ -61,8 +62,6 @@ VPCarrousel::VPCarrousel(VPLayout *layout, QWidget *parent) : //--------------------------------------------------------------------------------------------------------------------- void VPCarrousel::Refresh() { - // NOTE: alternative to clearing the carrousel and adding things again, we could make comparision - // --- clears the content of the carrousel Clear(); @@ -70,18 +69,14 @@ void VPCarrousel::Refresh() // Do not rely on m_layout because we do not control it. m_pieceLists = QList(); m_pieceLists.append(m_layout->GetUnplacedPieceList()); - for(auto sheet : m_layout->GetSheets()) - { - m_pieceLists.append(sheet->GetPieceList()); - } + m_pieceLists.append(m_layout->GetFocusedSheet()->GetPieceList()); - for (auto pieceList : m_pieceLists) - { - // add piece list name to combo - ui->comboBoxPieceList->blockSignals(true); - ui->comboBoxPieceList->addItem(pieceList->GetName()); - ui->comboBoxPieceList->blockSignals(false); - } + ui->comboBoxPieceList->blockSignals(true); + + ui->comboBoxPieceList->addItem(m_layout->GetUnplacedPieceList()->GetName()); + ui->comboBoxPieceList->addItem(tr("Pieces of ") + m_layout->GetFocusedSheet()->GetName()); + + ui->comboBoxPieceList->blockSignals(false); on_ActivePieceListChanged(0); @@ -148,3 +143,13 @@ void VPCarrousel::ClearSelection() { m_layout->ClearSelection(); } + + +//--------------------------------------------------------------------------------------------------------------------- +void VPCarrousel::ClearSelectionExceptForCurrentPieceList() +{ + if (m_layout != nullptr) + { + m_layout->ClearSelectionExceptForGivenPieceList(ui->listWidget->GetCurrentPieceList()); + } +} diff --git a/src/app/puzzle/vpcarrousel.h b/src/app/puzzle/vpcarrousel.h index f4aed9aff..4a3119a0e 100644 --- a/src/app/puzzle/vpcarrousel.h +++ b/src/app/puzzle/vpcarrousel.h @@ -75,11 +75,18 @@ public: */ void ClearSelection(); + /** + * @brief ClearSelectionExceptForCurrentPieceList Clears the selection of all pieces of + * the layout except for the one in the current piece list + */ + void ClearSelectionExceptForCurrentPieceList(); + private: Q_DISABLE_COPY(VPCarrousel) Ui::VPCarrousel *ui; - VPLayout *m_layout; + VPLayout *m_layout{nullptr}; + QList m_pieceLists{}; Qt::Orientation m_orientation{Qt::Vertical}; diff --git a/src/app/puzzle/vpcarrouselpiece.cpp b/src/app/puzzle/vpcarrouselpiece.cpp index a2ac6382a..93b737238 100644 --- a/src/app/puzzle/vpcarrouselpiece.cpp +++ b/src/app/puzzle/vpcarrouselpiece.cpp @@ -30,6 +30,7 @@ #include #include +#include #include "vpmimedatapiece.h" #include "vpcarrouselpiecelist.h" @@ -49,7 +50,7 @@ VPCarrouselPiece::VPCarrouselPiece(VPPiece *piece, QListWidget* parent) : int width = 120 - 8; QFontMetrics metrix = QFontMetrics(QFont()); QString clippedText = metrix.elidedText(piece->GetName(), Qt::ElideRight, width); - setIcon(m_piece->PieceIcon(QSize(120, 120))); + setIcon(CreatePieceIcon(QSize(120, 120))); setText(clippedText); } @@ -72,57 +73,50 @@ void VPCarrouselPiece::RefreshSelection() setSelected(m_piece->GetIsSelected()); } -////--------------------------------------------------------------------------------------------------------------------- -//void VPCarrouselPiece::contextMenuEvent(QContextMenuEvent *event) -//{ -// QMenu contextMenu; +//--------------------------------------------------------------------------------------------------------------------- +QIcon VPCarrouselPiece::CreatePieceIcon(const QSize &size) const +{ + QVector points = m_piece->GetSeamLine(); + if(points.isEmpty()) + { + points = m_piece->GetCuttingLine(); + } -// VPPieceList* unplacedPieces = m_piece->GetPieceList()->GetLayout()->GetUnplacedPieceList(); -// QList sheets = m_piece->GetPieceList()->GetLayout()->GetSheets(); -// QList pieceLists = QList(); -// for (auto sheet : sheets) -// { -// pieceLists.append(sheet->GetPieceList()); -// } + QPolygonF shape(points); + shape << shape.first(); -// // move to piece list actions -- TODO : To be tested properly when we have several piece lists -// pieceLists.removeAll(m_piece->GetPieceList()); -// if(pieceLists.count() > 0) -// { -// QMenu *moveMenu = contextMenu.addMenu(tr("Move to")); + QRectF boundingRect = shape.boundingRect(); + qreal canvasSize = qMax(boundingRect.height(), boundingRect.width()); + QRectF canvas = QRectF(0, 0, canvasSize, canvasSize); -// // TODO order in alphabetical order + qreal dx = canvas.center().x() - boundingRect.center().x(); + qreal dy = canvas.center().y() - boundingRect.center().y(); -// for (auto pieceList : pieceLists) -// { -// QAction* moveToPieceList = moveMenu->addAction(pieceList->GetName()); -// QVariant data = QVariant::fromValue(pieceList); -// moveToPieceList->setData(data); + QPixmap pixmap(size); + pixmap.fill(QColor("white")); -// connect(moveToPieceList, &QAction::triggered, this, &VPCarrouselPiece::on_ActionPieceMovedToPieceList); -// } -// } + QPainter painter; + painter.begin(&pixmap); + painter.setRenderHint(QPainter::Antialiasing); + painter.setRenderHint(QPainter::SmoothPixmapTransform); -// // remove from piece list action -// if(m_piece->GetPieceList() != unplacedPieces) -// { -// QAction *removeAction = contextMenu.addAction(tr("Remove from Sheet")); -// QVariant data = QVariant::fromValue(m_piece->GetPieceList()->GetLayout()->GetUnplacedPieceList()); -// removeAction->setData(data); -// connect(removeAction, &QAction::triggered, this, &VPCarrouselPiece::on_ActionPieceMovedToPieceList); -// } + int spacing = 2; + painter.translate(spacing, spacing); -// contextMenu.exec(event->globalPos()); -//} + 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))); -////--------------------------------------------------------------------------------------------------------------------- -//void VPCarrouselPiece::on_ActionPieceMovedToPieceList() -//{ -// QAction *act = qobject_cast(sender()); -// QVariant v = act->data(); -// VPPieceList *pieceList = v.value(); -// if(pieceList != nullptr) -// { -// pieceList->GetLayout()->MovePieceToPieceList(m_piece, pieceList); -// } -//} + painter.translate(dx, dy); + + painter.drawPolygon(shape); + painter.end(); + + QIcon icon; + + icon.addPixmap(pixmap,QIcon::Normal); + icon.addPixmap(pixmap,QIcon::Selected); + + return icon; +} diff --git a/src/app/puzzle/vpcarrouselpiece.h b/src/app/puzzle/vpcarrouselpiece.h index 46f0afe2c..7a2008a7d 100644 --- a/src/app/puzzle/vpcarrouselpiece.h +++ b/src/app/puzzle/vpcarrouselpiece.h @@ -51,12 +51,13 @@ public: */ void RefreshSelection(); -private slots: /** - * @brief on_ActionPieceMovedToPieceList Slot called when the piece is moved via the - * context menu to anoter piece list + * @brief CreatePieceIcon Creates an icon of the piece of given size + * @param size of the icon + * @return the created icon */ - void on_ActionPieceMovedToPieceList(); + QIcon CreatePieceIcon(const QSize &size) const; + private: VPPiece *m_piece; diff --git a/src/app/puzzle/vpcarrouselpiecelist.cpp b/src/app/puzzle/vpcarrouselpiecelist.cpp index 63cfced52..c782bfeb7 100644 --- a/src/app/puzzle/vpcarrouselpiecelist.cpp +++ b/src/app/puzzle/vpcarrouselpiecelist.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include "vpcarrousel.h" #include "vpcarrouselpiece.h" @@ -43,12 +44,11 @@ Q_LOGGING_CATEGORY(pCarrouselPieceList, "p.carrouselPieceList") //--------------------------------------------------------------------------------------------------------------------- VPCarrouselPieceList::VPCarrouselPieceList(QWidget* parent) : - QListWidget(parent) + QListWidget(parent), + m_dragStart(QPoint()) { -// Init(); - - setStyleSheet("QListWidget::item{background-color:transparent; border: 2px solid transparent; color: black;} QListWidget::item:selected {background-color:transparent; border: 2px solid red; color: black; selection-background-color: white;}"); - setContextMenuPolicy(Qt::CustomContextMenu); + 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); @@ -62,11 +62,9 @@ VPCarrouselPieceList::~VPCarrouselPieceList() } //--------------------------------------------------------------------------------------------------------------------- -void VPCarrouselPieceList::Init() +void VPCarrouselPieceList::SetCarrousel(VPCarrousel *carrousel) { -// // add the connections -// connect(m_pieceList, &VPPieceList::PieceAdded, this, &VPCarrouselPieceList::on_PieceAdded); -// connect(m_pieceList, &VPPieceList::PieceRemoved, this, &VPCarrouselPieceList::on_PieceRemoved); + m_carrousel = carrousel; } //--------------------------------------------------------------------------------------------------------------------- @@ -76,13 +74,11 @@ void VPCarrouselPieceList::Refresh() if(m_pieceList != nullptr) { + m_pieceList->disconnect(this); + // Updates the carrousel pieces from the pieces list QList pieces = m_pieceList->GetPieces(); - // sort the pieces in alphabetical order - std::sort(pieces.begin(), pieces.end(), - [](const VPPiece* a, const VPPiece* b) -> bool { return a->GetName() < b->GetName();}); - // create the corresponding carrousel pieces for (auto piece : pieces) { @@ -91,6 +87,10 @@ void VPCarrouselPieceList::Refresh() 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); } } @@ -112,8 +112,6 @@ void VPCarrouselPieceList::SetCurrentPieceList(VPPieceList* pieceList) //--------------------------------------------------------------------------------------------------------------------- void VPCarrouselPieceList::mousePressEvent(QMouseEvent *event) { - qCDebug(pCarrouselPieceList, "mouse pressed"); - if (event->button() == Qt::LeftButton) { m_dragStart = event->pos(); @@ -134,10 +132,9 @@ void VPCarrouselPieceList::mousePressEvent(QMouseEvent *event) //--------------------------------------------------------------------------------------------------------------------- void VPCarrouselPieceList::mouseMoveEvent(QMouseEvent *event) { - qCDebug(pCarrouselPieceList, "mouse moved"); - 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); @@ -152,28 +149,29 @@ void VPCarrouselPieceList::mouseMoveEvent(QMouseEvent *event) //--------------------------------------------------------------------------------------------------------------------- void VPCarrouselPieceList::startDrag(Qt::DropActions supportedActions) { + Q_UNUSED(supportedActions) - qCDebug(pCarrouselPieceList, "start drag"); - - QListWidgetItem* item = currentItem(); - if(item->type() == 1001) + QListWidgetItem* _item = currentItem(); + if(_item->type() == 1001) { - VPCarrouselPiece *pieceItem = static_cast (item); + VPCarrouselPiece *pieceItem = static_cast (_item); // starts the dragging QDrag *drag = new QDrag(this); VPMimeDataPiece *mimeData = new VPMimeDataPiece(); - mimeData->SetPiecePtr(pieceItem->GetPiece()); //TODO + VPPiece* piece = pieceItem->GetPiece(); + mimeData->SetPiecePtr(piece); mimeData->setObjectName("piecePointer"); - QPixmap pixmap = pieceItem->GetPiece()->PieceIcon(QSize(120,120)).pixmap(QSize(120,120)); + 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)); + delete takeItem(row(_item)); clearSelection(); + piece->SetIsSelected(true); } } } @@ -182,56 +180,128 @@ void VPCarrouselPieceList::startDrag(Qt::DropActions supportedActions) 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 (_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 (_item); + QAction *act = qobject_cast(sender()); + QVariant v = act->data(); + VPPieceList *pieceList = v.value(); + if(pieceList != nullptr) + { + pieceList->GetLayout()->MovePieceToPieceList(pieceItem->GetPiece(), pieceList); + } + } +} + + + //--------------------------------------------------------------------------------------------------------------------- void VPCarrouselPieceList::on_PieceAdded(VPPiece* piece) { - Q_UNUSED(piece) - - // TODO/ FIXME: see if we find a solution more efficient refreshing the complete layout everytime. - - Refresh(); + 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) { - // TODO - Q_UNUSED(piece) + for(int i = 0; i < count(); ++i) + { + QListWidgetItem* _item = item(i); + if(_item->type() == 1001) + { + VPCarrouselPiece *itemPiece = static_cast (_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 (_item); - blockSignals(true); itemPiece->GetPiece()->SetIsSelected(itemPiece->isSelected()); - blockSignals(false); } } + 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 (_item); - blockSignals(true); itemPiece->RefreshSelection(); - blockSignals(false); } } + blockSignals(false); } diff --git a/src/app/puzzle/vpcarrouselpiecelist.h b/src/app/puzzle/vpcarrouselpiecelist.h index 0af1870e8..8dd2ee55d 100644 --- a/src/app/puzzle/vpcarrouselpiecelist.h +++ b/src/app/puzzle/vpcarrouselpiecelist.h @@ -31,6 +31,7 @@ #include #include "vppiecelist.h" +#include "vpcarrousel.h" class VPCarrouselPieceList : public QListWidget @@ -40,7 +41,9 @@ public: VPCarrouselPieceList(QWidget* parent); ~VPCarrouselPieceList(); - void Init(); + /** + * @brief Refresh refreshes the items of the carrousel piece list + */ void Refresh(); /** @@ -53,9 +56,19 @@ public: * @brief SetCurrentPieceList Sets the current piece list to the given piece list and redraw * the carrousel. */ - void SetCurrentPieceList(VPPieceList* pieceList); + 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: @@ -65,11 +78,14 @@ protected: 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: @@ -83,8 +99,16 @@ private slots: */ 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 diff --git a/src/app/puzzle/vplayout.cpp b/src/app/puzzle/vplayout.cpp index 3b06f0020..fe77d2959 100644 --- a/src/app/puzzle/vplayout.cpp +++ b/src/app/puzzle/vplayout.cpp @@ -30,6 +30,11 @@ #include "vppiece.h" #include "vpsheet.h" + +#include + +Q_LOGGING_CATEGORY(pLayout, "p.layout") + //--------------------------------------------------------------------------------------------------------------------- VPLayout::VPLayout() : m_unplacedPieceList(new VPPieceList(this)), @@ -147,6 +152,25 @@ void VPLayout::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) { diff --git a/src/app/puzzle/vplayout.h b/src/app/puzzle/vplayout.h index 5d36fad93..a81017bb8 100644 --- a/src/app/puzzle/vplayout.h +++ b/src/app/puzzle/vplayout.h @@ -84,6 +84,14 @@ public: */ 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 diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index 16d6437a5..a2bd21750 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -395,6 +395,9 @@ void VPMainWindow::SetPropertyTabCurrentPieceData() //--------------------------------------------------------------------------------------------------------------------- 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()); diff --git a/src/app/puzzle/vpmainwindow.ui b/src/app/puzzle/vpmainwindow.ui index 927c80787..461e49af9 100644 --- a/src/app/puzzle/vpmainwindow.ui +++ b/src/app/puzzle/vpmainwindow.ui @@ -172,7 +172,7 @@ QTabWidget::Rounded - 1 + 0 @@ -230,7 +230,7 @@ 0 0 342 - 1318 + 1264 @@ -253,6 +253,18 @@ + + 0 + + + 0 + + + 0 + + + 0 + @@ -398,6 +410,18 @@ 0 + + 0 + + + 0 + + + 0 + + + 0 + @@ -420,6 +444,18 @@ + + 0 + + + 0 + + + 0 + + + 0 + @@ -519,6 +555,29 @@ + + + + Infos + + + + + + + + Name + + + + + + + + + + + diff --git a/src/app/puzzle/vppiece.cpp b/src/app/puzzle/vppiece.cpp index b1a3903e4..ed3df5899 100644 --- a/src/app/puzzle/vppiece.cpp +++ b/src/app/puzzle/vppiece.cpp @@ -256,50 +256,4 @@ void VPPiece::SetPieceList(VPPieceList* pieceList) } } -//--------------------------------------------------------------------------------------------------------------------- -QIcon VPPiece::PieceIcon(const QSize &size) const -{ - QVector 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(); - - QIcon icon; - - icon.addPixmap(pixmap,QIcon::Normal); - icon.addPixmap(pixmap,QIcon::Selected); - - return icon; -}