Angus Leeming wrote:
> Hi, Jürgen
>
> No, I don't remember why, but the relevant entries in the ChangeLog are
> below.

Thanks, Angus. Seems that the disconnection was because the refSelected signal 
caused an item always to be highlighted also if the dialog is shown for the 
first time. However, it breaks double-clicking, as mentioned.

Also:

>         * QRefDialog.C (changed_adaptor): only enable the OK button when
>         the "Label:" field is not empty.

this actually does not work.

Attached is a patch which restores double clicking, prevents highlighting if 
the dialog is shown the first time ans disables the ok button if the "Label:" 
field is empty. Something similar would be needed for 1.3.7

It's not crucial for 1.4.0, but it fixes a regression wrt 1.3.6

Jürgen

Index: src/frontends/qt2/QRef.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QRef.C,v
retrieving revision 1.41
diff -p -u -r1.41 QRef.C
--- src/frontends/qt2/QRef.C	22 Jul 2005 13:44:50 -0000	1.41
+++ src/frontends/qt2/QRef.C	7 Jan 2006 11:37:25 -0000
@@ -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);
@@ -221,6 +223,12 @@ void QRef::updateRefs()
 	dialog_->refsLB->setEnabled(!refs_.empty());
 	dialog_->gotoPB->setEnabled(!refs_.empty());
 	redoRefs();
+}
+
+
+bool QRef::isValid()
+{
+	return !dialog_->referenceED->text().isEmpty();
 }
 
 } // namespace frontend
Index: src/frontends/qt2/QRef.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QRef.h,v
retrieving revision 1.15
diff -p -u -r1.15 QRef.h
--- src/frontends/qt2/QRef.h	19 May 2004 15:11:33 -0000	1.15
+++ src/frontends/qt2/QRef.h	7 Jan 2006 11:37:25 -0000
@@ -30,6 +30,8 @@ public:
 	friend class QRefDialog;
 
 	QRef(Dialog &);
+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.19
diff -p -u -r1.19 QRefDialog.C
--- src/frontends/qt2/QRefDialog.C	22 Jul 2005 13:44:50 -0000	1.19
+++ src/frontends/qt2/QRefDialog.C	7 Jan 2006 11:37:25 -0000
@@ -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 QStri
 	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);
 	// <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.11
diff -p -u -r1.11 QRefDialogBase.ui
--- src/frontends/qt2/ui/QRefDialogBase.ui	28 Nov 2005 18:58:16 -0000	1.11
+++ src/frontends/qt2/ui/QRefDialogBase.ui	7 Jan 2006 11:37:27 -0000
@@ -410,6 +410,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