mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-13 21:40:11 +00:00
made double click actions in tables configurable
This commit is contained in:
parent
275bf854ed
commit
b0a7b457f7
@ -156,6 +156,52 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
|||||||
ritd->setDeclaredValues (values);
|
ritd->setDeclaredValues (values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declareSection ("table-input", "Table Input");
|
||||||
|
{
|
||||||
|
QString inPlaceEdit ("Edit in Place");
|
||||||
|
QString editRecord ("Edit Record");
|
||||||
|
QString view ("View");
|
||||||
|
QString editRecordAndClose ("Edit Record and Close");
|
||||||
|
|
||||||
|
QStringList values;
|
||||||
|
values
|
||||||
|
<< "None" << inPlaceEdit << editRecord << view << "Revert" << "Delete"
|
||||||
|
<< editRecordAndClose << "View and Close";
|
||||||
|
|
||||||
|
QString toolTip = "<ul>"
|
||||||
|
"<li>None</li>"
|
||||||
|
"<li>Edit in Place: Edit the clicked cell</li>"
|
||||||
|
"<li>Edit Record: Open a dialogue subview for the clicked record</li>"
|
||||||
|
"<li>View: Open a scene subview for the clicked record (not available everywhere)</li>"
|
||||||
|
"<li>Revert: Revert record</li>"
|
||||||
|
"<li>Delete: Delete recordy</li>"
|
||||||
|
"<li>Edit Record and Close: Open a dialogue subview for the clicked record and close the table subview</li>"
|
||||||
|
"<li>View And Close: Open a scene subview for the clicked record and close the table subview</li>"
|
||||||
|
"</ul>";
|
||||||
|
|
||||||
|
Setting *doubleClick = createSetting (Type_ComboBox, "double", "Double Click");
|
||||||
|
doubleClick->setDeclaredValues (values);
|
||||||
|
doubleClick->setDefaultValue (inPlaceEdit);
|
||||||
|
doubleClick->setToolTip ("Action on double click in table:<p>" + toolTip);
|
||||||
|
|
||||||
|
Setting *shiftDoubleClick = createSetting (Type_ComboBox, "double-s",
|
||||||
|
"Shift Double Click");
|
||||||
|
shiftDoubleClick->setDeclaredValues (values);
|
||||||
|
shiftDoubleClick->setDefaultValue (editRecord);
|
||||||
|
shiftDoubleClick->setToolTip ("Action on shift double click in table:<p>" + toolTip);
|
||||||
|
|
||||||
|
Setting *ctrlDoubleClick = createSetting (Type_ComboBox, "double-c",
|
||||||
|
"Control Double Click");
|
||||||
|
ctrlDoubleClick->setDeclaredValues (values);
|
||||||
|
ctrlDoubleClick->setDefaultValue (view);
|
||||||
|
ctrlDoubleClick->setToolTip ("Action on control double click in table:<p>" + toolTip);
|
||||||
|
|
||||||
|
Setting *shiftCtrlDoubleClick = createSetting (Type_ComboBox, "double-sc",
|
||||||
|
"Shift Control Double Click");
|
||||||
|
shiftCtrlDoubleClick->setDeclaredValues (values);
|
||||||
|
shiftCtrlDoubleClick->setDefaultValue (editRecordAndClose);
|
||||||
|
shiftCtrlDoubleClick->setToolTip ("Action on shift control double click in table:<p>" + toolTip);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
|
@ -520,18 +520,59 @@ void CSVWorld::Table::previewRecord()
|
|||||||
void CSVWorld::Table::updateUserSetting
|
void CSVWorld::Table::updateUserSetting
|
||||||
(const QString &name, const QStringList &list)
|
(const QString &name, const QStringList &list)
|
||||||
{
|
{
|
||||||
int columns = mModel->columnCount();
|
if (name=="records/type-format" || name=="records/status-format")
|
||||||
|
{
|
||||||
|
int columns = mModel->columnCount();
|
||||||
|
|
||||||
for (int i=0; i<columns; ++i)
|
for (int i=0; i<columns; ++i)
|
||||||
if (QAbstractItemDelegate *delegate = itemDelegateForColumn (i))
|
if (QAbstractItemDelegate *delegate = itemDelegateForColumn (i))
|
||||||
{
|
|
||||||
dynamic_cast<CommandDelegate&>
|
|
||||||
(*delegate).updateUserSetting (name, list);
|
|
||||||
{
|
{
|
||||||
emit dataChanged (mModel->index (0, i),
|
dynamic_cast<CommandDelegate&>
|
||||||
mModel->index (mModel->rowCount()-1, i));
|
(*delegate).updateUserSetting (name, list);
|
||||||
|
{
|
||||||
|
emit dataChanged (mModel->index (0, i),
|
||||||
|
mModel->index (mModel->rowCount()-1, i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString base ("table-input/double");
|
||||||
|
if (name.startsWith (base))
|
||||||
|
{
|
||||||
|
QString modifierString = name.mid (base.size());
|
||||||
|
Qt::KeyboardModifiers modifiers = 0;
|
||||||
|
|
||||||
|
if (modifierString=="-s")
|
||||||
|
modifiers = Qt::ShiftModifier;
|
||||||
|
else if (modifierString=="-c")
|
||||||
|
modifiers = Qt::ControlModifier;
|
||||||
|
else if (modifierString=="-sc")
|
||||||
|
modifiers = Qt::ShiftModifier | Qt::ControlModifier;
|
||||||
|
|
||||||
|
DoubleClickAction action = Action_None;
|
||||||
|
|
||||||
|
QString value = list.at (0);
|
||||||
|
|
||||||
|
if (value=="Edit in Place")
|
||||||
|
action = Action_InPlaceEdit;
|
||||||
|
else if (value=="Edit Record")
|
||||||
|
action = Action_EditRecord;
|
||||||
|
else if (value=="View")
|
||||||
|
action = Action_View;
|
||||||
|
else if (value=="Revert")
|
||||||
|
action = Action_Revert;
|
||||||
|
else if (value=="Delete")
|
||||||
|
action = Action_Delete;
|
||||||
|
else if (value=="Edit Record and Close")
|
||||||
|
action = Action_EditRecordAndClose;
|
||||||
|
else if (value=="View and Close")
|
||||||
|
action = Action_ViewAndClose;
|
||||||
|
|
||||||
|
mDoubleClickActions[modifiers] = action;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::Table::tableSizeUpdate()
|
void CSVWorld::Table::tableSizeUpdate()
|
||||||
@ -648,7 +689,6 @@ std::vector<std::string> CSVWorld::Table::getColumnsWithDisplay(CSMWorld::Column
|
|||||||
|
|
||||||
std::vector< CSMWorld::UniversalId > CSVWorld::Table::getDraggedRecords() const
|
std::vector< CSMWorld::UniversalId > CSVWorld::Table::getDraggedRecords() const
|
||||||
{
|
{
|
||||||
|
|
||||||
QModelIndexList selectedRows = selectionModel()->selectedRows();
|
QModelIndexList selectedRows = selectionModel()->selectedRows();
|
||||||
std::vector<CSMWorld::UniversalId> idToDrag;
|
std::vector<CSMWorld::UniversalId> idToDrag;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user