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

akregator

  • sources
  • kde-4.14
  • kdepim
  • akregator
  • src
addfeeddialog.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Akregator.
3 
4  Copyright (C) 2004 Stanislav Karchebny <Stanislav.Karchebny@kdemail.net>
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 
20  As a special exception, permission is given to link this program
21  with any edition of Qt, and distribute the resulting executable,
22  without including the source code for Qt in the source distribution.
23 */
24 
25 #include "addfeeddialog.h"
26 #include "feed.h"
27 #include "kernel.h"
28 
29 #include <kdebug.h>
30 #include <kiconloader.h>
31 #include <kicontheme.h>
32 #include <klineedit.h>
33 #include <klocale.h>
34 #include <kmessagebox.h>
35 #include <ksqueezedtextlabel.h>
36 #include <kurl.h>
37 
38 #include <QCheckBox>
39 
40 namespace Akregator {
41 
42 AddFeedWidget::AddFeedWidget(QWidget *parent, const char* name)
43  : QWidget(parent)
44 {
45  setObjectName(name);
46  setupUi(this);
47  pixmapLabel1->setPixmap(KIconLoader::global()->loadIcon( "applications-internet",KIconLoader::Desktop,KIconLoader::SizeHuge, KIconLoader::DefaultState, QStringList(), 0, true));
48  statusLabel->setText(QString());
49 }
50 
51 AddFeedWidget::~AddFeedWidget()
52 {}
53 
54 QSize AddFeedDialog::sizeHint() const
55 {
56  QSize sh = KDialog::sizeHint();
57  sh.setHeight(minimumSize().height());
58  sh.setWidth(sh.width() * 1.2);
59  return sh;
60 }
61 
62 Feed* AddFeedDialog::feed()
63 {
64  return m_feed;
65 }
66 
67 AddFeedDialog::AddFeedDialog(QWidget *parent, const char *name)
68  : KDialog(parent
69  /*Qt::WStyle_DialogBorder*/), m_feed( 0 )
70 {
71  setObjectName(name);
72  widget = new AddFeedWidget(this);
73  setCaption(i18n("Add Feed"));
74  setButtons(KDialog::Ok|KDialog::Cancel);
75  setDefaultButton(KDialog::Ok);
76  widget->urlEdit->setFocus();
77  connect(widget->urlEdit, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString)));
78  enableButtonOk(false);
79  setMainWidget(widget);
80 }
81 
82 AddFeedDialog::~AddFeedDialog()
83 {}
84 
85 void AddFeedDialog::setUrl(const QString& t)
86 {
87  widget->urlEdit->setText(t);
88 }
89 
90 void AddFeedDialog::accept()
91 {
92  enableButtonOk(false);
93  feedUrl = widget->urlEdit->text().trimmed();
94 
95  delete m_feed;
96  m_feed = new Feed( Kernel::self()->storage() );
97 
98  // HACK: make weird wordpress links ("feed:http://foobar/rss") work
99  if (feedUrl.startsWith(QLatin1String("feed:http")))
100  feedUrl = feedUrl.right( feedUrl.length() - 5 );
101 
102  if (feedUrl.indexOf(":/") == -1)
103  feedUrl.prepend("http://");
104 
105  KUrl asUrl( feedUrl );
106  if ( asUrl.scheme() == QLatin1String("feed") ) {
107  asUrl.setScheme( "http" );
108  feedUrl = asUrl.url();
109  }
110  m_feed->setXmlUrl(feedUrl);
111 
112  widget->statusLabel->setText( i18n("Downloading %1", feedUrl) );
113 
114  connect( m_feed, SIGNAL(fetched(Akregator::Feed*)),
115  this, SLOT(fetchCompleted(Akregator::Feed*)) );
116  connect( m_feed, SIGNAL(fetchError(Akregator::Feed*)),
117  this, SLOT(fetchError(Akregator::Feed*)) );
118  connect( m_feed, SIGNAL(fetchDiscovery(Akregator::Feed*)),
119  this, SLOT(fetchDiscovery(Akregator::Feed*)) );
120 
121  m_feed->fetch(true);
122 }
123 
124 void AddFeedDialog::fetchCompleted(Feed * /*f*/)
125 {
126  KDialog::accept();
127 }
128 
129 void AddFeedDialog::fetchError(Feed *)
130 {
131  KMessageBox::error(this, i18n("Feed not found from %1.", feedUrl));
132  KDialog::reject();
133 }
134 
135 void AddFeedDialog::fetchDiscovery(Feed *f)
136 {
137  widget->statusLabel->setText( i18n("Feed found, downloading...") );
138  feedUrl=f->xmlUrl();
139 }
140 
141 void AddFeedDialog::textChanged(const QString& text)
142 {
143  enableButtonOk(!text.isEmpty());
144 }
145 
146 } // namespace Akregator
147 
QString::indexOf
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
QWidget
QSize::setHeight
void setHeight(int height)
QWidget::setupUi
void setupUi(QWidget *widget)
QSize::width
int width() const
Akregator::AddFeedDialog::sizeHint
QSize sizeHint() const
Definition: addfeeddialog.cpp:54
kernel.h
Akregator::AddFeedDialog::accept
void accept()
Definition: addfeeddialog.cpp:90
QString::prepend
QString & prepend(QChar ch)
Akregator::AddFeedDialog::fetchError
void fetchError(Akregator::Feed *)
Definition: addfeeddialog.cpp:129
Akregator::AddFeedDialog::AddFeedDialog
AddFeedDialog(QWidget *parent=0, const char *name=0)
Definition: addfeeddialog.cpp:67
Akregator::AddFeedDialog::~AddFeedDialog
~AddFeedDialog()
Definition: addfeeddialog.cpp:82
KDialog
feed.h
QWidget::setFocus
void setFocus()
Akregator::AddFeedDialog::setUrl
void setUrl(const QString &t)
Definition: addfeeddialog.cpp:85
QSize::setWidth
void setWidth(int width)
Akregator::Kernel::self
static Kernel * self()
Definition: kernel.cpp:39
QObject::setObjectName
void setObjectName(const QString &name)
QString::isEmpty
bool isEmpty() const
QString::startsWith
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
Akregator::Feed::fetch
void fetch(bool followDiscovery=false)
starts fetching
Definition: feed.cpp:572
Akregator::Feed::xmlUrl
QString xmlUrl() const
returns the url of the actual feed source (rss/rdf/atom file)
Definition: feed.cpp:372
Akregator::AddFeedWidget
Definition: addfeeddialog.h:39
QString
Akregator::AddFeedDialog::fetchCompleted
void fetchCompleted(Akregator::Feed *)
Definition: addfeeddialog.cpp:124
QStringList
Akregator::AddFeedDialog::fetchDiscovery
void fetchDiscovery(Akregator::Feed *)
Definition: addfeeddialog.cpp:135
QString::right
QString right(int n) const
QSize
Akregator::AddFeedDialog::feed
Feed * feed()
Definition: addfeeddialog.cpp:62
Akregator::Feed::setXmlUrl
void setXmlUrl(const QString &s)
sets the url of the actual feed source (rss/rdf/atom file)
Definition: feed.cpp:374
QLatin1String
Akregator::Feed
represents a feed
Definition: feed.h:53
Akregator::AddFeedWidget::AddFeedWidget
AddFeedWidget(QWidget *parent=0, const char *name=0)
Definition: addfeeddialog.cpp:42
QString::length
int length() const
addfeeddialog.h
Akregator::AddFeedWidget::~AddFeedWidget
~AddFeedWidget()
Definition: addfeeddialog.cpp:51
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:00 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akregator

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

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal