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

List:       kde-commits
Subject:    [kdepim/akregator_port] akregator2/src: Port unread count
From:       Frank Osterfeld <frank.osterfeld () kdab ! com>
Date:       2012-03-04 19:20:26
Message-ID: 20120304192026.3F402A60C4 () git ! kde ! org
[Download RAW message or body]

Git commit 34f3c2de1986216f3a9297aeb6fbb3a50611e50b by Frank Osterfeld.
Committed on 04/03/2012 at 20:19.
Pushed by osterfeld into branch 'akregator_port'.

Port unread count

M  +16   -18   akregator2/src/articleformatter.cpp
M  +4    -3    akregator2/src/articleformatter.h
M  +2    -14   akregator2/src/articleviewer.cpp
M  +1    -2    akregator2/src/articleviewer.h
M  +6    -3    akregator2/src/mainwidget.cpp

http://commits.kde.org/kdepim/34f3c2de1986216f3a9297aeb6fbb3a50611e50b

diff --git a/akregator2/src/articleformatter.cpp \
b/akregator2/src/articleformatter.cpp index 1c464b9..c39ee95 100644
--- a/akregator2/src/articleformatter.cpp
+++ b/akregator2/src/articleformatter.cpp
@@ -27,6 +27,7 @@
 #include "utils.h"
 
 #include <Akonadi/Collection>
+#include <Akonadi/CollectionStatistics>
 
 #include <krss/feedcollection.h>
 #include <krss/enclosure.h>
@@ -113,35 +114,32 @@ int ArticleFormatter::pointsToPixel(int pointSize) const
     return ( pointSize * d->device->logicalDpiY() + 36 ) / 72 ;
 }
 
