Refactoring VPieceCarrousel

This commit is contained in:
Ronan Le Tiec 2020-05-23 14:29:18 +02:00
parent 74112a43ac
commit 690606b4e5
10 changed files with 55 additions and 55 deletions

View File

@ -5,11 +5,11 @@ SOURCES += \
$$PWD/dialogs/vpdialogabout.cpp \
$$PWD/main.cpp \
$$PWD/vpapplication.cpp \
$$PWD/vpcarrousel.cpp \
$$PWD/vpcommands.cpp \
$$PWD/vpiececarrouselpiecepreview.cpp \
$$PWD/vpmainwindow.cpp \
$$PWD/vpuzzlecommandline.cpp \
$$PWD/vpiececarrousel.cpp \
$$PWD/vpuzzlegraphicslayout.cpp \
$$PWD/vpuzzlegraphicspiece.cpp \
$$PWD/vpuzzlelayout.cpp \
@ -29,12 +29,12 @@ SOURCES += \
HEADERS += \
$$PWD/dialogs/vpdialogabout.h \
$$PWD/vpapplication.h \
$$PWD/vpcarrousel.h \
$$PWD/vpcommands.h \
$$PWD/vpiececarrouselpiecepreview.h \
$$PWD/vpmainwindow.h \
$$PWD/vpstable.h \
$$PWD/vpuzzlecommandline.h \
$$PWD/vpiececarrousel.h \
$$PWD/vpuzzlegraphicslayout.h \
$$PWD/vpuzzlegraphicspiece.h \
$$PWD/vpuzzlelayout.h \
@ -51,7 +51,7 @@ HEADERS += \
FORMS += \
$$PWD/dialogs/vpdialogabout.ui \
$$PWD/vpiececarrousel.ui \
$$PWD/vpcarrousel.ui \
$$PWD/vpmainwindow.ui
SOURCES += \

View File

