VisualizationDragDropContainer.h
61 lines
| 2.0 KiB
| text/x-c
|
CLexer
r846 | #ifndef SCIQLOP_VISUALIZATIONDRAGDROPCONTAINER_H | |||
#define SCIQLOP_VISUALIZATIONDRAGDROPCONTAINER_H | ||||
r838 | ||||
#include <Common/spimpl.h> | ||||
r880 | #include <QFrame> | |||
r850 | #include <QLoggingCategory> | |||
r844 | #include <QMimeData> | |||
#include <QVBoxLayout> | ||||
r838 | ||||
r850 | #include <functional> | |||
r884 | #include <DragAndDrop/DragDropHelper.h> | |||
r881 | ||||
r850 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationDragDropContainer) | |||
r838 | class VisualizationDragWidget; | |||
r880 | class VisualizationDragDropContainer : public QFrame { | |||
r838 | Q_OBJECT | |||
signals: | ||||
r875 | void dropOccuredInContainer(int dropIndex, const QMimeData *mimeData); | |||
void dropOccuredOnWidget(VisualizationDragWidget *dragWidget, const QMimeData *mimeData); | ||||
r838 | ||||
public: | ||||
r936 | enum class DropBehavior { Inserted, Merged, InsertedAndMerged, Forbidden }; | |||
r850 | using AcceptMimeDataFunction = std::function<bool(const QMimeData *mimeData)>; | |||
Alexandre Leroux
|
r1023 | using AcceptDragWidgetFunction | ||
= std::function<bool(const VisualizationDragWidget *dragWidget, const QMimeData *mimeData)>; | ||||
r850 | ||||
r844 | VisualizationDragDropContainer(QWidget *parent = nullptr); | |||
r838 | ||||
r844 | void addDragWidget(VisualizationDragWidget *dragWidget); | |||
void insertDragWidget(int index, VisualizationDragWidget *dragWidget); | ||||
r838 | ||||
r936 | void setMimeType(const QString &mimeType, DropBehavior behavior); | |||
r838 | ||||
int countDragWidget() const; | ||||
r850 | void setAcceptMimeDataFunction(AcceptMimeDataFunction fun); | |||
Alexandre Leroux
|
r1023 | void setAcceptDragWidgetFunction(AcceptDragWidgetFunction fun); | ||
r881 | void setPlaceHolderType(DragDropHelper::PlaceHolderType type, | |||
const QString &placeHolderText = QString()); | ||||
r838 | protected: | |||
void dragEnterEvent(QDragEnterEvent *event); | ||||
void dragLeaveEvent(QDragLeaveEvent *event); | ||||
void dragMoveEvent(QDragMoveEvent *event); | ||||
void dropEvent(QDropEvent *event); | ||||
private: | ||||
class VisualizationDragDropContainerPrivate; | ||||
spimpl::unique_impl_ptr<VisualizationDragDropContainerPrivate> impl; | ||||
private slots: | ||||
r844 | void startDrag(VisualizationDragWidget *dragWidget, const QPoint &dragPosition); | |||
r838 | }; | |||
r846 | #endif // SCIQLOP_VISUALIZATIONDRAGDROPCONTAINER_H | |||