minimumWidth() for TreeView in KJanusWidget

Tobias Koenig tokoe at kde.org
Sat Feb 28 19:27:54 GMT 2004


Hi,

the attached patch changes the minimumWidth() of the KListView to
a width, so that all items are visible without horizontal scrolling.
Since there is a QSplitter between the listview and the rest of the
widget that shouldn't be a problem for large (nested) trees.

Ok for commit?

Ciao,
Tobias
-- 
Separate politics from religion and economy!
-------------- next part --------------
Index: kjanuswidget.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kjanuswidget.cpp,v
retrieving revision 1.73
diff -p -u -b -r1.73 kjanuswidget.cpp
--- kjanuswidget.cpp	2 Jan 2004 14:21:55 -0000	1.73
+++ kjanuswidget.cpp	28 Feb 2004 19:22:49 -0000
@@ -418,6 +418,19 @@ void KJanusWidget::InsertTreeListItem(co
       }
       mTreeListToPageStack.insert(newChild, page);
     }
+
+    int itemWidth = 3;
+    if (mTreeList->rootIsDecorated())
+      itemWidth += 2 * mTreeList->treeStepSize();
+
+    QListViewItem *item = newChild;
+    while (item->parent() != 0) {
+      itemWidth += mTreeList->treeStepSize();
+      item = item->parent();
+    }
+
+    itemWidth += newChild->width(fontMetrics(), mTreeList, 0);
+    mTreeList->setMinimumWidth(QMAX(itemWidth, mTreeList->minimumWidth()));
   }
 }
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20040228/9dbe3227/attachment.sig>


More information about the kde-core-devel mailing list