mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-14 15:40:18 +00:00
Edit 'ID' action is available in dialogue sub-views (for LineEdits and Labels)
This commit is contained in:
parent
47b66b57ae
commit
e8e34f37dd
@ -332,6 +332,7 @@ CSVWorld::IdContextMenu::IdContextMenu(QWidget *widget, CSMWorld::ColumnBase::Di
|
|||||||
SLOT(showContextMenu(const QPoint &)));
|
SLOT(showContextMenu(const QPoint &)));
|
||||||
|
|
||||||
mEditIdAction = new QAction(this);
|
mEditIdAction = new QAction(this);
|
||||||
|
connect(mEditIdAction, SIGNAL(triggered()), this, SLOT(editIdRequest()));
|
||||||
|
|
||||||
QLineEdit *lineEdit = qobject_cast<QLineEdit *>(mWidget);
|
QLineEdit *lineEdit = qobject_cast<QLineEdit *>(mWidget);
|
||||||
if (lineEdit != NULL)
|
if (lineEdit != NULL)
|
||||||
@ -352,8 +353,8 @@ CSVWorld::IdContextMenu::IdContextMenu(QWidget *widget, CSMWorld::ColumnBase::Di
|
|||||||
|
|
||||||
QString CSVWorld::IdContextMenu::getWidgetValue() const
|
QString CSVWorld::IdContextMenu::getWidgetValue() const
|
||||||
{
|
{
|
||||||
static QLineEdit *lineEdit = qobject_cast<QLineEdit *>(mWidget);
|
QLineEdit *lineEdit = qobject_cast<QLineEdit *>(mWidget);
|
||||||
static QLabel *label = qobject_cast<QLabel *>(mWidget);
|
QLabel *label = qobject_cast<QLabel *>(mWidget);
|
||||||
|
|
||||||
QString value = "";
|
QString value = "";
|
||||||
if (lineEdit != NULL)
|
if (lineEdit != NULL)
|
||||||
@ -373,16 +374,16 @@ void CSVWorld::IdContextMenu::showContextMenu(const QPoint &pos)
|
|||||||
if (!value.isEmpty())
|
if (!value.isEmpty())
|
||||||
{
|
{
|
||||||
mEditIdAction->setText("Edit '" + value + "'");
|
mEditIdAction->setText("Edit '" + value + "'");
|
||||||
|
mContextMenu->exec(mWidget->mapToGlobal(pos));
|
||||||
QAction *selectedAction = mContextMenu->exec(mWidget->mapToGlobal(pos));
|
|
||||||
if (selectedAction != NULL && selectedAction == mEditIdAction)
|
|
||||||
{
|
|
||||||
CSMWorld::UniversalId editId(mIdType, value.toUtf8().constData());
|
|
||||||
emit editIdRequest(editId, "");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::IdContextMenu::editIdRequest()
|
||||||
|
{
|
||||||
|
CSMWorld::UniversalId editId(mIdType, getWidgetValue().toUtf8().constData());
|
||||||
|
emit editIdRequest(editId, "");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=============================================================EditWidget=====================================================
|
=============================================================EditWidget=====================================================
|
||||||
*/
|
*/
|
||||||
@ -557,6 +558,15 @@ void CSVWorld::EditWidget::remake(int row)
|
|||||||
editor->setEnabled(false);
|
editor->setEnabled(false);
|
||||||
label->setEnabled(false);
|
label->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CSMWorld::ColumnBase::isId(display))
|
||||||
|
{
|
||||||
|
IdContextMenu *menu = new IdContextMenu(editor, display);
|
||||||
|
connect(menu,
|
||||||
|
SIGNAL(editIdRequest(const CSMWorld::UniversalId &, const std::string &)),
|
||||||
|
this,
|
||||||
|
SIGNAL(editIdRequest(const CSMWorld::UniversalId &, const std::string &)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -676,6 +686,11 @@ CSVWorld::SimpleDialogueSubView::SimpleDialogueSubView (const CSMWorld::Universa
|
|||||||
mEditWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
mEditWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||||
|
|
||||||
dataChanged(mTable->getModelIndex (getUniversalId().getId(), 0));
|
dataChanged(mTable->getModelIndex (getUniversalId().getId(), 0));
|
||||||
|
|
||||||
|
connect(mEditWidget,
|
||||||
|
SIGNAL(editIdRequest(const CSMWorld::UniversalId &, const std::string &)),
|
||||||
|
this,
|
||||||
|
SIGNAL(focusId(const CSMWorld::UniversalId &, const std::string &)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::SimpleDialogueSubView::setEditLock (bool locked)
|
void CSVWorld::SimpleDialogueSubView::setEditLock (bool locked)
|
||||||
|
@ -168,6 +168,7 @@ namespace CSVWorld
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void showContextMenu(const QPoint &pos);
|
void showContextMenu(const QPoint &pos);
|
||||||
|
void editIdRequest();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void editIdRequest(const CSMWorld::UniversalId &id, const std::string &hint);
|
void editIdRequest(const CSMWorld::UniversalId &id, const std::string &hint);
|
||||||
@ -195,6 +196,9 @@ namespace CSVWorld
|
|||||||
virtual ~EditWidget();
|
virtual ~EditWidget();
|
||||||
|
|
||||||
void remake(int row);
|
void remake(int row);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void editIdRequest(const CSMWorld::UniversalId &id, const std::string &hint);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SimpleDialogueSubView : public CSVDoc::SubView
|
class SimpleDialogueSubView : public CSVDoc::SubView
|
||||||
|
Loading…
x
Reference in New Issue
Block a user