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

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpiececarrousel.cpp ** @file vpcarrousel.cpp
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 13 4, 2020 ** @date 13 4, 2020
** **
@ -25,8 +25,8 @@
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
*************************************************************************/ *************************************************************************/
#include "vpiececarrousel.h" #include "vpcarrousel.h"
#include "ui_vpiececarrousel.h" #include "ui_vpcarrousel.h"
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QMessageBox> #include <QMessageBox>
#include <QScrollBar> #include <QScrollBar>
@ -41,16 +41,16 @@
Q_LOGGING_CATEGORY(pCarrousel, "p.carrousel") Q_LOGGING_CATEGORY(pCarrousel, "p.carrousel")
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPieceCarrousel::VPieceCarrousel(VPuzzleLayout *layout, QWidget *parent) : VPCarrousel::VPCarrousel(VPuzzleLayout *layout, QWidget *parent) :
QWidget(parent), QWidget(parent),
ui(new Ui::VPieceCarrousel), ui(new Ui::VPCarrousel),
m_layout(layout) m_layout(layout)
{ {
ui->setupUi(this); ui->setupUi(this);
// init the combo box // init the combo box
connect(ui->comboBoxLayer, QOverload<int>::of(&QComboBox::currentIndexChanged), this, connect(ui->comboBoxLayer, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&VPieceCarrousel::on_ActiveLayerChanged); &VPCarrousel::on_ActiveLayerChanged);
ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu); 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 // 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 // remove the combobox entries
ui->comboBoxLayer->clear(); 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); 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; m_orientation = orientation;
RefreshOrientation(); RefreshOrientation();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPieceCarrousel::RefreshOrientation() void VPCarrousel::RefreshOrientation()
{ {
// then update the scrollarea min height / width and scrollbar behaviour // then update the scrollarea min height / width and scrollbar behaviour
if(m_orientation == Qt::Horizontal) if(m_orientation == Qt::Horizontal)
@ -150,7 +150,7 @@ void VPieceCarrousel::RefreshOrientation()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPieceCarrousel::ClearSelection() void VPCarrousel::ClearSelection()
{ {
m_layout->ClearSelection(); m_layout->ClearSelection();
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -72,7 +72,7 @@ VPMainWindow::VPMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *parent) :
InitMenuBar(); InitMenuBar();
InitProperties(); InitProperties();
InitPieceCarrousel(); InitCarrousel();
InitMainGraphics(); InitMainGraphics();
@ -85,7 +85,7 @@ VPMainWindow::VPMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *parent) :
VPMainWindow::~VPMainWindow() VPMainWindow::~VPMainWindow()
{ {
delete ui; delete ui;
delete m_pieceCarrousel; delete m_carrousel;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -168,7 +168,7 @@ void VPMainWindow::ImportRawLayouts(const QStringList &rawLayouts)
m_layout->GetUnplacedPiecesLayer()->AddPiece(piece); m_layout->GetUnplacedPiecesLayer()->AddPiece(piece);
} }
m_pieceCarrousel->Refresh(); m_carrousel->Refresh();
} }
else else
{ {
@ -321,13 +321,13 @@ void VPMainWindow::InitPropertyTabLayers()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::InitPieceCarrousel() void VPMainWindow::InitCarrousel()
{ {
m_pieceCarrousel = new VPieceCarrousel(m_layout, ui->dockWidgetPieceCarrousel); m_carrousel = new VPCarrousel(m_layout, ui->dockWidgetCarrousel);
ui->dockWidgetPieceCarrousel->setWidget(m_pieceCarrousel); ui->dockWidgetCarrousel->setWidget(m_carrousel);
connect(ui->dockWidgetPieceCarrousel, QOverload<Qt::DockWidgetArea>::of(&QDockWidget::dockLocationChanged), this, connect(ui->dockWidgetCarrousel, QOverload<Qt::DockWidgetArea>::of(&QDockWidget::dockLocationChanged), this,
&VPMainWindow::on_PieceCarrouselLocationChanged); &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) 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) 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 <QDoubleSpinBox>
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "vpiececarrousel.h" #include "vpcarrousel.h"
#include "vpuzzlemaingraphicsview.h" #include "vpuzzlemaingraphicsview.h"
#include "vpuzzlelayout.h" #include "vpuzzlelayout.h"
#include "vpuzzlepiece.h" #include "vpuzzlepiece.h"
@ -90,7 +90,7 @@ private:
Q_DISABLE_COPY(VPMainWindow) Q_DISABLE_COPY(VPMainWindow)
Ui::VPMainWindow *ui; Ui::VPMainWindow *ui;
VPieceCarrousel *m_pieceCarrousel{nullptr}; VPCarrousel *m_carrousel{nullptr};
VPuzzleMainGraphicsView *m_graphicsView{nullptr}; VPuzzleMainGraphicsView *m_graphicsView{nullptr};
VPuzzleCommandLinePtr m_cmd; VPuzzleCommandLinePtr m_cmd;
@ -135,9 +135,9 @@ private:
void InitPropertyTabLayers(); void InitPropertyTabLayers();
/** /**
* @brief InitPieceCarrousel Inits the piece carrousel * @brief InitCarrousel Inits the carrousel
*/ */
void InitPieceCarrousel(); void InitCarrousel();
/** /**
* @brief InitMainGraphics Initialises the puzzle main graphics * @brief InitMainGraphics Initialises the puzzle main graphics
@ -364,11 +364,11 @@ private slots:
void on_CurrentPiecePositionEdited(); void on_CurrentPiecePositionEdited();
/** /**
* @brief PieceCarrouselLocationChanged When the piece carrousel's location * @brief CarrouselLocationChanged When the piece carrousel's location
* has been changed * has been changed
* @param area The new area where the piece carrousel has been placed * @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 * @brief on_PieceSelectionChanged When the piece selection has changed

View File

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