mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-21 07:09:39 +00:00
Add Edit 'ID' action for nested fields
This commit is contained in:
parent
bcd0f0f4e4
commit
27c9eaeffc
2 changed files with 28 additions and 13 deletions
|
@ -428,6 +428,28 @@ void CSVWorld::IdContextMenu::editIdRequest()
|
||||||
=============================================================EditWidget=====================================================
|
=============================================================EditWidget=====================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void CSVWorld::EditWidget::createEditorContextMenu(QWidget *editor,
|
||||||
|
CSMWorld::ColumnBase::Display display,
|
||||||
|
int currentRow) const
|
||||||
|
{
|
||||||
|
Q_ASSERT(editor != NULL);
|
||||||
|
|
||||||
|
if (CSMWorld::ColumnBase::isId(display) &&
|
||||||
|
CSMWorld::TableMimeData::convertEnums(display) != CSMWorld::UniversalId::Type_None)
|
||||||
|
{
|
||||||
|
int idColumn = mTable->findColumnIndex(CSMWorld::Columns::ColumnId_Id);
|
||||||
|
QString id = mTable->data(mTable->index(currentRow, idColumn)).toString();
|
||||||
|
|
||||||
|
IdContextMenu *menu = new IdContextMenu(editor, display);
|
||||||
|
// Current ID is already opened, so no need to create Edit 'ID' action for it
|
||||||
|
menu->excludeId(id.toUtf8().constData());
|
||||||
|
connect(menu,
|
||||||
|
SIGNAL(editIdRequest(const CSMWorld::UniversalId &, const std::string &)),
|
||||||
|
this,
|
||||||
|
SIGNAL(editIdRequest(const CSMWorld::UniversalId &, const std::string &)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CSVWorld::EditWidget::~EditWidget()
|
CSVWorld::EditWidget::~EditWidget()
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < mNestedModels.size(); ++i)
|
for (unsigned i = 0; i < mNestedModels.size(); ++i)
|
||||||
|
@ -606,19 +628,7 @@ void CSVWorld::EditWidget::remake(int row)
|
||||||
label->setEnabled(false);
|
label->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CSMWorld::ColumnBase::isId(display))
|
createEditorContextMenu(editor, display, row);
|
||||||
{
|
|
||||||
int idColumn = mTable->findColumnIndex(CSMWorld::Columns::ColumnId_Id);
|
|
||||||
QString id = mTable->data(mTable->index(row, idColumn)).toString();
|
|
||||||
|
|
||||||
IdContextMenu *menu = new IdContextMenu(editor, display);
|
|
||||||
// Current ID is already opened, so no need to create Edit 'ID' action for it
|
|
||||||
menu->excludeId(id.toUtf8().constData());
|
|
||||||
connect(menu,
|
|
||||||
SIGNAL(editIdRequest(const CSMWorld::UniversalId &, const std::string &)),
|
|
||||||
this,
|
|
||||||
SIGNAL(editIdRequest(const CSMWorld::UniversalId &, const std::string &)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -670,6 +680,8 @@ void CSVWorld::EditWidget::remake(int row)
|
||||||
editor->setEnabled(false);
|
editor->setEnabled(false);
|
||||||
label->setEnabled(false);
|
label->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createEditorContextMenu(editor, display, row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mNestedTableMapper->setCurrentModelIndex(tree->index(0, 0, tree->index(row, i)));
|
mNestedTableMapper->setCurrentModelIndex(tree->index(0, 0, tree->index(row, i)));
|
||||||
|
|
|
@ -195,6 +195,9 @@ namespace CSVWorld
|
||||||
CSMDoc::Document& mDocument;
|
CSMDoc::Document& mDocument;
|
||||||
std::vector<CSMWorld::NestedTableProxyModel*> mNestedModels; //Plain, raw C pointers, deleted in the dtor
|
std::vector<CSMWorld::NestedTableProxyModel*> mNestedModels; //Plain, raw C pointers, deleted in the dtor
|
||||||
|
|
||||||
|
void createEditorContextMenu(QWidget *editor,
|
||||||
|
CSMWorld::ColumnBase::Display display,
|
||||||
|
int currentRow) const;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
EditWidget (QWidget *parent, int row, CSMWorld::IdTable* table,
|
EditWidget (QWidget *parent, int row, CSMWorld::IdTable* table,
|
||||||
|
|
Loading…
Reference in a new issue