• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

akregator

addfeeddialog.cpp

Go to the documentation of this file.
00001 /*
00002     This file is part of Akregator.
00003 
00004     Copyright (C) 2004 Stanislav Karchebny <Stanislav.Karchebny@kdemail.net>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019 
00020     As a special exception, permission is given to link this program
00021     with any edition of Qt, and distribute the resulting executable,
00022     without including the source code for Qt in the source distribution.
00023 */
00024 
00025 #include "addfeeddialog.h"
00026 #include "feed.h"
00027 #include "kernel.h"
00028 
00029 #include <kdebug.h>
00030 #include <kiconloader.h>
00031 #include <kicontheme.h>
00032 #include <klineedit.h>
00033 #include <klocale.h>
00034 #include <kmessagebox.h>
00035 #include <ksqueezedtextlabel.h>
00036 #include <kurl.h>
00037 
00038 #include <QCheckBox>
00039 
00040 namespace Akregator {
00041 
00042 AddFeedWidget::AddFeedWidget(QWidget *parent, const char* name)
00043    : QWidget(parent)
00044 {
00045     setObjectName(name);
00046     setupUi(this);
00047     pixmapLabel1->setPixmap(KIconLoader::global()->loadIcon( "applications-internet",KIconLoader::Desktop,KIconLoader::SizeHuge, KIconLoader::DefaultState, QStringList(), 0, true));
00048     statusLabel->setText(QString());
00049 }
00050 
00051 AddFeedWidget::~AddFeedWidget()
00052 {}
00053 
00054 Feed* AddFeedDialog::feed()
00055 {
00056     return m_feed;
00057 }
00058 
00059 AddFeedDialog::AddFeedDialog(QWidget *parent, const char *name)
00060    : KDialog(parent
00061      /*Qt::WStyle_DialogBorder*/), m_feed( 0 )
00062 {
00063     setObjectName(name);
00064     widget = new AddFeedWidget(this);
00065     setCaption(i18n("Add Feed"));
00066     setButtons(KDialog::Ok|KDialog::Cancel);
00067     setDefaultButton(KDialog::Ok);
00068     connect(widget->urlEdit, SIGNAL(textChanged(const QString&)), this, SLOT(textChanged(const QString&)));
00069     enableButtonOk(false);
00070     setMainWidget(widget);
00071 }
00072 
00073 AddFeedDialog::~AddFeedDialog()
00074 {}
00075 
00076 void AddFeedDialog::setUrl(const QString& t)
00077 {
00078     widget->urlEdit->setText(t);
00079 }
00080 
00081 void AddFeedDialog::accept()
00082 {
00083     enableButtonOk(false);
00084     feedUrl = widget->urlEdit->text().trimmed();
00085 
00086     delete m_feed;
00087     m_feed = new Feed( Kernel::self()->storage() );
00088 
00089     // HACK: make weird wordpress links ("feed:http://foobar/rss") work
00090     if (feedUrl.startsWith("feed:"))
00091         feedUrl = feedUrl.right( feedUrl.length() - 5 );
00092 
00093     if (feedUrl.indexOf(":/") == -1)
00094         feedUrl.prepend("http://");
00095     m_feed->setXmlUrl(feedUrl);
00096 
00097     widget->statusLabel->setText( i18n("Downloading %1", feedUrl) );
00098 
00099     connect( m_feed, SIGNAL(fetched(Akregator::Feed* )),
00100              this, SLOT(fetchCompleted(Akregator::Feed *)) );
00101     connect( m_feed, SIGNAL(fetchError(Akregator::Feed* )),
00102              this, SLOT(fetchError(Akregator::Feed *)) );
00103     connect( m_feed, SIGNAL(fetchDiscovery(Akregator::Feed* )),
00104              this, SLOT(fetchDiscovery(Akregator::Feed *)) );
00105 
00106     m_feed->fetch(true);
00107 }
00108 
00109 void AddFeedDialog::fetchCompleted(Feed * /*f*/)
00110 {
00111     KDialog::accept();
00112 }
00113 
00114 void AddFeedDialog::fetchError(Feed *)
00115 {
00116     KMessageBox::error(this, i18n("Feed not found from %1.", feedUrl));
00117     KDialog::reject();
00118 }
00119 
00120 void AddFeedDialog::fetchDiscovery(Feed *f)
00121 {
00122     widget->statusLabel->setText( i18n("Feed found, downloading...") );
00123     feedUrl=f->xmlUrl();
00124 }
00125 
00126 void AddFeedDialog::textChanged(const QString& text)
00127 {
00128     enableButtonOk(!text.isEmpty());
00129 }
00130 
00131 } // namespace Akregator
00132 
00133 #include "addfeeddialog.moc"

akregator

Skip menu "akregator"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal