mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-22 00:09:45 +00:00
Prevent the Edit 'ID' action for the current ID of the dialogue subview
This commit is contained in:
parent
d777c7a68a
commit
bdb063a691
2 changed files with 18 additions and 1 deletions
|
@ -345,6 +345,11 @@ CSVWorld::IdContextMenu::IdContextMenu(QWidget *widget, CSMWorld::ColumnBase::Di
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::IdContextMenu::excludeId(const std::string &id)
|
||||||
|
{
|
||||||
|
mExcludedIds.insert(id);
|
||||||
|
}
|
||||||
|
|
||||||
QString CSVWorld::IdContextMenu::getWidgetValue() const
|
QString CSVWorld::IdContextMenu::getWidgetValue() const
|
||||||
{
|
{
|
||||||
QLineEdit *lineEdit = qobject_cast<QLineEdit *>(mWidget);
|
QLineEdit *lineEdit = qobject_cast<QLineEdit *>(mWidget);
|
||||||
|
@ -397,7 +402,8 @@ void CSVWorld::IdContextMenu::removeEditIdActionFromMenu()
|
||||||
void CSVWorld::IdContextMenu::showContextMenu(const QPoint &pos)
|
void CSVWorld::IdContextMenu::showContextMenu(const QPoint &pos)
|
||||||
{
|
{
|
||||||
QString value = getWidgetValue();
|
QString value = getWidgetValue();
|
||||||
if (!value.isEmpty())
|
bool isExcludedId = mExcludedIds.find(value.toUtf8().constData()) != mExcludedIds.end();
|
||||||
|
if (!value.isEmpty() && !isExcludedId)
|
||||||
{
|
{
|
||||||
addEditIdActionToMenu("Edit '" + value + "'");
|
addEditIdActionToMenu("Edit '" + value + "'");
|
||||||
}
|
}
|
||||||
|
@ -597,7 +603,12 @@ void CSVWorld::EditWidget::remake(int row)
|
||||||
|
|
||||||
if (CSMWorld::ColumnBase::isId(display))
|
if (CSMWorld::ColumnBase::isId(display))
|
||||||
{
|
{
|
||||||
|
int idColumn = mTable->findColumnIndex(CSMWorld::Columns::ColumnId_Id);
|
||||||
|
QString id = mTable->data(mTable->index(row, idColumn)).toString();
|
||||||
|
|
||||||
IdContextMenu *menu = new IdContextMenu(editor, display);
|
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,
|
connect(menu,
|
||||||
SIGNAL(editIdRequest(const CSMWorld::UniversalId &, const std::string &)),
|
SIGNAL(editIdRequest(const CSMWorld::UniversalId &, const std::string &)),
|
||||||
this,
|
this,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef CSV_WORLD_DIALOGUESUBVIEW_H
|
#ifndef CSV_WORLD_DIALOGUESUBVIEW_H
|
||||||
#define CSV_WORLD_DIALOGUESUBVIEW_H
|
#define CSV_WORLD_DIALOGUESUBVIEW_H
|
||||||
|
|
||||||
|
#include <set>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
@ -151,12 +152,15 @@ namespace CSVWorld
|
||||||
CSMWorld::ColumnBase::Display display);
|
CSMWorld::ColumnBase::Display display);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// A context menu with "Edit 'ID'" action for editors in the dialogue subview
|
||||||
class IdContextMenu : public QObject
|
class IdContextMenu : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
QWidget *mWidget;
|
QWidget *mWidget;
|
||||||
CSMWorld::UniversalId::Type mIdType;
|
CSMWorld::UniversalId::Type mIdType;
|
||||||
|
std::set<std::string> mExcludedIds;
|
||||||
|
///< A list of IDs that should not have the Edit 'ID' action.
|
||||||
|
|
||||||
QMenu *mContextMenu;
|
QMenu *mContextMenu;
|
||||||
QAction *mEditIdAction;
|
QAction *mEditIdAction;
|
||||||
|
@ -168,6 +172,8 @@ namespace CSVWorld
|
||||||
public:
|
public:
|
||||||
IdContextMenu(QWidget *widget, CSMWorld::ColumnBase::Display display);
|
IdContextMenu(QWidget *widget, CSMWorld::ColumnBase::Display display);
|
||||||
|
|
||||||
|
void excludeId(const std::string &id);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void showContextMenu(const QPoint &pos);
|
void showContextMenu(const QPoint &pos);
|
||||||
void editIdRequest();
|
void editIdRequest();
|
||||||
|
|
Loading…
Reference in a new issue