mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 07:53:53 +00:00
Rework Dialogue subview code according to DropLineEdit changes
This commit is contained in:
parent
64701b273d
commit
7dcdd130bb
5 changed files with 14 additions and 112 deletions
|
@ -54,8 +54,9 @@ void CSVWidget::DropLineEdit::dropEvent(QDropEvent *event)
|
|||
int dataIndex = getAcceptedDataIndex(*data);
|
||||
if (dataIndex != -1)
|
||||
{
|
||||
setText(data->getData()[dataIndex].getId().c_str());
|
||||
emit tableMimeDataDropped(data->getData(), data->getDocumentPtr());
|
||||
std::vector<CSMWorld::UniversalId> idData = data->getData();
|
||||
setText(idData[dataIndex].getId().c_str());
|
||||
emit tableMimeDataDropped(idData[dataIndex], data->getDocumentPtr());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,11 +77,13 @@ int CSVWidget::DropLineEdit::getAcceptedDataIndex(const CSMWorld::TableMimeData
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool isReferenceable = mDropType == CSMWorld::UniversalId::Type_Referenceable;
|
||||
std::vector<CSMWorld::UniversalId> idData = data.getData();
|
||||
int size = static_cast<int>(idData.size());
|
||||
for (int i = 0; i < size; ++i)
|
||||
{
|
||||
if (idData[i].getType() == mDropType)
|
||||
CSMWorld::UniversalId::Type type = idData[i].getType();
|
||||
if (type == mDropType || isReferenceable && CSMWorld::TableMimeData::isReferencable(type))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
|
|
@ -43,8 +43,7 @@ namespace CSVWidget
|
|||
void dropEvent(QDropEvent *event);
|
||||
|
||||
signals:
|
||||
void tableMimeDataDropped(const std::vector<CSMWorld::UniversalId> &data,
|
||||
const CSMDoc::Document *document);
|
||||
void tableMimeDataDropped(const CSMWorld::UniversalId &id, const CSMDoc::Document *document);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -130,52 +130,6 @@ QWidget* CSVWorld::DialogueDelegateDispatcherProxy::getEditor() const
|
|||
return mEditor;
|
||||
}
|
||||
|
||||
void CSVWorld::DialogueDelegateDispatcherProxy::tableMimeDataDropped(const std::vector<CSMWorld::UniversalId>& data, const CSMDoc::Document* document)
|
||||
{
|
||||
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(mEditor);
|
||||
{
|
||||
if (!lineEdit || !mIndexWrapper.get())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (unsigned i = 0; i < data.size(); ++i)
|
||||
{
|
||||
CSMWorld::UniversalId::Type type = data[i].getType();
|
||||
if (mDisplay == CSMWorld::ColumnBase::Display_Referenceable)
|
||||
{
|
||||
if (type == CSMWorld::UniversalId::Type_Activator
|
||||
|| type == CSMWorld::UniversalId::Type_Potion
|
||||
|| type == CSMWorld::UniversalId::Type_Apparatus
|
||||
|| type == CSMWorld::UniversalId::Type_Armor
|
||||
|| type == CSMWorld::UniversalId::Type_Book
|
||||
|| type == CSMWorld::UniversalId::Type_Clothing
|
||||
|| type == CSMWorld::UniversalId::Type_Container
|
||||
|| type == CSMWorld::UniversalId::Type_Creature
|
||||
|| type == CSMWorld::UniversalId::Type_Door
|
||||
|| type == CSMWorld::UniversalId::Type_Ingredient
|
||||
|| type == CSMWorld::UniversalId::Type_CreatureLevelledList
|
||||
|| type == CSMWorld::UniversalId::Type_ItemLevelledList
|
||||
|| type == CSMWorld::UniversalId::Type_Light
|
||||
|| type == CSMWorld::UniversalId::Type_Lockpick
|
||||
|| type == CSMWorld::UniversalId::Type_Miscellaneous
|
||||
|| type == CSMWorld::UniversalId::Type_Npc
|
||||
|| type == CSMWorld::UniversalId::Type_Probe
|
||||
|| type == CSMWorld::UniversalId::Type_Repair
|
||||
|| type == CSMWorld::UniversalId::Type_Static
|
||||
|| type == CSMWorld::UniversalId::Type_Weapon)
|
||||
{
|
||||
type = CSMWorld::UniversalId::Type_Referenceable;
|
||||
}
|
||||
}
|
||||
if (mDisplay == CSMWorld::TableMimeData::convertEnums(type))
|
||||
{
|
||||
emit tableMimeDataDropped(mEditor, mIndexWrapper->mIndex, data[i], document);
|
||||
emit editorDataCommited(mEditor, mIndexWrapper->mIndex, mDisplay);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
==============================DialogueDelegateDispatcher==========================================
|
||||
*/
|
||||
|
@ -311,12 +265,8 @@ QWidget* CSVWorld::DialogueDelegateDispatcher::makeEditor(CSMWorld::ColumnBase::
|
|||
{
|
||||
connect(editor, SIGNAL(editingFinished()), proxy, SLOT(editorDataCommited()));
|
||||
|
||||
connect(editor, SIGNAL(tableMimeDataDropped(const std::vector<CSMWorld::UniversalId>&, const CSMDoc::Document*)),
|
||||
proxy, SLOT(tableMimeDataDropped(const std::vector<CSMWorld::UniversalId>&, const CSMDoc::Document*)));
|
||||
|
||||
connect(proxy, SIGNAL(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)),
|
||||
this, SIGNAL(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)));
|
||||
|
||||
connect(editor, SIGNAL(tableMimeDataDropped(const CSMWorld::UniversalId&, const CSMDoc::Document*)),
|
||||
proxy, SLOT(editorDataCommited()));
|
||||
}
|
||||
else if (qobject_cast<QCheckBox*>(editor))
|
||||
{
|
||||
|
@ -387,9 +337,6 @@ mCommandDispatcher (commandDispatcher),
|
|||
mDocument (document)
|
||||
{
|
||||
remake (row);
|
||||
|
||||
connect(mDispatcher, SIGNAL(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)),
|
||||
this, SIGNAL(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)));
|
||||
}
|
||||
|
||||
void CSVWorld::EditWidget::remake(int row)
|
||||
|
@ -680,8 +627,6 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM
|
|||
|
||||
mEditWidget = new EditWidget(mainWidget,
|
||||
mTable->getModelIndex(mCurrentId, 0).row(), mTable, mCommandDispatcher, document, false);
|
||||
connect(mEditWidget, SIGNAL(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)),
|
||||
this, SLOT(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)));
|
||||
|
||||
mMainLayout->addWidget(mEditWidget);
|
||||
mEditWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
|
@ -844,17 +789,6 @@ void CSVWorld::DialogueSubView::rowsAboutToBeRemoved(const QModelIndex &parent,
|
|||
}
|
||||
}
|
||||
|
||||
void CSVWorld::DialogueSubView::tableMimeDataDropped (QWidget* editor,
|
||||
const QModelIndex& index,
|
||||
const CSMWorld::UniversalId& id,
|
||||
const CSMDoc::Document* document)
|
||||
{
|
||||
if (document == &mDocument)
|
||||
{
|
||||
qobject_cast<CSVWidget::DropLineEdit*>(editor)->setText(id.getId().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void CSVWorld::DialogueSubView::requestFocus (const std::string& id)
|
||||
{
|
||||
changeCurrentId(id);
|
||||
|
|
|
@ -86,18 +86,12 @@ namespace CSVWorld
|
|||
public slots:
|
||||
void editorDataCommited();
|
||||
void setIndex(const QModelIndex& index);
|
||||
void tableMimeDataDropped(const std::vector<CSMWorld::UniversalId>& data,
|
||||
const CSMDoc::Document* document);
|
||||
|
||||
signals:
|
||||
void editorDataCommited(QWidget* editor,
|
||||
const QModelIndex& index,
|
||||
CSMWorld::ColumnBase::Display display);
|
||||
|
||||
void tableMimeDataDropped(QWidget* editor, const QModelIndex& index,
|
||||
const CSMWorld::UniversalId& id,
|
||||
const CSMDoc::Document* document);
|
||||
|
||||
};
|
||||
|
||||
class DialogueDelegateDispatcher : public QAbstractItemDelegate
|
||||
|
@ -153,11 +147,6 @@ namespace CSVWorld
|
|||
private slots:
|
||||
void editorDataCommited(QWidget* editor, const QModelIndex& index,
|
||||
CSMWorld::ColumnBase::Display display);
|
||||
|
||||
signals:
|
||||
void tableMimeDataDropped(QWidget* editor, const QModelIndex& index,
|
||||
const CSMWorld::UniversalId& id,
|
||||
const CSMDoc::Document* document);
|
||||
};
|
||||
|
||||
class EditWidget : public QScrollArea
|
||||
|
@ -182,11 +171,6 @@ namespace CSVWorld
|
|||
virtual ~EditWidget();
|
||||
|
||||
void remake(int row);
|
||||
|
||||
signals:
|
||||
void tableMimeDataDropped(QWidget* editor, const QModelIndex& index,
|
||||
const CSMWorld::UniversalId& id,
|
||||
const CSMDoc::Document* document);
|
||||
};
|
||||
|
||||
class DialogueSubView : public CSVDoc::SubView
|
||||
|
@ -230,10 +214,6 @@ namespace CSVWorld
|
|||
void dataChanged(const QModelIndex & index);
|
||||
///\brief we need to care for deleting currently edited record
|
||||
|
||||
void tableMimeDataDropped(QWidget* editor, const QModelIndex& index,
|
||||
const CSMWorld::UniversalId& id,
|
||||
const CSMDoc::Document* document);
|
||||
|
||||
void requestFocus (const std::string& id);
|
||||
|
||||
void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
|
||||
|
|
|
@ -236,29 +236,15 @@ QWidget *CSVWorld::CommandDelegate::createEditor (QWidget *parent, const QStyleO
|
|||
|
||||
return new QCheckBox(parent);
|
||||
|
||||
case CSMWorld::ColumnBase::Display_String:
|
||||
case CSMWorld::ColumnBase::Display_Skill:
|
||||
case CSMWorld::ColumnBase::Display_Script:
|
||||
case CSMWorld::ColumnBase::Display_Race:
|
||||
case CSMWorld::ColumnBase::Display_Region:
|
||||
case CSMWorld::ColumnBase::Display_Class:
|
||||
case CSMWorld::ColumnBase::Display_Faction:
|
||||
case CSMWorld::ColumnBase::Display_Miscellaneous:
|
||||
case CSMWorld::ColumnBase::Display_Sound:
|
||||
case CSMWorld::ColumnBase::Display_Mesh:
|
||||
case CSMWorld::ColumnBase::Display_Icon:
|
||||
case CSMWorld::ColumnBase::Display_Music:
|
||||
case CSMWorld::ColumnBase::Display_SoundRes:
|
||||
case CSMWorld::ColumnBase::Display_Texture:
|
||||
case CSMWorld::ColumnBase::Display_Video:
|
||||
case CSMWorld::ColumnBase::Display_GlobalVariable:
|
||||
|
||||
return new CSVWidget::DropLineEdit(CSMWorld::UniversalId::Type_None, parent);
|
||||
|
||||
case CSMWorld::ColumnBase::Display_ScriptLines:
|
||||
|
||||
return new ScriptEdit (mDocument, ScriptHighlighter::Mode_Console, parent);
|
||||
|
||||
case CSMWorld::ColumnBase::Display_String:
|
||||
// For other Display types (that represent record IDs) with drop support IdCompletionDelegate is used
|
||||
|
||||
return new CSVWidget::DropLineEdit(CSMWorld::UniversalId::Type_None, parent);
|
||||
|
||||
default:
|
||||
|
||||
return QStyledItemDelegate::createEditor (parent, option, index);
|
||||
|
|
Loading…
Reference in a new issue