From 34b67cc6e3cb5d57681d7bcc3c79ffe858efc4ca Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 15:29:57 +0200 Subject: [PATCH] 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;