[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdepimlibs/akregator_port] krss: show errors in the model: show warning icon if an error occurred,
From: Frank Osterfeld <frank.osterfeld () kdemail ! net>
Date: 2012-03-31 15:16:22
Message-ID: 20120331151622.03613A60E8 () git ! kde ! org
[Download RAW message or body]
Git commit 52f0b8eb046ac8d2c170b4ca1174d408ca67745a by Frank Osterfeld.
Committed on 06/10/2009 at 22:20.
Pushed by osterfeld into branch 'akregator_port'.
show errors in the model: show warning icon if an error occurred, show error string \
as tooltip.
svn path=/branches/work/akonadi-ports/kdepim/; revision=1032096
M +23 -2 krss/feed.cpp
M +20 -5 krss/feed.h
M +3 -1 krss/feed_p.h
M +43 -2 krss/feedlistmodel.cpp
M +1 -1 krss/resource.cpp
http://commits.kde.org/kdepimlibs/52f0b8eb046ac8d2c170b4ca1174d408ca67745a
diff --git a/krss/feed.cpp b/krss/feed.cpp
index 0b10ed3..001a67d 100644
--- a/krss/feed.cpp
+++ b/krss/feed.cpp
@@ -89,6 +89,21 @@ Feed::Feed( const FeedCollection& feedCollection, const \
shared_ptr<Resource>& re job->start();
}
+Feed::FetchError Feed::error() const
+{
+ return d->m_error;
+}
+
+bool Feed::hasError() const
+{
+ return d->m_error != NoError;
+}
+
+QString Feed::errorString() const
+{
+ return d->m_errorString;
+}
+
Feed::~Feed()
{
delete d;
@@ -250,18 +265,24 @@ void Feed::triggerFetchPercent( uint percentage )
void Feed::triggerFetchFinished()
{
+ d->m_error = NoError;
+ d->m_errorString.clear();
d->m_fetching = false;
emit fetchFinished( d->m_feedCollection.feedId() );
}
-void Feed::triggerFetchFailed( const QString& errorMessage )
+void Feed::triggerFetchFailed( FetchError error, const QString& errorMessage )
{
+ d->m_error = error;
+ d->m_errorString = errorMessage;
d->m_fetching = false;
- emit fetchFailed( d->m_feedCollection.feedId(), errorMessage );
+ emit fetchFailed( d->m_feedCollection.feedId() );
}
void Feed::triggerFetchAborted()
{
+ d->m_error = NoError;
+ d->m_errorString.clear();
d->m_fetching = false;
emit fetchAborted( d->m_feedCollection.feedId() );
}
diff --git a/krss/feed.h b/krss/feed.h
index da4bea1..fa8654b 100644
--- a/krss/feed.h
+++ b/krss/feed.h
@@ -34,7 +34,8 @@ class CollectionStatistics;
}
namespace KRss {
-
+class FeedModifyJobPrivate;
+class FeedDeleteJobPrivate;
class ConstFeedVisitor;
class Resource;
class FeedCollection;
@@ -53,6 +54,11 @@ class KRSS_EXPORT Feed : public QObject, public \
boost::enable_shared_from_this<F public:
typedef qint64 Id;
+ enum FetchError {
+ NoError=0,
+ SomeError //TODO be more specific :)
+ };
+
virtual ~Feed();
virtual void accept( FeedVisitor* ) = 0;
@@ -90,6 +96,15 @@ public:
bool isFetching() const;
+ /**
+ * returns a human-readable error message if the last fetch try resulted in an \
error, + * or an empty string otherwise.
+ */
+ QString errorString() const;
+
+ bool hasError() const;
+ FetchError error() const;
+
public Q_SLOTS:
virtual void fetch() const;
virtual void abortFetch() const;
@@ -98,7 +113,7 @@ Q_SIGNALS:
void fetchStarted( const KRss::Feed::Id& feedId );
void fetchPercent( const KRss::Feed::Id& feedId, uint percentage );
void fetchFinished( const KRss::Feed::Id& feedId );
- void fetchFailed( const KRss::Feed::Id& feedId, const QString &errorMessage );
+ void fetchFailed( const KRss::Feed::Id& feedId );
void fetchAborted( const KRss::Feed::Id& feedId );
void changed( const KRss::Feed::Id& feedId );
@@ -118,7 +133,7 @@ private:
void triggerFetchStarted();
void triggerFetchPercent( uint percentage );
void triggerFetchFinished();
- void triggerFetchFailed( const QString& errorMessage );
+ void triggerFetchFailed( FetchError error, const QString& errorMessage );
void triggerFetchAborted();
protected:
@@ -127,8 +142,8 @@ protected:
friend class ::KRss::Resource; // for trigger*Something
friend class ::KRss::FeedListPrivate;
- friend class FeedModifyJobPrivate;
- friend class FeedDeleteJobPrivate;
+ friend class ::KRss::FeedModifyJobPrivate;
+ friend class ::KRss::FeedDeleteJobPrivate;
friend class ::KRss::FeedPrivate;
friend class ::KRss::ItemListJobImpl;
friend class ::KRss::StatusModifyJobImpl;
diff --git a/krss/feed_p.h b/krss/feed_p.h
index decc300..423785e 100644
--- a/krss/feed_p.h
+++ b/krss/feed_p.h
@@ -46,7 +46,7 @@ public:
FeedPrivate( const FeedCollection& feedCollection, const boost::shared_ptr<const \
Resource>& resource, Feed *qq )
: q( qq ), m_feedCollection( feedCollection ), m_resource( resource ),
- m_unreadCount( 0 ), m_totalCount( 0 ), m_fetching( false )
+ m_unreadCount( 0 ), m_totalCount( 0 ), m_fetching( false ), m_error( \
Feed::NoError) {
}
@@ -69,6 +69,8 @@ public:
int m_totalCount;
bool m_fetching;
QIcon m_icon;
+ QString m_errorString;
+ Feed::FetchError m_error;
};
class ItemListJobImpl : public ItemListJob {
diff --git a/krss/feedlistmodel.cpp b/krss/feedlistmodel.cpp
index d8976fd..ef9f180 100644
--- a/krss/feedlistmodel.cpp
+++ b/krss/feedlistmodel.cpp
@@ -108,13 +108,46 @@ namespace {
void visit( const boost::shared_ptr<const FeedNode>& feedNode ) {
const boost::shared_ptr<const Feed> feed = m_feedList->constFeedById( \
feedNode->feedId() );
- m_icon = feed->icon().pixmap( KIconLoader::SizeSmall, feed->isFetching() \
? QIcon::Active : QIcon::Normal ); + if ( feed->isFetching() ) {
+ m_icon = feed->icon().pixmap( KIconLoader::SizeSmall, QIcon::Active \
); + } else {
+ if ( !feed->hasError() )
+ m_icon = feed->icon().pixmap( KIconLoader::SizeSmall, \
QIcon::Normal ); + else
+ m_icon = KIcon( "dialog-warning" ).pixmap( \
KIconLoader::SizeSmall ); + }
}
const shared_ptr<const FeedList> m_feedList;
QPixmap m_icon;
};
+ class ToolTipVisitor : public ConstTreeNodeVisitor
+ {
+ public:
+ ToolTipVisitor( const shared_ptr<const FeedList> feedList )
+ : m_feedList( feedList ) {}
+
+ void visit( const boost::shared_ptr<const RootNode>& r ) {
+ m_toolTip = r->title( m_feedList );
+ }
+
+ void visit( const boost::shared_ptr<const TagNode>& tagNode ) {
+ m_toolTip = tagNode->title( m_feedList );
+ }
+
+ void visit( const boost::shared_ptr<const FeedNode>& feedNode ) {
+ const boost::shared_ptr<const Feed> feed = m_feedList->constFeedById( \
feedNode->feedId() ); + if ( feed->isFetching() || !feed->hasError() )
+ m_toolTip = feed->title();
+ else
+ m_toolTip = feed->errorString();
+ }
+
+ const shared_ptr<const FeedList> m_feedList;
+ QString m_toolTip;
+ };
+
class CreateChildIndexVisitor : public TreeNodeVisitor
{
public:
@@ -503,7 +536,15 @@ QVariant FeedListModel::data(const QModelIndex &index, int role \
) const treeNode->accept( &visitor );
return visitor.m_icon;
}
- case Qt::ToolTipRole: return treeNode->title( d->m_feedList );
+ case Qt::ToolTipRole:
+ {
+ if ( index.column() != TitleColumn )
+ return QVariant();
+
+ ToolTipVisitor visitor( d->m_feedList );
+ treeNode->accept( &visitor );
+ return visitor.m_toolTip;
+ }
case HasUnreadRole: return treeNode->unreadCount( d->m_feedList ) > 0;
case TreeNodeRole: return QVariant::fromValue( treeNode );
case IsTagRole: return treeNode->tier() == TreeNode::TagTier;
diff --git a/krss/resource.cpp b/krss/resource.cpp
index 3aa5bfc..c68bd6a 100644
--- a/krss/resource.cpp
+++ b/krss/resource.cpp
@@ -113,7 +113,7 @@ void Resource::triggerFetchFailed( const KRss::Feed::Id& feedId, \
const QString & emit fetchFailed( d_ptr->m_id, feedId, errorMessage );
const QPointer<Feed> feed = d_ptr->m_feeds.value( feedId );
if ( feed )
- feed->triggerFetchFailed( errorMessage );
+ feed->triggerFetchFailed( Feed::SomeError, errorMessage );
}
void Resource::triggerFetchAborted( const KRss::Feed::Id& feedId )
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic