2020-04-26 12:09:28 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vpiececarrousellayer.cpp
|
|
|
|
** @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/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#include "vpiececarrousellayer.h"
|
|
|
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
#include <QLoggingCategory>
|
|
|
|
|
|
|
|
Q_LOGGING_CATEGORY(pCarrouselLayer, "p.carrouselLayer")
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-02 09:44:45 +02:00
|
|
|
VPieceCarrouselLayer::VPieceCarrouselLayer(VPuzzleLayer *layer, QWidget *parent) :
|
|
|
|
QWidget(parent),
|
|
|
|
m_layer(layer),
|
|
|
|
m_carrouselPieces(QList<VPieceCarrouselPiece*>())
|
2020-04-26 12:09:28 +02:00
|
|
|
{
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VPieceCarrouselLayer::~VPieceCarrouselLayer()
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPieceCarrouselLayer::Init()
|
|
|
|
{
|
|
|
|
// initiales the structure
|
|
|
|
QVBoxLayout *layoutPiecesLayout = new QVBoxLayout();
|
|
|
|
layoutPiecesLayout->setMargin(0);
|
|
|
|
setLayout(layoutPiecesLayout);
|
|
|
|
|
|
|
|
// then refresh the content
|
|
|
|
Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPieceCarrouselLayer::Refresh()
|
|
|
|
{
|
|
|
|
// remove the existing carrousel pieces
|
|
|
|
// TODO
|
|
|
|
|
|
|
|
// Updates the carrousel pieces from the pieces list
|
|
|
|
QList<VPuzzlePiece*> pieces = m_layer->GetPieces();
|
|
|
|
|
2020-04-26 14:03:43 +02:00
|
|
|
// sort the pieces in alphabetical order
|
|
|
|
std::sort(pieces.begin(), pieces.end(),
|
|
|
|
[](const VPuzzlePiece* a, const VPuzzlePiece* b) -> bool { return a->GetName() < b->GetName();});
|
|
|
|
|
|
|
|
// create the corresponding carrousel pieces
|
2020-04-26 22:32:08 +02:00
|
|
|
|
2020-04-26 12:09:28 +02:00
|
|
|
for (auto piece : pieces)
|
|
|
|
{
|
2020-04-26 14:03:43 +02:00
|
|
|
// qCDebug(pCarrouselLayer, "piece name : %s", piece->GetName().toStdString().c_str());
|
2020-04-26 12:09:28 +02:00
|
|
|
|
|
|
|
VPieceCarrouselPiece *carrouselPiece = new VPieceCarrouselPiece(piece);
|
|
|
|
m_carrouselPieces.append(carrouselPiece);
|
|
|
|
layout()->addWidget(carrouselPiece);
|
2020-04-26 22:32:08 +02:00
|
|
|
|
|
|
|
// FIXME? the fitInView inside the refresh of the piece doesn't workd properly.
|
|
|
|
// only by doing the following I did get it to work:
|
|
|
|
setVisible(true);
|
|
|
|
carrouselPiece->CleanPreview();
|
|
|
|
setVisible(false);
|
2020-04-26 12:09:28 +02:00
|
|
|
}
|
|
|
|
}
|
2020-05-01 18:26:02 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QList<VPieceCarrouselPiece*> VPieceCarrouselLayer::GetCarrouselPieces()
|
|
|
|
{
|
|
|
|
return m_carrouselPieces;
|
|
|
|
}
|
|
|
|
|