From kde-pim Wed Jan 28 16:55:48 2009 From: Jonathan Marten Date: Wed, 28 Jan 2009 16:55:48 +0000 To: kde-pim Subject: [Kde-pim] Akregator column widths Message-Id: X-MARC-Message: https://marc.info/?l=kde-pim&m=123316246418552 Some people have reported (bug 152702) that the problem with remembering column widths and configuration is not fixed in 4.2 released today, and I've noticed the same with current trunk. Part of the problem may be there there are possibly three separate bugs here: (1) feed list columns not being set up on startup; (2) the article list's last ("Date") column expanding itself when switching feeds; (3) article list columns resizing themselves when new articles arrive, bug 181742. There were some commits made to address (2) last week, but they don't seem to have completely fixed things. I've done some investigating and managed to finally get an Akregator which remembers the column widths as intended. (1) was just a line of code needing to be added, while (2) may be something in Qt that I don't fully understand but which it is possible to work around in Akregator. (Short explanation: QHeaderViewPrivate::resizeSections() expands the last column to at least the saved lastSectionSize, which is not initialised unless a model is set and is not reset when changing the column configuration). (3) may also be a problem with Qt, but which it is not possible to work around in Akregator. There is a simple patch, but I don't know if there would be any point in trying to get this into Qt 4.4 since 4.5 will be out soon (and KDE 4.3 will require Qt 4.5, is that correct?). Qt 4.5 seems to be quite different in this code area, so maybe the bug is already fixed. The patch also maintains separate article list column configurations for the "feed" and the "group" mode, instead of simply removing/adding the "Feed" column. Doing that resizes the following column ("Date") to fit, where it would make more sense to resize the variable-length "Title" column. Patches are below; since this is my first work on Akregator I thought it better to check with the list first before committing anything. Any comments? -- akregator.patch --------------------------------------------------- Index: articlelistview.cpp =================================================================== --- articlelistview.cpp (revision 917242) +++ articlelistview.cpp (working copy) @@ -202,15 +202,21 @@ void ArticleListView::saveHeaderSettings() { if ( model() ) - m_headerState = header()->saveState(); + { + if ( m_columnMode == FeedMode ) m_feedHeaderState = header()->saveState(); + if ( m_columnMode == GroupMode ) m_groupHeaderState = header()->saveState(); + } + KConfigGroup conf( Settings::self()->config(), "General" ); - conf.writeEntry( "ArticleListHeaders", m_headerState.toBase64() ); + conf.writeEntry( "ArticleListFeedHeaders", m_feedHeaderState.toBase64() ); + conf.writeEntry( "ArticleListGroupHeaders", m_groupHeaderState.toBase64() ); } void ArticleListView::loadHeaderSettings() { KConfigGroup conf( Settings::self()->config(), "General" ); - m_headerState = QByteArray::fromBase64( conf.readEntry( "ArticleListHeaders" ).toAscii() ); + m_feedHeaderState = QByteArray::fromBase64( conf.readEntry( "ArticleListFeedHeaders" ).toAscii() ); + m_groupHeaderState = QByteArray::fromBase64( conf.readEntry( "ArticleListGroupHeaders" ).toAscii() ); } QItemSelectionModel* ArticleListView::articleSelectionModel() const @@ -242,17 +248,19 @@ void ArticleListView::setGroupMode() { - if ( m_columnMode == GroupMode ) - return; - setColumnHidden( ArticleListView::FeedTitleColumn, false ); + if ( m_columnMode == GroupMode ) return; + + header()->resizeSection( header()->count() - 1, 1 ); // reset QHeaderViewPrivate::lastSectionSize + header()->restoreState( m_groupHeaderState ); m_columnMode = GroupMode; } void ArticleListView::setFeedMode() { - if ( m_columnMode == FeedMode ) - return; - setColumnHidden( ArticleListView::FeedTitleColumn, true ); + if ( m_columnMode == FeedMode ) return; + + header()->resizeSection( header()->count() - 1, 1 ); + header()->restoreState( m_feedHeaderState ); m_columnMode = FeedMode; } @@ -377,13 +385,23 @@ } -void ArticleListView::setModel( QAbstractItemModel* m ) { +void ArticleListView::setModel( QAbstractItemModel* m ) +{ + bool groupMode = ( m_columnMode == GroupMode ); + QAbstractItemModel* const oldModel = model(); if ( oldModel ) - m_headerState = header()->saveState(); + { + if ( groupMode ) m_groupHeaderState = header()->saveState(); + else m_feedHeaderState = header()->saveState(); + } + QTreeView::setModel( m ); if ( m ) - header()->restoreState( m_headerState ); + { + header()->resizeSection( header()->count() - 1, 1 ); + header()->restoreState( groupMode ? m_groupHeaderState : m_feedHeaderState ); + } } void ArticleListView::slotClear() Index: subscriptionlistview.cpp =================================================================== --- subscriptionlistview.cpp (revision 917242) +++ subscriptionlistview.cpp (working copy) @@ -216,6 +217,7 @@ { const KConfigGroup conf( Settings::self()->config(), "General" ); m_headerState = QByteArray::fromBase64( conf.readEntry( "SubscriptionListHeaders" ).toAscii() ); + header()->restoreState( m_headerState ); } void Akregator::SubscriptionListView::slotPrevFeed() Index: articlelistview.h =================================================================== --- articlelistview.h (revision 917242) +++ articlelistview.h (working copy) @@ -159,13 +159,13 @@ private: - enum Column { ItemTitleColumn=0, FeedTitleColumn, DateColumn, ColumnCount }; enum ColumnMode { Unspecified, GroupMode, FeedMode }; ColumnMode m_columnMode; bool m_isAggregation; QPointer m_proxy; std::vector > m_matchers; - QByteArray m_headerState; + QByteArray m_feedHeaderState; + QByteArray m_groupHeaderState; }; } // namespace Akregator -- akregator.patch end ----------------------------------------------- -- qt.patch ---------------------------------------------------------- --- qt-copy/src/gui/itemviews/qtreeview.cpp.orig2 2008-11-11 19:04:15.000000000 +0000 +++ qt-copy/src/gui/itemviews/qtreeview.cpp 2009-01-28 15:28:17.000000000 +0000 @@ -2990,7 +2990,7 @@ * * We can expand the column to make the contents properly visible. */ - if (!header || !header->isVisible() || ((header->count() - header->hiddenSectionCount()) <= 1)) { + if (!header || header->isHidden() || ((header->count() - header->hiddenSectionCount()) <= 1)) { q->resizeColumnToContents(q->currentIndex().column()); } } -- qt.patch end ------------------------------------------------------ -- Jonathan Marten http://www.keelhaul.demon.co.uk Twickenham, UK jjm2@keelhaul.demon.co.uk _______________________________________________ KDE PIM mailing list kde-pim@kde.org https://mail.kde.org/mailman/listinfo/kde-pim KDE PIM home page at http://pim.kde.org/