1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-06 02:49:41 +00:00

added the new qlineedit subclass

This commit is contained in:
Marek Kochanowicz 2014-03-12 19:36:46 +01:00
parent 30a0c82e22
commit 1bf67e7390
3 changed files with 52 additions and 4 deletions

View file

@ -528,7 +528,7 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event)
void CSVWorld::Table::dragEnterEvent(QDragEnterEvent *event)
{
event->acceptProposedAction();
event->acceptProposedAction();
}
void CSVWorld::Table::dropEvent(QDropEvent *event)
@ -560,7 +560,7 @@ void CSVWorld::Table::dropEvent(QDropEvent *event)
void CSVWorld::Table::dragMoveEvent(QDragMoveEvent *event)
{
event->accept();
event->accept();
}
std::vector<std::string> CSVWorld::Table::getColumnsWithDisplay(CSMWorld::ColumnBase::Display display) const

View file

@ -12,9 +12,10 @@
#include <QComboBox>
#include <QCheckBox>
#include <QPlainTextEdit>
#include <QEvent>
#include "../../model/world/commands.hpp"
#include <iostream>
#include "../../model/world/tablemimedata.hpp"
CSVWorld::NastyTableModelHack::NastyTableModelHack (QAbstractItemModel& model)
: mModel (model)
@ -167,7 +168,7 @@ QWidget *CSVWorld::CommandDelegate::createEditor (QWidget *parent, const QStyleO
display == CSMWorld::ColumnBase::Display_Class ||
display == CSMWorld::ColumnBase::Display_Faction)
{
return new QLineEdit(parent);
return new DropLineEdit(parent);
}
if (display == CSMWorld::ColumnBase::Display_Boolean)
{
@ -233,4 +234,26 @@ void CSVWorld::CommandDelegate::setEditorData (QWidget *editor, const QModelInde
editor->setProperty(n, v);
}
}
CSVWorld::DropLineEdit::DropLineEdit(QWidget* parent) :
QLineEdit(parent)
{
setAcceptDrops(true);
}
void CSVWorld::DropLineEdit::dragEnterEvent(QDragEnterEvent *event)
{
event->acceptProposedAction();
}
void CSVWorld::DropLineEdit::dragMoveEvent(QDragMoveEvent *event)
{
event->accept();
}
void CSVWorld::DropLineEdit::dropEvent(QDropEvent *event)
{
emit tableMimeDataDropped(dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData())->getData());
//WIP
}

View file

@ -5,11 +5,18 @@
#include <QAbstractTableModel>
#include <QStyledItemDelegate>
#include <QLineEdit>
#include "../../model/world/columnbase.hpp"
class QUndoStack;
namespace CSMWorld
{
class TableMimeData;
class UniversalId;
}
namespace CSVWorld
{
///< \brief Getting the data out of an editor widget
@ -79,6 +86,24 @@ namespace CSVWorld
};
class DropLineEdit : public QLineEdit
{
Q_OBJECT
public:
DropLineEdit(QWidget *parent);
private:
void dragEnterEvent(QDragEnterEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
void dropEvent(QDropEvent *event);
signals:
void tableMimeDataDropped(const std::vector<CSMWorld::UniversalId>& data);
};
///< \brief Use commands instead of manipulating the model directly
class CommandDelegate : public QStyledItemDelegate
{