[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdepimlibs/akregator_port] krss: Move FeedListView from krss to Akregator.
From:       Frank Osterfeld <frank.osterfeld () kdab ! com>
Date:       2012-03-31 15:16:24
Message-ID: 20120331151624.6924BA6129 () git ! kde ! org
[Download RAW message or body]

Git commit 5e8fa3b589ed80868dff303d6f77904a7c2eec03 by Frank Osterfeld.
Committed on 24/02/2012 at 16:19.
Pushed by osterfeld into branch 'akregator_port'.

Move FeedListView from krss to Akregator.

M  +0    -3    krss/CMakeLists.txt
D  +0    -337  krss/ui/feedlistview.cpp
D  +0    -73   krss/ui/feedlistview.h

http://commits.kde.org/kdepimlibs/5e8fa3b589ed80868dff303d6f77904a7c2eec03

diff --git a/krss/CMakeLists.txt b/krss/CMakeLists.txt
index c6aade7..5395d84 100644
--- a/krss/CMakeLists.txt
+++ b/krss/CMakeLists.txt
@@ -23,7 +23,6 @@ set(krss_LIB_SRCS
    helper.cpp
    feeditemmodel.cpp
 # ui stuff
-   ui/feedlistview.cpp
    ui/feedpropertiesdialog.cpp
 )
 
@@ -70,8 +69,6 @@ set(krss_LIB_HDRS
 )
 
 set(krss_UI_LIB_HDRS
-   ui/feedlistview.h
-   ui/netfeedcreatedialog.h
    ui/feedpropertiesdialog.h
 )
 
diff --git a/krss/ui/feedlistview.cpp b/krss/ui/feedlistview.cpp
deleted file mode 100644
index 6dd7e26..0000000
--- a/krss/ui/feedlistview.cpp
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
-    Copyright (C) 2008       Dmitry Ivanov <vonami@gmail.com>
-                  2007, 2009 Frank Osterfeld <osterfeld@kde.org>
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "feedlistview.h"
-#include "krss/feeditemmodel.h"
-
-#include <Akonadi/CollectionStatisticsDelegate>
-
-#include <KConfigGroup>
-#include <KLocalizedString>
-#include <KMenu>
-
-#include <QByteArray>
-#include <QHeaderView>
-#include <QMetaType>
-#include <QPointer>
-
-#include <cassert>
-
-using namespace KRss;
-using boost::shared_ptr;
-
-// helper functions
-static QModelIndex prevIndex( const QModelIndex&idx )
-{
-    if ( !idx.isValid() )
-        return QModelIndex();
-    const QAbstractItemModel* const model = idx.model();
-    assert( model );
-
-    if ( idx.row() > 0 ) {
-        QModelIndex i = idx.sibling( idx.row() - 1, idx.column() );
-        while ( model->hasChildren( i ) ) {
-            i = i.child( model->rowCount( i ) - 1, i.column() );
-        }
-        return i;
-    }
-    else
-        return idx.parent();
-}
-
-static QModelIndex prevFeedIndex( const QModelIndex& idx, bool allowPassed = false )
-{
-    QModelIndex prev = allowPassed ? idx : prevIndex( idx );
-    while ( prev.isValid() && prev.data( FeedItemModel::IsFolderRole ).toBool() ) {
-        prev = prevIndex( prev );
-    }
-    return prev;
-}
-
-static QModelIndex prevUnreadFeedIndex( const QModelIndex& idx, bool allowPassed = \
                false )
