-
Notifications
You must be signed in to change notification settings - Fork 1
/
editor_window.cpp
50 lines (44 loc) · 1.09 KB
/
editor_window.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* editor_window.cpp
* JoyPrompter
*
* Created by Andrew Stucki on 2/5/11.
* Copyright 2011 JoyVision. All rights reserved.
*
*/
//to-do: implement drag and drop for native file types - just need to add type-checking via writing a magic number
//0xCAFEF00D
//#include <QList>
//#include <QString>
//#include <QUrl>
//#include <QFile>
//#include <QTextStream>
//#include <QIODevice>
#include "editor_window.h"
EditorWindow::EditorWindow(QWidget *parent)
: QTextEdit(parent)
{
this->setAcceptRichText(false);
this->setAcceptDrops(true);
}
void EditorWindow::dropEvent(QDropEvent *event)
{
// if (event->mimeData()->hasFormat("text/uri-list")) {
// QList<QUrl> urls = event->mimeData()->urls();
// if (urls.isEmpty())
// return;
//
// QString fileName = urls.first().toLocalFile();
// if (fileName.isEmpty())
// return;
//
// QFile file(fileName);
// if (!file.open (QIODevice::ReadOnly))
// return;
// QTextStream stream ( &file );
// this->setPlainText(stream.readAll());
// file.close();
// }
if (event->mimeData()->hasText())
this->setPlainText(event->mimeData()->text());
}