26 #include <tqstylesheet.h>
28 #include <tdelocale.h>
29 #include <kstaticdeleter.h>
31 #include <libtdepim/progressmanager.h>
37 #include "progressmanager.h"
43 class ProgressManager::ProgressManagerPrivate
47 TQMap<Feed*, ProgressItemHandler*> handlers;
51 static KStaticDeleter<ProgressManager> progressmanagersd;
52 ProgressManager* ProgressManager::m_self = 0;
54 ProgressManager* ProgressManager::self()
57 m_self = progressmanagersd.setObject(m_self,
new ProgressManager);
61 ProgressManager::ProgressManager() : d(new ProgressManagerPrivate)
66 ProgressManager::~ProgressManager()
72 void ProgressManager::setFeedList(
FeedList* feedList)
74 if (feedList == d->feedList)
79 for (TQMap<Feed*, ProgressItemHandler*>::ConstIterator it = d->handlers.begin(); it != d->handlers.end(); ++it)
83 disconnect(d->feedList, TQ_SIGNAL(signalNodeAdded(
TreeNode*)),
this, TQ_SLOT(slotNodeAdded(
TreeNode*)));
84 disconnect(d->feedList, TQ_SIGNAL(signalNodeRemoved(
TreeNode*)),
this, TQ_SLOT(slotNodeRemoved(
TreeNode*)));
87 d->feedList = feedList;
91 TQValueList<TreeNode*> list = feedList->asFlatList();
93 for (TQValueList<TreeNode*>::ConstIterator it = list.begin(); it != list.end(); ++it)
95 connect(feedList, TQ_SIGNAL(signalNodeAdded(
TreeNode*)),
this, TQ_SLOT(slotNodeAdded(
TreeNode*)));
96 connect(feedList, TQ_SIGNAL(signalNodeRemoved(
TreeNode*)),
this, TQ_SLOT(slotNodeRemoved(
TreeNode*)));
100 void ProgressManager::slotNodeAdded(
TreeNode* node)
102 Feed* feed =
dynamic_cast<Feed*
>(node);
105 if (!d->handlers.contains(feed))
107 connect(feed, TQ_SIGNAL(signalDestroyed(
TreeNode*)),
this, TQ_SLOT(slotNodeDestroyed(
TreeNode*)));
111 void ProgressManager::slotNodeRemoved(TreeNode* node)
113 Feed* feed =
dynamic_cast<Feed*
>(node);
116 disconnect(feed, TQ_SIGNAL(signalDestroyed(TreeNode*)),
this, TQ_SLOT(slotNodeDestroyed(TreeNode*)));
117 delete d->handlers[feed];
118 d->handlers.remove(feed);
122 void ProgressManager::slotNodeDestroyed(TreeNode* node)
124 Feed* feed =
dynamic_cast<Feed*
>(node);
127 delete d->handlers[feed];
128 d->handlers.remove(feed);
132 class ProgressItemHandler::ProgressItemHandlerPrivate
137 KPIM::ProgressItem* progressItem;
140 ProgressItemHandler::ProgressItemHandler(Feed* feed) : d(new ProgressItemHandlerPrivate)
145 connect(feed, TQ_SIGNAL(fetchStarted(Feed*)),
this, TQ_SLOT(slotFetchStarted()));
146 connect(feed, TQ_SIGNAL(fetched(Feed*)),
this, TQ_SLOT(slotFetchCompleted()));
147 connect(feed, TQ_SIGNAL(fetchError(Feed*)),
this, TQ_SLOT(slotFetchError()));
148 connect(feed, TQ_SIGNAL(fetchAborted(Feed*)),
this, TQ_SLOT(slotFetchAborted()));
151 ProgressItemHandler::~ProgressItemHandler()
155 d->progressItem->setComplete();
163 void ProgressItemHandler::slotFetchStarted()
167 d->progressItem->setComplete();
171 d->progressItem = KPIM::ProgressManager::createProgressItem(KPIM::ProgressManager::getUniqueID(), TQStyleSheet::escape( d->feed->title() ), TQString(),
true);
173 connect(d->progressItem, TQ_SIGNAL(progressItemCanceled(KPIM::ProgressItem*)), d->feed, TQ_SLOT(slotAbortFetch()));
177 void ProgressItemHandler::slotFetchCompleted()
181 d->progressItem->setStatus(i18n(
"Fetch completed"));
182 d->progressItem->setComplete();
187 void ProgressItemHandler::slotFetchError()
191 d->progressItem->setStatus(i18n(
"Fetch error"));
192 d->progressItem->setComplete();
197 void ProgressItemHandler::slotFetchAborted()
201 d->progressItem->setStatus(i18n(
"Fetch aborted"));
202 d->progressItem->setComplete();
209 #include "progressmanager.moc"
The model of a feed tree, represents an OPML document.
this class handles the creation and deletion of progress items for one feed.
Abstract base class for all kind of elements in the feed tree, like feeds and feed groups (and search...