@ -1,6 +1,6 @@
/************************************************************************
**
** @file vpiececarrousel.cpp
** @file vpcarrousel.cpp
** @author Ronan Le Tiec
** @date 13 4, 2020
**
@ -25,8 +25,8 @@
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vpiececarrousel.h"
#include "ui_vpiececarrousel.h"
#include "vpcarrousel.h"
#include "ui_vpcarrousel.h"
#include <QVBoxLayout>
#include <QMessageBox>
#include <QScrollBar>
@ -41,16 +41,16 @@
Q_LOGGING_CATEGORY(pCarrousel, "p.carrousel")
//---------------------------------------------------------------------------------------------------------------------
VPieceCarrousel::VPieceCarrousel(VPuzzleLayout *layout, QWidget *parent) :
VPCarrousel::VPCarrousel(VPuzzleLayout *layout, QWidget *parent) :
QWidget(parent),
ui(new Ui::VPieceCarrousel),
ui(new Ui::VPCarrousel),
m_layout(layout)
{
ui->setupUi(this);
// init the combo box
connect(ui->comboBoxLayer, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&VPieceCarrousel::on_ActiveLayerChanged);
&VPCarrousel::on_ActiveLayerChanged);
ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu);
@ -59,7 +59,7 @@ VPieceCarrousel::VPieceCarrousel(VPuzzleLayout *layout, QWidget *parent) :
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrousel::Refresh()
void VPCarrousel::Refresh()
{
// NOTE: alternative to clearing the carrousel and adding things again, we could make comparision
@ -85,7 +85,7 @@ void VPieceCarrousel::Refresh()
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrousel::Clear()
void VPCarrousel::Clear()
{
// remove the combobox entries
ui->comboBoxLayer->clear();
@ -94,7 +94,7 @@ void VPieceCarrousel::Clear()
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrousel::on_ActiveLayerChanged(int index)
void VPCarrousel::on_ActiveLayerChanged(int index)
{
qCDebug(pCarrousel, "index changed %i", index);
@ -117,14 +117,14 @@ void VPieceCarrousel::on_ActiveLayerChanged(int index)
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrousel::SetOrientation(Qt::Orientation orientation)
void VPCarrousel::SetOrientation(Qt::Orientation orientation)
{
m_orientation = orientation;
RefreshOrientation();
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrousel::RefreshOrientation()
void VPCarrousel::RefreshOrientation()
{
// then update the scrollarea min height / width and scrollbar behaviour
if(m_orientation == Qt::Horizontal)
@ -150,7 +150,7 @@ void VPieceCarrousel::RefreshOrientation()
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrousel::ClearSelection()
void VPCarrousel::ClearSelection()
{
m_layout->ClearSelection();
}

View File

@ -1,6 +1,6 @@
/************************************************************************
**
** @file vpiececarrousel.h
** @file vpcarrousel.h
** @author Ronan Le Tiec
** @date 13 04, 2020
**
@ -26,8 +26,8 @@
**
*************************************************************************/
#ifndef VPIECECARROUSEL_H
#define VPIECECARROUSEL_H
#ifndef VPCARROUSEL_H
#define VPCARROUSEL_H
#include <QWidget>
#include <QComboBox>
@ -37,15 +37,15 @@
namespace Ui
{
class VPieceCarrousel;
class VPCarrousel;
}
class VPieceCarrousel : public QWidget
class VPCarrousel : public QWidget
{
Q_OBJECT
public:
explicit VPieceCarrousel(VPuzzleLayout *layout, QWidget *parent = nullptr);
virtual ~VPieceCarrousel() = default;
explicit VPCarrousel(VPuzzleLayout *layout, QWidget *parent = nullptr);
virtual ~VPCarrousel() = default;
/**
* @brief SetOrientation Sets the orientation to the given value and refreshes
@ -76,8 +76,8 @@ public:
void ClearSelection();
private:
Q_DISABLE_COPY(VPieceCarrousel)
Ui::VPieceCarrousel *ui;
Q_DISABLE_COPY(VPCarrousel)
Ui::VPCarrousel *ui;
VPuzzleLayout *m_layout;
QList<VPuzzleLayer*> m_layers{};
@ -94,4 +94,4 @@ private slots:
void on_ActiveLayerChanged(int index);
};
#endif // VPIECECARROUSEL_H
#endif // VPCARROUSEL_H

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>VPieceCarrousel</class>
<widget class="QWidget" name="VPieceCarrousel">
<class>VPCarrousel</class>
<widget class="QWidget" name="VPCarrousel">
<property name="geometry">
<rect>
<x>0</x>
@ -42,7 +42,7 @@
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragOnly</enum>
<enum>QAbstractItemView::NoDragDrop</enum>
</property>
<property name="iconSize">
<size>

View File

@ -27,7 +27,7 @@
*************************************************************************/
#include "vpiececarrousellayer.h"
#include "vpiececarrousel.h"
#include "vpcarrousel.h"
#include "../vmisc/backport/qoverload.h"
#include <QVBoxLayout>
@ -37,7 +37,7 @@
Q_LOGGING_CATEGORY(pCarrouselLayer, "p.carrouselLayer")
//---------------------------------------------------------------------------------------------------------------------
VPieceCarrouselLayer::VPieceCarrouselLayer(VPuzzleLayer *layer, VPieceCarrousel *carrousel) :
VPieceCarrouselLayer::VPieceCarrouselLayer(VPuzzleLayer *layer, VPCarrousel *carrousel) :
m_layer(layer),
m_carrousel(carrousel),
m_carrouselPieces(QList<VPieceCarrouselPiece*>())
@ -117,7 +117,7 @@ QList<VPieceCarrouselPiece*> VPieceCarrouselLayer::GetCarrouselPieces()
}
//---------------------------------------------------------------------------------------------------------------------
VPieceCarrousel* VPieceCarrouselLayer::GetCarrousel()
VPCarrousel* VPieceCarrouselLayer::GetCarrousel()
{
return m_carrousel;
}

View File

