27 #include "actionmanagerimpl.h"
28 #include "akregator_part.h"
29 #include "akregator_run.h"
30 #include "akregator_view.h"
31 #include "listtabwidget.h"
32 #include "addfeeddialog.h"
33 #include "propertiesdialog.h"
35 #include "fetchqueue.h"
36 #include "feedlistview.h"
37 #include "articlelistview.h"
38 #include "articleviewer.h"
41 #include "tagfolder.h"
44 #include "akregatorconfig.h"
46 #include "pageviewer.h"
47 #include "searchbar.h"
48 #include "speechclient.h"
50 #include "tabwidget.h"
54 #include "tagnodelist.h"
55 #include "tagpropertiesdialog.h"
57 #include "progressmanager.h"
58 #include "treenodevisitor.h"
59 #include "notificationmanager.h"
62 #include <kapplication.h>
63 #include <kcharsets.h>
64 #include <kcombobox.h>
68 #include <kfiledialog.h>
69 #include <kfileitem.h>
70 #include <khtml_part.h>
71 #include <khtmlview.h>
72 #include <kiconloader.h>
73 #include <kinputdialog.h>
74 #include <klineedit.h>
75 #include <klistview.h>
77 #include <kmessagebox.h>
82 #include <kstandarddirs.h>
84 #include <kxmlguifactory.h>
85 #include <kparts/partmanager.h>
87 #include <tqbuttongroup.h>
88 #include <tqcheckbox.h>
89 #include <tqdatetime.h>
94 #include <tqmultilineedit.h>
95 #include <tqpopupmenu.h>
96 #include <tqptrlist.h>
97 #include <tqstylesheet.h>
98 #include <tqtextstream.h>
100 #include <tqtoolbutton.h>
101 #include <tqtooltip.h>
102 #include <tqvaluevector.h>
103 #include <tqwhatsthis.h>
104 #include <tqclipboard.h>
106 namespace Akregator {
108 class View::EditNodePropertiesVisitor :
public TreeNodeVisitor
111 EditNodePropertiesVisitor(
View* view) : m_view(view) {}
113 virtual bool visitTagNode(TagNode* node)
115 TagPropertiesDialog* dlg =
new TagPropertiesDialog(m_view);
116 dlg->setTag(node->tag());
122 virtual bool visitFolder(Folder* node)
124 m_view->m_listTabWidget->activeView()->startNodeRenaming(node);
128 virtual bool visitFeed(Feed* node)
130 FeedPropertiesDialog *dlg =
new FeedPropertiesDialog( m_view,
"edit_feed" );
141 class View::DeleteNodeVisitor :
public TreeNodeVisitor
144 DeleteNodeVisitor(
View* view) : m_view(view) {}
146 virtual bool visitTagNode(TagNode* node)
148 TQString msg = i18n(
"<qt>Are you sure you want to delete tag <b>%1</b>? The tag will be removed from all articles.</qt>").arg(node->title());
149 if (KMessageBox::warningContinueCancel(0, msg, i18n(
"Delete Tag"), KStdGuiItem::del()) == KMessageBox::Continue)
151 Tag tag = node->tag();
152 TQValueList<Article> articles = m_view->m_feedList->rootNode()->articles(tag.id());
153 node->setNotificationMode(
false);
154 for (TQValueList<Article>::Iterator it = articles.begin(); it != articles.end(); ++it)
155 (*it).removeTag(tag.id());
156 node->setNotificationMode(
true);
157 Kernel::self()->tagSet()->remove(tag);
158 m_view->m_listTabWidget->activeView()->setFocus();
163 virtual bool visitFolder(Folder* node)
166 if (node->title().isEmpty())
167 msg = i18n(
"<qt>Are you sure you want to delete this folder and its feeds and subfolders?</qt>");
169 msg = i18n(
"<qt>Are you sure you want to delete folder <b>%1</b> and its feeds and subfolders?</qt>").arg(node->title());
171 if (KMessageBox::warningContinueCancel(0, msg, i18n(
"Delete Folder"), KStdGuiItem::del()) == KMessageBox::Continue)
174 m_view->m_listTabWidget->activeView()->setFocus();
179 virtual bool visitFeed(Feed* node)
182 if (node->title().isEmpty())
183 msg = i18n(
"<qt>Are you sure you want to delete this feed?</qt>");
185 msg = i18n(
"<qt>Are you sure you want to delete feed <b>%1</b>?</qt>").arg(node->title());
187 if (KMessageBox::warningContinueCancel(0, msg, i18n(
"Delete Feed"), KStdGuiItem::del()) == KMessageBox::Continue)
190 m_view->m_listTabWidget->activeView()->setFocus();
207 kdDebug() <<
"View::~View(): slotOnShutdown() wasn't called. Calling it now." << endl;
210 kdDebug() <<
"View::~View(): leaving" << endl;
214 : TQWidget(parent, name), m_viewMode(NormalView), m_actionManager(actionManager)
216 m_editNodePropertiesVisitor =
new EditNodePropertiesVisitor(
this);
217 m_deleteNodeVisitor =
new DeleteNodeVisitor(
this);
218 m_keepFlagIcon = TQPixmap(locate(
"data",
"akregator/pics/akregator_flag.png"));
221 m_tagNodeList =
new TagNodeList(m_feedList, Kernel::self()->tagSet());
222 m_shuttingDown =
false;
223 m_displayingAboutPage =
false;
225 setFocusPolicy(TQ_StrongFocus);
227 TQVBoxLayout *lt =
new TQVBoxLayout(
this );
229 m_horizontalSplitter =
new TQSplitter(Qt::Horizontal,
this);
231 m_horizontalSplitter->setOpaqueResize(
true);
232 lt->addWidget(m_horizontalSplitter);
235 connect (Kernel::self()->fetchQueue(), TQT_SIGNAL(signalStarted()),
this, TQT_SLOT(slotFetchingStarted()));
236 connect (Kernel::self()->fetchQueue(), TQT_SIGNAL(signalStopped()),
this, TQT_SLOT(slotFetchingStopped()));
238 connect(Kernel::self()->tagSet(), TQT_SIGNAL(signalTagAdded(
const Tag&)),
this, TQT_SLOT(slotTagCreated(
const Tag&)));
239 connect(Kernel::self()->tagSet(), TQT_SIGNAL(signalTagRemoved(
const Tag&)),
this, TQT_SLOT(slotTagRemoved(
const Tag&)));
242 m_actionManager->initListTabWidget(m_listTabWidget);
246 if (!Settings::showTaggingGUI())
247 m_listTabWidget->setViewMode(ListTabWidget::single);
249 m_feedListView =
new NodeListView(
this,
"feedtree" );
250 m_listTabWidget->addView(m_feedListView, i18n(
"Feeds"), KGlobal::iconLoader()->loadIcon(
"folder", KIcon::Small));
254 connect(m_feedListView, TQT_SIGNAL(signalDropped (KURL::List &,
TreeNode*,
258 m_tagNodeListView =
new NodeListView(
this);
259 m_listTabWidget->addView(m_tagNodeListView, i18n(
"Tags"), KGlobal::iconLoader()->loadIcon(
"rss_tag", KIcon::Small));
264 ProgressManager::self()->setFeedList(m_feedList);
266 m_tabs =
new TabWidget(m_horizontalSplitter);
267 m_actionManager->initTabWidget(m_tabs);
269 connect( m_part, TQT_SIGNAL(signalSettingsChanged()), m_tabs, TQT_SLOT(slotSettingsChanged()));
271 connect( m_tabs, TQT_SIGNAL( currentFrameChanged(Frame *) ),
this,
274 TQWhatsThis::add(m_tabs, i18n(
"You can view multiple articles in several open tabs."));
276 m_mainTab =
new TQWidget(
this,
"Article Tab");
277 TQVBoxLayout *mainTabLayout =
new TQVBoxLayout( m_mainTab, 0, 2,
"mainTabLayout");
279 TQWhatsThis::add(m_mainTab, i18n(
"Articles list."));
281 m_searchBar =
new SearchBar(m_mainTab);
283 if ( !Settings::showQuickFilter() )
286 mainTabLayout->addWidget(m_searchBar);
288 m_articleSplitter =
new TQSplitter(Qt::Vertical, m_mainTab,
"panner2");
290 m_articleList =
new ArticleListView( m_articleSplitter,
"articles" );
291 m_actionManager->initArticleListView(m_articleList);
293 connect( m_articleList, TQT_SIGNAL(signalMouseButtonPressed(
int,
const Article&,
const TQPoint &,
int)),
this, TQT_SLOT(
slotMouseButtonPressed(
int,
const Article&,
const TQPoint &,
int)));
296 connect( m_articleList, TQT_SIGNAL(signalArticleChosen(
const Article&)),
298 connect( m_articleList, TQT_SIGNAL(signalDoubleClicked(
const Article&,
const TQPoint&,
int)),
301 m_articleViewer =
new ArticleViewer(m_articleSplitter,
"article_viewer");
302 m_articleViewer->setSafeMode();
304 m_actionManager->initArticleViewer(m_articleViewer);
310 connect( m_articleViewer, TQT_SIGNAL(urlClicked(
const KURL&, Viewer*,
bool,
bool)),
313 connect( m_articleViewer->browserExtension(), TQT_SIGNAL(mouseOverInfo(
const KFileItem *)),
316 connect( m_part, TQT_SIGNAL(signalSettingsChanged()), m_articleViewer, TQT_SLOT(slotPaletteOrFontChanged()));
317 TQWhatsThis::add(m_articleViewer->widget(), i18n(
"Browsing area."));
318 mainTabLayout->addWidget( m_articleSplitter );
320 m_mainFrame=
new Frame(TQT_TQOBJECT(
this), m_part, m_mainTab, i18n(
"Articles"),
false);
321 connectFrame(m_mainFrame);
322 m_tabs->addFrame(m_mainFrame);
324 const TQValueList<int> sp1sizes = Settings::splitter1Sizes();
325 if ( sp1sizes.count() >= m_horizontalSplitter->sizes().count() )
326 m_horizontalSplitter->setSizes( sp1sizes );
327 const TQValueList<int> sp2sizes = Settings::splitter2Sizes();
328 if ( sp2sizes.count() >= m_articleSplitter->sizes().count() )
329 m_articleSplitter->setSizes( sp2sizes );
331 KConfig *conf = Settings::self()->config();
332 conf->setGroup(
"General");
333 if(!conf->readBoolEntry(
"Disable Introduction",
false))
335 m_articleList->hide();
337 m_articleViewer->displayAboutPage();
338 m_mainFrame->setTitle(i18n(
"About"));
339 m_displayingAboutPage =
true;
342 m_fetchTimer =
new TQTimer(
this);
343 connect( m_fetchTimer, TQT_SIGNAL(timeout()),
this, TQT_SLOT(slotDoIntervalFetches()) );
344 m_fetchTimer->start(1000*60);
347 m_expiryTimer =
new TQTimer(
this);
348 connect(m_expiryTimer, TQT_SIGNAL(timeout()),
this,
349 TQT_SLOT(slotDeleteExpiredArticles()) );
350 m_expiryTimer->start(3600*1000);
352 m_markReadTimer =
new TQTimer(
this);
355 switch (Settings::viewMode())
367 if (!Settings::resetQuickFilterOnNodeChange())
369 m_searchBar->slotSetStatus(Settings::statusFilter());
370 m_searchBar->slotSetText(Settings::textFilter());
373 TQTimer::singleShot(1000,
this, TQT_SLOT(slotDeleteExpiredArticles()) );
377 void View::slotSettingsChanged()
380 m_listTabWidget->setViewMode(Settings::showTaggingGUI() ? ListTabWidget::verticalTabs : ListTabWidget::single);
384 void View::slotOnShutdown()
386 m_shuttingDown =
true;
388 m_articleList->slotShowNode(0);
391 Kernel::self()->fetchQueue()->slotAbort();
393 m_feedListView->setNodeList(0);
394 ProgressManager::self()->setFeedList(0);
397 delete m_tagNodeList;
401 m_tabs->setCurrentPage(m_tabs->count()-1);
402 while (m_tabs->count() > 1)
403 m_tabs->slotRemoveCurrentFrame();
407 delete m_editNodePropertiesVisitor;
408 delete m_deleteNodeVisitor;
413 const TQValueList<int> spl1 = m_horizontalSplitter->sizes();
414 if ( spl1.contains( 0 ) == 0 )
415 Settings::setSplitter1Sizes( spl1 );
416 const TQValueList<int> spl2 = m_articleSplitter->sizes();
417 if ( spl2.contains( 0 ) == 0 )
418 Settings::setSplitter2Sizes( spl2 );
419 Settings::setViewMode( m_viewMode );
420 Settings::writeConfig();
425 PageViewer* page =
new PageViewer(
this,
"page");
427 connect( m_part, TQT_SIGNAL(signalSettingsChanged()), page, TQT_SLOT(slotPaletteOrFontChanged()));
429 connect( page, TQT_SIGNAL(setTabIcon(
const TQPixmap&)),
430 this, TQT_SLOT(setTabIcon(
const TQPixmap&)));
431 connect( page, TQT_SIGNAL(urlClicked(
const KURL &, Viewer*,
bool,
bool)),
434 Frame* frame =
new Frame(TQT_TQOBJECT(
this), page, page->widget(), i18n(
"Untitled"));
435 frame->setAutoDeletePart(
true);
437 connect(page, TQT_SIGNAL(setWindowCaption (
const TQString &)), frame, TQT_SLOT(setTitle (
const TQString &)));
439 m_tabs->addFrame(frame);
442 m_tabs->showPage(page->widget());
450 void View::setTabIcon(
const TQPixmap& icon)
452 const PageViewer *s =
dynamic_cast<const PageViewer*
>(sender());
454 m_tabs->setTabIconSet(const_cast<PageViewer*>(s)->widget(), icon);
458 void View::connectFrame(Frame *f)
460 connect(f, TQT_SIGNAL(statusText(
const TQString &)),
this, TQT_SLOT(
slotStatusText(
const TQString&)));
461 connect(f, TQT_SIGNAL(captionChanged (
const TQString &)),
this, TQT_SLOT(
slotCaptionChanged (
const TQString &)));
462 connect(f, TQT_SIGNAL(loadingProgress(
int)),
this, TQT_SLOT(slotLoadingProgress(
int)) );
463 connect(f, TQT_SIGNAL(started()),
this, TQT_SLOT(slotStarted()));
464 connect(f, TQT_SIGNAL(completed()),
this, TQT_SLOT(slotCompleted()));
465 connect(f, TQT_SIGNAL(canceled(
const TQString &)),
this, TQT_SLOT(slotCanceled(
const TQString&)));
470 if (sender() == m_currentFrame)
471 emit setStatusBarText(c);
476 if (sender() == m_currentFrame)
477 emit setWindowCaption(c);
480 void View::slotStarted()
482 if (sender() == m_currentFrame)
483 emit signalStarted(0);
486 void View::slotCanceled(
const TQString &s)
488 if (sender() == m_currentFrame)
489 emit signalCanceled(s);
492 void View::slotCompleted()
494 if (sender() == m_currentFrame)
495 emit signalCompleted();
498 void View::slotLoadingProgress(
int percent)
500 if (sender() == m_currentFrame)
501 emit setProgress(percent);
515 TQString title = feedList->title();
518 title = i18n(
"Imported Folder");
521 title = KInputDialog::getText(i18n(
"Add Imported Folder"), i18n(
"Imported folder name:"), title, &ok);
530 m_feedList->rootNode()->appendChild(fg);
531 m_feedList->
append(feedList, fg);
547 m_feedListView->setUpdatesEnabled(
false);
548 m_tagNodeListView->setUpdatesEnabled(
false);
551 TagSet* tagSet = Kernel::self()->tagSet();
553 Kernel::self()->setFeedList(feedList);
554 ProgressManager::self()->setFeedList(feedList);
555 disconnectFromFeedList(m_feedList);
557 delete m_tagNodeList;
558 m_feedList = feedList;
559 connectToFeedList(m_feedList);
561 m_tagNodeList =
new TagNodeList(m_feedList, tagSet);
562 m_feedListView->setNodeList(m_feedList);
563 m_tagNodeListView->setNodeList(m_tagNodeList);
565 TQStringList tagIDs = m_feedList->rootNode()->tags();
566 TQStringList::ConstIterator end = tagIDs.end();
567 for (TQStringList::ConstIterator it = tagIDs.begin(); it != end; ++it)
569 kdDebug() << *it << endl;
581 m_feedList->
append(feedList, parent);
583 m_feedListView->setUpdatesEnabled(
true);
584 m_feedListView->triggerUpdate();
585 m_tagNodeListView->setUpdatesEnabled(
true);
586 m_tagNodeListView->triggerUpdate();
590 void View::slotDeleteExpiredArticles()
592 TreeNode* rootNode = m_feedList->rootNode();
599 return m_feedList->
toXML();
606 TreeNode* node = m_feedListView->findNodeByTitle(groupName);
612 m_feedList->rootNode()->appendChild(g);
616 group =
static_cast<Folder*
>(node);
620 addFeed(url, 0, group,
true);
625 if (m_viewMode == NormalView)
628 if (m_viewMode == CombinedView)
630 m_articleList->slotShowNode(m_listTabWidget->activeView()->selectedNode());
631 m_articleList->show();
633 Article article = m_articleList->currentArticle();
635 if (!article.isNull())
638 m_articleViewer->slotShowSummary(m_listTabWidget->activeView()->selectedNode());
641 m_articleSplitter->setOrientation(Qt::Vertical);
642 m_viewMode = NormalView;
644 Settings::setViewMode( m_viewMode );
649 if (m_viewMode == WidescreenView)
652 if (m_viewMode == CombinedView)
654 m_articleList->slotShowNode(m_listTabWidget->activeView()->selectedNode());
655 m_articleList->show();
657 Article article = m_articleList->currentArticle();
659 if (!article.isNull())
662 m_articleViewer->slotShowSummary(m_listTabWidget->activeView()->selectedNode());
665 m_articleSplitter->setOrientation(Qt::Horizontal);
666 m_viewMode = WidescreenView;
668 Settings::setViewMode( m_viewMode );
673 if (m_viewMode == CombinedView)
676 m_articleList->slotClear();
677 m_articleList->hide();
678 m_viewMode = CombinedView;
681 Settings::setViewMode( m_viewMode );
691 emit setWindowCaption(f->caption());
692 emit setProgress(f->progress());
693 emit setStatusBarText(f->statusText());
695 if (f->part() == m_part)
700 f->widget()->setFocus();
705 emit signalStarted(0);
707 case Frame::Canceled:
708 emit signalCanceled(TQString());
711 case Frame::Completed:
713 emit signalCompleted();
719 m_tabs->showPage(m_mainTab);
722 void View::slotMoveCurrentNodeUp()
724 TreeNode* current = m_listTabWidget->activeView()->selectedNode();
730 if (!prev || !parent)
735 m_listTabWidget->activeView()->ensureNodeVisible(current);
738 void View::slotMoveCurrentNodeDown()
740 TreeNode* current = m_listTabWidget->activeView()->selectedNode();
743 TreeNode* next = current->nextSibling();
744 Folder* parent = current->
parent();
746 if (!next || !parent)
750 parent->insertChild(current, next);
751 m_listTabWidget->activeView()->ensureNodeVisible(current);
754 void View::slotMoveCurrentNodeLeft()
756 TreeNode* current = m_listTabWidget->activeView()->selectedNode();
757 if (!current || !current->parent() || !current->parent()->parent())
760 Folder* parent = current->parent();
761 Folder* grandparent = current->parent()->parent();
763 parent->removeChild(current);
764 grandparent->insertChild(current, parent);
765 m_listTabWidget->activeView()->ensureNodeVisible(current);
768 void View::slotMoveCurrentNodeRight()
770 TreeNode* current = m_listTabWidget->activeView()->selectedNode();
771 if (!current || !current->parent())
775 if ( prev && prev->isGroup() )
777 Folder* fg =
static_cast<Folder*
>(prev);
779 fg->appendChild(current);
780 m_listTabWidget->activeView()->ensureNodeVisible(current);
786 m_markReadTimer->stop();
790 kdDebug() <<
"node selected: " << node->
title() << endl;
791 kdDebug() <<
"unread: " << node->
unread() << endl;
792 kdDebug() <<
"total: " << node->
totalCount() << endl;
795 if (m_displayingAboutPage)
797 m_mainFrame->setTitle(i18n(
"Articles"));
798 if (m_viewMode != CombinedView)
799 m_articleList->show();
800 if (Settings::showQuickFilter())
802 m_displayingAboutPage =
false;
805 m_tabs->showPage(m_mainTab);
807 if (Settings::resetQuickFilterOnNodeChange())
808 m_searchBar->slotClearSearch();
810 if (m_viewMode == CombinedView)
814 m_articleList->slotShowNode(node);
815 m_articleViewer->slotShowSummary(node);
819 m_mainFrame->setCaption(node->
title());
821 m_actionManager->slotNodeSelected(node);
826 void View::slotOpenURL(
const KURL& url, Viewer* currentViewer, BrowserRun::OpeningMode mode)
828 if (mode == BrowserRun::EXTERNAL)
829 Viewer::displayInExternalBrowser(url);
832 KParts::URLArgs args = currentViewer ? currentViewer->browserExtension()->urlArgs() : KParts::URLArgs();
834 BrowserRun* r =
new BrowserRun(
this, currentViewer, url, args, mode);
835 connect(r, TQT_SIGNAL(signalOpenInViewer(
const KURL&, Akregator::Viewer*, Akregator::BrowserRun::OpeningMode)),
836 this, TQT_SLOT(
slotOpenURLReply(
const KURL&, Akregator::Viewer*, Akregator::BrowserRun::OpeningMode)));
846 slotOpenURL(url, viewer, BrowserRun::CURRENT_TAB);
850 slotOpenURL(url, 0L, background ? BrowserRun::NEW_TAB_BACKGROUND : BrowserRun::NEW_TAB_FOREGROUND);
859 case BrowserRun::CURRENT_TAB:
860 currentViewer->openURL(url);
862 case BrowserRun::NEW_TAB_FOREGROUND:
863 case BrowserRun::NEW_TAB_BACKGROUND:
866 case BrowserRun::EXTERNAL:
867 Viewer::displayInExternalBrowser(url);
875 if (!m_feedListView->selectedNode())
876 group = m_feedList->rootNode();
880 if ( m_feedListView->selectedNode()->isGroup())
881 group = static_cast<Folder*>(m_feedListView->selectedNode());
883 group= m_feedListView->selectedNode()->parent();
889 addFeed(TQString(), lastChild, group,
false);
892 void View::addFeed(
const TQString& url,
TreeNode *after,
Folder* parent,
bool autoExec)
895 AddFeedDialog *afd =
new AddFeedDialog( 0,
"add_feed" );
897 afd->setURL(KURL::decode_string(url));
903 if (afd->exec() != TQDialog::Accepted)
910 Feed* feed = afd->feed;
913 FeedPropertiesDialog *dlg =
new FeedPropertiesDialog( 0,
"edit_feed" );
916 dlg->selectFeedName();
919 if (dlg->exec() != TQDialog::Accepted)
927 parent = m_feedList->rootNode();
931 m_feedListView->ensureNodeVisible(feed);
939 TreeNode* node = m_feedListView->selectedNode();
943 node = m_feedListView->rootNode();
957 TQString text = KInputDialog::getText(i18n(
"Add Folder"), i18n(
"Folder name:"),
"", &Ok);
967 m_feedListView->ensureNodeVisible(newGroup);
973 TreeNode* selectedNode = m_listTabWidget->activeView()->selectedNode();
976 if (!selectedNode || selectedNode == m_feedList->rootNode())
979 m_deleteNodeVisitor->visit(selectedNode);
984 TreeNode* node = m_listTabWidget->activeView()->selectedNode();
986 m_editNodePropertiesVisitor->visit(node);
992 if (m_viewMode == CombinedView)
993 m_listTabWidget->activeView()->slotNextUnreadFeed();
995 TreeNode* sel = m_listTabWidget->activeView()->selectedNode();
996 if (sel && sel->
unread() > 0)
997 m_articleList->slotNextUnreadArticle();
999 m_listTabWidget->activeView()->slotNextUnreadFeed();
1004 if (m_viewMode == CombinedView)
1005 m_listTabWidget->activeView()->slotPrevUnreadFeed();
1007 TreeNode* sel = m_listTabWidget->activeView()->selectedNode();
1008 if (sel && sel->
unread() > 0)
1009 m_articleList->slotPreviousUnreadArticle();
1011 m_listTabWidget->activeView()->slotPrevUnreadFeed();
1016 m_feedList->rootNode()->slotMarkAllArticlesAsRead();
1021 if(!m_listTabWidget->activeView()->selectedNode())
return;
1022 m_listTabWidget->activeView()->selectedNode()->slotMarkAllArticlesAsRead();
1027 Feed* feed =
dynamic_cast<Feed *
>(m_listTabWidget->activeView()->selectedNode());
1032 KURL url = KURL(feed->
htmlUrl())
1034 switch (Settings::lMBBehaviour())
1036 case Settings::EnumLMBBehaviour::OpenInExternalBrowser:
1037 slotOpenURL(url, 0, BrowserRun::EXTERNAL);
1039 case Settings::EnumLMBBehaviour::OpenInBackground:
1040 slotOpenURL(url, 0, BrowserRun::NEW_TAB_BACKGROUND);
1043 slotOpenURL(url, 0, BrowserRun::NEW_TAB_FOREGROUND);
1052 void View::slotDoIntervalFetches()
1054 m_feedList->rootNode()->slotAddToFetchQueue(Kernel::self()->fetchQueue(),
true);
1059 if ( !m_listTabWidget->activeView()->selectedNode() )
1061 m_listTabWidget->activeView()->selectedNode()->slotAddToFetchQueue(Kernel::self()->fetchQueue());
1066 m_feedList->rootNode()->slotAddToFetchQueue(Kernel::self()->fetchQueue());
1069 void View::slotFetchingStarted()
1071 m_mainFrame->setState(Frame::Started);
1072 m_actionManager->action(
"feed_stop")->setEnabled(
true);
1073 m_mainFrame->setStatusText(i18n(
"Fetching Feeds..."));
1076 void View::slotFetchingStopped()
1078 m_mainFrame->setState(Frame::Completed);
1079 m_actionManager->action(
"feed_stop")->setEnabled(
false);
1080 m_mainFrame->setStatusText(TQString());
1088 TQValueList<Article> articles = feed->
articles();
1089 TQValueList<Article>::ConstIterator it;
1090 TQValueList<Article>::ConstIterator end = articles.end();
1091 for (it = articles.begin(); it != end; ++it)
1093 if ((*it).status()==Article::New && ((*it).feed()->useNotification() || Settings::useNotifications()))
1103 if (button == Qt::MidButton)
1105 KURL link = article.link();
1106 switch (Settings::mMBBehaviour())
1108 case Settings::EnumMMBBehaviour::OpenInExternalBrowser:
1109 slotOpenURL(link, 0L, BrowserRun::EXTERNAL);
1111 case Settings::EnumMMBBehaviour::OpenInBackground:
1112 slotOpenURL(link, 0L, BrowserRun::NEW_TAB_BACKGROUND);
1115 slotOpenURL(link, 0L, BrowserRun::NEW_TAB_FOREGROUND);
1120 void View::slotAssignTag(
const Tag& tag,
bool assign)
1122 kdDebug() << (assign ?
"assigned" :
"removed") <<
" tag \"" << tag.id() <<
"\"" << endl;
1123 TQValueList<Article> selectedArticles = m_articleList->selectedArticles();
1124 for (TQValueList<Article>::Iterator it = selectedArticles.begin(); it != selectedArticles.end(); ++it)
1127 (*it).addTag(tag.id());
1129 (*it).removeTag(tag.id());
1144 void View::slotNewTag()
1146 Tag tag(KApplication::randomString(8),
"New Tag");
1147 Kernel::self()->tagSet()->insert(tag);
1148 TagNode* node = m_tagNodeList->findByTagID(tag.id());
1150 m_tagNodeListView->startNodeRenaming(node);
1153 void View::slotTagCreated(
const Tag& tag)
1155 if (m_tagNodeList && !m_tagNodeList->containsTagId(tag.id()))
1157 TagNode* tagNode =
new TagNode(tag, m_feedList->rootNode());
1158 m_tagNodeList->rootNode()->appendChild(tagNode);
1162 void View::slotTagRemoved(
const Tag& )
1168 if (m_viewMode == CombinedView)
1171 m_markReadTimer->stop();
1173 Feed *feed = article.feed();
1178 if (a.status() != Article::Read)
1182 if ( Settings::useMarkReadDelay() )
1184 delay = Settings::markReadDelay();
1187 m_markReadTimer->start( delay*1000,
true );
1189 a.setStatus(Article::Read);
1193 KToggleAction* maai =
dynamic_cast<KToggleAction*
>(m_actionManager->action(
"article_set_status_important"));
1194 maai->setChecked(a.
keep());
1196 kdDebug() <<
"selected: " << a.guid() << endl;
1205 if (!article.isNull())
1206 Viewer::displayInExternalBrowser(article.link());
1212 Article article = m_articleList->currentArticle();
1214 if (article.isNull())
1218 if (article.link().isValid())
1219 link = article.link();
1220 else if (article.guidIsPermaLink())
1221 link = KURL(article.guid());
1225 slotOpenURL(link, 0L, BrowserRun::NEW_TAB_FOREGROUND);
1236 Article article = m_articleList->currentArticle();
1238 if (article.isNull())
1243 if (article.link().isValid())
1244 link = article.link();
1245 else if (article.guidIsPermaLink())
1246 link = KURL(article.guid());
1250 slotOpenURL(link, 0L, BrowserRun::NEW_TAB_BACKGROUND);
1256 Article article = m_articleList->currentArticle();
1258 if(article.isNull())
1262 if (article.link().isValid() || (article.guidIsPermaLink() && KURL(article.guid()).isValid()))
1265 if (article.link().isValid())
1266 link = article.link().url();
1268 link = article.guid();
1269 TQClipboard *cb = TQApplication::clipboard();
1270 cb->setText(link, TQClipboard::Clipboard);
1271 cb->setText(link, TQClipboard::Selection);
1277 KURL::List::iterator it;
1278 for ( it = urls.begin(); it != urls.end(); ++it )
1280 addFeed((*it).prettyURL(), after, parent,
false);
1286 if ( Settings::showQuickFilter() )
1288 Settings::setShowQuickFilter(
false);
1289 m_searchBar->slotClearSearch();
1290 m_searchBar->hide();
1294 Settings::setShowQuickFilter(
true);
1295 if (!m_displayingAboutPage)
1296 m_searchBar->show();
1304 if ( m_viewMode == CombinedView )
1307 TQValueList<Article> articles = m_articleList->selectedArticles();
1310 switch (articles.count())
1315 msg = i18n(
"<qt>Are you sure you want to delete article <b>%1</b>?</qt>").arg(TQStyleSheet::escape(articles.first().title()));
1318 msg = i18n(
"<qt>Are you sure you want to delete the selected article?</qt>",
1319 "<qt>Are you sure you want to delete the %n selected articles?</qt>",
1323 if (KMessageBox::warningContinueCancel(0, msg, i18n(
"Delete Article"), KStdGuiItem::del()) == KMessageBox::Continue)
1325 if (m_listTabWidget->activeView()->selectedNode())
1326 m_listTabWidget->activeView()->selectedNode()->setNotificationMode(
false);
1328 TQValueList<Feed*> feeds;
1329 for (TQValueList<Article>::Iterator it = articles.begin(); it != articles.end(); ++it)
1331 Feed* feed = (*it).feed();
1332 if (!feeds.contains(feed))
1338 for (TQValueList<Feed*>::Iterator it = feeds.begin(); it != feeds.end(); ++it)
1340 (*it)->setNotificationMode(
true);
1343 if (m_listTabWidget->activeView()->selectedNode())
1344 m_listTabWidget->activeView()->selectedNode()->setNotificationMode(
true);
1351 TQValueList<Article> articles = m_articleList->selectedArticles();
1353 if (articles.isEmpty())
1356 bool allFlagsSet =
true;
1357 for (TQValueList<Article>::Iterator it = articles.begin(); allFlagsSet && it != articles.end(); ++it)
1359 allFlagsSet =
false;
1361 for (TQValueList<Article>::Iterator it = articles.begin(); it != articles.end(); ++it)
1362 (*it).setKeep(!allFlagsSet);
1367 TQValueList<Article> articles = m_articleList->selectedArticles();
1369 if (articles.isEmpty())
1372 for (TQValueList<Article>::Iterator it = articles.begin(); it != articles.end(); ++it)
1373 (*it).setStatus(Article::Read);
1378 if (m_currentFrame == m_mainFrame)
1380 if (m_viewMode != CombinedView)
1383 SpeechClient::self()->slotSpeak(m_articleList->selectedArticles());
1388 if (m_listTabWidget->activeView()->selectedNode())
1396 TQString selectedText =
static_cast<PageViewer *
>(m_currentFrame->part())->selectedText();
1398 if (!selectedText.isEmpty())
1399 SpeechClient::self()->slotSpeak(selectedText,
"en");
1405 TQValueList<Article> articles = m_articleList->selectedArticles();
1407 if (articles.isEmpty())
1410 for (TQValueList<Article>::Iterator it = articles.begin(); it != articles.end(); ++it)
1411 (*it).setStatus(Article::Unread);
1416 TQValueList<Article> articles = m_articleList->selectedArticles();
1418 if (articles.isEmpty())
1421 for (TQValueList<Article>::Iterator it = articles.begin(); it != articles.end(); ++it)
1422 (*it).setStatus(Article::New);
1427 Article article = m_articleList->currentArticle();
1429 if (article.isNull())
1432 article.setStatus(Article::Read);
1439 KFileItem *k=(KFileItem*)kifi;
1440 m_mainFrame->setStatusText(k->url().prettyURL());
1444 m_mainFrame->setStatusText(TQString());
1451 if (!Settings::resetQuickFilterOnNodeChange())
1453 m_searchBar->slotSetText(config->readEntry(
"searchLine"));
1454 int statusfilter = config->readNumEntry(
"searchCombo", -1);
1455 if (statusfilter != -1)
1456 m_searchBar->slotSetStatus(statusfilter);
1459 int selectedID = config->readNumEntry(
"selectedNodeID", -1);
1460 if (selectedID != -1)
1462 TreeNode* selNode = m_feedList->findByID(selectedID);
1464 m_listTabWidget->activeView()->setSelectedNode(selNode);
1467 TQStringList urls = config->readListEntry(
"FeedBrowserURLs");
1468 TQStringList::ConstIterator it = urls.begin();
1469 for (; it != urls.end(); ++it)
1471 KURL url = KURL::fromPathOrURL(*it);
1477 void View::saveProperties(KConfig* config)
1480 config->writeEntry(
"searchLine", m_searchBar->text());
1481 config->writeEntry(
"searchCombo", m_searchBar->status());
1483 TreeNode* sel = m_listTabWidget->activeView()->selectedNode();
1487 config->writeEntry(
"selectedNodeID", sel->
id() );
1492 TQPtrList<Frame> frames = m_tabs->frames();
1493 TQPtrList<Frame>::ConstIterator it = frames.begin();
1494 for (; it != frames.end(); ++it)
1497 KParts::ReadOnlyPart *part = frame->part();
1498 PageViewer *pageViewer =
dynamic_cast<PageViewer*
>(part);
1501 KURL url = pageViewer->url();
1503 urls.append(url.prettyURL());
1507 config->writeEntry(
"FeedBrowserURLs", urls);
1510 void View::connectToFeedList(FeedList* feedList)
1512 connect(feedList->rootNode(), TQT_SIGNAL(signalChanged(TreeNode*)),
this, TQT_SLOT(
slotSetTotalUnread()));
1516 void View::disconnectFromFeedList(FeedList* feedList)
1518 disconnect(feedList->rootNode(), TQT_SIGNAL(signalChanged(TreeNode*)),
this, TQT_SLOT(
slotSetTotalUnread()));
1521 void View::updateTagActions()
1525 TQValueList<Article> selectedArticles = m_articleList->selectedArticles();
1527 for (TQValueList<Article>::ConstIterator it = selectedArticles.begin(); it != selectedArticles.end(); ++it)
1529 TQStringList atags = (*it).tags();
1530 for (TQStringList::ConstIterator it2 = atags.begin(); it2 != atags.end(); ++it2)
1532 if (!tags.contains(*it2))
1541 #include "akregator_view.moc"