Jean-Marc Lasgouttes wrote:
> Juergen> Thanks, it's in. Jean-Marc, would you be interested in a
> Juergen> similar patch for 1.3.7?
>
> Sure.

This would be the attached. I had to change the behaviour of refSelected, 
because this signal is emitted for both double clicking and enter key, and 
enter should not trigger goto-label (see the line above my insertion in 
status.13x in the patch).

OK to commit?

Jürgen

P.S.: there's still a pending patch for 1.3.7 at bug 1977 waiting for your 
comment.
Index: status.13x
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/Attic/status.13x,v
retrieving revision 1.1.2.284
diff -p -u -r1.1.2.284 status.13x
--- status.13x	7 Jan 2006 18:37:38 -0000	1.1.2.284
+++ status.13x	8 Jan 2006 16:09:06 -0000
@@ -56,6 +56,8 @@ What's new
 - The Return key is no longer bound to the Goto button in the reference
   dialog. [Qt only].
 
+- Double clicking in the reference dialog now inserts a reference [Qt only].
+
 - Searching backwards in the citation dialog always skipped one result
   (bug 2002). Fixed now.
 
Index: src/frontends/qt2/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/ChangeLog,v
retrieving revision 1.389.2.83
diff -p -u -r1.389.2.83 ChangeLog
--- src/frontends/qt2/ChangeLog	19 Oct 2005 15:30:59 -0000	1.389.2.83
+++ src/frontends/qt2/ChangeLog	8 Jan 2006 16:09:11 -0000
@@ -1,3 +1,19 @@
+2006-01-08  Jürgen Spitzmüller  <[EMAIL PROTECTED]>
+
+	* 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).
+
+	* QRefDialog.C (refSelected): insert reference on double click/
+	enter (bug 2187).
+
 2005-10-19  Angus Leeming  <[EMAIL PROTECTED]>
 
 	* lyx_gui.C (LApplication d-tor): remove code to unlock
Index: src/frontends/qt2/QRef.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QRef.C,v
retrieving revision 1.16.2.4
diff -p -u -r1.16.2.4 QRef.C
--- src/frontends/qt2/QRef.C	22 Jul 2005 13:46:04 -0000	1.16.2.4
+++ src/frontends/qt2/QRef.C	8 Jan 2006 16:09:11 -0000
@@ -86,7 +86,7 @@ void QRef::update_contents()
 
 	updateRefs();
 
-	bc().invalid();
+	bc().valid(isValid());
 }
 
 
@@ -154,6 +154,8 @@ void QRef::redoRefs()
 	dialog_->refsLB->blockSignals(true);
 	dialog_->referenceED->blockSignals(true);
 
+	int lastref = dialog_->refsLB->currentItem();
+
 	dialog_->refsLB->setAutoUpdate(false);
 	dialog_->refsLB->clear();
 
@@ -171,10 +173,17 @@ void QRef::redoRefs()
 
 	dialog_->referenceED->setText(tmp);
 
-	for (unsigned int i = 0; i < dialog_->refsLB->count(); ++i) {
-		if (tmp == dialog_->refsLB->text(i))
-			dialog_->refsLB->setCurrentItem(i);
-	}
+	// restore the last selection for new insets
+	// but do not highlight it
+	if (tmp.isEmpty() && lastref != -1
+	    && lastref < int(dialog_->refsLB->count())) {
+		dialog_->refsLB->setCurrentItem(lastref);
+		dialog_->refsLB->clearSelection();
+	} else
+		for (unsigned int i = 0; i < dialog_->refsLB->count(); ++i) {
+			if (tmp == dialog_->refsLB->text(i))
+				dialog_->refsLB->setSelected(i, true);
+		}
 
 	dialog_->refsLB->setAutoUpdate(true);
 	dialog_->refsLB->update();
@@ -196,4 +205,10 @@ void QRef::updateRefs()
 	dialog_->sortCB->setEnabled(!refs_.empty());
 	dialog_->refsLB->setEnabled(!refs_.empty());
 	redoRefs();
+}
+
+
+bool QRef::isValid()
+{
+	return !dialog_->referenceED->text().isEmpty();
 }
Index: src/frontends/qt2/QRef.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QRef.h,v
retrieving revision 1.7.2.1
diff -p -u -r1.7.2.1 QRef.h
--- src/frontends/qt2/QRef.h	7 Dec 2004 10:49:13 -0000	1.7.2.1
+++ src/frontends/qt2/QRef.h	8 Jan 2006 16:09:12 -0000
@@ -27,6 +27,8 @@ public:
 	friend class QRefDialog;
 
 	QRef();
+protected:
+	virtual bool isValid();
 private:
 	/// apply changes
 	virtual void apply();
Index: src/frontends/qt2/QRefDialog.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QRefDialog.C,v
retrieving revision 1.7.2.3
diff -p -u -r1.7.2.3 QRefDialog.C
--- src/frontends/qt2/QRefDialog.C	22 Jul 2005 13:46:04 -0000	1.7.2.3
+++ src/frontends/qt2/QRefDialog.C	8 Jan 2006 16:09:12 -0000
@@ -36,8 +36,7 @@ QRefDialog::QRefDialog(QRef * form)
 
 void QRefDialog::changed_adaptor()
 {
-	if (!referenceED->text().isEmpty())
-		form_->changed();
+	form_->changed();
 }
 
 
@@ -71,7 +70,17 @@ void QRefDialog::refHighlighted(const QS
 
 void QRefDialog::refSelected(const QString &)
 {
-	form_->gotoRef();
+	if (form_->readOnly())
+		return;
+
+	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);
+	// <enter> or double click, inserts ref and closes dialog
+	form_->slotOK();
 }
 
 
Index: src/frontends/qt2/ui/QRefDialogBase.ui
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/ui/QRefDialogBase.ui,v
retrieving revision 1.1.2.3
diff -p -u -r1.1.2.3 QRefDialogBase.ui
--- src/frontends/qt2/ui/QRefDialogBase.ui	22 Jul 2005 13:46:05 -0000	1.1.2.3
+++ src/frontends/qt2/ui/QRefDialogBase.ui	8 Jan 2006 16:09:13 -0000
@@ -400,6 +400,12 @@
         <slot>refHighlighted(const QString&amp;)</slot>
     </connection>
     <connection>
+        <sender>refsLB</sender>
+        <signal>selected(const QString&amp;)</signal>
+        <receiver>QRefDialogBase</receiver>
+        <slot>refSelected(const QString&amp;)</slot>
+    </connection>
+    <connection>
         <sender>sortCB</sender>
         <signal>toggled(bool)</signal>
         <receiver>QRefDialogBase</receiver>

Reply via email to