mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-08 10:51:03 +00:00
Some improvements.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24493 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
26e958bac7
commit
7a24384e6d
@ -33,7 +33,7 @@ GuiSelectionManager::GuiSelectionManager(
|
|||||||
QPushButton * down,
|
QPushButton * down,
|
||||||
QAbstractListModel * amod,
|
QAbstractListModel * amod,
|
||||||
QAbstractListModel * smod)
|
QAbstractListModel * smod)
|
||||||
{
|
{
|
||||||
availableLV = avail;
|
availableLV = avail;
|
||||||
selectedLV = sel;
|
selectedLV = sel;
|
||||||
addPB = add;
|
addPB = add;
|
||||||
@ -262,10 +262,10 @@ void GuiSelectionManager::downPB_clicked()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//FIXME These slots do not really do what they need to do, since focus
|
// FIXME These slots do not really do what they need to do, since focus
|
||||||
//can enter the QListView in other ways. But there are no signals sent
|
// can enter the QListView in other ways. But there are no signals sent
|
||||||
//in that case. We need to reimplement focusInEvent() to capture those,
|
// in that case. We need to reimplement focusInEvent() to capture those,
|
||||||
//which means subclassing QListView. (rgh)
|
// which means subclassing QListView. (rgh)
|
||||||
void GuiSelectionManager::availableLV_clicked(const QModelIndex &)
|
void GuiSelectionManager::availableLV_clicked(const QModelIndex &)
|
||||||
{
|
{
|
||||||
selectedHasFocus_ = false;
|
selectedHasFocus_ = false;
|
||||||
@ -300,46 +300,56 @@ bool GuiSelectionManager::eventFilter(QObject * obj, QEvent * event)
|
|||||||
QKeyEvent * keyEvent = static_cast<QKeyEvent *>(event);
|
QKeyEvent * keyEvent = static_cast<QKeyEvent *>(event);
|
||||||
int const keyPressed = keyEvent->key();
|
int const keyPressed = keyEvent->key();
|
||||||
Qt::KeyboardModifiers const keyModifiers = keyEvent->modifiers();
|
Qt::KeyboardModifiers const keyModifiers = keyEvent->modifiers();
|
||||||
//Enter key without modifier will add current item.
|
// Enter key without modifier will add current item.
|
||||||
//Ctrl-Enter will add it and close the dialog.
|
// Ctrl-Enter will add it and close the dialog.
|
||||||
//This is designed to work both with the main enter key
|
// This is designed to work both with the main enter key
|
||||||
//and the one on the numeric keypad.
|
// and the one on the numeric keypad.
|
||||||
if ((keyPressed == Qt::Key_Enter || keyPressed == Qt::Key_Return) &&
|
if (keyPressed == Qt::Key_Enter || keyPressed == Qt::Key_Return) {
|
||||||
//We want one or both of Control and Keypad, and nothing else
|
if (!keyModifiers)
|
||||||
//(KeypadModifier is what you get if you use the Enter key on the
|
addPB_clicked();
|
||||||
//numeric keypad.)
|
else if ((keyModifiers == Qt::ControlModifier) ||
|
||||||
(!keyModifiers ||
|
|
||||||
(keyModifiers == Qt::ControlModifier) ||
|
|
||||||
(keyModifiers == Qt::KeypadModifier) ||
|
(keyModifiers == Qt::KeypadModifier) ||
|
||||||
(keyModifiers == (Qt::ControlModifier | Qt::KeypadModifier))
|
(keyModifiers == (Qt::ControlModifier | Qt::KeypadModifier))
|
||||||
)
|
) {
|
||||||
) {
|
if (addPB->isEnabled()) {
|
||||||
if (addPB->isEnabled()) {
|
addPB_clicked();
|
||||||
addPB_clicked();
|
okHook(); //signal
|
||||||
okHook(); //signal
|
}
|
||||||
}
|
}
|
||||||
event->accept();
|
event->accept();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (obj == selectedLV) {
|
} else if (obj == selectedLV) {
|
||||||
//Delete or backspace key will delete current item
|
// Delete or backspace key will delete current item
|
||||||
//...with control modifier will clear the list
|
// ...with control modifier will clear the list
|
||||||
if (event->type() != QEvent::KeyPress)
|
if (event->type() != QEvent::KeyPress)
|
||||||
return QObject::eventFilter(obj, event);
|
return QObject::eventFilter(obj, event);
|
||||||
QKeyEvent * keyEvent = static_cast<QKeyEvent *>(event);
|
QKeyEvent * keyEvent = static_cast<QKeyEvent *>(event);
|
||||||
int const keyPressed = keyEvent->key();
|
int const keyPressed = keyEvent->key();
|
||||||
Qt::KeyboardModifiers const keyModifiers = keyEvent->modifiers();
|
Qt::KeyboardModifiers const keyModifiers = keyEvent->modifiers();
|
||||||
if (keyPressed == Qt::Key_Delete || keyPressed == Qt::Key_Backspace) {
|
if (keyPressed == Qt::Key_Delete || keyPressed == Qt::Key_Backspace) {
|
||||||
if (keyModifiers == Qt::NoModifier && deletePB->isEnabled())
|
if (keyModifiers == Qt::NoModifier && deletePB->isEnabled()) {
|
||||||
deletePB_clicked();
|
deletePB_clicked();
|
||||||
else if (keyModifiers == Qt::ControlModifier) {
|
updateHook();
|
||||||
|
} else if (keyModifiers == Qt::ControlModifier) {
|
||||||
selectedModel->removeRows(0, selectedModel->rowCount());
|
selectedModel->removeRows(0, selectedModel->rowCount());
|
||||||
updateHook();
|
updateHook();
|
||||||
} else
|
} else
|
||||||
//ignore it otherwise
|
|
||||||
return QObject::eventFilter(obj, event);
|
return QObject::eventFilter(obj, event);
|
||||||
|
} else if (keyPressed == Qt::Key_Up) {
|
||||||
|
if (keyModifiers == Qt::ControlModifier) {
|
||||||
|
if (upPB->isEnabled())
|
||||||
|
upPB_clicked();
|
||||||
event->accept();
|
event->accept();
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
} else if (keyPressed == Qt::Key_Down) {
|
||||||
|
if (keyModifiers == Qt::ControlModifier) {
|
||||||
|
if (downPB->isEnabled())
|
||||||
|
downPB_clicked();
|
||||||
|
event->accept();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return QObject::eventFilter(obj, event);
|
return QObject::eventFilter(obj, event);
|
||||||
|
Loading…
Reference in New Issue
Block a user