The patch tries to fix (the rest of) bug 1146
http://bugzilla.lyx.org/show_bug.cgi?id=1146

It always opens the find dialog if a new citation inset is being inserted (and 
thus saves a few annoying keypresses).
Can some kind soul please review?
It works nicely, except for one thing: after applying (pressing apply, not ok) 
the find dialog is also opened (which is o.k.), but the bc().valid() call is 
not recognized: the buttons stay disabled. Any idea on this?

Thanks,
J�rgen.
Index: src/frontends/qt2/QCitation.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QCitation.C,v
retrieving revision 1.28
diff -u -r1.28 QCitation.C
--- src/frontends/qt2/QCitation.C	6 Oct 2003 15:42:50 -0000	1.28
+++ src/frontends/qt2/QCitation.C	17 Feb 2004 18:17:43 -0000
@@ -179,6 +179,9 @@
 
 	fillStyles();
 	updateStyle();
+	
+	// open the find dialog if nothing has been selected (yet)
+	dialog_->autoAdd();
 }
 
 
Index: src/frontends/qt2/QCitationDialog.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QCitationDialog.C,v
retrieving revision 1.27
diff -u -r1.27 QCitationDialog.C
--- src/frontends/qt2/QCitationDialog.C	11 Dec 2003 14:42:39 -0000	1.27
+++ src/frontends/qt2/QCitationDialog.C	17 Feb 2004 18:17:43 -0000
@@ -4,6 +4,8 @@
  * Licence details can be found in the file COPYING.
  *
  * \author Kalle Dalheimer
+ * \author John Levon
+ * \author Jürgen Spitzmüller
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -12,6 +14,7 @@
 
 #include "qt_helpers.h"
 #include "controllers/ControlCitation.h"
+#include "ButtonController.h"
 
 #include <qcheckbox.h>
 #include <qlineedit.h>
@@ -68,6 +71,21 @@
 	deletePB->setEnabled(sel_nr >= 0);
 	upPB->setEnabled(sel_nr > 0);
 	downPB->setEnabled(sel_nr >= 0 && sel_nr < int(selectedLB->count() - 1));
+}
+
+
+void QCitationDialog::autoAdd()
+{
+	if (form_->readOnly())
+		return;
+	
+	if (selectedLB->count() == 0){
+		// open the find dialog
+		add();
+		// and let the user press ok afterwards
+		// FIXME: does not work after "apply"
+		form_->bc().valid();
+	}
 }
 
 
Index: src/frontends/qt2/QCitationDialog.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QCitationDialog.h,v
retrieving revision 1.10
diff -u -r1.10 QCitationDialog.h
--- src/frontends/qt2/QCitationDialog.h	23 Aug 2003 00:16:38 -0000	1.10
+++ src/frontends/qt2/QCitationDialog.h	17 Feb 2004 18:17:43 -0000
@@ -28,6 +28,8 @@
 	~QCitationDialog();
 
 	void setButtons();
+	/// open the find dialog if nothing selected
+	void autoAdd();
 
 	QCitationFindDialogBase * add_;
 

Reply via email to