From 8b4fe75907a20f8425e8b1e9d187b266a92834f6 Mon Sep 17 00:00:00 2001 From: Szymon Tomasz Stefanek Date: Wed, 9 Feb 2011 23:52:39 +0000 Subject: Yet another attempt at fixing #1093 git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@5446 17fca916-40b9-46aa-a4ea-0a15b648b75c --- src/modules/list/ListWindow.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/modules/list/ListWindow.cpp') diff --git a/src/modules/list/ListWindow.cpp b/src/modules/list/ListWindow.cpp index 8de6d8759..11366c444 100644 --- a/src/modules/list/ListWindow.cpp +++ b/src/modules/list/ListWindow.cpp @@ -68,8 +68,8 @@ ChannelTreeWidgetItemData::~ChannelTreeWidgetItemData() } -ChannelTreeWidgetItem::ChannelTreeWidgetItem(QTreeWidget * v,ChannelTreeWidgetItemData * pData) -: QTreeWidgetItem(v), m_pData(pData) +ChannelTreeWidgetItem::ChannelTreeWidgetItem(ChannelTreeWidgetItemData * pData) +: QTreeWidgetItem(), m_pData(pData) { setToolTip(0, m_pData->m_szChan); setToolTip(1, m_pData->m_szUsers); @@ -114,13 +114,6 @@ QSize ChannelTreeWidgetItemDelegate::sizeHint( const QStyleOptionViewItem &sovIt ChannelTreeWidget* treeWidget = (ChannelTreeWidget*)parent(); int iHeight=treeWidget->fontMetrics().lineSpacing(); - // Model-View-Delegate-Crappiness... - // - // This function is called when items aren't fully constructed. In particular - // when the ChannelTreeWidgetItem constructor calls the base class constructor - // this function is sometimes called with the newly inserted item which is not - // a ChannelTreeWidgetItem yet. - ChannelTreeWidgetItem * item = dynamic_cast(treeWidget->itemFromIndex(index)); if(!item) @@ -546,7 +539,14 @@ void ListWindow::flush() m_pTreeWidget->setUpdatesEnabled(false); /* for v_scroolbar */ while(ChannelTreeWidgetItemData * d = m_pItemList->first()) { - (void)new ChannelTreeWidgetItem(m_pTreeWidget,d); + // Model-View-Delegate-Crappiness... + // + // Don't use the constructor that takes QTreeWidget as parent + // as it will insert the item and call the delegate's sizeHint() + // function when the item is not yet fully constructed. + + m_pTreeWidget->addTopLevelItem(new ChannelTreeWidgetItem(d)); + m_pItemList->removeFirst(); } m_pTreeWidget->setUpdatesEnabled(true); -- cgit v1.3.1-10-gc9f91