#include <QtWidgets>
#import "Foundation/Foundation.h"

class TreeView : public QTreeView
{
    Q_OBJECT
public:
    void mousePressEvent(QMouseEvent *event) override
    {
        Q_UNUSED(event);
        auto drag = new QDrag(this);
        QMimeData *mimeData = new QMimeData();
        QList<QUrl> urlList = { QUrl(), QUrl() };
        mimeData->setUrls(urlList);
        drag->setMimeData(mimeData);
        try {
            drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction);
        } catch (NSException *exception) {
            NSLog( @"NSException caught" );
            NSLog( @"Name: %@", exception.name);
            NSLog( @"Reason: %@", exception.reason );
        }
    }
};



int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    auto view = new TreeView;

    view->setDragEnabled(true);
    view->show();

    return a.exec();
}

#include "bug_dnd_mojave.moc"


