summaryrefslogtreecommitdiffstats
path: root/konq-plugins/sidebar/newsticker
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit84da08d7b7fcda12c85caeb5a10b4903770a6f69 (patch)
tree2a6aea76f2dfffb4cc04bb907c4725af94f70e72 /konq-plugins/sidebar/newsticker
downloadtdeaddons-84da08d7b7fcda12c85caeb5a10b4903770a6f69.tar.gz
tdeaddons-84da08d7b7fcda12c85caeb5a10b4903770a6f69.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeaddons@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'konq-plugins/sidebar/newsticker')
-rw-r--r--konq-plugins/sidebar/newsticker/Makefile.am36
-rw-r--r--konq-plugins/sidebar/newsticker/README38
-rw-r--r--konq-plugins/sidebar/newsticker/configfeeds.cpp38
-rw-r--r--konq-plugins/sidebar/newsticker/configfeeds.h53
-rw-r--r--konq-plugins/sidebar/newsticker/configfeedsbase.ui26
-rw-r--r--konq-plugins/sidebar/newsticker/konq_sidebarnews.kcfg15
-rw-r--r--konq-plugins/sidebar/newsticker/news_add.desktop44
-rw-r--r--konq-plugins/sidebar/newsticker/norsswidget.cpp100
-rw-r--r--konq-plugins/sidebar/newsticker/norsswidget.h51
-rw-r--r--konq-plugins/sidebar/newsticker/nspanel.cpp181
-rw-r--r--konq-plugins/sidebar/newsticker/nspanel.h109
-rw-r--r--konq-plugins/sidebar/newsticker/nsstacktabwidget.cpp365
-rw-r--r--konq-plugins/sidebar/newsticker/nsstacktabwidget.h91
-rw-r--r--konq-plugins/sidebar/newsticker/pics/LICENSE16
-rw-r--r--konq-plugins/sidebar/newsticker/pics/Makefile.am1
-rw-r--r--konq-plugins/sidebar/newsticker/pics/cr16-app-konqsidebar_news.pngbin0 -> 759 bytes
-rw-r--r--konq-plugins/sidebar/newsticker/pics/livemark-item.pngbin0 -> 3449 bytes
-rw-r--r--konq-plugins/sidebar/newsticker/sidebar_news.cpp279
-rw-r--r--konq-plugins/sidebar/newsticker/sidebar_news.h89
-rw-r--r--konq-plugins/sidebar/newsticker/sidebarsettings.kcfgc5
20 files changed, 1537 insertions, 0 deletions
diff --git a/konq-plugins/sidebar/newsticker/Makefile.am b/konq-plugins/sidebar/newsticker/Makefile.am
new file mode 100644
index 0000000..4dc9fae
--- /dev/null
+++ b/konq-plugins/sidebar/newsticker/Makefile.am
@@ -0,0 +1,36 @@
+SUBDIRS = . pics
+
+AM_CPPFLAGS = $(all_includes)
+METASOURCES = AUTO
+
+
+
+################################
+# these are the headers for your project
+noinst_HEADERS = nspanel.h nsstacktabwidget.h sidebar_news.h norsswidget.h
+
+kde_module_LTLIBRARIES = konq_sidebarnews.la
+
+# the Part's source, library search path, and link libraries
+konq_sidebarnews_la_SOURCES = sidebar_news.cpp sidebar_news.skel nsstacktabwidget.cpp \
+ nspanel.cpp nspanel.skel norsswidget.cpp \
+ sidebarsettings.kcfgc \
+ configfeedsbase.ui configfeeds.cpp
+konq_sidebarnews_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+konq_sidebarnews_la_LIBADD = $(LIB_KPARTS) $(LIB_KFILE) -lkonqsidebarplugin
+
+
+globaladddir = $(kde_datadir)/konqsidebartng/add
+globaladd_DATA = news_add.desktop
+
+kde_kcfg_DATA = konq_sidebarnews.kcfg
+
+
+
+############################
+#
+# i18n
+#
+messages: rc.cpp
+ $(XGETTEXT) *.cpp -o $(podir)/konqsidebar_news.pot
+
diff --git a/konq-plugins/sidebar/newsticker/README b/konq-plugins/sidebar/newsticker/README
new file mode 100644
index 0000000..65d15e6
--- /dev/null
+++ b/konq-plugins/sidebar/newsticker/README
@@ -0,0 +1,38 @@
+Konqsidebarnews is based on the rss DCOP service in
+kdenetwork/dcoprss. So you most likely you want to
+install it before using the sidebar applet.
+
+
+
+TODO
+====
+
+- better handling of starting up rssservice
+
+- less crashes (check for stupid user input, etc...)
+
+- cleanly recover from a crashing dcop service
+
+- documentation
+
+- accessibility aware UI
+
+- integration with kdenetwork/knewsticker
+
+
+
+THANKS TO
+=========
+
+- Joseph Wenningen (jowenn@kde.org)
+ idea and original code
+
+- Frerich Raabe (raabe@kde.org)
+ for kdenonbeta/librss where all the magic happens
+
+- Ian Reinhard Geiser (geiseri@kde.org)
+ for maintaining the DCOP service
+
+
+---
+Marcus Camen <mcamen@mcamen.de>
diff --git a/konq-plugins/sidebar/newsticker/configfeeds.cpp b/konq-plugins/sidebar/newsticker/configfeeds.cpp
new file mode 100644
index 0000000..c682ab3
--- /dev/null
+++ b/konq-plugins/sidebar/newsticker/configfeeds.cpp
@@ -0,0 +1,38 @@
+// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8; -*-
+
+/***************************************************************************
+ configfeeds.cpp
+ Copyright: Marcus Camen <mcamen@mcamen.de>
+ Copyright: Nathan Toone <nathan@toonetown.com>
+***************************************************************************/
+
+/*
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "sidebarsettings.h"
+#include "configfeeds.h"
+
+
+namespace KSB_News {
+
+ConfigFeeds::ConfigFeeds(QWidget* parent, const char* name) : ConfigFeedsBase(parent, name)
+{
+}
+
+} // namespace KSB_News
+
+#include "configfeeds.moc"
diff --git a/konq-plugins/sidebar/newsticker/configfeeds.h b/konq-plugins/sidebar/newsticker/configfeeds.h
new file mode 100644
index 0000000..555b4f5
--- /dev/null
+++ b/konq-plugins/sidebar/newsticker/configfeeds.h
@@ -0,0 +1,53 @@
+// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8; -*-
+
+/***************************************************************************
+ configfeeds.h
+ Copyright: Marcus Camen <mcamen@mcamen.de>
+ Copyright: Nathan Toone <nathan@toonetown.com>
+***************************************************************************/
+
+/*
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _konq_sidebar_news_configfeedsh_
+#define _konq_sidebar_news_configfeedsh_
+
+#include "configfeedsbase.h"
+
+
+//
+//
+// ATM this is just a noop wrapper
+//
+//
+
+
+namespace KSB_News {
+
+ class ConfigFeeds : public ConfigFeedsBase {
+
+ Q_OBJECT
+
+ public:
+ ConfigFeeds(QWidget* parent, const char* name = 0);
+
+ };
+
+} // namespace KSB_News
+
+
+#endif
diff --git a/konq-plugins/sidebar/newsticker/configfeedsbase.ui b/konq-plugins/sidebar/newsticker/configfeedsbase.ui
new file mode 100644
index 0000000..8389747
--- /dev/null
+++ b/konq-plugins/sidebar/newsticker/configfeedsbase.ui
@@ -0,0 +1,26 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>ConfigFeedsBase</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>ConfigFeedsBase</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KEditListBox">
+ <property name="name">
+ <cstring>kcfg_Sources</cstring>
+ </property>
+ <property name="title">
+ <string>RSS Feeds</string>
+ </property>
+ </widget>
+ </vbox>
+</widget>
+<layoutdefaults spacing="6" margin="0"/>
+<includehints>
+ <includehint>keditlistbox.h</includehint>
+ <includehint>klineedit.h</includehint>
+</includehints>
+</UI>
diff --git a/konq-plugins/sidebar/newsticker/konq_sidebarnews.kcfg b/konq-plugins/sidebar/newsticker/konq_sidebarnews.kcfg
new file mode 100644
index 0000000..7641ab2
--- /dev/null
+++ b/konq-plugins/sidebar/newsticker/konq_sidebarnews.kcfg
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+ <kcfgfile name="konq_sidebarnewsrc"/>
+
+ <group name="RSS sources">
+ <entry name="Sources" type="StringList">
+ <label>List of RSS Sources</label>
+ <default>http://www.kde.org/dotkdeorg.rdf</default>
+ </entry>
+ </group>
+
+</kcfg>
diff --git a/konq-plugins/sidebar/newsticker/news_add.desktop b/konq-plugins/sidebar/newsticker/news_add.desktop
new file mode 100644
index 0000000..989abf3
--- /dev/null
+++ b/konq-plugins/sidebar/newsticker/news_add.desktop
@@ -0,0 +1,44 @@
+[Desktop Entry]
+Type=Link
+URL=
+Icon=konqsidebar_news
+Name=Newsticker
+Name[bs]=News Ticker
+Name[ca]=Teletip de notícies
+Name[da]=Nyhedstelegraf
+Name[eo]=Novaĵprezentilo
+Name[es]=Teletipo de noticias
+Name[et]=Uudistejälgija
+Name[fi]=Uutisnäyttäjä
+Name[fr]=Téléscripteur de nouvelles
+Name[gl]=Notícias
+Name[he]=מציג חדשות
+Name[hi]=न्यूज़टिकर
+Name[hr]=Obavijesti o novostima
+Name[hu]=Hírmegjelenítő
+Name[is]=Fréttastrimill
+Name[it]=NewsTicker
+Name[ja]=ニュースティッカー
+Name[ka]=სიახლეთა მიმღები
+Name[lt]=Naujienų pranešiklis
+Name[nb]=Nyhetstelegraf
+Name[nds]=Narichtentelegraaf
+Name[ne]=न्यूजटिकर
+Name[nn]=Nyhendetelegraf
+Name[pa]=ਖ਼ਬਰਸਾਰ
+Name[pl]=Pasek wiadomości
+Name[pt]=Notícias
+Name[pt_BR]=Mostrador de Notícias
+Name[ru]=Индикатор новостей
+Name[sk]=Sledovanie správ
+Name[sl]=Prikazovalnik novic
+Name[sv]=Nyhetsövervakare
+Name[ta]=புதிய நகரும் செய்தி
+Name[tr]=Haber Bandı
+Name[uk]=Стрічка новин
+Name[vi]=Bộ theo dõi tin tức
+Name[zh_CN]=新闻点点通
+Open=false
+X-KDE-KonqSidebarAddModule=konq_sidebarnews
+X-KDE-KonqSidebarUniversal=true
+TryExec=rssservice
diff --git a/konq-plugins/sidebar/newsticker/norsswidget.cpp b/konq-plugins/sidebar/newsticker/norsswidget.cpp
new file mode 100644
index 0000000..d4c803a
--- /dev/null
+++ b/konq-plugins/sidebar/newsticker/norsswidget.cpp
@@ -0,0 +1,100 @@
+// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8; -*-
+
+/***************************************************************************
+ norsswidget.cpp
+ Copyright: Marcus Camen <mcamen@mcamen.de>
+***************************************************************************/
+
+/*
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <qlayout.h>
+#include <qsizepolicy.h>
+#include <dcopref.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kpushbutton.h>
+#include <kdebug.h>
+#include <kconfigdialog.h>
+#include "sidebarsettings.h"
+#include "configfeeds.h"
+#include "norsswidget.h"
+
+
+namespace KSB_News {
+
+ NoRSSWidget::NoRSSWidget(QWidget *parent, const char *name)
+ : QWidget(parent, name) {
+
+ QVBoxLayout *topLayout = new QVBoxLayout(this);
+
+ topLayout->addStretch();
+
+ KPushButton *btn = new KPushButton(i18n("&Configure"), this);
+ btn->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
+ connect(btn, SIGNAL(clicked()), this, SLOT(slotBtnClicked()));
+ topLayout->addWidget(btn, 0, Qt::AlignHCenter);
+
+ topLayout->addStretch();
+ }
+
+
+ void NoRSSWidget::slotBtnClicked() {
+ // An instance of your dialog could be already created and could be
+ // cached, in which case you want to display the cached dialog
+ // instead of creating another one
+ if (KConfigDialog::showDialog("settings"))
+ return;
+
+ // KConfigDialog didn't find an instance of this dialog, so lets create it
+ m_confdlg = new KConfigDialog(this, "settings", SidebarSettings::self(),
+ KDialogBase::Plain,
+ KDialogBase::Ok|KDialogBase::Cancel|KDialogBase::Default,
+ KDialogBase::Ok,
+ true);
+ ConfigFeeds *conf_widget = new ConfigFeeds(0, "feedcfgdlg");
+ m_confdlg->addPage(conf_widget, i18n("RSS Settings"), "pixmap_name");
+
+ // User edited the configuration - update your local copies of the
+ // configuration data
+ connect(m_confdlg, SIGNAL(settingsChanged()), this,
+ SLOT(slotConfigure_okClicked()));
+
+ m_confdlg->show();
+ }
+
+
+ void NoRSSWidget::slotConfigure_okClicked() {
+ DCOPRef rss_document("rssservice", "RSSService");
+
+ // read list of sources
+ QStringList m_our_rsssources = SidebarSettings::sources();
+
+ // add new sources
+ QStringList::iterator it;
+ for (it = m_our_rsssources.begin(); it != m_our_rsssources.end(); ++it) {
+ rss_document.call("add", ( *it ));
+ }
+
+ // save configuration to disk
+ SidebarSettings::setSources(m_our_rsssources);
+ SidebarSettings::writeConfig();
+ }
+
+} // namespace KSB_News
+
+#include "norsswidget.moc"
diff --git a/konq-plugins/sidebar/newsticker/norsswidget.h b/konq-plugins/sidebar/newsticker/norsswidget.h
new file mode 100644
index 0000000..cebac3b
--- /dev/null
+++ b/konq-plugins/sidebar/newsticker/norsswidget.h
@@ -0,0 +1,51 @@
+// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8; -*-
+
+/***************************************************************************
+ Copyright: norsswidget.h
+ Marcus Camen <mcamen@mcamen.de>
+***************************************************************************/
+
+/*
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _NORSSWIDGET_H_
+#define _NORSSWIDGET_H_
+
+
+class KConfigDialog;
+
+
+namespace KSB_News {
+
+ class NoRSSWidget : public QWidget {
+ Q_OBJECT
+
+ public:
+ NoRSSWidget(QWidget *parent = 0, const char *name = 0);
+
+ private slots:
+ void slotBtnClicked();
+ void slotConfigure_okClicked();
+
+ private:
+ KConfigDialog *m_confdlg;
+ };
+
+
+} // namespace KSB_News
+
+#endif
diff --git a/konq-plugins/sidebar/newsticker/nspanel.cpp b/konq-plugins/sidebar/newsticker/nspanel.cpp
new file mode 100644
index 0000000..8086b35
--- /dev/null
+++ b/konq-plugins/sidebar/newsticker/nspanel.cpp
@@ -0,0 +1,181 @@
+// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8; -*-
+
+/***************************************************************************
+ Copyright: nspanel.cpp
+ Marcus Camen <mcamen@mcamen.de>
+***************************************************************************/
+
+/*
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <qlistview.h>
+#include <qfontmetrics.h>
+#include <qtimer.h>
+#include <kdebug.h>
+#include <klistbox.h>
+#include "nspanel.h"
+
+
+namespace KSB_News {
+
+////////////////////////////////////////////////////////////////
+// ListBox including ToolTip for item
+////////////////////////////////////////////////////////////////
+ TTListBox::TTListBox(QWidget *parent, const char *name, WFlags f)
+ : KListBox(parent, name, f),
+ QToolTip(this) {
+ }
+
+ void TTListBox::clear() {
+ KListBox::clear();
+ }
+
+ void TTListBox::maybeTip(const QPoint &point) {
+ QListBoxItem *item = itemAt(point);
+ if (item) {
+ QString text = item->text();
+ if (!text.isEmpty()) {
+ // Show ToolTip only if necessary
+ QFontMetrics fm(fontMetrics());
+ int textWidth = fm.width(text);
+ int widgetSpace = visibleWidth();
+ if ((textWidth > widgetSpace) || (contentsX() > 0))
+ tip(itemRect(item), text);
+ }
+ }
+ }
+
+
+
+ NSPanel::NSPanel(QObject *parent, const char *name, const QString &key,
+ DCOPRef *rssservice)
+ :QObject(parent, name)
+ ,DCOPObject(QString(QString("sidebar-newsticker-")+key).latin1())
+ ,m_listbox()
+ ,m_pixmap()
+{
+ kdDebug(90140) << "NSPanel: CTOR " << key << " " << rssservice << endl;
+
+ m_rssservice = rssservice;
+ m_key = key;
+ m_rssdocument = m_rssservice->call("document(QString)", m_key);
+ m_isValid = false;
+
+ connectDCOPSignal("rssservice", m_rssdocument.obj(),
+ "documentUpdated(DCOPRef)",
+ "emitDocumentUpdated(DCOPRef)", false);
+ connectDCOPSignal("rssservice", m_rssdocument.obj(),
+ "documentUpdated(DCOPRef)",
+ "emitTitleUpdated(DCOPRef)", false);
+ connectDCOPSignal("rssservice", m_rssdocument.obj(),
+ "pixmapUpdated(DCOPRef)",
+ "emitPixmapUpdated(DCOPRef)", false);
+
+ // updating of RSS documents
+ m_timeoutinterval = 10 * 60 * 1000; // 10 mins
+ m_timer = new QTimer(this);
+ connect(m_timer, SIGNAL(timeout()), this, SLOT(refresh()));
+ m_timer->start(m_timeoutinterval);
+ refresh();
+ }
+
+
+ void NSPanel::refresh() {
+ m_rssdocument.call("refresh()");
+ }
+
+
+ NSPanel::~NSPanel() {
+ }
+
+
+ void NSPanel::setTitle(const QString &tit) {
+ m_title = tit;
+ }
+
+
+ void NSPanel::setListbox(TTListBox *lb) {
+ m_listbox = lb;
+ }
+
+
+ void NSPanel::setPixmap(const QPixmap &pm) {
+ m_pixmap = pm;
+ }
+
+
+ TTListBox *NSPanel::listbox() const {
+ return m_listbox;
+ }
+
+
+ QPixmap NSPanel::pixmap() {
+ return m_pixmap;
+ }
+
+
+ QString NSPanel::key() const {
+ return m_key;
+ }
+
+ QString NSPanel::title() const {
+ return m_title;
+ }
+
+ QStringList NSPanel::articles() {
+ return m_articles;
+ }
+
+ QStringList NSPanel::articleLinks() {
+ return m_articlelinks;
+ }
+
+ bool NSPanel::isValid() const {
+ return m_isValid;
+ }
+
+
+ void NSPanel::emitDocumentUpdated(DCOPRef /*dcopref*/) {
+ kdDebug(90140) << "NSPanel::emitDocumentUpdated" << endl;
+
+ m_articles.clear();
+ m_articlelinks.clear();
+ m_count = m_rssdocument.call("count()");
+ QString temp = m_rssdocument.call("title()");
+ m_title = temp;
+ m_isValid = true;
+ for (int idx = 0; idx < m_count; ++idx) {
+ DCOPRef rss_article = m_rssdocument.call("article(int)", idx);
+ m_articles.append(rss_article.call("title()"));
+ m_articlelinks.append(rss_article.call("link()"));
+ }
+
+ emit documentUpdated(this);
+ }
+
+ void NSPanel::emitPixmapUpdated(DCOPRef /*dcopref*/) {
+ if (m_rssdocument.call("pixmapValid()")) {
+ QPixmap tmp = m_rssdocument.call("pixmap()");
+ m_pixmap = tmp;
+
+ emit pixmapUpdated(this);
+ }
+ }
+
+} // namespace KSB_News
+
+#include "nspanel.moc"
diff --git a/konq-plugins/sidebar/newsticker/nspanel.h b/konq-plugins/sidebar/newsticker/nspanel.h
new file mode 100644
index 0000000..0f30152
--- /dev/null
+++ b/konq-plugins/sidebar/newsticker/nspanel.h
@@ -0,0 +1,109 @@
+// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8; -*-
+
+/***************************************************************************
+ Copyright: nspanel.h
+ Marcus Camen <mcamen@mcamen.de>
+***************************************************************************/
+
+/*
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _konq_sidebar_news_nspanelh_
+#define _konq_sidebar_news_nspanelh_
+
+#include <qstring.h>
+#include <qpixmap.h>
+#include <qtooltip.h>
+#include <dcopref.h>
+#include <dcopobject.h>
+#include <kio/job.h>
+#include <klistbox.h>
+
+
+class QBuffer;
+class QTimer;
+
+namespace KSB_News {
+
+////////////////////////////////////////////////////////////////
+// ListBox including ToolTip for item
+////////////////////////////////////////////////////////////////
+ class TTListBox : public KListBox, QToolTip {
+ public:
+ TTListBox (QWidget *parent = 0, const char *name = 0, WFlags f = 0);
+ void clear();
+
+ protected:
+ virtual void maybeTip(const QPoint &);
+ };
+
+
+
+ class NSPanel : public QObject, public DCOPObject {
+ Q_OBJECT
+ K_DCOP
+
+ public:
+ NSPanel(QObject *parent, const char *name, const QString &key,
+ DCOPRef *rssservice);
+ ~NSPanel();
+
+ void setTitle(const QString &tit);
+ void setListbox(TTListBox *lb);
+ void setPixmap(const QPixmap &pm);
+ void setPixmapBuffer(QBuffer *buf);
+ void setJob(KIO::Job *kio_job);
+
+ TTListBox *listbox() const;
+ QPixmap pixmap();
+ QString key() const;
+ QString title() const;
+ QStringList articles();
+ QStringList articleLinks();
+ bool isValid() const;
+
+ k_dcop:
+ virtual void emitDocumentUpdated(DCOPRef);
+ virtual void emitPixmapUpdated(DCOPRef);
+
+ private:
+ DCOPRef *m_rssservice;
+ DCOPRef m_rssdocument;
+ QString m_key;
+ QString m_title;
+ TTListBox *m_listbox;
+ QPixmap m_pixmap;
+ int m_count;
+ QStringList m_articles; // TODO: use proper container
+ QStringList m_articlelinks; // TODO: use proper container
+ int m_timeoutinterval;
+ QTimer *m_timer;
+ bool m_isValid;
+
+ signals:
+ void documentUpdated(NSPanel *);
+ void pixmapUpdated(NSPanel *);
+
+ public slots:
+ void refresh();
+
+ };
+
+
+} // namespace KSB_News
+
+#endif
diff --git a/konq-plugins/sidebar/newsticker/nsstacktabwidget.cpp b/konq-plugins/sidebar/newsticker/nsstacktabwidget.cpp
new file mode 100644
index 0000000..74aa07e
--- /dev/null
+++ b/konq-plugins/sidebar/newsticker/nsstacktabwidget.cpp
@@ -0,0 +1,365 @@
+// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8; -*-
+
+/***************************************************************************
+ nsstacktabwidget.cpp - description
+ -------------------
+ begin : Sat 07.09.2002
+ copyright : (C) 2002-2004 Marcus Camen
+ email : mcamen@mcamen.de
+***************************************************************************/
+
+/*
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <qpushbutton.h>
+#include <qlayout.h>
+#include <qscrollview.h>
+#include <qptrdict.h>
+#include <qsizepolicy.h>
+#include <qtooltip.h>
+#include <qcursor.h>
+#include <qimage.h>
+#include <kdebug.h>
+#include <kaboutdata.h>
+#include <kaboutapplication.h>
+#include <kpopupmenu.h>
+#include <kiconloader.h>
+#include <kstringhandler.h>
+#include <kapplication.h>
+#include <kbugreport.h>
+#include <kstdguiitem.h>
+#include <kconfigdialog.h>
+#include "sidebarsettings.h"
+#include "configfeeds.h"
+#include "nsstacktabwidget.h"
+
+
+namespace KSB_News {
+
+ NSStackTabWidget::NSStackTabWidget(QWidget *parent, const char *name,
+ QPixmap appIcon) : QWidget(parent, name) {
+ currentPage = 0;
+ layout = new QVBoxLayout(this);
+
+ pagesheader.setAutoDelete(TRUE);
+ pages.setAutoDelete(TRUE);
+
+ // about dialog
+ m_aboutdata = new KAboutData("konq_sidebarnews",
+ I18N_NOOP("Newsticker"),
+ KDE::versionString(),
+ I18N_NOOP("RSS Feed Viewer"),
+ KAboutData::License_LGPL,
+ I18N_NOOP("(c) 2002-2004, the Sidebar Newsticker developers"));
+ m_aboutdata->addAuthor("Marcus Camen", I18N_NOOP("Maintainer"),
+ "mcamen@mcamen.de");
+ m_aboutdata->addAuthor("Frerich Raabe", "librss",
+ "raabe@kde.org");
+ m_aboutdata->addAuthor("Ian Reinhart Geiser", "dcoprss",
+ "geiseri@kde.org");
+ m_aboutdata->addAuthor("Joseph Wenninger",
+ I18N_NOOP("Idea and former maintainer"),
+ "jowenn@kde.org");
+ m_aboutdata->setProductName("konqueror/sidebar newsticker");
+ m_about = new KAboutApplication(m_aboutdata, this);
+
+
+ // bugreport dialog
+ m_bugreport = new KBugReport(0, true, m_aboutdata);
+
+
+ // popup menu
+ popup = new KPopupMenu(this);
+ popup->insertItem(KStdGuiItem::configure().iconSet(),
+ i18n("&Configure Newsticker..."), this,
+ SLOT(slotConfigure()));
+ popup->insertItem(SmallIconSet("reload"), i18n("&Reload"), this,
+ SLOT(slotRefresh()));
+ popup->insertItem(KStdGuiItem::close().iconSet(),
+ KStdGuiItem::close().text(), this, SLOT(slotClose()));
+ popup->insertSeparator();
+
+ // help menu
+ helpmenu = new KPopupMenu(this);
+ helpmenu->insertItem(appIcon, i18n("&About Newsticker"), this,
+ SLOT(slotShowAbout()));
+ helpmenu->insertItem(i18n("&Report Bug..."), this,
+ SLOT(slotShowBugreport()));
+
+ popup->insertItem(KStdGuiItem::help().iconSet(),
+ KStdGuiItem::help().text(), helpmenu);
+
+
+ // read configuration from disk and initialize widget
+ m_our_rsssources = SidebarSettings::sources();
+ }
+
+
+ void NSStackTabWidget::addStackTab(NSPanel *nsp, QWidget *page) {
+ QPushButton *button = new QPushButton(this);
+
+ button->setText(KStringHandler::rPixelSqueeze(nsp->title(),
+ button->fontMetrics(),
+ button->width() - 4 ));
+ button->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
+ QSizePolicy::Preferred));
+ connect(button, SIGNAL(clicked()), this, SLOT(buttonClicked()));
+ QToolTip::add(button, nsp->title());
+
+ // eventFiler for the title button
+ button->installEventFilter(this);
+
+ QScrollView *sv = new QScrollView(this);
+ sv->setResizePolicy(QScrollView::AutoOneFit);
+ sv->addChild(page);
+ sv->setFrameStyle(QFrame::NoFrame);
+ page->show();
+
+ pagesheader.insert(nsp, button);
+ pages.insert(nsp, sv);
+
+ layout->addWidget(button);
+ layout->addWidget(sv);
+ button->show();
+ if (pages.count() == 1) {
+ currentPage = sv;
+ sv->show();
+ } else {
+ sv->hide();
+ }
+ }
+
+
+
+ void NSStackTabWidget::delStackTab(NSPanel *nsp) {
+ pages.remove(nsp);
+ pagesheader.remove(nsp);
+
+ if (pages.count() >= 1) {
+ QPtrDictIterator<QWidget> it(pages);
+ QWidget *previousPage = currentPage;
+ currentPage = it.current();
+ if (currentPage != previousPage)
+ currentPage->show();
+ }
+ }
+
+
+
+ void NSStackTabWidget::updateTitle(NSPanel *nsp) {
+ QPushButton *pb = (QPushButton *)pagesheader.find(nsp);
+ if (! pb->pixmap())
+ pb->setText(nsp->title());
+ }
+
+
+
+ void NSStackTabWidget::updatePixmap(NSPanel *nsp) {
+ QPushButton *pb = (QPushButton *)pagesheader.find(nsp);
+ QPixmap pixmap = nsp->pixmap();
+ if ((pixmap.width() > 88) || (pixmap.height() > 31)) {
+ QImage image = pixmap.convertToImage();
+ pixmap.convertFromImage(image.smoothScale(88, 31, QImage::ScaleMin));
+ }
+ pb->setPixmap(pixmap);
+ }
+
+
+
+
+ void NSStackTabWidget::buttonClicked() {
+ QPushButton *pb = (QPushButton*)sender();
+ NSPanel *nsp = NULL;
+
+ // Which NSPanel belongs to pb
+ QPtrDictIterator<QWidget> it(pagesheader);
+ for (; it.current(); ++it) {
+ QPushButton *currentWidget = (QPushButton *)it.current();
+ if (currentWidget == pb)
+ nsp = (NSPanel *)it.currentKey();
+ }
+
+ if (! nsp)
+ return;
+
+ // Find current ScrollView
+ QWidget *sv = pages.find(nsp);
+
+ // Change visible page
+ if (currentPage != sv) {
+ nsp->refresh();
+ if (currentPage)
+ currentPage->hide();
+ currentPage = sv;
+ currentPage->show();
+ }
+ }
+
+
+
+ bool NSStackTabWidget::eventFilter(QObject *obj, QEvent *ev) {
+ if (ev->type() == QEvent::MouseButtonPress
+ && ((QMouseEvent *)ev)->button() == QMouseEvent::RightButton) {
+ m_last_button_rightclicked = (QPushButton *)obj;
+ popup->exec(QCursor::pos());
+ return true;
+ } else if (ev->type() == QEvent::Resize) {
+ QPushButton *pb = (QPushButton *)obj;
+
+ const QPixmap *pm = pb->pixmap();
+ if ( ! pm ) {
+ // Which NSPanel belongs to pb
+ NSPanel *nsp = NULL;
+ QPtrDictIterator<QWidget> it(pagesheader);
+ for (; it.current(); ++it) {
+ QPushButton *currentWidget = (QPushButton *)it.current();
+ if (currentWidget == pb)
+ nsp = (NSPanel *)it.currentKey();
+ }
+ pb->setText(KStringHandler::rPixelSqueeze(nsp->title(),
+ pb->fontMetrics(),
+ pb->width() - 4 ));
+ }
+ return true;
+ }
+ return false; // pass through event
+ }
+
+
+ void NSStackTabWidget::slotConfigure() {
+ // An instance of your dialog could be already created and could be
+ // cached, in which case you want to display the cached dialog
+ // instead of creating another one
+ if (KConfigDialog::showDialog("settings"))
+ return;
+
+ // KConfigDialog didn't find an instance of this dialog, so lets create it
+ m_confdlg = new KConfigDialog(this, "settings", SidebarSettings::self(),
+ KDialogBase::Plain,
+ KDialogBase::Ok|KDialogBase::Cancel| \
+ KDialogBase::Default| \
+ KDialogBase::Apply,
+ KDialogBase::Ok,
+ true);
+ ConfigFeeds *conf_widget = new ConfigFeeds(0, "feedcfgdlg");
+ m_confdlg->addPage(conf_widget, i18n("RSS Settings"), QString());
+
+ // User edited the configuration - update your local copies of the
+ // configuration data
+ connect(m_confdlg, SIGNAL(settingsChanged()), this,
+ SLOT(slotConfigure_okClicked()));
+
+ m_confdlg->show();
+ }
+
+
+ void NSStackTabWidget::slotConfigure_okClicked() {
+ DCOPRef rss_document("rssservice", "RSSService");
+
+ // remove old sources and old stack tabs
+ QStringList::iterator it;
+ for (it = m_our_rsssources.begin(); it != m_our_rsssources.end(); ++it) {
+ rss_document.call("remove", (*it));
+ }
+
+ // read list of sources
+ m_our_rsssources = SidebarSettings::sources();
+
+ // add new sources and new stack tabs
+ for (it = m_our_rsssources.begin(); it != m_our_rsssources.end(); ++it) {
+ rss_document.call("add", (*it));
+ }
+
+ // save configuration to disk
+ SidebarSettings::setSources(m_our_rsssources);
+ SidebarSettings::writeConfig();
+ }
+
+
+ void NSStackTabWidget::slotShowAbout() {
+ m_about->show();
+ }
+
+
+ void NSStackTabWidget::slotShowBugreport() {
+ m_bugreport->show();
+ }
+
+
+ void NSStackTabWidget::slotRefresh() {
+ NSPanel *nsp = NULL;
+
+ // find appendant NSPanel
+ QPtrDictIterator<QWidget> it(pagesheader);
+ for (; it.current(); ++it) {
+ QPushButton *currentWidget = (QPushButton *)it.current();
+ if (currentWidget == m_last_button_rightclicked)
+ nsp = (NSPanel *)it.currentKey();
+ }
+
+ if (! nsp) {
+ return;
+ } else {
+ nsp->refresh();
+ }
+ }
+
+
+ void NSStackTabWidget::slotClose() {
+ NSPanel *nsp = NULL;
+ // find appendant NSPanel
+ QPtrDictIterator<QWidget> it(pagesheader);
+ for (; it.current(); ++it) {
+ QPushButton *currentWidget = (QPushButton *)it.current();
+ if (currentWidget == m_last_button_rightclicked)
+ nsp = (NSPanel *)it.currentKey();
+ }
+
+ if (! nsp) {
+ return;
+ } else {
+ // TODO: check, if rssservice is available
+
+ // deregister RSS source and save configuration to disk
+ m_our_rsssources.remove(nsp->key());
+ SidebarSettings::setSources(m_our_rsssources);
+ SidebarSettings::writeConfig();
+
+ DCOPRef rss_document("rssservice", "RSSService");
+ rss_document.call("remove", nsp->key());
+ }
+ }
+
+
+ bool NSStackTabWidget::isEmpty() const {
+ return pagesheader.isEmpty();
+ }
+
+
+ bool NSStackTabWidget::isRegistered(const QString &key) {
+ m_our_rsssources = SidebarSettings::sources();
+ if (m_our_rsssources.findIndex(key) == -1)
+ return false;
+ else
+ return true;
+ }
+
+
+} // namespace KSB_News;
+
+
+#include "nsstacktabwidget.moc"
diff --git a/konq-plugins/sidebar/newsticker/nsstacktabwidget.h b/konq-plugins/sidebar/newsticker/nsstacktabwidget.h
new file mode 100644
index 0000000..7b84289
--- /dev/null
+++ b/konq-plugins/sidebar/newsticker/nsstacktabwidget.h
@@ -0,0 +1,91 @@
+// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8; -*-
+
+/***************************************************************************
+ nsstacktabwidget.h - description
+ -------------------
+ begin : Sat 07.09.2002
+ copyright : (C) 2002-2004 Marcus Camen
+ email : mcamen@mcamen.de
+***************************************************************************/
+
+/*
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _NSSTACKTABWIDGET_H_
+#define _NSSTACKTABWIDGET_H_
+
+#include <qptrdict.h>
+#include "nspanel.h"
+
+
+class QVBoxLayout;
+class QPushButton;
+class QStringList;
+class KPopupMenu;
+class KAboutData;
+class KAboutApplication;
+class KBugReport;
+class KConfigDialog;
+
+namespace KSB_News {
+
+ class NewRssSourceDlg;
+
+ class NSStackTabWidget : public QWidget {
+ Q_OBJECT
+
+ public:
+ NSStackTabWidget(QWidget *parent = 0, const char *name = 0,
+ QPixmap appIcon = QPixmap());
+ void addStackTab(NSPanel *nsp, QWidget *page);
+ void delStackTab(NSPanel *nsp);
+ void updateTitle(NSPanel *nsp);
+ void updatePixmap(NSPanel *nsp);
+ bool isEmpty() const;
+ bool isRegistered(const QString &key);
+
+ protected:
+ bool eventFilter(QObject *obj, QEvent *ev);
+
+ private slots:
+ void buttonClicked();
+ void slotShowAbout();
+ void slotShowBugreport();
+ void slotRefresh();
+ void slotClose();
+ void slotConfigure();
+ void slotConfigure_okClicked();
+
+ private:
+ QPtrDict<QWidget> pages;
+ QPtrDict<QWidget> pagesheader;
+ QVBoxLayout *layout;
+ QWidget *currentPage;
+ KPopupMenu *popup, *helpmenu;
+ KAboutData *m_aboutdata;
+ KAboutApplication *m_about;
+ KBugReport *m_bugreport;
+ QPushButton *m_last_button_rightclicked;
+ KConfigDialog *m_confdlg;
+ QStringList m_our_rsssources;
+ };
+
+
+} // namespace KSB_News
+
+
+#endif
diff --git a/konq-plugins/sidebar/newsticker/pics/LICENSE b/konq-plugins/sidebar/newsticker/pics/LICENSE
new file mode 100644
index 0000000..7108d2b
--- /dev/null
+++ b/konq-plugins/sidebar/newsticker/pics/LICENSE
@@ -0,0 +1,16 @@
+cr16-app-konqsidebar_news.png is based on livemark-item.png
+
+You can find the original file in the mozilla AVIARY_1_0_20040515_BRANCH:
+http://lxr.mozilla.org/aviarybranch/source/browser/themes/winstripe/browser/licemark-item.png, Version 1.1
+
+According to
+http://lxr.mozilla.org/aviarybranch/source/browser/themes/LICENSE
+the file is MPL / GPL / LPGP (confirmed to me in private mail by
+Stephen Horlander <stephen@noved.org>):
+ "All files in this directory are assumed to be licensed under the
+ tri-license (MPL/GPL/LGPL) used throughout this codebase."
+
+--
+Marcus <mcamen@mcamen.de>
+
+ \ No newline at end of file
diff --git a/konq-plugins/sidebar/newsticker/pics/Makefile.am b/konq-plugins/sidebar/newsticker/pics/Makefile.am
new file mode 100644
index 0000000..e5515a8
--- /dev/null
+++ b/konq-plugins/sidebar/newsticker/pics/Makefile.am
@@ -0,0 +1 @@
+KDE_ICON = AUTO
diff --git a/konq-plugins/sidebar/newsticker/pics/cr16-app-konqsidebar_news.png b/konq-plugins/sidebar/newsticker/pics/cr16-app-konqsidebar_news.png
new file mode 100644
index 0000000..4a7321a
--- /dev/null
+++ b/konq-plugins/sidebar/newsticker/pics/cr16-app-konqsidebar_news.png
Binary files differ
diff --git a/konq-plugins/sidebar/newsticker/pics/livemark-item.png b/konq-plugins/sidebar/newsticker/pics/livemark-item.png
new file mode 100644
index 0000000..91cb614
--- /dev/null
+++ b/konq-plugins/sidebar/newsticker/pics/livemark-item.png
Binary files differ
diff --git a/konq-plugins/sidebar/newsticker/sidebar_news.cpp b/konq-plugins/sidebar/newsticker/sidebar_news.cpp
new file mode 100644
index 0000000..f96bcd6
--- /dev/null
+++ b/konq-plugins/sidebar/newsticker/sidebar_news.cpp
@@ -0,0 +1,279 @@
+// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8; -*-
+
+/***************************************************************************
+ sidebar_news.cpp - The real sidebar plugin
+ -------------------
+ begin : Sat June 23 13:35:30 CEST 2001
+ copyright : (C) 2001,2002 Marcus Camen, Joseph Wenninger
+ copyright : (C) 2003,2004 Marcus Camen
+ email : Marcus Camen <mcamen@mcamen.de>
+ idea and original code: jowenn@kde.org
+***************************************************************************/
+
+/*
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <dcopclient.h>
+#include <qtimer.h>
+#include <qbuffer.h>
+#include <qwidgetstack.h>
+#include <kdebug.h>
+#include <kapplication.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kdesktopfile.h>
+#include <kiconloader.h>
+#include <kdemacros.h>
+#include "sidebar_news.h"
+#include "nsstacktabwidget.h"
+#include "norsswidget.h"
+#include "sidebarsettings.h"
+
+
+namespace KSB_News {
+
+ KonqSidebar_News::KonqSidebar_News(KInstance *inst, QObject *parent,
+ QWidget *widgetParent,
+ QString &desktopName, const char* name)
+ : KonqSidebarPlugin(inst, parent, widgetParent, desktopName, name),
+ DCOPObject("sidebar-newsticker")
+ {
+ // get the application icon
+ // FIXME: as konqueror knows the icon there might be a possibility to
+ // access the already present QPixmap
+ KDesktopFile desktopFile(desktopName, true);
+ QString iconName = desktopFile.readIcon();
+ KIconLoader iconLoader;
+ m_appIcon = iconLoader.loadIcon(iconName, KIcon::Small);
+
+ // create all sidebar widgets
+ widgets = new QWidgetStack(widgetParent, "main_widgetstack");
+ newswidget = new NSStackTabWidget(widgets, "feedbrowser_stackchld",
+ m_appIcon);
+ noRSSwidget = new NoRSSWidget(widgets, "nofeed_stackchld");
+ widgets->addWidget(newswidget);
+ widgets->addWidget(noRSSwidget);
+ widgets->raiseWidget(noRSSwidget);
+ noRSSwidget->show();
+
+ // try to connect to the DCOP service
+ if (checkDcopService() > 0) {
+ KMessageBox::sorry(widgets,
+ i18n("<qt>Cannot connect to RSS service. Please make "
+ "sure the <strong>rssservice</strong> program "
+ "is available (usually distributed as part "
+ "of kdenetwork).</qt>"),
+ i18n("Sidebar Newsticker"));
+ noRSSwidget->setEnabled(false);
+ } else {
+ m_rssservice = DCOPRef("rssservice", "RSSService");
+
+ QStringList reslist = SidebarSettings::sources();
+ QStringList::iterator it;
+ for (it = reslist.begin(); it != reslist.end(); ++it) {
+ addedRSSSource(*it);
+ }
+
+ // fetch added and removed RSS sources
+ connectDCOPSignal("rssservice", m_rssservice.obj(), "added(QString)",
+ "addedRSSSource(QString)", false);
+ connectDCOPSignal("rssservice", m_rssservice.obj(), "removed(QString)",
+ "removedRSSSource(QString)", false);
+
+ // show special widget if there are no RSS sources available
+ if (newswidget->isEmpty()) {
+ widgets->raiseWidget(noRSSwidget);
+ noRSSwidget->show();
+ } else {
+ widgets->raiseWidget(newswidget);
+ }
+ }
+ }
+
+
+ KonqSidebar_News::~KonqSidebar_News() {
+ }
+
+
+
+ void *KonqSidebar_News::provides(const QString &) {return 0;}
+
+ void KonqSidebar_News::emitStatusBarText (const QString &) {;}
+
+ QWidget *KonqSidebar_News::getWidget(){return widgets;}
+
+ void KonqSidebar_News::handleURL(const KURL &/*url*/) {;}
+
+
+///////// startup of the DCOP servce ///////////////////////////////////////
+
+ int KonqSidebar_News::checkDcopService() {
+ QString rdfservice_error;
+ int err = 0;
+
+ if (! kapp->dcopClient()->isApplicationRegistered("rssservice"))
+ if (KApplication::startServiceByDesktopName("rssservice", QString(),
+ &rdfservice_error) > 0)
+ err = 1;
+
+ return err;
+ }
+
+
+
+///////// helper methods ///////////////////////////////////////////////////
+
+ NSPanel *KonqSidebar_News::getNSPanelByKey(QString key) {
+ NSPanel *nsp = NULL, *current_nsp;
+
+ for (current_nsp = nspanelptrlist.first(); current_nsp;
+ current_nsp = nspanelptrlist.next()) {
+ if (current_nsp->key() == key)
+ nsp = current_nsp;
+ }
+
+ return nsp;
+ }
+
+
+ void KonqSidebar_News::addedRSSSource(QString key) {
+ kdDebug(90140) << "KonqSidebar_News::addedRSSSource: " << key << endl;
+
+ // Only add RSS source if we have registered the URI before in
+ // NSStackTabWidget.
+ if (newswidget->isRegistered(key)) {
+ NSPanel *nspanel = new NSPanel(this,
+ QString(QString("sidebar-newsticker-")+key).latin1(),
+ key, &m_rssservice);
+ nspanel->setTitle(key);
+ nspanelptrlist.append(nspanel);
+
+ // add preliminary widgets for this newssource
+ if (! nspanel->listbox()) {
+ TTListBox *listbox = new TTListBox(newswidget, "article_lb");
+ newswidget->addStackTab(nspanel, listbox);
+ connect(listbox, SIGNAL(executed(QListBoxItem *)),
+ this, SLOT(slotArticleItemExecuted(QListBoxItem *)));
+ listbox->insertItem(i18n("Connecting..." ));
+ nspanel->setListbox(listbox);
+ }
+
+ // listen to updates
+ connect(nspanel, SIGNAL(documentUpdated(NSPanel *)),
+ this, SLOT(updateArticles(NSPanel *)));
+ connect(nspanel, SIGNAL(documentUpdated(NSPanel *)),
+ this, SLOT(updateTitle(NSPanel *)));
+ connect(nspanel, SIGNAL(pixmapUpdated(NSPanel *)),
+ this, SLOT(updatePixmap(NSPanel *)));
+
+ if (widgets->visibleWidget() != newswidget)
+ widgets->raiseWidget(newswidget);
+ }
+ }
+
+
+ void KonqSidebar_News::removedRSSSource(QString key) {
+ kdDebug(90140) << "inside KonqSidebar_News::removedSource " << key << endl;
+
+ if (NSPanel *nsp = getNSPanelByKey(key)) {
+ newswidget->delStackTab(nsp);
+ delete nspanelptrlist.take(nspanelptrlist.findRef(nsp));
+ } else
+ kdWarning() << "removedSource called for non-existing id" << endl;
+
+ if (newswidget->isEmpty())
+ widgets->raiseWidget(noRSSwidget);
+ }
+
+
+/////////////////////////////////////////////////////////////////////
+
+ void KonqSidebar_News::slotArticleItemExecuted(QListBoxItem *item) {
+ if (!item) return;
+
+ NSPanel *current_nspanel, *nspanel = NULL;
+ for (current_nspanel = nspanelptrlist.first(); current_nspanel;
+ current_nspanel = nspanelptrlist.next()) {
+ if (current_nspanel->listbox() == item->listBox())
+ nspanel = current_nspanel;
+ }
+
+ int subid = nspanel->listbox()->index(item);
+ QString link = nspanel->articleLinks()[subid];
+
+ emit openURLRequest(KURL(link));
+
+ }
+
+
+
+//////////// update article headlines ////////////
+
+ void KonqSidebar_News::updateArticles(NSPanel *nsp) {
+ nsp->listbox()->clear();
+
+ QStringList articleList = nsp->articles();
+ QStringList::iterator it;
+ for (it = articleList.begin(); it != articleList.end(); ++it)
+ nsp->listbox()->insertItem((*it));
+ }
+
+
+/////////// Title stuff /////////////////////////////////////
+
+ void KonqSidebar_News::updateTitle(NSPanel *nsp) {
+ newswidget->updateTitle(nsp);
+ }
+
+
+/////////// Pixmap stuff /////////////////////////////////////
+
+ void KonqSidebar_News::updatePixmap(NSPanel *nsp) {
+ newswidget->updatePixmap(nsp);
+ }
+
+
+
+/////////////////////////////////////////////////////////
+
+
+ extern "C" {
+ KDE_EXPORT void* create_konq_sidebarnews(KInstance *instance, QObject *par,
+ QWidget *widp,
+ QString &desktopname,
+ const char *name) {
+ KGlobal::locale()->insertCatalogue("konqsidebar_news");
+ return new KonqSidebar_News(instance, par, widp, desktopname, name);
+ }
+ }
+
+ extern "C" {
+ KDE_EXPORT bool add_konq_sidebarnews(QString* fn, QString*,
+ QMap<QString,QString> *map) {
+ map->insert("Type", "Link");
+ map->insert("Icon", "konqsidebar_news");
+ map->insert("Name", i18n("Newsticker"));
+ map->insert("Open", "false");
+ map->insert("X-KDE-KonqSidebarModule", "konq_sidebarnews");
+ fn->setLatin1("news%1.desktop");
+ return true;
+ }
+ }
+
+} // namespace KSB_News
+
+#include "sidebar_news.moc"
diff --git a/konq-plugins/sidebar/newsticker/sidebar_news.h b/konq-plugins/sidebar/newsticker/sidebar_news.h
new file mode 100644
index 0000000..e6da786
--- /dev/null
+++ b/konq-plugins/sidebar/newsticker/sidebar_news.h
@@ -0,0 +1,89 @@
+// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8; -*-
+
+/***************************************************************************
+ sidebar_news.h - The real sidebar plugin
+ -------------------
+ begin : Sat July 23 20:35:30 CEST 2001
+ copyright : (C) 2001,2002 Marcus Camen, Joseph Wenninger
+ copyright : (C) 2003,2004 Marcus Camen
+ email : Marcus Camen <mcamen@mcamen.de>
+ idea and original code: jowenn@kde.org
+***************************************************************************/
+
+/*
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _konq_sidebar_news_h_
+#define _konq_sidebar_news_h_
+
+#include <konqsidebarplugin.h>
+#include "nspanel.h"
+
+
+class QPixmap;
+class QWidgetStack;
+
+namespace KSB_News {
+
+ class NSStackTabWidget;
+ class NoRSSWidget;
+
+ class KonqSidebar_News : public KonqSidebarPlugin, DCOPObject {
+ Q_OBJECT
+ K_DCOP
+
+ public:
+ KonqSidebar_News(KInstance *instance, QObject *parent,
+ QWidget *widgetParent, QString &desktopName_,
+ const char* name=0);
+ ~KonqSidebar_News();
+ virtual void *provides(const QString &);
+ void emitStatusBarText (const QString &);
+ virtual QWidget *getWidget();
+
+ k_dcop:
+ virtual void addedRSSSource(QString);
+ virtual void removedRSSSource(QString);
+
+ protected:
+ virtual void handleURL(const KURL &url);
+
+ private:
+ int checkDcopService();
+ QWidgetStack *widgets;
+ NSStackTabWidget *newswidget;
+ NoRSSWidget *noRSSwidget;
+ QPtrList<NSPanel> nspanelptrlist;
+ NSPanel *getNSPanelByKey(QString key);
+ DCOPRef m_rssservice;
+ QPixmap m_appIcon;
+
+ signals:
+ // see <konqsidebarplugin.h>
+ void openURLRequest(const KURL &url,
+ const KParts::URLArgs &args = KParts::URLArgs());
+
+ private slots:
+ void slotArticleItemExecuted(QListBoxItem *item);
+ void updateArticles(NSPanel *nsp);
+ void updateTitle(NSPanel *nsp);
+ void updatePixmap(NSPanel *nsp);
+ };
+
+} // namespace KSB_News
+
+#endif
diff --git a/konq-plugins/sidebar/newsticker/sidebarsettings.kcfgc b/konq-plugins/sidebar/newsticker/sidebarsettings.kcfgc
new file mode 100644
index 0000000..6e24cde
--- /dev/null
+++ b/konq-plugins/sidebar/newsticker/sidebarsettings.kcfgc
@@ -0,0 +1,5 @@
+File=konq_sidebarnews.kcfg
+ClassName=SidebarSettings
+Singleton=true
+Mutators=true
+NameSpace=KSB_News