@ -33,13 +33,13 @@
#include "vpuzzlelayer.h"
#include "vpiececarrouselpiece.h"
class VPieceCarrousel;
class VPCarrousel;
class VPieceCarrouselLayer : public QWidget
{
Q_OBJECT
public:
VPieceCarrouselLayer(VPuzzleLayer *layer, VPieceCarrousel *carrousel);
VPieceCarrouselLayer(VPuzzleLayer *layer, VPCarrousel *carrousel);
~VPieceCarrouselLayer();
void Init();
@ -52,7 +52,7 @@ public:
QList<VPieceCarrouselPiece*> GetCarrouselPieces();
VPieceCarrousel* GetCarrousel();
VPCarrousel* GetCarrousel();
/**
* @brief GetPuzzleLayer Returns the corresponding VPuzzleLayer
@ -64,7 +64,7 @@ private:
Q_DISABLE_COPY(VPieceCarrouselLayer)
VPuzzleLayer *m_layer;
VPieceCarrousel *m_carrousel;
VPCarrousel *m_carrousel;
QList<VPieceCarrouselPiece*> m_carrouselPieces;
private slots:

View File

@ -39,7 +39,7 @@
#include "vpuzzlemimedatapiece.h"
#include "vpiececarrousellayer.h"
#include "vpiececarrousel.h"
#include "vpcarrousel.h"
#include <QLoggingCategory>

View File

@ -72,7 +72,7 @@ VPMainWindow::VPMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *parent) :
InitMenuBar();
InitProperties();
InitPieceCarrousel();
InitCarrousel();
InitMainGraphics();
@ -85,7 +85,7 @@ VPMainWindow::VPMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *parent) :
VPMainWindow::~VPMainWindow()
{
delete ui;
delete m_pieceCarrousel;
delete m_carrousel;
}
//---------------------------------------------------------------------------------------------------------------------
@ -168,7 +168,7 @@ void VPMainWindow::ImportRawLayouts(const QStringList &rawLayouts)
m_layout->GetUnplacedPiecesLayer()->AddPiece(piece);
}
m_pieceCarrousel->Refresh();
m_carrousel->Refresh();
}
else
{
@ -321,13 +321,13 @@ void VPMainWindow::InitPropertyTabLayers()
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::InitPieceCarrousel()
void VPMainWindow::InitCarrousel()
{
m_pieceCarrousel = new VPieceCarrousel(m_layout, ui->dockWidgetPieceCarrousel);
ui->dockWidgetPieceCarrousel->setWidget(m_pieceCarrousel);
m_carrousel = new VPCarrousel(m_layout, ui->dockWidgetCarrousel);
ui->dockWidgetCarrousel->setWidget(m_carrousel);
connect(ui->dockWidgetPieceCarrousel, QOverload<Qt::DockWidgetArea>::of(&QDockWidget::dockLocationChanged), this,
&VPMainWindow::on_PieceCarrouselLocationChanged);
connect(ui->dockWidgetCarrousel, QOverload<Qt::DockWidgetArea>::of(&QDockWidget::dockLocationChanged), this,
&VPMainWindow::on_CarrouselLocationChanged);
}
@ -973,15 +973,15 @@ void VPMainWindow::on_CurrentPiecePositionEdited()
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_PieceCarrouselLocationChanged(Qt::DockWidgetArea area)
void VPMainWindow::on_CarrouselLocationChanged(Qt::DockWidgetArea area)
{
if(area == Qt::BottomDockWidgetArea || area == Qt::TopDockWidgetArea)
{
m_pieceCarrousel->SetOrientation(Qt::Horizontal);
m_carrousel->SetOrientation(Qt::Horizontal);
}
else if (area == Qt::LeftDockWidgetArea || area == Qt::RightDockWidgetArea)
{
m_pieceCarrousel->SetOrientation(Qt::Vertical);
m_carrousel->SetOrientation(Qt::Vertical);
}
}

View File

@ -33,7 +33,7 @@
#include <QDoubleSpinBox>
#include "../vmisc/def.h"
#include "vpiececarrousel.h"
#include "vpcarrousel.h"
#include "vpuzzlemaingraphicsview.h"
#include "vpuzzlelayout.h"
#include "vpuzzlepiece.h"
@ -90,7 +90,7 @@ private:
Q_DISABLE_COPY(VPMainWindow)
Ui::VPMainWindow *ui;
VPieceCarrousel *m_pieceCarrousel{nullptr};
VPCarrousel *m_carrousel{nullptr};
VPuzzleMainGraphicsView *m_graphicsView{nullptr};
VPuzzleCommandLinePtr m_cmd;
@ -135,9 +135,9 @@ private:
void InitPropertyTabLayers();
/**
* @brief InitPieceCarrousel Inits the piece carrousel
* @brief InitCarrousel Inits the carrousel
*/
void InitPieceCarrousel();
void InitCarrousel();
/**
* @brief InitMainGraphics Initialises the puzzle main graphics
@ -364,11 +364,11 @@ private slots:
void on_CurrentPiecePositionEdited();
/**
* @brief PieceCarrouselLocationChanged When the piece carrousel's location
* @brief CarrouselLocationChanged When the piece carrousel's location
* has been changed
* @param area The new area where the piece carrousel has been placed
*/
void on_PieceCarrouselLocationChanged(Qt::DockWidgetArea area);
void on_CarrouselLocationChanged(Qt::DockWidgetArea area);
/**
* @brief on_PieceSelectionChanged When the piece selection has changed

View File

@ -82,7 +82,7 @@
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<widget class="QDockWidget" name="dockWidgetPieceCarrousel">
<widget class="QDockWidget" name="dockWidgetCarrousel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -110,7 +110,7 @@
<attribute name="dockWidgetArea">
<number>1</number>
</attribute>
<widget class="QWidget" name="widgetPieceCarrousel">
<widget class="QWidget" name="widgetCarrousel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>