connect(selectionManager, SIGNAL(okHook()),
this, SLOT(on_okPB_clicked()));
- setFocusProxy(availableLV);
-
// FIXME: the sizeHint() for this is _way_ too high
infoML->setFixedHeight(60);
}
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);
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);
#include "support/debug.h"
-#include <QKeyEvent>
+#include <QAbstractListModel>
+#include <QItemSelection>
#include <QListView>
+#include <QKeyEvent>
#include <QPushButton>
-#include <QAbstractListModel>
#ifdef KeyPress
#undef KeyPress
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()),
}
+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())
}
+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())
class QPushButton;
class QVariant;
class QAbstractItemView;
+class QItemSelection;
template <class T, class U> class QMap;
namespace lyx {
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();
///