-static QString formatFolderSummary( const Collection& c ) {
+static QString formatFolderSummary( const Collection& c, int unread ) {
     const QString title = FeedCollection( c ).title();
     QString text = QString::fromLatin1("<div class=\"headerbox\" \
                dir=\"%1\">\n").arg(QApplication::isRightToLeft() ? "rtl" : "ltr");
     text += QString::fromLatin1("<div class=\"headertitle\" \
                dir=\"%1\">%2").arg(Utils::directionOf(Utils::stripTags(title)), \
                title);
-#ifdef KRSS_PORT_DISABLED
-    if(node->unread() == 0)
+
+    if(unread == 0)
         text += i18n(" (no unread articles)");
     else
-        text += i18np(" (1 unread article)", " (%1 unread articles)", \
                node->unread());
-#else
-    kWarning() << "Code temporarily disabled (Akonadi port)";
-#endif //KRSS_PORT_DISABLED
+        text += i18np(" (1 unread article)", " (%1 unread articles)", unread);
     text += QString("</div>\n");
     text += "</div>\n"; // /headerbox
     return text;
 }
 
-static QString formatFeedSummary( const FeedCollection& feed, const KUrl& imageDir ) \
{ +static QString formatFeedSummary( const FeedCollection& feed, int unread, const \
KUrl& imageDir ) {  
     QString text = QString("<div class=\"headerbox\" \
dir=\"%1\">\n").arg(QApplication::isRightToLeft() ? "rtl" : "ltr");  
     text += QString("<div class=\"headertitle\" \
dir=\"%1\">").arg(Utils::directionOf(Utils::stripTags(feed.title())));  text += \
                feed.title();
-#ifdef KRSS_PORT_DISABLED
-    if(node->unread() == 0)
+
+    if(unread == 0)
         text += i18n(" (no unread articles)");
     else
-        text += i18np(" (1 unread article)", " (%1 unread articles)", \
                node->unread());
-#endif
+        text += i18np(" (1 unread article)", " (%1 unread articles)", unread);
+
     text += "</div>\n"; // headertitle
     text += "</div>\n"; // /headerbox
 
@@ -178,12 +176,12 @@ static QString formatFeedSummary( const FeedCollection& feed, \
const KUrl& imageD  return text;
 }
 
-static QString formatCollectionSummary( const Collection& c, const KUrl& imageDir ) \
{ +static QString formatCollectionSummary( const Collection& c, int unread, const \
KUrl& imageDir ) {  FeedCollection fc;
     if ( fc.isFolder() )
-        return formatFolderSummary( c );
+        return formatFolderSummary( c, unread );
     else
-        return formatFeedSummary( fc, imageDir );
+        return formatFeedSummary( fc, unread, imageDir );
 }
 
 QString DefaultNormalViewFormatter::formatItem( const KRss::Item& item, IconOption \
icon) const @@ -527,12 +525,12 @@ QString DefaultCombinedViewFormatter::getCss() \
const  return css;
 }
 
-QString DefaultNormalViewFormatter::formatSummary( const Akonadi::Collection& c ) \
const +QString DefaultNormalViewFormatter::formatSummary( const Akonadi::Collection& \
c, int unread ) const  {
-    return formatCollectionSummary( c, m_imageDir );
+    return formatCollectionSummary( c, unread, m_imageDir );
 }
 
-QString DefaultCombinedViewFormatter::formatSummary( const Akonadi::Collection& ) \
const +QString DefaultCombinedViewFormatter::formatSummary( const \
Akonadi::Collection&, int ) const  {
     return QString();
 }
diff --git a/akregator2/src/articleformatter.h b/akregator2/src/articleformatter.h
index db41736..60919dd 100644
--- a/akregator2/src/articleformatter.h
+++ b/akregator2/src/articleformatter.h
@@ -39,6 +39,7 @@ namespace KRss {
 namespace Akonadi {
     class Collection;
 }
+
 namespace Akregator2 {
 
 class ArticleFormatter
@@ -58,7 +59,7 @@ class ArticleFormatter
 
         virtual QString formatItem( const KRss::Item& item, IconOption icon ) const \
= 0;  
-        virtual QString formatSummary( const Akonadi::Collection& collection ) const \
= 0; +        virtual QString formatSummary( const Akonadi::Collection& collection, \
int unread ) const = 0;  
         virtual QString getCss() const = 0;
 
@@ -81,7 +82,7 @@ class DefaultNormalViewFormatter : public ArticleFormatter
 
         QString formatItem( const KRss::Item& item, IconOption option ) const;
 
-        /* reimp */ QString formatSummary( const Akonadi::Collection& collection ) \
const; +        /* reimp */ QString formatSummary( const Akonadi::Collection& \
collection, int unread ) const;  
         QString getCss() const;
 
@@ -102,7 +103,7 @@ class DefaultCombinedViewFormatter : public ArticleFormatter
 
         QString formatItem( const KRss::Item& item, IconOption option ) const;
 
-        /* reimp */ QString formatSummary( const Akonadi::Collection& ) const;
+        /* reimp */ QString formatSummary( const Akonadi::Collection& collection, \
int unread ) const;  
         QString getCss() const;
 
diff --git a/akregator2/src/articleviewer.cpp b/akregator2/src/articleviewer.cpp
index 319d7c1..aca2c86 100644
--- a/akregator2/src/articleviewer.cpp
+++ b/akregator2/src/articleviewer.cpp
@@ -87,7 +87,6 @@ ArticleViewer::ArticleViewer(QWidget *parent)
       m_htmlFooter(),
       m_currentText(),
       m_imageDir( KUrl::fromPath( KGlobal::dirs()->saveLocation("cache", \
                "akregator2/Media/" ) ) ),
-      m_collectionId(0),
       m_viewMode(NormalView),
       m_part( new ArticleViewerPart( this ) ),
       m_model( 0 ),
@@ -481,7 +480,7 @@ void ArticleViewer::endWriting()
 }
 
 
-void ArticleViewer::slotShowSummary( const Akonadi::Collection& c )
+void ArticleViewer::slotShowSummary( const Akonadi::Collection& c, int unread )
 {
     m_viewMode = SummaryView;
 
@@ -491,18 +490,7 @@ void ArticleViewer::slotShowSummary( const Akonadi::Collection& \
c )  return;
     }
 
-    if ( c.id() == m_collectionId )
-    {
-    #ifdef KRSS_PORT_DISABLED
-        disconnectFromNode(m_node);
-        connectToNode(node);
-    #else
-        kWarning() << "Code temporarily disabled (Akonadi port)";
-    #endif //KRSS_PORT_DISABLED
-        m_collectionId = c.id();
-    }
-
-    QString summary = m_normalViewFormatter->formatSummary( c );
+    QString summary = m_normalViewFormatter->formatSummary( c, unread );
     m_link.clear();
     renderContent(summary);
 
diff --git a/akregator2/src/articleviewer.h b/akregator2/src/articleviewer.h
index 04a4599..9a8b4b0 100644
--- a/akregator2/src/articleviewer.h
+++ b/akregator2/src/articleviewer.h
@@ -98,7 +98,7 @@ class ArticleViewer : public QWidget
          */
         void slotClear();
 
-        void slotShowSummary( const Akonadi::Collection& );
+        void slotShowSummary( const Akonadi::Collection& collection, int unreadCount \
);  
         void slotPaletteOrFontChanged();
 
@@ -190,7 +190,6 @@ class ArticleViewer : public QWidget
         QString m_currentText;
         KUrl m_imageDir;
         KUrl m_link;
-        Akonadi::Collection::Id m_collectionId;
         enum ViewMode { NormalView, CombinedView, SummaryView };
         ViewMode m_viewMode;
         ArticleViewerPart* m_part;
diff --git a/akregator2/src/mainwidget.cpp b/akregator2/src/mainwidget.cpp
index 0f4359a..c74d3e2 100644
--- a/akregator2/src/mainwidget.cpp
+++ b/akregator2/src/mainwidget.cpp
@@ -464,7 +464,8 @@ void Akregator2::MainWidget::slotNormalView()
         if ( !item.isNull() )
             m_articleViewer->showItem( item );
         else
-            m_articleViewer->slotShowSummary( \
m_selectionController->selectedCollection() ); +            \
m_articleViewer->slotShowSummary( m_selectionController->selectedCollection(), +      \
m_selectionController->selectedCollectionIndex().data( \
Akonadi::EntityTreeModel::UnreadCountRole ).toInt() );  }
 
     m_articleSplitter->setOrientation(Qt::Vertical);
@@ -487,7 +488,8 @@ void Akregator2::MainWidget::slotWidescreenView()
         if ( !item.isNull() )
             m_articleViewer->showItem( item );
         else
-            m_articleViewer->slotShowSummary( \
m_selectionController->selectedCollection() ); +            \
m_articleViewer->slotShowSummary( m_selectionController->selectedCollection(), +      \
m_selectionController->selectedCollectionIndex().data( \
Akonadi::EntityTreeModel::UnreadCountRole ).toInt() );  }
     m_articleSplitter->setOrientation(Qt::Horizontal);
     m_viewMode = WidescreenView;
@@ -514,6 +516,7 @@ void Akregator2::MainWidget::slotNodeSelected(const \
Akonadi::Collection& c)  {
     m_markReadTimer->stop();
 
+    const int unread = m_selectionController->selectedCollectionIndex().data( \
Akonadi::EntityTreeModel::UnreadCountRole ).toInt();  if (m_displayingAboutPage)
     {
         m_mainFrame->slotSetTitle(i18n("Articles"));
@@ -534,7 +537,7 @@ void Akregator2::MainWidget::slotNodeSelected(const \
Akonadi::Collection& c)  }
     else
     {
-        m_articleViewer->slotShowSummary( c );
+        m_articleViewer->slotShowSummary( c, unread );
     }
 
     if ( c.isValid() )


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

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