168 lines
3.9 KiB
C++
Executable File
168 lines
3.9 KiB
C++
Executable File
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include "plan_editor.h"
|
|
|
|
#include <Map/drop_event_manager.h>
|
|
|
|
#include <LtsWidgets/lts_drop_handler.h>
|
|
|
|
#include <QtCore/QMimeData>
|
|
|
|
|
|
namespace PlanEditor
|
|
{
|
|
|
|
class DropEventManager : public SituationMap::DropEventManager
|
|
{
|
|
public:
|
|
|
|
DropEventManager() = default;
|
|
|
|
virtual ~DropEventManager()
|
|
{
|
|
|
|
qDeleteAll(m_dropHandlerMap);
|
|
}
|
|
|
|
QString mimeFormatString() const override { return QLatin1String("DropHandlerPtr"); }
|
|
|
|
void manageDrop(QPoint windowPos, const QMimeData *mimeData) override
|
|
{
|
|
bool ok = false;
|
|
qulonglong dropHandlerAddress = mimeData->data(mimeFormatString()).toULongLong(&ok);
|
|
if (ok)
|
|
{
|
|
|
|
auto dropHandler = m_dropHandlerMap.find(dropHandlerAddress);
|
|
if (dropHandler != m_dropHandlerMap.end())
|
|
(*dropHandler)->doDrop(windowPos.x(), windowPos.y(), mimeData);
|
|
}
|
|
}
|
|
|
|
qulonglong add(LtsWidgets::LtsDropHandler *dropHandler)
|
|
{
|
|
|
|
|
|
qulonglong key = qulonglong(dropHandler);
|
|
if (dropHandler)
|
|
{
|
|
|
|
m_dropHandlerMap[key] = dropHandler;
|
|
}
|
|
return key;
|
|
}
|
|
|
|
|
|
protected:
|
|
|
|
QHash<qulonglong, LtsWidgets::LtsDropHandler *> m_dropHandlerMap;
|
|
|
|
};
|
|
|
|
|
|
class DropCreateLine : public LtsWidgets::LtsDropHandler
|
|
{
|
|
PlanEditor *m_planEditor;
|
|
PlanEditor::InternalData *m_planEditorInternal;
|
|
|
|
public:
|
|
|
|
DropCreateLine(PlanEditor *planEditor, PlanEditor::InternalData *planEditorInternal)
|
|
: LtsWidgets::LtsDropHandler()
|
|
, m_planEditor(planEditor)
|
|
, m_planEditorInternal(planEditorInternal) {;}
|
|
|
|
virtual ~DropCreateLine() = default;
|
|
|
|
void doDrop(int x, int y, const QMimeData *mimeData) const override;
|
|
|
|
};
|
|
|
|
|
|
class DropCreatePolyLine : public LtsWidgets::LtsDropHandler
|
|
{
|
|
PlanEditor *m_planEditor;
|
|
PlanEditor::InternalData *m_planEditorInternal;
|
|
bool m_smooth;
|
|
|
|
public:
|
|
|
|
DropCreatePolyLine(PlanEditor *planEditor, PlanEditor::InternalData *planEditorInternal, bool smooth = false)
|
|
: LtsWidgets::LtsDropHandler()
|
|
, m_planEditor(planEditor)
|
|
, m_planEditorInternal(planEditorInternal)
|
|
, m_smooth(smooth) {;}
|
|
|
|
virtual ~DropCreatePolyLine() = default;
|
|
|
|
void doDrop(int x, int y, const QMimeData *mimeData) const override;
|
|
|
|
};
|
|
|
|
|
|
class DropCreatePolygon : public LtsWidgets::LtsDropHandler
|
|
{
|
|
PlanEditor *m_planEditor;
|
|
PlanEditor::InternalData *m_planEditorInternal;
|
|
bool m_smooth;
|
|
|
|
public:
|
|
|
|
DropCreatePolygon(PlanEditor *planEditor, PlanEditor::InternalData *planEditorInternal, bool smooth = false)
|
|
: LtsWidgets::LtsDropHandler()
|
|
, m_planEditor(planEditor)
|
|
, m_planEditorInternal(planEditorInternal)
|
|
, m_smooth(smooth) {;}
|
|
|
|
virtual ~DropCreatePolygon() = default;
|
|
|
|
void doDrop(int x, int y, const QMimeData *mimeData) const override;
|
|
|
|
};
|
|
|
|
|
|
class DropCreateRectangle : public LtsWidgets::LtsDropHandler
|
|
{
|
|
PlanEditor *m_planEditor;
|
|
PlanEditor::InternalData *m_planEditorInternal;
|
|
bool m_ellipse;
|
|
|
|
public:
|
|
|
|
DropCreateRectangle(PlanEditor *planEditor, PlanEditor::InternalData *planEditorInternal, bool ellipse = false)
|
|
: LtsWidgets::LtsDropHandler()
|
|
, m_planEditor(planEditor)
|
|
, m_planEditorInternal(planEditorInternal)
|
|
, m_ellipse(ellipse) {;}
|
|
|
|
virtual ~DropCreateRectangle() = default;
|
|
|
|
void doDrop(int x, int y, const QMimeData *mimeData) const override;
|
|
|
|
};
|
|
|
|
|
|
class DropCreateTextLine : public LtsWidgets::LtsDropHandler
|
|
{
|
|
PlanEditor *m_planEditor;
|
|
PlanEditor::InternalData *m_planEditorInternal;
|
|
|
|
public:
|
|
|
|
DropCreateTextLine(PlanEditor *planEditor, PlanEditor::InternalData *planEditorInternal)
|
|
: LtsWidgets::LtsDropHandler()
|
|
, m_planEditor(planEditor)
|
|
, m_planEditorInternal(planEditorInternal) {;}
|
|
|
|
virtual ~DropCreateTextLine() = default;
|
|
|
|
void doDrop(int x, int y, const QMimeData *mimeData) const override;
|
|
|
|
};
|
|
|
|
}
|