diff --git a/apps/opencs/view/world/scriptedit.cpp b/apps/opencs/view/world/scriptedit.cpp index 3a71d8f0c..4eb652add 100644 --- a/apps/opencs/view/world/scriptedit.cpp +++ b/apps/opencs/view/world/scriptedit.cpp @@ -1,27 +1,18 @@ -/* - * - * Copyright 2014 Marek Kochanowicz - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License or (at your option) version 3 or any later version - * accepted by the membership of KDE e.V. (or its successor approved - * by the membership of KDE e.V.), which shall act as a proxy - * defined in Section 14 of version 3 of the license. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - #include "scriptedit.hpp" +#include + +#include + +#include "../../model/world/universalid.hpp" +#include "../../model/world/tablemimedata.hpp" + +CSVWorld::ScriptEdit::ScriptEdit (QWidget* parent) : +QTextEdit(parent) +{ + +} + void CSVWorld::ScriptEdit::dragEnterEvent (QDragEnterEvent* event) { event->acceptProposedAction(); @@ -34,6 +25,13 @@ void CSVWorld::ScriptEdit::dragMoveEvent (QDragMoveEvent* event) void CSVWorld::ScriptEdit::dropEvent (QDropEvent* event) { + const CSMWorld::TableMimeData* mime = dynamic_cast (event->mimeData()); + std::vector records (mime->getData()); + + for (std::vector::iterator it = records.begin(); it != records.end(); ++it) + { + insertPlainText (QString::fromStdString (it->getId())); + } } // kate: indent-mode cstyle; indent-width 4; replace-tabs on; diff --git a/apps/opencs/view/world/scriptedit.hpp b/apps/opencs/view/world/scriptedit.hpp index 74e15ecbf..6df4acc5f 100644 --- a/apps/opencs/view/world/scriptedit.hpp +++ b/apps/opencs/view/world/scriptedit.hpp @@ -1,34 +1,19 @@ -/* - * - * Copyright 2014 Marek Kochanowicz - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License or (at your option) version 3 or any later version - * accepted by the membership of KDE e.V. (or its successor approved - * by the membership of KDE e.V.), which shall act as a proxy - * defined in Section 14 of version 3 of the license. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - #ifndef SCRIPTEDIT_H #define SCRIPTEDIT_H -#include +#include + +class QWidget; namespace CSVWorld { class ScriptEdit : public QTextEdit { + Q_OBJECT + public: + ScriptEdit (QWidget* parent); + + private: void dragEnterEvent (QDragEnterEvent* event); void dropEvent (QDropEvent* event); @@ -37,4 +22,4 @@ namespace CSVWorld }; } #endif // SCRIPTEDIT_H -// kate: indent-mode cstyle; indent-width 4; replace-tabs on; \ No newline at end of file +// kate: indent-mode cstyle; indent-width 4; replace-tabs on; diff --git a/apps/opencs/view/world/scriptsubview.cpp b/apps/opencs/view/world/scriptsubview.cpp index 446c34e5f..4fe5aafac 100644 --- a/apps/opencs/view/world/scriptsubview.cpp +++ b/apps/opencs/view/world/scriptsubview.cpp @@ -13,6 +13,7 @@ #include "../../model/world/idtable.hpp" #include "scripthighlighter.hpp" +#include "scriptedit.hpp" CSVWorld::ScriptSubView::ChangeLock::ChangeLock (ScriptSubView& view) : mView (view) { @@ -27,7 +28,7 @@ CSVWorld::ScriptSubView::ChangeLock::~ChangeLock() CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document) : SubView (id), mDocument (document), mColumn (-1), mChangeLocked (0) { - setWidget (mEditor = new QTextEdit (this)); + setWidget (mEditor = new ScriptEdit (this)); mEditor->setAcceptRichText (false); mEditor->setLineWrapMode (QTextEdit::NoWrap);