-{
-    QModelIndex prev = allowPassed ? idx : prevIndex( idx );
-    while ( prev.isValid() && ( prev.data( FeedItemModel::IsFolderRole ).toBool() ||
-            prev.sibling( prev.row(), FeedItemModel::UnreadCountColumn \
                ).data().toInt() == 0 ) ) {
-        prev = prevIndex( prev );
-    }
-    return prev;
-}
-
-static QModelIndex lastLeaveChild( const QAbstractItemModel* const model )
-{
-    assert( model );
-    if ( model->rowCount() == 0 )
-        return QModelIndex();
-    QModelIndex idx = model->index( model->rowCount() - 1, 0 );
-    while ( model->hasChildren( idx ) ) {
-        idx = idx.child( model->rowCount( idx ) - 1, idx.column() );
-    }
-    return idx;
-}
-
-static QModelIndex nextIndex( const QModelIndex& idx )
-{
-    if ( !idx.isValid() )
-        return QModelIndex();
-    const QAbstractItemModel* const model = idx.model();
-    assert( model );
-    if ( model->hasChildren( idx ) )
-        return idx.child( 0, idx.column() );
-    QModelIndex i = idx;
-    while ( true ) {
-        if ( !i.isValid() )
-            return i;
-        const int siblings = model->rowCount( i.parent() );
-        if ( i.row() + 1 < siblings )
-            return i.sibling( i.row() + 1, i.column() );
-        i = i.parent();
-    }
-}
-
-static QModelIndex nextFeedIndex( const QModelIndex& idx )
-{
-    QModelIndex next = nextIndex( idx );
-    while ( next.isValid() && next.data( FeedItemModel::IsFolderRole ).toBool() ) {
-        next = nextIndex( next );
-    }
-    return next;
-}
-
-static QModelIndex nextUnreadFeedIndex( const QModelIndex& idx )
-{
-    QModelIndex next = nextIndex( idx );
-    while ( next.isValid() && ( next.data( FeedItemModel::IsFolderRole ).toBool() ||
-            next.sibling( next.row(), FeedItemModel::UnreadCountColumn \
                ).data().toInt() == 0 ) ) {
-        next = nextIndex( next );
-    }
-    return next;
-}
-
-class KRss::FeedListView::Private
-{
-    FeedListView* const q;
-public:
-
-    explicit Private( FeedListView* );
-    ~Private() {
-        saveHeaderSettings();
-    }
-
-    QByteArray headerState;
-    KConfigGroup configGroup;
-
-    void loadHeaderSettings();
-    void saveHeaderSettings();
-    void slotClicked( const QModelIndex& index );
-    void slotActivated( const QModelIndex& index );
-    void showHeaderMenu( const QPoint& );
-    void headerMenuItemTriggered( QAction* action );
-
-};
-
-FeedListView::Private::Private( FeedListView* qq ) : q( qq )
-{
-}
-
-void FeedListView::Private::slotClicked( const QModelIndex &index )
-{
-#ifdef KRSS_PORT_REMOVED
-    emit q->clicked( q->model()->data( index, FeedItemModel::TreeNodeRole \
                ).value<shared_ptr<TreeNode> >() );
-#endif
-}
-
-void FeedListView::Private::slotActivated( const QModelIndex &index )
-{
-#ifdef KRSS_PORT_REMOVED
-    emit q->clicked( q->model()->data( index, FeedItemModel::TreeNodeRole \
                ).value<shared_ptr<TreeNode> >() );
-#endif
-}
-
-void FeedListView::Private::showHeaderMenu( const QPoint& pos )
-{
-    if( ! q->model() )
-        return;
-
-    QPointer<KMenu> menu = new KMenu( q );
-    menu->addTitle( i18n( "Columns" ) );
-    menu->setAttribute( Qt::WA_DeleteOnClose );
-    q->connect(menu, SIGNAL(triggered(QAction*)), q, \
                SLOT(headerMenuItemTriggered(QAction*)) );
-
-    for (int i = 0; i < q->model()->columnCount(); ++i)
-    {
-        const QString col = q->model()->headerData( i, Qt::Horizontal, \
                Qt::DisplayRole ).toString();
-        QAction* act = menu->addAction( col );
-        act->setCheckable( true );
-        act->setChecked( !q->header()->isSectionHidden( i ) );
-        act->setData( i );
-    }
-
-    menu->popup( q->header()->mapToGlobal( pos ) );
-}
-
-void FeedListView::Private::loadHeaderSettings()
-{
-    if ( !configGroup.isValid() )
-        return;
-    headerState = QByteArray::fromBase64( configGroup.readEntry( "FeedListHeaders" \
                ).toAscii() );
-    q->header()->restoreState( headerState );        // needed, even with Qt 4.5
-}
-
-void FeedListView::Private::saveHeaderSettings()
-{
-    if ( q->model() )
-        headerState = q->header()->saveState();
-    if ( configGroup.isValid() )
-        configGroup.writeEntry( "FeedListHeaders", headerState.toBase64() );
-}
-
-FeedListView::FeedListView( QWidget *parent )
-    :  Akonadi::EntityTreeView( parent ), d( new Private( this ) )
-{
-    setSelectionMode( QAbstractItemView::SingleSelection );
-    setSelectionBehavior( QAbstractItemView::SelectRows );
-    setAlternatingRowColors( true );
-    setContextMenuPolicy( Qt::CustomContextMenu );
-    setDragDropMode( QAbstractItemView::DragDrop );
-    setDropIndicatorShown( true );
-    setAcceptDrops( true );
-    setUniformRowHeights( true );
-    Akonadi::CollectionStatisticsDelegate* delegate = new \
                Akonadi::CollectionStatisticsDelegate( this );
-    delegate->setProgressAnimationEnabled( true );
-    delegate->setUnreadCountShown( true );
-    setItemDelegate( delegate );
-    connect( header(), SIGNAL(customContextMenuRequested(QPoint)), this, \
                SLOT(showHeaderMenu(QPoint)) );
-    connect( this, SIGNAL(clicked(QModelIndex)),
-             this, SLOT(slotClicked(QModelIndex)) );
-    connect( this, SIGNAL(activated(QModelIndex)),
-             this, SLOT( slotActivated(QModelIndex)) );
-
-    d->loadHeaderSettings();
-}
-
-KConfigGroup FeedListView::configGroup() const {
-    return d->configGroup;
-}
-
-void FeedListView::setConfigGroup( const KConfigGroup& g ) {
-    d->configGroup = g;
-    d->loadHeaderSettings();
-}
-
-FeedListView::~FeedListView()
-{
-    delete d;
-}
-
-void FeedListView::setModel( QAbstractItemModel* m )
-{
-    if ( model() )
-        d->headerState = header()->saveState();
-
-    EntityTreeView::setModel( m );
-
-    if ( m )
-        header()->restoreState( d->headerState );
-
-#ifdef KRSS_PORT_DISABLED
-    QStack<QModelIndex> stack;
-    stack.push( rootIndex() );
-    while ( !stack.isEmpty() )
-    {
-        const QModelIndex i = stack.pop();
-        const int childCount = m->rowCount( i );
-        for ( int j = 0; j < childCount; ++j )
-        {
-            const QModelIndex child = m->index( j, 0, i );
-            if ( child.isValid() )
-                stack.push( child );
-        }
-        setExpanded( i, i.data( Akregator::SubscriptionListModel::IsOpenRole \
                ).toBool() );
-    }
-#endif // KRSS_PORT_DISABLED
-
-    header()->setContextMenuPolicy( Qt::CustomContextMenu );
-}
-
-void FeedListView::Private::headerMenuItemTriggered( QAction* action )
-{
-    assert( action );
-    const int col = action->data().toInt();
-    if ( action->isChecked() )
-        q->header()->showSection( col );
-    else
-        q->header()->hideSection( col );
-}
-
-
-void FeedListView::slotPrevFeed()
-{
-    if ( !model() )
-        return;
-    const QModelIndex current = currentIndex();
-    QModelIndex prev = prevFeedIndex( current );
-    if ( !prev.isValid() )
-        prev = prevFeedIndex( lastLeaveChild( model() ), true );
-    if ( prev.isValid() )
-        setCurrentIndex( prev );
-}
-
-void FeedListView::slotNextFeed()
-{
-    if ( !model() )
-        return;
-    const QModelIndex current = currentIndex();
-    QModelIndex next = nextFeedIndex( current );
-    if ( !next.isValid() )
-        next = nextFeedIndex( model()->index( 0, 0 ) );
-    if ( next.isValid() )
-        setCurrentIndex( next );
-}
-
-void FeedListView::slotPrevUnreadFeed()
-{
-    if ( !model() )
-        return;
-    const QModelIndex current = currentIndex();
-    QModelIndex prev = prevUnreadFeedIndex( current );
-    if ( !prev.isValid() )
-        prev = prevUnreadFeedIndex( lastLeaveChild( model() ), true );
-    if ( prev.isValid() )
-        setCurrentIndex( prev );
-}
-
-void FeedListView::slotNextUnreadFeed()
-{
-    if ( !model() )
-        return;
-    const QModelIndex current = currentIndex();
-    QModelIndex next = nextUnreadFeedIndex( current );
-    if ( !next.isValid() )
-        next = nextUnreadFeedIndex( model()->index( 0, 0 ) );
-    if ( next.isValid() )
-        setCurrentIndex( next );
-}
-
-void FeedListView::scrollToCollection( const Akonadi::Collection& c, \
                QAbstractItemView::ScrollHint hint ) {
-    Q_UNUSED( c )
-    Q_UNUSED( hint )
-    //TODO
-}
-
-#include "feedlistview.moc"
diff --git a/krss/ui/feedlistview.h b/krss/ui/feedlistview.h
deleted file mode 100644
index cb0c19f..0000000
--- a/krss/ui/feedlistview.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
-    Copyright (C) 2008       Dmitry Ivanov <vonami@gmail.com>
-                  2007, 2009 Frank Osterfeld <osterfeld@kde.org>
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef KRSS_FEEDLISTVIEW_H
-#define KRSS_FEEDLISTVIEW_H
-
-#include "krss/krss_export.h"
-
-#include <Akonadi/EntityTreeView>
-
-#include <QtGui/QTreeView>
-
-class KConfigGroup;
-
-namespace Akonadi {
-    class Collection;
-}
-namespace KRss {
-
-class KRSS_EXPORT FeedListView : public Akonadi::EntityTreeView
-{
-    Q_OBJECT
-
-public:
-
-    explicit FeedListView( QWidget *parent = 0 );
-    ~FeedListView();
-
-    /* reimp */ void setModel( QAbstractItemModel* model );
-
-    KConfigGroup configGroup() const;
-    void setConfigGroup( const KConfigGroup& group);
-
-    void scrollToCollection( const Akonadi::Collection& c, \
                QAbstractItemView::ScrollHint hint=EnsureVisible );
-
-public Q_SLOTS:
-    void slotPrevFeed();
-    void slotNextFeed();
-    void slotPrevUnreadFeed();
-    void slotNextUnreadFeed();
-
-Q_SIGNALS:
-
-    void clicked( const Akonadi::Collection& );
-    void activated( const Akonadi::Collection& );
-
-private:
-    class Private;
-    Private* const d;
-    Q_PRIVATE_SLOT( d, void slotClicked( const QModelIndex& ) )
-    Q_PRIVATE_SLOT( d, void slotActivated( const QModelIndex& ) )
-    Q_PRIVATE_SLOT( d, void showHeaderMenu( const QPoint& ) )
-    Q_PRIVATE_SLOT( d, void headerMenuItemTriggered( QAction* ) )
-};
-
-} // namespace KRss
-
-#endif // KRSS_FEEDLISTVIEW_H


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic