#undef ControlModifier
#endif
+#ifdef FocusIn
+#undef FocusIn
+#endif
+
namespace lyx {
namespace frontend {
QPushButton * down,
QAbstractListModel * amod,
QAbstractListModel * smod)
+ : availableLV(avail), selectedLV(sel), addPB(add), deletePB(del),
+ upPB(up), downPB(down), availableModel(amod), selectedModel(smod),
+ selectedHasFocus_(false)
{
- availableLV = avail;
- selectedLV = sel;
- addPB = add;
- deletePB = del;
- upPB = up;
- downPB = down;
- availableModel = amod;
- selectedModel = smod;
selectedLV->setModel(smod);
availableLV->setModel(amod);
SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
this, SLOT(availableChanged(QItemSelection, QItemSelection)));
connect(selectedLV->selectionModel(),
- SIGNAL(currentChanged(QItemSelection, QItemSelection)),
+ SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
this, SLOT(selectedChanged(QItemSelection, QItemSelection)));
connect(addPB, SIGNAL(clicked()),
this, SLOT(addPB_clicked()));
bool GuiSelectionManager::insertRowToSelected(int i,
QMap<int, QVariant> const & itemData)
{
- if (i <= -1 || i > selectedModel->rowCount())
- return false;
+ if (i <= -1)
+ i = 0;
+ if (i > selectedModel->rowCount())
+ i = selectedModel->rowCount();
if (!selectedModel->insertRow(i))
return false;
return selectedModel->setItemData(selectedModel->index(i), itemData);
void GuiSelectionManager::upPB_clicked()
{
- QModelIndex idx = selectedLV->currentIndex();
+ QModelIndexList selIdx =
+ selectedLV->selectionModel()->selectedIndexes();
+ if (selIdx.isEmpty())
+ return;
+ QModelIndex idx = selIdx.first();
int const pos = idx.row();
if (pos <= 0)
void GuiSelectionManager::downPB_clicked()
{
- QModelIndex idx = selectedLV->currentIndex();
+ QModelIndexList selIdx =
+ selectedLV->selectionModel()->selectedIndexes();
+ if (selIdx.isEmpty())
+ return;
+ QModelIndex idx = selIdx.first();
int const pos = idx.row();
if (pos >= selectedModel->rowCount() - 1)
// This is designed to work both with the main enter key
// and the one on the numeric keypad.
if (keyPressed == Qt::Key_Enter || keyPressed == Qt::Key_Return) {
- if (!keyModifiers)
- addPB_clicked();
- else if (keyModifiers == Qt::ControlModifier ||
- keyModifiers == Qt::KeypadModifier ||
- keyModifiers == (Qt::ControlModifier | Qt::KeypadModifier)) {
- if (addPB->isEnabled()) {
+ if (addPB->isEnabled()) {
+ if (!keyModifiers) {
+ addPB_clicked();
+ } else if (keyModifiers == Qt::ControlModifier ||
+ keyModifiers == Qt::KeypadModifier ||
+ keyModifiers == (Qt::ControlModifier | Qt::KeypadModifier)) {
addPB_clicked();
okHook(); //signal
}