1
0
Fork 0

GUI: change multi-selection hotkeys (#1743)

closes #1762
closes #1761
This commit is contained in:
Duncan Ogilvie 2017-10-14 19:46:47 +02:00
parent f6590e6465
commit f85cea6bcd
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
2 changed files with 38 additions and 7 deletions

View File

@ -148,39 +148,51 @@ void StdTable::keyPressEvent(QKeyEvent* event)
switch(key)
{
case Qt::Key_Up:
if(mIsMultiSelectionAllowed && modifiers == Qt::ShiftModifier)
if(mIsMultiSelectionAllowed && modifiers == Qt::ShiftModifier) //Shift+Up -> expand selection upwards
{
expandUp();
}
else
else //Up -> select previous
{
selectPrevious();
}
break;
case Qt::Key_Down:
if(mIsMultiSelectionAllowed && modifiers == Qt::ShiftModifier)
if(mIsMultiSelectionAllowed && modifiers == Qt::ShiftModifier) //Shift+Down -> expand selection downwards
{
expandDown();
}
else
else //Down -> select next
{
selectNext();
}
break;
case Qt::Key_Home:
if(modifiers == Qt::ControlModifier)
if(mIsMultiSelectionAllowed && modifiers == Qt::ShiftModifier) //Shift+Home -> expand selection to top
{
expandTop();
}
else if(modifiers == Qt::NoModifier) //Home -> select first line
{
selectStart();
}
break;
case Qt::Key_End:
if(modifiers == Qt::ControlModifier)
if(mIsMultiSelectionAllowed && modifiers == Qt::ShiftModifier) //Shift+End -> expand selection to bottom
{
expandBottom();
}
else if(modifiers == Qt::NoModifier) //End -> select last line
{
selectEnd();
}
break;
case Qt::Key_A:
if(mIsMultiSelectionAllowed && modifiers == Qt::ControlModifier)
if(mIsMultiSelectionAllowed && modifiers == Qt::ControlModifier) //Ctrl+A -> select all
{
selectAll();
}
@ -284,6 +296,23 @@ void StdTable::expandDown()
}
}
void StdTable::expandTop()
{
if(getRowCount() > 0)
{
expandSelectionUpTo(0);
}
}
void StdTable::expandBottom()
{
int endIndex = getRowCount() - 1;
if(endIndex >= 0)
{
expandSelectionUpTo(endIndex);
}
}
void StdTable::setSingleSelection(int index)
{
mSelection.firstSelectedIndex = index;

View File

@ -24,6 +24,8 @@ public:
void expandSelectionUpTo(int to);
void expandUp();
void expandDown();
void expandTop();
void expandBottom();
void setSingleSelection(int index);
int getInitialSelection();
QList<int> getSelection();