Refactoring VPuzzleLayer
This commit is contained in:
parent
45be7271bb
commit
34b67cc6e3
|
@ -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 \
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <QScrollBar>
|
||||
|
||||
#include "../vmisc/backport/qoverload.h"
|
||||
#include "vpuzzlelayer.h"
|
||||
#include "vppiecelist.h"
|
||||
|
||||
#include <QLoggingCategory>
|
||||
#include <QMenu>
|
||||
|
@ -49,8 +49,8 @@ VPCarrousel::VPCarrousel(VPuzzleLayout *layout, QWidget *parent) :
|
|||
ui->setupUi(this);
|
||||
|
||||
// init the combo box
|
||||
connect(ui->comboBoxLayer, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||
&VPCarrousel::on_ActiveLayerChanged);
|
||||
connect(ui->comboBoxPieceList, QOverload<int>::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<VPuzzlePiece*> pieces = layer->GetPieces();
|
||||
QList<VPuzzlePiece*> 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);
|
||||
|
|
|
@ -80,7 +80,7 @@ private:
|
|||
Ui::VPCarrousel *ui;
|
||||
|
||||
VPuzzleLayout *m_layout;
|
||||
QList<VPuzzleLayer*> m_layers{};
|
||||
QList<VPPieceList*> 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
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBoxLayer">
|
||||
<widget class="QComboBox" name="comboBoxPieceList">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
|
|
|
@ -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<VPuzzleLayer*> layers = m_piece->GetLayer()->GetLayout()->GetLayers();
|
||||
VPPieceList* unplacedPieces = m_piece->GetPieceList()->GetLayout()->GetUnplacedPieceList();
|
||||
QList<VPPieceList*> 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<QAction *>(sender());
|
||||
QVariant v = act->data();
|
||||
VPuzzleLayer *layer = v.value<VPuzzleLayer *>();
|
||||
if(layer != nullptr)
|
||||
VPPieceList *pieceList = v.value<VPPieceList *>();
|
||||
if(pieceList != nullptr)
|
||||
{
|
||||
layer->GetLayout()->MovePieceToLayer(m_piece, layer);
|
||||
pieceList->GetLayout()->MovePieceToPieceList(m_piece, pieceList);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -34,11 +34,11 @@
|
|||
|
||||
#include <QLoggingCategory>
|
||||
|
||||
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<VPCarrouselPiece*>())
|
||||
{
|
||||
|
@ -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<VPuzzlePiece*> pieces = m_layer->GetPieces();
|
||||
QList<VPuzzlePiece*> 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;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#define VPCARROUSELPIECELIST_H
|
||||
|
||||
#include <QWidget>
|
||||
#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<VPCarrouselPiece*> m_carrouselPieces;
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include <QGraphicsScene>
|
||||
|
||||
#include "vpuzzlepiece.h"
|
||||
#include "vpuzzlelayer.h"
|
||||
#include "vppiecelist.h"
|
||||
#include "vpuzzlelayout.h"
|
||||
|
||||
#include <QLoggingCategory>
|
||||
|
@ -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<VPuzzleLayer*> 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<VPPieceList*> 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<QAction *>(sender());
|
||||
QVariant v = act->data();
|
||||
VPuzzleLayer *layer = v.value<VPuzzleLayer *>();
|
||||
if(layer != nullptr)
|
||||
VPPieceList *pieceList = v.value<VPPieceList *>();
|
||||
if(pieceList != nullptr)
|
||||
{
|
||||
layer->GetLayout()->MovePieceToLayer(m_piece, layer);
|
||||
pieceList->GetLayout()->MovePieceToPieceList(m_piece, pieceList);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -172,7 +172,7 @@
|
|||
<enum>QTabWidget::Rounded</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
|
@ -955,86 +955,6 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tabLayersProperty">
|
||||
<attribute name="icon">
|
||||
<iconset resource="share/resources/puzzleicon.qrc">
|
||||
<normaloff>:/puzzleicon/64x64/iconLayers.png</normaloff>:/puzzleicon/64x64/iconLayers.png</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string/>
|
||||
</attribute>
|
||||
<attribute name="toolTip">
|
||||
<string>Layers properties</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayoutLayersProperty">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollAreaLayers">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContentsLayers">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>356</width>
|
||||
<height>760</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">font-weight:bold;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Layers</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -1126,7 +1046,6 @@
|
|||
<tabstop>doubleSpinBoxLayoutMarginLeft</tabstop>
|
||||
<tabstop>doubleSpinBoxLayoutMarginRight</tabstop>
|
||||
<tabstop>doubleSpinBoxLayoutMarginBottom</tabstop>
|
||||
<tabstop>scrollAreaLayers</tabstop>
|
||||
<tabstop>scrollAreaTiles</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
#include "vpuzzlelayer.h"
|
||||
#include "vppiecelist.h"
|
||||
|
||||
#include "vpuzzlelayout.h"
|
||||
|
||||
#include <QLoggingCategory>
|
||||
|
||||
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<VPuzzlePiece *> VPuzzleLayer::GetPieces()
|
||||
QList<VPuzzlePiece *> 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;
|
||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
#ifndef VPUZZLELAYER_H
|
||||
#define VPUZZLELAYER_H
|
||||
#ifndef VPPIECELIST_H
|
||||
#define VPPIECELIST_H
|
||||
|
||||
#include <QList>
|
||||
#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<VPuzzlePiece *> 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<VPuzzlePiece *> m_pieces{};
|
||||
|
@ -88,4 +88,4 @@ private:
|
|||
|
||||
};
|
||||
|
||||
#endif // VPUZZLELAYER_H
|
||||
#endif // VPPIECELIST_H
|
|
@ -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<VPuzzleLayer *> VPuzzleLayout::GetLayers()
|
||||
QList<VPPieceList *> VPuzzleLayout::GetPiecesLists()
|
||||
{
|
||||
return m_layers;
|
||||
return m_pieceLists;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -83,12 +83,12 @@ QList<VPuzzlePiece *> VPuzzleLayout::GetSelectedPieces()
|
|||
{
|
||||
QList<VPuzzlePiece *> result = QList<VPuzzlePiece *>();
|
||||
|
||||
QList<VPuzzleLayer *> layers = m_layers;
|
||||
layers.prepend(m_unplacedPiecesLayer);
|
||||
QList<VPPieceList *> 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);
|
||||
}
|
||||
|
|
|
@ -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<VPuzzleLayer *> GetLayers();
|
||||
VPPieceList* AddPieceList();
|
||||
VPPieceList* AddPieceList(VPPieceList *pieceList);
|
||||
QList<VPPieceList *> 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<VPuzzleLayer *> m_layers{};
|
||||
VPPieceList *m_unplacedPieceList;
|
||||
QList<VPPieceList *> 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};
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <QKeyEvent>
|
||||
|
||||
#include "vpuzzlemimedatapiece.h"
|
||||
#include "vpuzzlelayer.h"
|
||||
#include "vppiecelist.h"
|
||||
#include "../vwidgets/vmaingraphicsscene.h"
|
||||
|
||||
#include <QLoggingCategory>
|
||||
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include <QtMath>
|
||||
|
||||
#include "vpuzzlelayer.h"
|
||||
#include "vppiecelist.h"
|
||||
#include "../vmisc/def.h"
|
||||
|
||||
#include <QIcon>
|
||||
|
@ -242,17 +242,17 @@ QVector<QPointF> 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <QPoint>
|
||||
#include <QTransform>
|
||||
|
||||
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
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <QXmlStreamReader>
|
||||
#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();
|
||||
|
|
|
@ -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<VPuzzleLayer*> layers = layout->GetLayers();
|
||||
for (auto layer : layers)
|
||||
QList<VPPieceList*> 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<VPuzzlePiece*> pieces = layer->GetPieces();
|
||||
QList<VPuzzlePiece*> pieces = pieceList->GetPieces();
|
||||
for (auto piece : pieces)
|
||||
{
|
||||
WritePiece(piece);
|
||||
}
|
||||
|
||||
writeEndElement(); // layer
|
||||
writeEndElement(); // piece list
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user