Development/Tutorials/Collaboration/HotNewStuff/Updates: Difference between revisions

From KDE TechBase
(Created page with '{{Template:I18n/Language Navigation Bar|Development/Tutorials/Collaboration/HotNewStuff/Updates}} {{TutorialBrowser| series=HotNewStuff| name=Get Hot New Stuff 3 Introd...')
 
Line 9: Line 9:


== Overview  ==
== Overview  ==
Just like firefox informs you of updates to your addons, KNewStuff can let you check for updates since KDE SC 4.5.
There is an example in [http://websvn.kde.org/trunk/KDE/kdeexamples/knewstuff/updatechecker/ kdeexamples].
== DownloadManager ==
The class in question is DownloadManager.
Use an instance of DownloadManager in your class:
<code cppqt="cppqt">
m_downloadManager = new KNS3::DownloadManager("plasmoids.knsrc", this);
    connect(m_downloadManager, SIGNAL(searchResult(KNS3::Entry::List)), this, SLOT(slotUpdatesFound(KNS3::Entry::List)));
    connect(m_downloadManager, SIGNAL(entryStatusChanged(KNS3::Entry)), this, SLOT(entryStatusChanged(KNS3::Entry)));
    m_downloadManager->checkForUpdates();
</code>
The entryStatusChanged signal informs you when you installed an entry. If you don't want to make use of that possibility, you can ignore the signal.
<code cppqt="cppqt">
void UpdateChecker::slotUpdatesFound(const KNS3::Entry::List& updates)
{
    m_updates = updates;
    foreach (const KNS3::Entry& entry, updates) {
        kDebug() << entry.name();
    }
}</code>
To install an entry you can show the download dialog or do it without the dialog by using:
<code cppqt="cppqt">
m_downloadManager->installEntry(entry);
</code>

Revision as of 17:27, 1 April 2010


Development/Tutorials/Collaboration/HotNewStuff/Updates


Get Hot New Stuff 3 Introduction
Tutorial Series   HotNewStuff
Previous   Get Hot New Stuff 3 - Download
What's Next   Get Hot New Stuff 3 - Upload
Further Reading   n/a

Overview

Just like firefox informs you of updates to your addons, KNewStuff can let you check for updates since KDE SC 4.5.

There is an example in kdeexamples.

DownloadManager

The class in question is DownloadManager.

Use an instance of DownloadManager in your class: m_downloadManager = new KNS3::DownloadManager("plasmoids.knsrc", this);

   connect(m_downloadManager, SIGNAL(searchResult(KNS3::Entry::List)), this, SLOT(slotUpdatesFound(KNS3::Entry::List)));
   connect(m_downloadManager, SIGNAL(entryStatusChanged(KNS3::Entry)), this, SLOT(entryStatusChanged(KNS3::Entry)));
   m_downloadManager->checkForUpdates();

The entryStatusChanged signal informs you when you installed an entry. If you don't want to make use of that possibility, you can ignore the signal. void UpdateChecker::slotUpdatesFound(const KNS3::Entry::List& updates) {

   m_updates = updates;
   foreach (const KNS3::Entry& entry, updates) {
       kDebug() << entry.name();
   }

} To install an entry you can show the download dialog or do it without the dialog by using: m_downloadManager->installEntry(entry);