API Documentation
Loading...
Searching...
No Matches
FileDropFrame.h
Go to the documentation of this file.
1#pragma once
2#include <QFrame>
3#include <QMimeData>
4#include <QDragEnterEvent>
5#include <QDropEvent>
6namespace NDEVR
7{
8 class FileDropFrame : public QFrame
9 {
10 public:
11 FileDropFrame(QWidget* parent = nullptr)
12 : QFrame(parent)
13 {
14 setAcceptDrops(true);
15 }
16 void dragEnterEvent(QDragEnterEvent* event)
17 {
18 if(m_drop_filter == nullptr)
19 event->acceptProposedAction();
20 else if (m_drop_filter(event->mimeData()))
21 event->acceptProposedAction();
22 }
23 void dropEvent(QDropEvent* event)
24 {
26 m_drop_callback(event);
27 }
28 void setDropCallback(const std::function<void(QDropEvent* event)>& drop_callback)
29 {
30 m_drop_callback = drop_callback;
31 }
32 void setDropFilter(std::function<bool(const QMimeData* event)> filter)
33 {
34 m_drop_filter = filter;
35 }
36 protected:
37 std::function<void(QDropEvent* event)> m_drop_callback;
38 std::function<bool(const QMimeData* event)> m_drop_filter;
39 };
40}
Definition FileDropFrame.h:9
std::function< bool(const QMimeData *event)> m_drop_filter
Definition FileDropFrame.h:38
void dropEvent(QDropEvent *event)
Definition FileDropFrame.h:23
void setDropCallback(const std::function< void(QDropEvent *event)> &drop_callback)
Definition FileDropFrame.h:28
void dragEnterEvent(QDragEnterEvent *event)
Definition FileDropFrame.h:16
void setDropFilter(std::function< bool(const QMimeData *event)> filter)
Definition FileDropFrame.h:32
FileDropFrame(QWidget *parent=nullptr)
Definition FileDropFrame.h:11
std::function< void(QDropEvent *event)> m_drop_callback
Definition FileDropFrame.h:37
Definition ACIColor.h:37