2020-04-26 12:09:28 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
2020-05-23 14:36:35 +02:00
|
|
|
** @file vpcarrouselpiece.cpp
|
2020-04-26 12:09:28 +02:00
|
|
|
** @author Ronan Le Tiec
|
|
|
|
** @date 25 4, 2020
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentina project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2020 Valentina project
|
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
|
|
|
**
|
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
2020-05-23 14:36:35 +02:00
|
|
|
#include "vpcarrouselpiece.h"
|
2020-05-05 07:44:20 +02:00
|
|
|
|
|
|
|
#include <QApplication>
|
2020-05-09 09:54:56 +02:00
|
|
|
#include <QMenu>
|
2020-05-05 07:44:20 +02:00
|
|
|
|
2020-05-23 15:38:59 +02:00
|
|
|
#include "vpmimedatapiece.h"
|
2020-05-23 14:33:02 +02:00
|
|
|
#include "vpcarrouselpiecelist.h"
|
2020-05-23 14:29:18 +02:00
|
|
|
#include "vpcarrousel.h"
|
2020-05-23 17:47:04 +02:00
|
|
|
#include "vpsheet.h"
|
2020-04-26 12:09:28 +02:00
|
|
|
|
|
|
|
#include <QLoggingCategory>
|
|
|
|
|
|
|
|
Q_LOGGING_CATEGORY(pCarrouselPiece, "p.carrouselPiece")
|
|
|
|
|
2020-05-05 07:44:20 +02:00
|
|
|
|
2020-04-26 12:09:28 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-24 14:55:03 +02:00
|
|
|
VPCarrouselPiece::VPCarrouselPiece(VPPiece *piece, QListWidget* parent) :
|
|
|
|
QListWidgetItem(parent,1001),
|
|
|
|
m_piece(piece)
|
2020-04-26 12:09:28 +02:00
|
|
|
{
|
2020-05-24 14:55:03 +02:00
|
|
|
int width = 120 - 8;
|
|
|
|
QFontMetrics metrix = QFontMetrics(QFont());
|
|
|
|
QString clippedText = metrix.elidedText(piece->GetName(), Qt::ElideRight, width);
|
|
|
|
setIcon(m_piece->PieceIcon(QSize(120, 120)));
|
|
|
|
setText(clippedText);
|
2020-04-26 12:09:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:36:35 +02:00
|
|
|
VPCarrouselPiece::~VPCarrouselPiece()
|
2020-04-26 12:09:28 +02:00
|
|
|
{
|
|
|
|
|
2020-05-01 18:26:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 15:42:51 +02:00
|
|
|
VPPiece * VPCarrouselPiece::GetPiece()
|
2020-05-01 18:26:02 +02:00
|
|
|
{
|
|
|
|
return m_piece;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-24 14:55:03 +02:00
|
|
|
void VPCarrouselPiece::RefreshSelection()
|
2020-05-05 07:44:20 +02:00
|
|
|
{
|
2020-05-24 14:55:03 +02:00
|
|
|
setSelected(m_piece->GetIsSelected());
|
2020-05-05 07:44:20 +02:00
|
|
|
}
|
2020-05-09 09:54:56 +02:00
|
|
|
|
2020-05-24 14:55:03 +02:00
|
|
|
////---------------------------------------------------------------------------------------------------------------------
|
|
|
|
//void VPCarrouselPiece::contextMenuEvent(QContextMenuEvent *event)
|
|
|
|
//{
|
|
|
|
// QMenu contextMenu;
|
|
|
|
|
|
|
|
// VPPieceList* unplacedPieces = m_piece->GetPieceList()->GetLayout()->GetUnplacedPieceList();
|
|
|
|
// QList<VPSheet*> sheets = m_piece->GetPieceList()->GetLayout()->GetSheets();
|
|
|
|
// QList<VPPieceList*> pieceLists = QList<VPPieceList*>();
|
|
|
|
// for (auto sheet : sheets)
|
|
|
|
// {
|
|
|
|
// pieceLists.append(sheet->GetPieceList());
|
|
|
|
// }
|
|
|
|
|
|
|
|
// // move to piece list actions -- TODO : To be tested properly when we have several piece lists
|
|
|
|
// pieceLists.removeAll(m_piece->GetPieceList());
|
|
|
|
// if(pieceLists.count() > 0)
|
|
|
|
// {
|
|
|
|
// QMenu *moveMenu = contextMenu.addMenu(tr("Move to"));
|
|
|
|
|
|
|
|
// // TODO order in alphabetical order
|
|
|
|
|
|
|
|
// for (auto pieceList : pieceLists)
|
|
|
|
// {
|
|
|
|
// QAction* moveToPieceList = moveMenu->addAction(pieceList->GetName());
|
|
|
|
// QVariant data = QVariant::fromValue(pieceList);
|
|
|
|
// moveToPieceList->setData(data);
|
|
|
|
|
|
|
|
// connect(moveToPieceList, &QAction::triggered, this, &VPCarrouselPiece::on_ActionPieceMovedToPieceList);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// // remove from piece list action
|
|
|
|
// if(m_piece->GetPieceList() != unplacedPieces)
|
|
|
|
// {
|
|
|
|
// QAction *removeAction = contextMenu.addAction(tr("Remove from Sheet"));
|
|
|
|
// QVariant data = QVariant::fromValue(m_piece->GetPieceList()->GetLayout()->GetUnplacedPieceList());
|
|
|
|
// removeAction->setData(data);
|
|
|
|
// connect(removeAction, &QAction::triggered, this, &VPCarrouselPiece::on_ActionPieceMovedToPieceList);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// contextMenu.exec(event->globalPos());
|
|
|
|
//}
|
|
|
|
|
|
|
|
////---------------------------------------------------------------------------------------------------------------------
|
|
|
|
//void VPCarrouselPiece::on_ActionPieceMovedToPieceList()
|
|
|
|
//{
|
|
|
|
// QAction *act = qobject_cast<QAction *>(sender());
|
|
|
|
// QVariant v = act->data();
|
|
|
|
// VPPieceList *pieceList = v.value<VPPieceList *>();
|
|
|
|
// if(pieceList != nullptr)
|
|
|
|
// {
|
|
|
|
// pieceList->GetLayout()->MovePieceToPieceList(m_piece, pieceList);
|
|
|
|
// }
|
|
|
|
//}
|