vnote/src/widgets/dragdropareaindicator.h
Le Tan 52702a32e9 hard days for VNoteX project
Never say "refactor" again!!!
2020-11-28 23:10:43 +08:00

43 lines
1.1 KiB
C++

#ifndef DRAGDROPAREAINDICATOR_H
#define DRAGDROPAREAINDICATOR_H
#include <QFrame>
namespace vnotex
{
class DragDropAreaIndicatorInterface
{
public:
virtual ~DragDropAreaIndicatorInterface() {}
virtual bool handleDragEnterEvent(QDragEnterEvent *p_event) = 0;
virtual bool handleDropEvent(QDropEvent *p_event) = 0;
};
class DragDropAreaIndicator : public QFrame
{
Q_OBJECT
public:
DragDropAreaIndicator(DragDropAreaIndicatorInterface *p_interface,
const QString &p_text,
QWidget *p_parent = nullptr);
protected:
// To accept specific drop.
void dragEnterEvent(QDragEnterEvent *p_event) Q_DECL_OVERRIDE;
// Drop the data.
void dropEvent(QDropEvent *p_event) Q_DECL_OVERRIDE;
void mouseReleaseEvent(QMouseEvent *p_event) Q_DECL_OVERRIDE;
private:
void setupUI(const QString &p_text);
DragDropAreaIndicatorInterface *m_interface = nullptr;
};
}
#endif // DRAGDROPAREAINDICATOR_H