From 460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: 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/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- akregator/src/addfeeddialog.cpp | 123 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 akregator/src/addfeeddialog.cpp (limited to 'akregator/src/addfeeddialog.cpp') diff --git a/akregator/src/addfeeddialog.cpp b/akregator/src/addfeeddialog.cpp new file mode 100644 index 000000000..c6fa6be18 --- /dev/null +++ b/akregator/src/addfeeddialog.cpp @@ -0,0 +1,123 @@ +/* + This file is part of Akregator. + + Copyright (C) 2004 Stanislav Karchebny + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ + +#include "feed.h" +#include "addfeeddialog.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Akregator { + +AddFeedWidget::AddFeedWidget(QWidget *parent, const char *name) + : AddFeedWidgetBase(parent, name) +{ + pixmapLabel1->setPixmap(kapp->iconLoader()->loadIcon( "package_network",KIcon::Desktop,KIcon::SizeHuge, KIcon::DefaultState, 0, true)); + statusLabel->setText(QString::null); +} + +AddFeedWidget::~AddFeedWidget() +{} + +AddFeedDialog::AddFeedDialog(QWidget *parent, const char *name) + : KDialogBase(KDialogBase::Swallow, Qt::WStyle_DialogBorder, parent, name, true, i18n("Add Feed"), KDialogBase::Ok|KDialogBase::Cancel) +{ + widget = new AddFeedWidget(this); + connect(widget->urlEdit, SIGNAL(textChanged(const QString&)), this, SLOT(textChanged(const QString&))); + enableButtonOK(false); + setMainWidget(widget); +} + +AddFeedDialog::~AddFeedDialog() +{} + +void AddFeedDialog::setURL(const QString& t) +{ + widget->urlEdit->setText(t); +} + +void AddFeedDialog::slotOk( ) +{ + enableButtonOK(false); + feedURL = widget->urlEdit->text().stripWhiteSpace(); + + Feed *f=new Feed(); + + feed=f; + + // HACK: make weird wordpress links ("feed:http://foobar/rss") work + if (feedURL.startsWith("feed:")) + feedURL = feedURL.right( feedURL.length() - 5 ); + + if (feedURL.find(":/") == -1) + feedURL.prepend("http://"); + f->setXmlUrl(feedURL); + + widget->statusLabel->setText( i18n("Downloading %1").arg(feedURL) ); + + connect( feed, SIGNAL(fetched(Feed* )), + this, SLOT(fetchCompleted(Feed *)) ); + connect( feed, SIGNAL(fetchError(Feed* )), + this, SLOT(fetchError(Feed *)) ); + connect( feed, SIGNAL(fetchDiscovery(Feed* )), + this, SLOT(fetchDiscovery(Feed *)) ); + + f->fetch(true); +} + +void AddFeedDialog::fetchCompleted(Feed */*f*/) +{ + KDialogBase::slotOk(); +} + +void AddFeedDialog::fetchError(Feed *) +{ + KMessageBox::error(this, i18n("Feed not found from %1.").arg(feedURL)); + KDialogBase::slotCancel(); +} + +void AddFeedDialog::fetchDiscovery(Feed *f) +{ + widget->statusLabel->setText( i18n("Feed found, downloading...") ); + feedURL=f->xmlUrl(); +} + +void AddFeedDialog::textChanged(const QString& text) +{ + enableButtonOK(!text.isEmpty()); +} + +} // namespace Akregator + +#include "addfeeddialog.moc" +// vim: ts=4 sw=4 et -- cgit v1.2.1