From 10a5c58dbdfb022f38efb98796183a72c1d442fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Sun, 8 Jan 2006 10:57:31 +0000 Subject: [PATCH] restore double clicking in the QRefs dialog (bug 2194), plus some small ui fixes. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10714 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt2/ChangeLog | 13 +++++++++++++ src/frontends/qt2/QRef.C | 16 ++++++++++++---- src/frontends/qt2/QRef.h | 2 ++ src/frontends/qt2/QRefDialog.C | 10 +++++++--- src/frontends/qt2/ui/QRefDialogBase.ui | 6 ++++++ 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 202a2bd227..bbaf84e32f 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,16 @@ +2006-01-08 Jürgen Spitzmüller + + * ui/QRefDialogBase.ui: re-connect the refsLB->Selected signal + in order to restore double clicking (bug 2194) + + * QRef.[Ch]: add isValid member and use it (disable OK button + when text widget is empty). + + * QRef.C: + * QRefDialog.C: assure that the browser items are correctly + highlighted/not highlighted if a dialog is opened for the first + time (was distorted by the refsLB->Selected signal). + 2005-12-14 Hartmut Haase * ui/QPrefLatexModule.ui: make the papersize choices in diff --git a/src/frontends/qt2/QRef.C b/src/frontends/qt2/QRef.C index fc8791cb59..7a53587669 100644 --- a/src/frontends/qt2/QRef.C +++ b/src/frontends/qt2/QRef.C @@ -100,7 +100,7 @@ void QRef::update_contents() dialog_->bufferCO->setCurrentItem(controller().getBufferNum()); updateRefs(); - bc().valid(false); + bc().valid(isValid()); } @@ -192,13 +192,15 @@ void QRef::redoRefs() dialog_->referenceED->setText(tmp); // restore the last selection for new insets + // but do not highlight it if (tmp.isEmpty() && lastref != -1 - && lastref < int(dialog_->refsLB->count())) + && lastref < int(dialog_->refsLB->count())) { dialog_->refsLB->setCurrentItem(lastref); - else + dialog_->refsLB->clearSelection(); + } else for (unsigned int i = 0; i < dialog_->refsLB->count(); ++i) { if (tmp == dialog_->refsLB->text(i)) - dialog_->refsLB->setCurrentItem(i); + dialog_->refsLB->setSelected(i, true); } dialog_->refsLB->setAutoUpdate(true); @@ -223,5 +225,11 @@ void QRef::updateRefs() redoRefs(); } + +bool QRef::isValid() +{ + return !dialog_->referenceED->text().isEmpty(); +} + } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt2/QRef.h b/src/frontends/qt2/QRef.h index f23d0aa3c1..f3a79fb21c 100644 --- a/src/frontends/qt2/QRef.h +++ b/src/frontends/qt2/QRef.h @@ -30,6 +30,8 @@ public: friend class QRefDialog; QRef(Dialog &); +protected: + virtual bool isValid(); private: /// apply changes virtual void apply(); diff --git a/src/frontends/qt2/QRefDialog.C b/src/frontends/qt2/QRefDialog.C index 619f5c5816..332dbb8201 100644 --- a/src/frontends/qt2/QRefDialog.C +++ b/src/frontends/qt2/QRefDialog.C @@ -44,8 +44,7 @@ void QRefDialog::show() void QRefDialog::changed_adaptor() { - if (!referenceED->text().isEmpty()) - form_->changed(); + form_->changed(); } @@ -82,7 +81,12 @@ void QRefDialog::refSelected(const QString & sel) if (form_->readOnly()) return; - referenceED->setText(sel); + int const cur_item = refsLB->currentItem(); + bool const cur_item_selected = cur_item >= 0 ? + refsLB->isSelected(cur_item) : false; + + if (cur_item_selected) + referenceED->setText(sel); // or double click, inserts ref and closes dialog form_->slotOK(); } diff --git a/src/frontends/qt2/ui/QRefDialogBase.ui b/src/frontends/qt2/ui/QRefDialogBase.ui index cf6724c0e9..3c4db57a91 100644 --- a/src/frontends/qt2/ui/QRefDialogBase.ui +++ b/src/frontends/qt2/ui/QRefDialogBase.ui @@ -409,6 +409,12 @@ QRefDialogBase refHighlighted(const QString&) + + refsLB + selected(const QString&) + QRefDialogBase + refSelected(const QString&) + sortCB toggled(bool)