2012-12-13 12:35:08 +00:00
|
|
|
#ifndef CSV_WORLD_DIALOGUESUBVIEW_H
|
|
|
|
#define CSV_WORLD_DIALOGUESUBVIEW_H
|
|
|
|
|
2014-03-07 16:15:43 +00:00
|
|
|
#include <map>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include <QAbstractItemDelegate>
|
|
|
|
|
2012-12-13 12:35:08 +00:00
|
|
|
#include "../doc/subview.hpp"
|
2014-03-07 16:15:43 +00:00
|
|
|
#include "../../model/world/columnbase.hpp"
|
2012-12-13 12:35:08 +00:00
|
|
|
|
2013-01-08 13:59:40 +00:00
|
|
|
class QDataWidgetMapper;
|
2014-03-07 16:15:43 +00:00
|
|
|
class QSize;
|
|
|
|
class QEvent;
|
|
|
|
|
|
|
|
namespace CSMWorld
|
|
|
|
{
|
|
|
|
class IdTable;
|
|
|
|
}
|
2013-01-08 13:59:40 +00:00
|
|
|
|
2012-12-13 12:35:08 +00:00
|
|
|
namespace CSMDoc
|
|
|
|
{
|
|
|
|
class Document;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace CSVWorld
|
|
|
|
{
|
2014-03-07 16:15:43 +00:00
|
|
|
class CommandDelegate;
|
|
|
|
|
|
|
|
class DialogueDelegateDispatcher : public QAbstractItemDelegate
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
std::map<int, CommandDelegate*> mDelegates;
|
|
|
|
|
|
|
|
QObject* mParent;
|
|
|
|
|
|
|
|
const CSMWorld::IdTable* mTable; //nor sure if it is needed TODO
|
|
|
|
|
|
|
|
QUndoStack& mUndoStack;
|
|
|
|
|
|
|
|
public:
|
|
|
|
DialogueDelegateDispatcher(QObject* parent, CSMWorld::IdTable* table, QUndoStack& undoStack);
|
|
|
|
|
|
|
|
CSVWorld::CommandDelegate* makeDelegate(CSMWorld::ColumnBase::Display display);
|
|
|
|
|
|
|
|
QWidget* makeEditor(CSMWorld::ColumnBase::Display display, const QModelIndex& index);
|
|
|
|
///< will return null if delegate is not present, parent of the widget is same as for dispatcher itself
|
|
|
|
|
|
|
|
virtual void setEditorData (QWidget* editor, const QModelIndex& index) const;
|
|
|
|
|
|
|
|
virtual void setModelData (QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
|
|
|
|
|
|
|
|
virtual void paint (QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
|
|
|
///< does nothing
|
|
|
|
|
|
|
|
virtual QSize sizeHint (const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
|
|
|
///< does nothing
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void editorDataCommited( QWidget * editor );
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2012-12-13 12:35:08 +00:00
|
|
|
class DialogueSubView : public CSVDoc::SubView
|
|
|
|
{
|
2013-01-08 13:59:40 +00:00
|
|
|
QDataWidgetMapper *mWidgetMapper;
|
2014-03-07 16:15:43 +00:00
|
|
|
std::auto_ptr<DialogueDelegateDispatcher> mDispatcher;
|
2012-12-13 12:35:08 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2014-03-06 19:10:13 +00:00
|
|
|
DialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document, bool createAndDelete = false);
|
2012-12-13 12:35:08 +00:00
|
|
|
|
|
|
|
virtual void setEditLock (bool locked);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|