Add a trash list and delete context menu function
This commit is contained in:
parent
b606497c48
commit
b9e26f0b3f
|
@ -197,10 +197,16 @@ void VPCarrouselPieceList::contextMenuEvent(QContextMenuEvent *event)
|
|||
{
|
||||
VPPieceList* sheetPieces = pieceItem->GetPiece()->GetPieceList()->GetLayout()->GetFocusedSheet()->GetPieceList();
|
||||
QAction *moveAction = contextMenu.addAction(tr("Move to Sheet"));
|
||||
QVariant data = QVariant::fromValue(sheetPieces);
|
||||
moveAction->setData(data);
|
||||
QVariant moveData = QVariant::fromValue(sheetPieces);
|
||||
moveAction->setData(moveData);
|
||||
|
||||
VPPieceList* trashPieceList = pieceItem->GetPiece()->GetPieceList()->GetLayout()->GetTrashPieceList();
|
||||
QAction *deleteAction = contextMenu.addAction(tr("Delete"));
|
||||
QVariant deleteData = QVariant::fromValue(trashPieceList);
|
||||
deleteAction->setData(deleteData);
|
||||
|
||||
connect(moveAction, &QAction::triggered, this, &VPCarrouselPieceList::on_ActionPieceMovedToPieceList);
|
||||
connect(deleteAction, &QAction::triggered, this, &VPCarrouselPieceList::on_ActionPieceMovedToPieceList);
|
||||
}
|
||||
|
||||
// remove from piece list action
|
||||
|
@ -235,8 +241,6 @@ void VPCarrouselPieceList::on_ActionPieceMovedToPieceList()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPCarrouselPieceList::on_PieceAdded(VPPiece* piece)
|
||||
{
|
||||
|
|
|
@ -108,7 +108,6 @@ private slots:
|
|||
* @brief on_ActionPieceMovedToPieceList when a piece is moved to another piece list via a context menu
|
||||
*/
|
||||
void on_ActionPieceMovedToPieceList();
|
||||
|
||||
};
|
||||
|
||||
#endif // VPCARROUSELPIECELIST_H
|
||||
|
|
|
@ -38,6 +38,7 @@ Q_LOGGING_CATEGORY(pLayout, "p.layout")
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPLayout::VPLayout() :
|
||||
m_unplacedPieceList(new VPPieceList(this)),
|
||||
m_trashPieceList(new VPPieceList(this)),
|
||||
m_sheets(QList<VPSheet*>())
|
||||
{
|
||||
m_unplacedPieceList->SetName(QObject::tr("Unplaced pieces"));
|
||||
|
@ -48,6 +49,7 @@ VPLayout::~VPLayout()
|
|||
{
|
||||
qDeleteAll(m_sheets);
|
||||
delete m_unplacedPieceList;
|
||||
delete m_trashPieceList;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -56,6 +58,12 @@ VPPieceList* VPLayout::GetUnplacedPieceList()
|
|||
return m_unplacedPieceList;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPPieceList* VPLayout::GetTrashPieceList()
|
||||
{
|
||||
return m_trashPieceList;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPSheet* VPLayout::AddSheet()
|
||||
{
|
||||
|
@ -208,7 +216,7 @@ void VPLayout::MovePieceToPieceList(VPPiece* piece, VPPieceList* pieceList)
|
|||
pieceList->AddPiece(piece);
|
||||
|
||||
// signal, that a piece was moved
|
||||
emit PieceMovedToPieceList(piece, pieceListBefore,pieceList);
|
||||
emit PieceMovedToPieceList(piece, pieceListBefore, pieceList);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -50,6 +50,12 @@ public:
|
|||
*/
|
||||
VPPieceList* GetUnplacedPieceList();
|
||||
|
||||
/**
|
||||
* @brief GetTrashPieceList Returns the piece list of the trash
|
||||
* @return the pieces list of trashed pieces.
|
||||
*/
|
||||
VPPieceList* GetTrashPieceList();
|
||||
|
||||
VPSheet* AddSheet();
|
||||
VPSheet* AddSheet(VPSheet *sheet);
|
||||
QList<VPSheet *> GetSheets();
|
||||
|
@ -265,16 +271,12 @@ private:
|
|||
|
||||
VPPieceList *m_unplacedPieceList;
|
||||
|
||||
QList<VPSheet*> m_sheets;
|
||||
|
||||
/**
|
||||
TODO : To be replaced by m_focusedSheet
|
||||
* @brief m_focusedPieceList pointer the the focused piece list, to which pieces will be
|
||||
* added via drag and drop, or if no piece list is defined.
|
||||
* @brief m_trashPieceList Holds the pieces that were deleted
|
||||
*/
|
||||
VPPieceList *m_focusedPieceList{nullptr};
|
||||
|
||||
VPPieceList *m_trashPieceList;
|
||||
|
||||
QList<VPSheet*> m_sheets;
|
||||
VPSheet *m_focusedSheet{nullptr};
|
||||
|
||||
// format
|
||||
|
|
|
@ -213,7 +213,7 @@ void VPMainGraphicsView::on_PieceMovedToPieceList(VPPiece *piece, VPPieceList *p
|
|||
scene()->removeItem(_graphicsPiece);
|
||||
m_graphicsPieces.removeAll(_graphicsPiece);
|
||||
}
|
||||
else if(pieceListAfter != m_layout->GetUnplacedPieceList())
|
||||
else if(pieceListAfter != m_layout->GetUnplacedPieceList() && pieceListAfter != m_layout->GetTrashPieceList())
|
||||
{
|
||||
if(_graphicsPiece == nullptr)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user