[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdepim/akregator/src
From: Teemu Rytilahti <tpr () d5k ! net>
Date: 2008-08-22 3:04:53
Message-ID: 1219374293.133547.4851.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 850696 by rytilahti:
- use saveState()/restoreState() for handling the header states.
-- The sizes for the feedlist are saved now correctly, as well as the shown items. \
Also the ordering is saved now.
-- Call loadHeaderList only once, now it doesn't display the ugly horizontal \
scrollbar after being restarted \o/
- adapt subscriptionlistview to use the popupmenu stuff for the headers like \
articlelistview did already.
- move connecting the rmb click on the header to be inside the ctor to avoid multiple \
connections (and thus multiple popupmenus)
saveState()/restoreState() wasn't used due to some Qt-bug? I only had problem while \
trying to directly use Settings class to save the settings, with KConfigGroup it \
works just fine. could this be a bug in KConfigXT instead of in Qt?
TODO:
- ArticleListView does not still respect the sizes its entries has been given to, \
needs to be fixed (perhaps by setting up the headers some other way than directly \
inside setModel()?
- Backporting to 4.1 branch after that's been done.
- Figuring out whether we need feed specific header settings.
CCMAIL:frank.osterfeld@kdemail.net
CCMAIL:l.appelhans@gmx.de
BUG:167803
CCBUG:152702
M +15 -32 articlelistview.cpp
M +41 -46 subscriptionlistview.cpp
M +1 -2 subscriptionlistview.h
--- trunk/KDE/kdepim/akregator/src/articlelistview.cpp #850695:850696
@@ -142,13 +142,6 @@
void ArticleListView::setArticleModel( ArticleModel* model )
{
- //const QByteArray headerState = header()->saveState();
- QList<int> columnsSize;
- for (int i = 0; i < header()->count(); ++i)
- columnsSize.append( columnWidth( i ) );
-
- //FIXME: HACK: Change back to saveState() when it's working again
-
slotClear();
if ( !model )
return;
@@ -168,9 +161,6 @@
columnsProxy->setColumnEnabled( ArticleModel::AuthorColumn );
setModel( columnsProxy );
- //header()->restoreState( headerState );
- for (int i = 0; i < columnsSize.count(); ++i)
- setColumnWidth( i, columnsSize.at( i ) );
if ( !m_headerSetUp )
{
@@ -178,8 +168,6 @@
m_headerSetUp = true;
}
header()->setContextMenuPolicy( Qt::CustomContextMenu );
- connect( header(), SIGNAL( customContextMenuRequested( QPoint ) ),
- this, SLOT( showHeaderMenu( QPoint ) ) );
}
void ArticleListView::showHeaderMenu(const QPoint& pos)
@@ -217,31 +205,24 @@
void ArticleListView::saveHeaderSettings()
{
- //Settings::setArticlelistHeaderStates( header()->saveState().toBase64() );
- QList<int> columnsSize;
- for (int i = 0; i < header()->count(); i++)
- columnsSize.append( columnWidth( i ) );
-
//FIXME: HACK: Change back to saveState() when the Qt-bug is fixed
- Settings::setArticlelistHeaderStates(columnsSize);
- Settings::setArticlelistSortColumn( header()->sortIndicatorSection() );
- Settings::setArticlelistSortOrder( header()->sortIndicatorOrder() == \
Qt::AscendingOrder ? 1 : 0 ); + // is it qt-bug, really? at least saveState is \
working, but calling the next line causes app to hang.. -Teemu + \
//Settings::setArticlelistHeaderStates( header()->saveState().toBase64() ); +
+ QByteArray s = header()->saveState();
+ KConfigGroup conf( Settings::self()->config(), "General" );
+ conf.writeEntry( "ArticleListHeaders", s.toBase64() );
}
void ArticleListView::loadHeaderSettings()
{
- /*const QByteArray s = QByteArray::fromBase64( \
Settings::articlelistHeaderStates().toAscii() );
- if ( !s.isNull() )
- header()->restoreState( s );*/
- QList<int> columnsSize = Settings::articlelistHeaderStates();
- if ( !columnsSize.isEmpty() ) {
- for (int i = 0; i < columnsSize.count(); i++)
- setColumnWidth( i, columnsSize.at( i ) );
-
- //FIXME: HACK: Change back to saveState() when the Qt-bug is fixed
- }
- header()->setSortIndicator( Settings::articlelistSortColumn(), ( \
Settings::articlelistSortOrder() == 1 ? Qt::AscendingOrder : \
Qt::DescendingOrder ) );
- sortByColumn( Settings::articlelistSortColumn(), ( \
Settings::articlelistSortOrder() == 1 ? Qt::AscendingOrder : Qt::DescendingOrder ) ); \
+ //FIXME: HACK: change back to loadState+Settings class instead of using \
KConfigGroup directly.. + //QByteArray s = QByteArray::fromBase64( \
Settings::feedlistHeaderStates().toAscii() ); // this fails currently, I think -Teemu \
+ + KConfigGroup conf( Settings::self()->config(), "General" );
+ QByteArray s = QByteArray::fromBase64( conf.readEntry( "ArticleListHeaders" \
).toAscii() ); + if( !s.isNull() )
+ header()->restoreState( s );
}
QItemSelectionModel* ArticleListView::articleSelectionModel() const
@@ -309,6 +290,8 @@
"Here you can browse articles from the currently selected feed. "
"You can also manage articles, as marking them as persistent (\"Keep \
Article\") or delete them, using the right mouse button menu."
"To view the web page of the article, you can open the article internally in \
a tab or in an external browser window.")); +
+ connect( header(), SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( \
showHeaderMenu( QPoint ) ) ); }
void ArticleListView::mousePressEvent( QMouseEvent *ev )
--- trunk/KDE/kdepim/akregator/src/subscriptionlistview.cpp #850695:850696
@@ -28,6 +28,7 @@
#include <QHeaderView>
#include <QStack>
+#include <QPointer>
#include <KMenu>
#include <KLocale>
@@ -134,6 +135,8 @@
setDragDropMode( QAbstractItemView::DragDrop );
setDropIndicatorShown( true );
setAcceptDrops( true );
+ m_headerSetup = false;
+ connect( header(), SIGNAL( customContextMenuRequested( const QPoint & ) ), this, \
SLOT( showHeaderMenu( const QPoint& ) ) ); }
Akregator::SubscriptionListView::~SubscriptionListView()
@@ -160,73 +163,65 @@
setExpanded( i, i.data( Akregator::SubscriptionListModel::IsOpenRole \
).toBool() ); }
- // To show/hide specific columns, borrowed from KTorrent
header()->setContextMenuPolicy( Qt::CustomContextMenu );
- connect( header(), SIGNAL( customContextMenuRequested( const QPoint & ) ), this, \
SLOT( showHeaderMenu( const QPoint& ) ) );
- m_headerMenu = new KMenu( this );
- m_headerMenu->addTitle( i18n( "Columns" ) );
- for (int i = 0; i < model->columnCount(); i++)
- {
- QString col = model->headerData( i, Qt::Horizontal, Qt::DisplayRole \
).toString();
- QAction* act = m_headerMenu->addAction( col );
- act->setCheckable( true );
- act->setChecked( true );
- m_columnMap[act] = i;
+ if( ! m_headerSetup ) {
+ loadHeaderSettings();
+ m_headerSetup = true;
}
-
- connect(m_headerMenu, SIGNAL( triggered( QAction* ) ), this, SLOT( \
headerMenuItemTriggered( QAction* ) ) );
-
- loadHeaderSettings();
}
void Akregator::SubscriptionListView::showHeaderMenu( const QPoint& pos )
{
- m_headerMenu->popup( header()->mapToGlobal( pos ) );
+ if( ! model() )
+ return;
+
+ QPointer<KMenu> menu = new KMenu( this );
+ menu->addTitle( i18n( "Columns" ) );
+ menu->setAttribute( Qt::WA_DeleteOnClose );
+ connect(menu, SIGNAL( triggered( QAction* ) ), this, SLOT( \
headerMenuItemTriggered( QAction* ) ) ); +
+ for (int i = 0; i < model()->columnCount(); i++)
+ {
+ QString col = model()->headerData( i, Qt::Horizontal, Qt::DisplayRole \
).toString(); + QAction* act = menu->addAction( col );
+ act->setCheckable( true );
+ act->setChecked( !header()->isSectionHidden( i ) );
+ act->setData( i );
+ }
+
+ menu->popup( header()->mapToGlobal( pos ) );
}
void Akregator::SubscriptionListView::headerMenuItemTriggered( QAction* act )
{
- int idx = m_columnMap[act];
+ assert( act );
+ const int col = act->data().toInt();
if ( act->isChecked() )
- header()->showSection( idx );
+ header()->showSection( col );
else
- header()->hideSection( idx );
+ header()->hideSection( col );
}
void Akregator::SubscriptionListView::saveHeaderSettings()
-{
- //QByteArray s = header()->saveState();
- //Settings::setFeedlistHeaderStates( s.toBase64() );
- QList<int> columnsSize;
- for (int i = 0; i != header()->count(); i++)
- {
- kDebug() << i;
- columnsSize.append( columnWidth( i ) );
- }//FIXME: HACK: Change back to saveState() when the Qt-bug is fixed
- Settings::setFeedlistHeaderStates( columnsSize );
+{
+ QByteArray s = header()->saveState();
+ KConfigGroup conf( Settings::self()->config(), "General" );
+ conf.writeEntry( "SubscriptionListHeaders", s.toBase64() );
+
+ //FIXME: HACK: Change back to Settings, when it starts to work again..
+ // Settings::setFeedlistHeaderStates( s.toBase64() );
}
void Akregator::SubscriptionListView::loadHeaderSettings()
{
+ // FIXME: HACK: Change back to Settings when it's working
//QByteArray s = QByteArray::fromBase64( \
Settings::feedlistHeaderStates().toAscii() );
- //if ( !s.isNull() )
- // header()->restoreState( s );
- QList<int> columnsSize = Settings::feedlistHeaderStates();
- if ( !columnsSize.isEmpty() ) {
- for (int i = 0; i != columnsSize.count(); i++)
- {
- kDebug() << i << " " << columnsSize.at( i );
- setColumnWidth( i, columnsSize.at( i ) );
- }//FIXME: HACK: Change back to saveState() when the Qt-bug is fixed
- }
- QMap<QAction*,int>::iterator i = m_columnMap.begin();
- while ( i != m_columnMap.end() )
- {
- QAction* act = i.key();
- act->setChecked( !header()->isSectionHidden( i.value() ) );
- i++;
- }
+
+ KConfigGroup conf( Settings::self()->config(), "General" );
+ QByteArray s = QByteArray::fromBase64( conf.readEntry( "SubscriptionListHeaders" \
).toAscii() ); + if( !s.isNull() )
+ header()->restoreState( s );
}
void Akregator::SubscriptionListView::slotPrevFeed()
--- trunk/KDE/kdepim/akregator/src/subscriptionlistview.h #850695:850696
@@ -83,8 +83,7 @@
void headerMenuItemTriggered( QAction* action );
private:
- QMap<QAction*,int> m_columnMap;
- KMenu *m_headerMenu;
+ bool m_headerSetup;
};
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic