http://bugzilla.lyx.org/show_bug.cgi?id=1033

I finally got sick by the fact that the navigating listviews in the prefs and 
document dialog crop the text of the listview items (especially in the German 
translation, where almost half of the text is cropped in some cases). Since 
there seems to be no way to tell qt directly to resize the ListView according 
to its longest item, we have to calculate the width ourselves and set the 
widget's width manually.

The attached patch implements this to the panelstack. It works like a charm. I 
have tried quite a range of languages, and both the prefs and the document 
dialog always resized perfectly, i.e. the navigating listview is always just 
as wide as the widest item in the given language.

OK to apply?

J�rgen
Index: panelstack.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/panelstack.C,v
retrieving revision 1.10
diff -u -r1.10 panelstack.C
--- panelstack.C	6 Oct 2003 15:42:52 -0000	1.10
+++ panelstack.C	10 Apr 2005 16:27:30 -0000
@@ -15,6 +15,7 @@
 #include "qt_helpers.h"
 
 #include <qwidgetstack.h>
+#include <qfontmetrics.h>
 #include <qlayout.h>
 #include <qlistview.h>
 
@@ -87,8 +88,13 @@
 	item->setOpen(true);
 	panel_map_[n] = item;
 
-	// Qt is just unbelievably moronic
-	list_->setMinimumSize(QSize(150, list_->minimumHeight()));
+	// calculate the real size the current item needs in the listview
+	QFontMetrics fm(list_->font());
+	int itemsize = item->width(fm, list_, 0) + 10
+		   + list_->treeStepSize() * (item->depth() + 1) + list_->itemMargin();
+	// adjust the listview width to the max. itemsize
+	if (itemsize > list_->minimumWidth())
+		list_->setMinimumWidth(itemsize);
 }
 
 

Reply via email to