namespace frontend {
TocWidget::TocWidget(GuiView & gui_view, QWidget * parent)
- : QWidget(parent), depth_(0), persistent_(false), gui_view_(gui_view),
- timer_(new QTimer(this))
+ : QWidget(parent), depth_(0), persistent_(false), keep_expanded_(false),
+ gui_view_(gui_view), timer_(new QTimer(this))
{
setupUi(this);
void TocWidget::on_tocTV_pressed(QModelIndex const & index)
{
-
+ DocIterator const & dit = gui_view_.documentBufferView()->cursor();
+ keep_expanded_ = gui_view_.tocModels().currentIndex(current_type_, dit) == index;
Qt::MouseButtons const button = QApplication::mouseButtons();
if (button & Qt::LeftButton) {
goTo(index);
}
+void TocWidget::on_tocTV_doubleClicked(QModelIndex const &)
+{
+ keep_expanded_ = true;
+}
+
+
void TocWidget::goTo(QModelIndex const & index)
{
LYXERR(Debug::GUI, "goto " << index.row()
// Expensive operations are on a timer. We finish the update immediately
// for sparse edition actions, i.e. there was no edition/cursor movement
// recently, then every 300ms.
- if (!timer_->isActive()) {
+ if (!timer_->isActive() && !keep_expanded_) {
finishUpdateView();
timer_->start(300);
}
// text and moving with arrows. For bigger operations, this is negligible,
// and outweighted by TocModels::reset() anyway.
if (canNavigate()) {
- if (!persistent_)
+ if (!persistent_ && !keep_expanded_)
setTreeDepth(depth_);
+ keep_expanded_ = false;
persistentCB->setChecked(persistent_);
// select the item at current cursor location
if (gui_view_.documentBufferView()) {
void on_tocTV_activated(QModelIndex const &);
void on_tocTV_pressed(QModelIndex const &);
+ void on_tocTV_doubleClicked(QModelIndex const &);
void on_updateTB_clicked();
void on_sortCB_stateChanged(int state);
void on_persistentCB_stateChanged(int state);
int depth_;
/// persistence of uncollapsed nodes in toc view
bool persistent_;
+ /// keep uncollapsed nodes in this event
+ bool keep_expanded_;
///
GuiView & gui_view_;
// Timer for scheduling expensive update operations