1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-19 17:09:40 +00:00

allow drag and drop into the script edit window.

This commit is contained in:
Marek Kochanowicz 2014-02-15 19:52:40 +01:00
parent 97fe5465bf
commit 930b77e60a
3 changed files with 31 additions and 47 deletions

View file

@ -1,27 +1,18 @@
/*
* <one line to give the library's name and an idea of what it does.>
* Copyright 2014 Marek Kochanowicz <sirherrbatka@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*
*/
#include "scriptedit.hpp"
#include <vector>
#include <QDragEnterEvent>
#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<const CSMWorld::TableMimeData*> (event->mimeData());
std::vector<CSMWorld::UniversalId> records (mime->getData());
for (std::vector<CSMWorld::UniversalId>::iterator it = records.begin(); it != records.end(); ++it)
{
insertPlainText (QString::fromStdString (it->getId()));
}
}
// kate: indent-mode cstyle; indent-width 4; replace-tabs on;

View file

@ -1,34 +1,19 @@
/*
* <one line to give the library's name and an idea of what it does.>
* Copyright 2014 Marek Kochanowicz <sirherrbatka@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*
*/
#ifndef SCRIPTEDIT_H
#define SCRIPTEDIT_H
#include <QTextEdit>
#include <qtextedit.h>
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;
// kate: indent-mode cstyle; indent-width 4; replace-tabs on;

View file

@ -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);