akregator/src/librss
RSS::Loader Class Reference
#include <loader.h>
Detailed Description
This class is the preferred way of loading RSS files.Usage is very straightforward:
Loader *loader = Loader::create(); connect(loader, SIGNAL(loadingComplete(Loader *, Document, Status)), this, SLOT(slotLoadingComplete(Loader *, Document, Status))); loader->loadFrom("http://www.blah.org/foobar.rdf", new FileRetriever);
This creates a Loader object, connects it's loadingComplete() signal to your custom slot and then makes it load the file 'http://www.blah.org/foobar.rdf' using the FileRetriever. You could've done something like this as well:
// create the Loader, connect it's signal... loader->loadFrom("/home/myself/some-script.py", new OutputRetriever);
That'd make the Loader use another algorithm for retrieving the RSS data; 'OutputRetriever' will make it execute the script '/home/myself/some-script.py' and assume whatever that script prints to stdout is RSS markup. This is e.g. handy for conversion scripts, which download an HTML file and convert it's contents into RSS markup.
No matter what kind of retrieval algorithm you employ, your 'slotLoadingComplete' method might look like this:
void MyClass::slotLoadingComplete(Loader *loader, Document doc, Status status) { // Note that Loader::~Loader() is private, so you cannot delete Loader instances. // You don't need to do that anyway since Loader instances delete themselves. if (status != RSS::Success) return; QString title = doc.title(); // do whatever you want with the information. }
- Note:
- You have to create a copy of the passed Document instance in case you want/need to use it after the slot attached to the loadingComplete signal goes out of scope. This is e.g. the case if you intend to call getPixmap() on Document::image()!
Definition at line 254 of file loader.h.
Signals | |
void | loadingComplete (Loader *loader, Document doc, Status status) |
Public Member Functions | |
void | loadFrom (const KURL &url, DataRetriever *retriever) |
int | errorCode () const |
const KURL & | discoveredFeedURL () const |
void | abort () |
Static Public Member Functions | |
static Loader * | create () |
static Loader * | create (QObject *object, const char *slot) |
Friends | |
class | someClassWhichDoesNotExist |
Member Function Documentation
|
Convenience method. Does the same as the above method except that it also does the job of connecting the loadingComplete() signal to the given slot for you.
|
|
Constructs a Loader instance. This is pretty much what the default constructor would do, except that it ensures that all Loader instances have been allocated on the heap (this is required so that Loader's can delete themselves safely after they emitted the loadingComplete() signal.).
|
|
Retrieves the error code of the last loading process (if any), as reported by the employed data retrever.
|
|
Loads the RSS file referenced by the given URL using the specified retrieval algorithm. Make sure that you connected to the loadingComplete() signal before calling this method so that you're guaranteed to get notified when the loading finished.
|
|
This signal gets emitted when the loading process triggered by calling loadFrom() finished.
|
The documentation for this class was generated from the following file: