mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-29 17:06:43 +00:00
made double click behaviour in report tables configurable (Fixes #2622)
This commit is contained in:
parent
12e0873446
commit
88d1f158d0
3 changed files with 104 additions and 5 deletions
|
@ -234,6 +234,47 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||||
jumpToAdded->setDeclaredValues (jumpValues);
|
jumpToAdded->setDeclaredValues (jumpValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declareSection ("report-input", "Report Input");
|
||||||
|
{
|
||||||
|
QString none ("None");
|
||||||
|
QString edit ("Edit");
|
||||||
|
QString remove ("Remove");
|
||||||
|
QString editAndRemove ("Edit And Remove");
|
||||||
|
|
||||||
|
QStringList values;
|
||||||
|
values << none << edit << remove << editAndRemove;
|
||||||
|
|
||||||
|
QString toolTip = "<ul>"
|
||||||
|
"<li>None</li>"
|
||||||
|
"<li>Edit: Open a table or dialogue suitable for addressing the listed report</li>"
|
||||||
|
"<li>Remove: Remove the report from the report table</li>"
|
||||||
|
"<li>Edit and Remove: Open a table or dialogue suitable for addressing the listed report, then remove the report from the report table</li>"
|
||||||
|
"</ul>";
|
||||||
|
|
||||||
|
Setting *doubleClick = createSetting (Type_ComboBox, "double", "Double Click");
|
||||||
|
doubleClick->setDeclaredValues (values);
|
||||||
|
doubleClick->setDefaultValue (edit);
|
||||||
|
doubleClick->setToolTip ("Action on double click in report table:<p>" + toolTip);
|
||||||
|
|
||||||
|
Setting *shiftDoubleClick = createSetting (Type_ComboBox, "double-s",
|
||||||
|
"Shift Double Click");
|
||||||
|
shiftDoubleClick->setDeclaredValues (values);
|
||||||
|
shiftDoubleClick->setDefaultValue (remove);
|
||||||
|
shiftDoubleClick->setToolTip ("Action on shift double click in report table:<p>" + toolTip);
|
||||||
|
|
||||||
|
Setting *ctrlDoubleClick = createSetting (Type_ComboBox, "double-c",
|
||||||
|
"Control Double Click");
|
||||||
|
ctrlDoubleClick->setDeclaredValues (values);
|
||||||
|
ctrlDoubleClick->setDefaultValue (editAndRemove);
|
||||||
|
ctrlDoubleClick->setToolTip ("Action on control double click in report table:<p>" + toolTip);
|
||||||
|
|
||||||
|
Setting *shiftCtrlDoubleClick = createSetting (Type_ComboBox, "double-sc",
|
||||||
|
"Shift Control Double Click");
|
||||||
|
shiftCtrlDoubleClick->setDeclaredValues (values);
|
||||||
|
shiftCtrlDoubleClick->setDefaultValue (none);
|
||||||
|
shiftCtrlDoubleClick->setToolTip ("Action on shift control double click in report table:<p>" + toolTip);
|
||||||
|
}
|
||||||
|
|
||||||
declareSection ("search", "Search & Replace");
|
declareSection ("search", "Search & Replace");
|
||||||
{
|
{
|
||||||
Setting *before = createSetting (Type_SpinBox, "char-before",
|
Setting *before = createSetting (Type_SpinBox, "char-before",
|
||||||
|
|
|
@ -96,21 +96,35 @@ void CSVTools::ReportTable::mouseDoubleClickEvent (QMouseEvent *event)
|
||||||
selectionModel()->select (index,
|
selectionModel()->select (index,
|
||||||
QItemSelectionModel::Clear | QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
QItemSelectionModel::Clear | QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||||
|
|
||||||
switch (modifiers)
|
std::map<Qt::KeyboardModifiers, DoubleClickAction>::iterator iter =
|
||||||
|
mDoubleClickActions.find (modifiers);
|
||||||
|
|
||||||
|
if (iter==mDoubleClickActions.end())
|
||||||
{
|
{
|
||||||
case 0:
|
event->accept();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (iter->second)
|
||||||
|
{
|
||||||
|
case Action_None:
|
||||||
|
|
||||||
|
event->accept();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Action_Edit:
|
||||||
|
|
||||||
event->accept();
|
event->accept();
|
||||||
showSelection();
|
showSelection();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::ShiftModifier:
|
case Action_Remove:
|
||||||
|
|
||||||
event->accept();
|
event->accept();
|
||||||
removeSelection();
|
removeSelection();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::ControlModifier:
|
case Action_EditAndRemove:
|
||||||
|
|
||||||
event->accept();
|
event->accept();
|
||||||
showSelection();
|
showSelection();
|
||||||
|
@ -156,6 +170,10 @@ CSVTools::ReportTable::ReportTable (CSMDoc::Document& document,
|
||||||
mReplaceAction = new QAction (tr ("Replace"), this);
|
mReplaceAction = new QAction (tr ("Replace"), this);
|
||||||
connect (mReplaceAction, SIGNAL (triggered()), this, SIGNAL (replaceRequest()));
|
connect (mReplaceAction, SIGNAL (triggered()), this, SIGNAL (replaceRequest()));
|
||||||
addAction (mReplaceAction);
|
addAction (mReplaceAction);
|
||||||
|
|
||||||
|
mDoubleClickActions.insert (std::make_pair (Qt::NoModifier, Action_Edit));
|
||||||
|
mDoubleClickActions.insert (std::make_pair (Qt::ShiftModifier, Action_Remove));
|
||||||
|
mDoubleClickActions.insert (std::make_pair (Qt::ControlModifier, Action_EditAndRemove));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CSMWorld::UniversalId> CSVTools::ReportTable::getDraggedRecords() const
|
std::vector<CSMWorld::UniversalId> CSVTools::ReportTable::getDraggedRecords() const
|
||||||
|
@ -176,6 +194,35 @@ std::vector<CSMWorld::UniversalId> CSVTools::ReportTable::getDraggedRecords() co
|
||||||
void CSVTools::ReportTable::updateUserSetting (const QString& name, const QStringList& list)
|
void CSVTools::ReportTable::updateUserSetting (const QString& name, const QStringList& list)
|
||||||
{
|
{
|
||||||
mIdTypeDelegate->updateUserSetting (name, list);
|
mIdTypeDelegate->updateUserSetting (name, list);
|
||||||
|
|
||||||
|
QString base ("report-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")
|
||||||
|
action = Action_Edit;
|
||||||
|
else if (value=="Remove")
|
||||||
|
action = Action_Remove;
|
||||||
|
else if (value=="Edit And Remove")
|
||||||
|
action = Action_EditAndRemove;
|
||||||
|
|
||||||
|
mDoubleClickActions[modifiers] = action;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> CSVTools::ReportTable::getReplaceIndices (bool selection) const
|
std::vector<int> CSVTools::ReportTable::getReplaceIndices (bool selection) const
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef CSV_TOOLS_REPORTTABLE_H
|
#ifndef CSV_TOOLS_REPORTTABLE_H
|
||||||
#define CSV_TOOLS_REPORTTABLE_H
|
#define CSV_TOOLS_REPORTTABLE_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "../world/dragrecordtable.hpp"
|
#include "../world/dragrecordtable.hpp"
|
||||||
|
|
||||||
class QAction;
|
class QAction;
|
||||||
|
@ -21,11 +23,20 @@ namespace CSVTools
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
enum DoubleClickAction
|
||||||
|
{
|
||||||
|
Action_None,
|
||||||
|
Action_Edit,
|
||||||
|
Action_Remove,
|
||||||
|
Action_EditAndRemove
|
||||||
|
};
|
||||||
|
|
||||||
CSMTools::ReportModel *mModel;
|
CSMTools::ReportModel *mModel;
|
||||||
CSVWorld::CommandDelegate *mIdTypeDelegate;
|
CSVWorld::CommandDelegate *mIdTypeDelegate;
|
||||||
QAction *mShowAction;
|
QAction *mShowAction;
|
||||||
QAction *mRemoveAction;
|
QAction *mRemoveAction;
|
||||||
QAction *mReplaceAction;
|
QAction *mReplaceAction;
|
||||||
|
std::map<Qt::KeyboardModifiers, DoubleClickAction> mDoubleClickActions;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue