VisualizationDragDropContainer.h
61 lines
| 2.0 KiB
| text/x-c
|
CLexer
r849 | #ifndef SCIQLOP_VISUALIZATIONDRAGDROPCONTAINER_H | |||
#define SCIQLOP_VISUALIZATIONDRAGDROPCONTAINER_H | ||||
r841 | ||||
#include <Common/spimpl.h> | ||||
r886 | #include <QFrame> | |||
r852 | #include <QLoggingCategory> | |||
r847 | #include <QMimeData> | |||
#include <QVBoxLayout> | ||||
r841 | ||||
r852 | #include <functional> | |||
r1110 | #include <DragAndDrop/DragDropGuiController.h> | |||
r887 | ||||
r852 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationDragDropContainer) | |||
r841 | class VisualizationDragWidget; | |||
r886 | class VisualizationDragDropContainer : public QFrame { | |||
r841 | Q_OBJECT | |||
signals: | ||||
r881 | void dropOccuredInContainer(int dropIndex, const QMimeData *mimeData); | |||
void dropOccuredOnWidget(VisualizationDragWidget *dragWidget, const QMimeData *mimeData); | ||||
r841 | ||||
public: | ||||
r977 | enum class DropBehavior { Inserted, Merged, InsertedAndMerged, Forbidden }; | |||
r852 | using AcceptMimeDataFunction = std::function<bool(const QMimeData *mimeData)>; | |||
Alexandre Leroux
|
r1064 | using AcceptDragWidgetFunction | ||
= std::function<bool(const VisualizationDragWidget *dragWidget, const QMimeData *mimeData)>; | ||||
r852 | ||||
r847 | VisualizationDragDropContainer(QWidget *parent = nullptr); | |||
r841 | ||||
r847 | void addDragWidget(VisualizationDragWidget *dragWidget); | |||
void insertDragWidget(int index, VisualizationDragWidget *dragWidget); | ||||
r841 | ||||
r977 | void setMimeType(const QString &mimeType, DropBehavior behavior); | |||
r841 | ||||
int countDragWidget() const; | ||||
r852 | void setAcceptMimeDataFunction(AcceptMimeDataFunction fun); | |||
Alexandre Leroux
|
r1064 | void setAcceptDragWidgetFunction(AcceptDragWidgetFunction fun); | ||
r1110 | void setPlaceHolderType(DragDropGuiController::PlaceHolderType type, | |||
r887 | const QString &placeHolderText = QString()); | |||
r841 | 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: | ||||
r847 | void startDrag(VisualizationDragWidget *dragWidget, const QPoint &dragPosition); | |||
r841 | }; | |||
r849 | #endif // SCIQLOP_VISUALIZATIONDRAGDROPCONTAINER_H | |||