]> git.lyx.org Git - features.git/commitdiff
fix qt dialog list resizing (bug 1033)
authorJürgen Spitzmüller <spitz@lyx.org>
Mon, 11 Apr 2005 07:00:03 +0000 (07:00 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Mon, 11 Apr 2005 07:00:03 +0000 (07:00 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9802 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt2/ChangeLog
src/frontends/qt2/panelstack.C

index 8ab07cdccbdfb5f9a100c5f3b8a827278cd823d4..e296965b36d6ffcf588b1eaa56e70050cfec8411 100644 (file)
@@ -1,3 +1,8 @@
+2005-04-11  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
+
+       * panelstack.C (addCategory): let the listview compute the
+       correct width.
+
 2005-04-08  Angus Leeming  <leeming@lyx.org>
 
        * QAbout.C (build_dialog): specify that the CREDITS data is
index a3bc98e27b2dfe55de9cf689a683a3585a144780..1845c73b2afe18dc0ad4ac4e64b97efe861815a3 100644 (file)
@@ -15,6 +15,7 @@
 #include "qt_helpers.h"
 
 #include <qwidgetstack.h>
+#include <qfontmetrics.h>
 #include <qlayout.h>
 #include <qlistview.h>
 
@@ -87,8 +88,13 @@ void PanelStack::addCategory(string const & n, string const & parent)
        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);
 }