Disable inter-window drag&drop.
This commit is contained in:
parent
74090f7ffd
commit
665101a6c5
|
@ -226,6 +226,12 @@ void VPCarrousel::on_ActivePieceListChanged(int index)
|
|||
RefreshSheetNames();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPLayoutWeakPtr VPCarrousel::Layout() const
|
||||
{
|
||||
return m_layout;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPCarrousel::SetOrientation(Qt::Orientation orientation)
|
||||
{
|
||||
|
|
|
@ -76,6 +76,8 @@ public:
|
|||
*/
|
||||
void Clear();
|
||||
|
||||
VPLayoutWeakPtr Layout() const;
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* @brief Refresh Refreshes the content of the carrousel
|
||||
|
|
|
@ -137,9 +137,20 @@ void VPCarrouselPieceList::startDrag(Qt::DropActions supportedActions)
|
|||
{
|
||||
auto *pieceItem = static_cast<VPCarrouselPiece *> (_item);
|
||||
|
||||
if (m_carrousel == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
VPLayoutPtr layout = m_carrousel->Layout().toStrongRef();
|
||||
if (layout.isNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// starts the dragging
|
||||
auto *drag = new QDrag(this);
|
||||
auto *mimeData = new VPMimeDataPiece();
|
||||
auto *mimeData = new VPMimeDataPiece(layout->Uuid());
|
||||
VPPiecePtr piece = pieceItem->GetPiece();
|
||||
mimeData->SetPiecePtr(piece);
|
||||
|
||||
|
|
|
@ -35,6 +35,11 @@
|
|||
|
||||
const QString VPMimeDataPiece::mineFormatPiecePtr = QStringLiteral("application/vnd.puzzle.piece.ptr");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPMimeDataPiece::VPMimeDataPiece(const QUuid &layoutUuid)
|
||||
:m_layoutUuid(layoutUuid)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPMimeDataPiece::formats() const -> QStringList
|
||||
{
|
||||
|
@ -65,3 +70,9 @@ auto VPMimeDataPiece::DragCursor(const QPixmap &piecePixmap) -> QPixmap
|
|||
painter.end();
|
||||
return dragCursor;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
const QUuid &VPMimeDataPiece::LayoutUuid() const
|
||||
{
|
||||
return m_layoutUuid;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include <QMimeData>
|
||||
#include <QSharedPointer>
|
||||
#include <QUuid>
|
||||
|
||||
#include "../layout/layoutdef.h"
|
||||
|
||||
|
@ -39,7 +40,7 @@ class VPMimeDataPiece : public QMimeData
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
VPMimeDataPiece() = default;
|
||||
VPMimeDataPiece(const QUuid &layoutUuid);
|
||||
virtual ~VPMimeDataPiece() = default;
|
||||
|
||||
virtual auto formats() const -> QStringList override;
|
||||
|
@ -60,10 +61,14 @@ public:
|
|||
|
||||
static const QString mineFormatPiecePtr;
|
||||
|
||||
const QUuid &LayoutUuid() const;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VPMimeDataPiece)
|
||||
|
||||
VPPieceWeakPtr m_piece{};
|
||||
|
||||
QUuid m_layoutUuid;
|
||||
};
|
||||
|
||||
#endif // VPMIMEDATAPIECE_H
|
||||
|
|
|
@ -119,6 +119,12 @@ void VPLayout::AddPiece(const VPPiecePtr &piece)
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
const QUuid &VPLayout::Uuid() const
|
||||
{
|
||||
return m_uuid;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPTileFactory *VPLayout::TileFactory() const
|
||||
{
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QUuid>
|
||||
|
||||
#include "def.h"
|
||||
#include "vplayoutsettings.h"
|
||||
|
@ -99,6 +100,8 @@ public:
|
|||
|
||||
auto IsSheetsUniform() const -> bool;
|
||||
|
||||
const QUuid &Uuid() const;
|
||||
|
||||
signals:
|
||||
void PieceSheetChanged(const VPPiecePtr &piece);
|
||||
void ActiveSheetChanged(const VPSheetPtr &focusedSheet);
|
||||
|
@ -129,6 +132,8 @@ private:
|
|||
QUndoStack *m_undoStack;
|
||||
|
||||
VPTileFactory *m_tileFactory{nullptr};
|
||||
|
||||
QUuid m_uuid{QUuid::createUuid()};
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(VPLayoutPtr)
|
||||
|
|
|
@ -120,10 +120,20 @@ void VPMainGraphicsView::dragEnterEvent(QDragEnterEvent *event)
|
|||
const QMimeData *mime = event->mimeData();
|
||||
|
||||
if(mime->hasFormat(VPMimeDataPiece::mineFormatPiecePtr))
|
||||
{
|
||||
VPLayoutPtr layout = m_layout.toStrongRef();
|
||||
if (layout.isNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const auto *mimePiece = qobject_cast<const VPMimeDataPiece *> (mime);
|
||||
if (mimePiece != nullptr && mimePiece->LayoutUuid() == layout->Uuid())
|
||||
{
|
||||
qCDebug(pMainGraphicsView(), "drag enter");
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -132,9 +142,19 @@ void VPMainGraphicsView::dragMoveEvent(QDragMoveEvent *event)
|
|||
const QMimeData *mime = event->mimeData();
|
||||
|
||||
if(mime->hasFormat(VPMimeDataPiece::mineFormatPiecePtr))
|
||||
{
|
||||
VPLayoutPtr layout = m_layout.toStrongRef();
|
||||
if (layout.isNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const auto *mimePiece = qobject_cast<const VPMimeDataPiece *> (mime);
|
||||
if (mimePiece != nullptr && mimePiece->LayoutUuid() == layout->Uuid())
|
||||
{
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -151,11 +171,6 @@ void VPMainGraphicsView::dropEvent(QDropEvent *event)
|
|||
qCDebug(pMainGraphicsView(), "drop enter , %s", qUtf8Printable(mime->objectName()));
|
||||
|
||||
if(mime->hasFormat(VPMimeDataPiece::mineFormatPiecePtr))
|
||||
{
|
||||
const auto *mimePiece = qobject_cast<const VPMimeDataPiece *> (mime);
|
||||
|
||||
VPPiecePtr piece = mimePiece->GetPiecePtr();
|
||||
if(not piece.isNull())
|
||||
{
|
||||
VPLayoutPtr layout = m_layout.toStrongRef();
|
||||
if (layout.isNull())
|
||||
|
@ -163,6 +178,16 @@ void VPMainGraphicsView::dropEvent(QDropEvent *event)
|
|||
return;
|
||||
}
|
||||
|
||||
const auto *mimePiece = qobject_cast<const VPMimeDataPiece *> (mime);
|
||||
|
||||
if (mimePiece == nullptr || mimePiece->LayoutUuid() != layout->Uuid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
VPPiecePtr piece = mimePiece->GetPiecePtr();
|
||||
if(not piece.isNull())
|
||||
{
|
||||
qCDebug(pMainGraphicsView(), "element dropped, %s", qUtf8Printable(piece->GetName()));
|
||||
event->acceptProposedAction();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user