mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-07 12:32:26 +00:00
Fix bug #6486. Patch inspired by work by John McCabe-Dansted.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33851 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
04da0f68fb
commit
559da350f0
@ -114,8 +114,6 @@ GuiCitation::GuiCitation(GuiView & lv)
|
||||
connect(selectionManager, SIGNAL(okHook()),
|
||||
this, SLOT(on_okPB_clicked()));
|
||||
|
||||
setFocusProxy(availableLV);
|
||||
|
||||
// FIXME: the sizeHint() for this is _way_ too high
|
||||
infoML->setFixedHeight(60);
|
||||
}
|
||||
@ -268,38 +266,40 @@ void GuiCitation::updateStyle()
|
||||
updateFormatting(cs.style);
|
||||
}
|
||||
|
||||
|
||||
// This one needs to be called whenever citationStyleCO needs
|
||||
// to be updated---and this would be on anything that changes the
|
||||
// selection in selectedLV, or on a general update.
|
||||
void GuiCitation::fillStyles(BiblioInfo const & bi)
|
||||
{
|
||||
int const oldIndex = citationStyleCO->currentIndex();
|
||||
|
||||
citationStyleCO->clear();
|
||||
|
||||
QStringList selected_keys = selected_model_.stringList();
|
||||
if (selected_keys.empty()) {
|
||||
int curr = selectedLV->model()->rowCount() - 1;
|
||||
|
||||
if (curr < 0 || selected_keys.empty()) {
|
||||
citationStyleCO->clear();
|
||||
citationStyleCO->setEnabled(false);
|
||||
citationStyleLA->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
int curr = selectedLV->model()->rowCount() - 1;
|
||||
if (curr < 0)
|
||||
return;
|
||||
int const oldIndex = citationStyleCO->currentIndex();
|
||||
|
||||
if (!selectedLV->selectionModel()->selectedIndexes().empty())
|
||||
curr = selectedLV->selectionModel()->selectedIndexes()[0].row();
|
||||
|
||||
QStringList sty = citationStyles(bi, curr);
|
||||
citationStyleCO->clear();
|
||||
|
||||
citationStyleCO->setEnabled(!sty.isEmpty());
|
||||
citationStyleLA->setEnabled(!sty.isEmpty());
|
||||
|
||||
if (sty.isEmpty())
|
||||
if (sty.isEmpty()) {
|
||||
// some error
|
||||
citationStyleCO->setEnabled(false);
|
||||
citationStyleLA->setEnabled(false);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
citationStyleCO->insertItems(0, sty);
|
||||
citationStyleCO->setEnabled(true);
|
||||
citationStyleLA->setEnabled(true);
|
||||
|
||||
if (oldIndex != -1 && oldIndex < citationStyleCO->count())
|
||||
citationStyleCO->setCurrentIndex(oldIndex);
|
||||
@ -519,6 +519,15 @@ void GuiCitation::init()
|
||||
else
|
||||
cited_keys_ = str.split(",");
|
||||
selected_model_.setStringList(cited_keys_);
|
||||
if (selected_model_.rowCount()) {
|
||||
selectedLV->blockSignals(true);
|
||||
selectedLV->setFocus();
|
||||
QModelIndex idx = selected_model_.index(0, 0);
|
||||
selectedLV->selectionModel()->select(idx,
|
||||
QItemSelectionModel::ClearAndSelect);
|
||||
selectedLV->blockSignals(false);
|
||||
} else
|
||||
availableLV->setFocus();
|
||||
fillFields(bi);
|
||||
fillEntries(bi);
|
||||
updateControls(bi);
|
||||
|
@ -18,10 +18,11 @@
|
||||
|
||||
#include "support/debug.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <QListView>
|
||||
#include <QPushButton>
|
||||
#include <QAbstractListModel>
|
||||
#include <QItemSelection>
|
||||
#include <QListView>
|
||||
#include <QKeyEvent>
|
||||
#include <QPushButton>
|
||||
|
||||
#ifdef KeyPress
|
||||
#undef KeyPress
|
||||
@ -58,11 +59,17 @@ GuiSelectionManager::GuiSelectionManager(
|
||||
availableLV->setModel(amod);
|
||||
|
||||
connect(availableLV->selectionModel(),
|
||||
SIGNAL(currentChanged(QModelIndex,QModelIndex)),
|
||||
SIGNAL(currentChanged(QModelIndex, QModelIndex)),
|
||||
this, SLOT(availableChanged(QModelIndex, QModelIndex)));
|
||||
connect(selectedLV->selectionModel(),
|
||||
SIGNAL(currentChanged(QModelIndex, QModelIndex)),
|
||||
this, SLOT(selectedChanged(QModelIndex, QModelIndex)));
|
||||
connect(availableLV->selectionModel(),
|
||||
SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
|
||||
this, SLOT(availableChanged(QItemSelection, QItemSelection)));
|
||||
connect(selectedLV->selectionModel(),
|
||||
SIGNAL(currentChanged(QItemSelection, QItemSelection)),
|
||||
this, SLOT(selectedChanged(QItemSelection, QItemSelection)));
|
||||
connect(addPB, SIGNAL(clicked()),
|
||||
this, SLOT(addPB_clicked()));
|
||||
connect(deletePB, SIGNAL(clicked()),
|
||||
@ -181,6 +188,15 @@ bool GuiSelectionManager::isSelected(const QModelIndex & idx)
|
||||
}
|
||||
|
||||
|
||||
void GuiSelectionManager::availableChanged(QItemSelection const & qis, QItemSelection const &)
|
||||
{
|
||||
QModelIndexList il = qis.indexes();
|
||||
if (il.empty())
|
||||
return;
|
||||
availableChanged(il.front(), QModelIndex());
|
||||
}
|
||||
|
||||
|
||||
void GuiSelectionManager::availableChanged(const QModelIndex & idx, const QModelIndex &)
|
||||
{
|
||||
if (!idx.isValid())
|
||||
@ -191,6 +207,15 @@ void GuiSelectionManager::availableChanged(const QModelIndex & idx, const QModel
|
||||
}
|
||||
|
||||
|
||||
void GuiSelectionManager::selectedChanged(QItemSelection const & qis, QItemSelection const &)
|
||||
{
|
||||
QModelIndexList il = qis.indexes();
|
||||
if (il.empty())
|
||||
return;
|
||||
selectedChanged(il.front(), QModelIndex());
|
||||
}
|
||||
|
||||
|
||||
void GuiSelectionManager::selectedChanged(const QModelIndex & idx, const QModelIndex &)
|
||||
{
|
||||
if (!idx.isValid())
|
||||
|
@ -20,6 +20,7 @@ class QListView;
|
||||
class QPushButton;
|
||||
class QVariant;
|
||||
class QAbstractItemView;
|
||||
class QItemSelection;
|
||||
template <class T, class U> class QMap;
|
||||
|
||||
namespace lyx {
|
||||
@ -106,9 +107,13 @@ protected:
|
||||
|
||||
protected Q_SLOTS:
|
||||
///
|
||||
void availableChanged(const QModelIndex & idx, const QModelIndex &);
|
||||
void availableChanged(QModelIndex const & idx, QModelIndex const &);
|
||||
///
|
||||
void selectedChanged(const QModelIndex & idx, const QModelIndex &);
|
||||
void selectedChanged(QModelIndex const & idx, QModelIndex const &);
|
||||
///
|
||||
void availableChanged(QItemSelection const & qis, QItemSelection const &);
|
||||
///
|
||||
void selectedChanged(QItemSelection const & qis, QItemSelection const &);
|
||||
///
|
||||
virtual void addPB_clicked();
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user