kget
kget.cpp
Go to the documentation of this file.
69 KGet::TransferData::TransferData(const KUrl &source, const KUrl &destination, const QString& group, bool doStart, const QDomElement *element)
179 TransferHandler * KGet::addTransfer(KUrl srcUrl, QString destDir, QString suggestedFileName, // krazy:exclude=passbyvalue
184 kDebug(5001) << "Source:" << srcUrl.url() << ", dest: " << destDir << ", sugg file: " << suggestedFileName << endl;
257 i18n("<p>The following transfer has been added to the download list:</p><p style=\"font-size: small;\">%1</p>", transfer->source().pathOrUrl()),
264 QList<TransferHandler*> KGet::addTransfers(const QList<QDomElement> &elements, const QString &groupName)
281 const QList<TransferHandler *> KGet::addTransfer(KUrl::List srcUrls, QString destDir, QString groupName, bool start)
303 TransferHandler * newTransfer = addTransfer(srcUrls.first(), destDir, srcUrls.first().fileName(), groupName, start);
355 KGet::showNotification(m_mainWindow, "added", message + content, "kget", i18n("Download added"));
538 TransferGroup * foundGroup = m_transferTreeModel->findGroup( nodeList.item(i).toElement().attribute("Name") );
734 const QStringList patterns = handler->regExp().pattern().split(',');//FIXME 4.5 add a tooltip: "Enter a list of foo separated by ," and then do split(i18nc("used as separator in a list, translate to the same thing you translated \"Enter a list of foo separated by ,\"", ","))
787 //if (m_scheduler->downloadLimit())//TODO: Remove this and the both other hacks in the 2 upper functions with a better replacement
829 QObject::connect(m_transferTreeModel, SIGNAL(transfersAboutToBeRemovedEvent(QList<TransferHandler*>)),
831 QObject::connect(m_transferTreeModel, SIGNAL(transfersChangedEvent(QMap<TransferHandler*,Transfer::ChangesFlags>)),
836 KGet::setHasNetworkConnection((status == Solid::Networking::Connected) || (status == Solid::Networking::Unknown));
846 delete m_jobManager; //This one must always be before the scheduler otherwise the job manager can't remove the notifications when deleting.
855 TransferHandler * KGet::createTransfer(const KUrl &src, const KUrl &dest, const QString& groupName,
858 QList<TransferHandler*> transfer = createTransfers(QList<TransferData>() << TransferData(src, dest, groupName, start, e));
874 kDebug(5001) << "srcUrl=" << data.src << " destUrl=" << data.dest << " group=" << data.groupName;
886 // kDebug(5001) << "KGet::createTransfer -> CREATING NEW TRANSFER ON GROUP: _" << group->name() << "_";
903 QString message = i18np("<p>The following URL cannot be downloaded, its protocol is not supported by KGet:</p>",
913 KGet::showNotification(m_mainWindow, "error", message + content, "dialog-error", i18n("Protocol unsupported"));
928 return handlers;//TODO implement error message if it is 0, or should the addTransfers stuff do that, in case if the numer of returned items does not match the number of sent data?
931 TransferDataSource * KGet::createTransferDataSource(const KUrl &src, const QDomElement &type, QObject *parent)
967 newtransfer = KInputDialog::getText(i18n("New Download"), i18n("Enter URL:"), newtransfer, &ok, 0);
993 KUrl KGet::destFileInputDialog(QString destDir, const QString& suggestedFileName) // krazy:exclude=passbyvalue
1004 KUrl destUrl = KFileDialog::getSaveUrl(startLocation, QString(), m_mainWindow, i18n("Save As"));
1035 i18n("You have already completed a download from the location: \n\n%1\n\nDownload it again?", source.prettyUrl()),
1048 i18n("You have a download in progress from the location: \n\n%1\n\nDelete it and download again?", source.prettyUrl()),
1107 i18n("You have already downloaded that file from another location.\n\nDownload and delete the previous one?"),
1117 dlg = new KIO::RenameDialog( m_mainWindow, i18n("You are already downloading the same file"/*, destUrl.prettyUrl()*/), srcUrl,
1158 KService::List offers = KServiceTypeTrader::self()->query( "KGet/Plugin", str + "'TransferFactory'" );
1282 const QString &text, const QString &icon, const QString &title, const KNotification::NotificationFlags &flags)
1284 return KNotification::event(eventType, title, text, KIcon(icon).pixmap(KIconLoader::SizeMedium), parent, flags);
1292 connect(KGet::model(), SIGNAL(groupRemovedEvent(TransferGroupHandler*)), SLOT(groupRemovedEvent(TransferGroupHandler*)));
1295 connect(KGet::model(), SIGNAL(groupAddedEvent(TransferGroupHandler*)), SLOT(groupAddedEvent(TransferGroupHandler*)));
1298 connect(KGet::model(), SIGNAL(transfersChangedEvent(QMap<TransferHandler*,Transfer::ChangesFlags>)),
1300 connect(KGet::model(), SIGNAL(groupsChangedEvent(QMap<TransferGroupHandler*,TransferGroup::ChangesFlags>)),
1341 void GenericObserver::transferMovedEvent(TransferHandler *transfer, TransferGroupHandler *group)
1370 void GenericObserver::transfersChangedEvent(QMap<TransferHandler*, Transfer::ChangesFlags> transfers)
1384 i18n("<p>The following file has finished downloading:</p><p style=\"font-size: small;\">%1</p>", transfer->dest().fileName()),
1388 i18n("<p>The following transfer has been started:</p><p style=\"font-size: small;\">%1</p>", transfer->source().pathOrUrl()),
1390 } else if (transfer->status() == Job::Aborted && transfer->error().type != Job::AutomaticRetry) {
1391 KNotification * notification = KNotification::event("error", i18n("Error"), i18n("<p>There has been an error in the following transfer:</p><p style=\"font-size: small;\">%1</p>"
1392 "<p>The error message is:</p><p style=\"font-size: small;\">%2</p>", transfer->source().pathOrUrl(), transfer->error().text),
1448 notification = KGet::showNotification(KGet::m_mainWindow, "notification", i18n("KGet is now closing, as all downloads have completed."), "kget", "KGet", KNotification::Persistent | KNotification::CloseWhenWidgetActivated);
1452 notification = KGet::showNotification(KGet::m_mainWindow, "notification", i18n("The computer will now turn off, as all downloads have completed."), "system-shutdown", i18nc("Shutting down computer", "Shutdown"), KNotification::Persistent | KNotification::CloseWhenWidgetActivated);
1455 notification = KGet::showNotification(KGet::m_mainWindow, "notification", i18n("The computer will now suspend to disk, as all downloads have completed."), "system-suspend-hibernate", i18nc("Hibernating computer", "Hibernating"), KNotification::Persistent | KNotification::CloseWhenWidgetActivated);
1458 notification = KGet::showNotification(KGet::m_mainWindow, "notification", i18n("The computer will now suspend to RAM, as all downloads have completed."), "system-suspend", i18nc("Suspending computer", "Suspending"), KNotification::Persistent | KNotification::CloseWhenWidgetActivated);
1486 kDebug() << "Resolve error for" << handler->source().pathOrUrl() << "with id" << handler->error().id;
1502 KGet::setHasNetworkConnection((status == Solid::Networking::Connected) || (status == Solid::Networking::Unknown));
1505 void GenericObserver::groupsChangedEvent(QMap<TransferGroupHandler*, TransferGroup::ChangesFlags> groups)
1534 (transfer->startStatus() != Job::Finished && transfer->startStatus() != Job::FinishedKeepAlive)) {
void setUploadLimit(int limit)
Sets a upload limit to the scheduler.
Definition: transfergroupscheduler.cpp:119
static QString generalDestDir(bool preferXDGDownloadDir=false)
Returns a download directory.
Definition: kget.cpp:945
static void redownloadTransfer(TransferHandler *transfer)
Redownload a transfer.
Definition: kget.cpp:405
Transfer * findTransfer(const KUrl &src)
Definition: transfertreemodel.cpp:467
static TransferHandler * addTransfer(KUrl srcUrl, QString destDir=QString(), QString suggestedFileName=QString(), QString groupName=QString(), bool start=false)
Adds a new transfer to the KGet.
Definition: kget.cpp:179
static void renameGroup(const QString &oldName, const QString &newName)
Changes the name of the group.
Definition: kget.cpp:158
Definition: transfer.h:59
void setIsSuspended(bool isSuspended)
Can be used to suspend the scheduler before doing lenghty operations and activating it later again...
Definition: scheduler.cpp:39
The job is stopped, but this also indicates that it stopped because an error occurred.
Definition: job.h:47
void transfersChangedEvent(QMap< TransferHandler *, Transfer::ChangesFlags > transfers)
Definition: kget.cpp:1370
const int FrameworkVersion
Bump this number whenever the plugin framework gets incompatible with older versions.
Definition: plugin.h:55
Definition: transfergrouphandler.h:30
Definition: job.h:69
static void settingsChanged()
This will be called when the settings have been changed.
Definition: kget.cpp:717
Definition: job.h:70
Definition: transferhistorystore.h:23
static QList< TransferGroupHandler * > selectedTransferGroups()
Definition: kget.cpp:469
static bool delTransfers(const QList< TransferHandler * > &transfers, DeleteMode mode=AutoDelete)
Removes multiple transfers from the KGet.
Definition: kget.cpp:367
static void setGlobalDownloadLimit(int limit)
Sets the global download limit.
Definition: kget.cpp:775
void groupsChangedEvent(QMap< TransferGroupHandler *, TransferGroup::ChangesFlags > groups)
Definition: kget.cpp:1505
static void calculateGlobalDownloadLimit()
Recalculates the global download-limit.
Definition: kget.cpp:793
TransferGroup * findGroup(const QString &groupName)
Definition: transfertreemodel.cpp:457
Definition: transferhistorystore.h:53
This Class is an interface for inter-plugins data change.
Definition: transferdatasource.h:26
static bool matchesExceptions(const KUrl &sourceUrl, const QStringList &patterns)
Returns true if sourceUrl matches any of the patterns.
Definition: kget.cpp:743
QList< TransferGroup * > transferGroups()
Definition: transfertreemodel.cpp:447
Definition: transfertreemodel.h:108
void setDownloadLimit(int limit)
Sets a download limit to the scheduler.
Definition: transfergroupscheduler.cpp:113
static QList< TransferGroupHandler * > allTransferGroups()
Gets all transfer-groups.
Definition: kget.cpp:668
void load(const QDomElement &e)
Adds all the groups in the given QDomNode * to the group.
Definition: transfergroup.cpp:361
Definition: transfer.h:53
ModelItem * itemFromIndex(const QModelIndex &index) const
Definition: transfertreemodel.cpp:391
Definition: transfergroup.h:58
Definition: job.h:43
static void calculateGlobalUploadLimit()
Recalculates the global upload-limit.
Definition: kget.cpp:798
virtual void load(const QDomElement *element)
Loads the transfer's info from the QDomElement.
Definition: transfer.cpp:244
static void save(QString filename=QString(), bool plain=false)
Exports all the transfers and groups to the given file.
Definition: kget.cpp:573
void calculateDownloadLimit()
Calculates the DownloadLimits.
Definition: transfergroupscheduler.cpp:33
static bool addGroup(const QString &groupName)
Adds a new group to the KGet.
Definition: kget.cpp:101
void addTransfers(const QList< Transfer * > &transfers, TransferGroup *group)
Definition: transfertreemodel.cpp:246
virtual void stop()=0
void delTransfers(const QList< Transfer * > &transfers)
Definition: transfertreemodel.cpp:284
void save(QDomElement e)
Saves this group object to the given QDomNode.
Definition: transfergroup.cpp:324
static void moveTransfer(TransferHandler *transfer, const QString &groupName)
Moves a transfer to a new group.
Definition: kget.cpp:399
Definition: transfer.h:96
static QList< TransferHandler * > finishedTransfers()
Definition: kget.cpp:456
TransferGroupScheduler class: what handle all the transfers in kget.
Definition: transfergroupscheduler.h:23
static void setSuspendScheduler(bool isSuspended)
true suspends the scheduler, any events that would result in a reschedule are ignored false wakes up ...
Definition: kget.cpp:652
static TransferGroupHandler * findGroup(const QString &name)
Get the group with the given name.
Definition: kget.cpp:690
static void load(QString filename=QString())
Imports the transfers and groups included in the provided xml file.
Definition: kget.cpp:508
void setHasNetworkConnection(bool hasConnection)
The JobQueues will be informed of changes in the network connection If there is no network connection...
Definition: scheduler.cpp:50
TransferGroupHandler * groupHandler()
Definition: transfertreemodel.cpp:178
void transfersRemovedEvent(const QList< TransferHandler * > &handlers)
Definition: kget.cpp:1333
Definition: transfergroup.h:57
virtual void saveItems(const QList< TransferHistoryItem > &items)
Definition: transferhistorystore.h:78
void transferMovedEvent(TransferHandler *, TransferGroupHandler *)
Definition: kget.cpp:1341
static QList< TransferGroupHandler * > groupsFromExceptions(const KUrl &filename)
Definition: kget.cpp:730
Definition: nepomukcontroller.h:44
Definition: transfer.h:56
Definition: transfertreemodel.h:59
Definition: kget.h:82
void transfersAddedEvent(const QList< TransferHandler * > &handlers)
Definition: kget.cpp:1325
virtual void setSystemTrayDownloading(bool running)
Definition: mainwindow.cpp:1106
void settingsChanged()
This function gets called by the KGet class whenever the settings have changed.
Definition: scheduler.cpp:109
static TransferDataSource * createTransferDataSource(const KUrl &src, const QDomElement &type=QDomElement(), QObject *parent=0)
Scans for all the available plugins and creates the proper transfer DataSource object for transfers C...
Definition: kget.cpp:931
static QList< TransferHandler * > selectedTransfers()
Definition: kget.cpp:416
static void delGroups(QList< TransferGroupHandler * > groups, bool askUser=true)
Removes specific groups from the KGet.
Definition: kget.cpp:132
Transfer * findTransferByDestination(const KUrl &dest)
Definition: transfertreemodel.cpp:483
static QList< TransferHandler * > addTransfers(const QList< QDomElement > &elements, const QString &groupName=QString())
Adds new transfers to the KGet, it is assumed that this takes place because of loading that results i...
Definition: kget.cpp:264
const QList< TransferHandler * > transfers()
Definition: transfergrouphandler.cpp:134
Definition: transfergroup.h:55
Definition: kget.h:78
static KNotification * showNotification(QWidget *parent, const QString &eventType, const QString &text, const QString &icon=QString("dialog-error"), const QString &title=i18n("KGet"), const KNotification::NotificationFlags &flags=KNotification::CloseOnTimeout)
Shows a knotification.
Definition: kget.cpp:1281
static void calculateGlobalSpeedLimits()
Recalculates the global speedlimits.
Definition: kget.cpp:785
static TransferHandler * findTransfer(const KUrl &src)
Get the transfer with the given url.
Definition: kget.cpp:680
Definition: transfer.h:55
Definition: kget.h:79
TransferData(const KUrl &src, const KUrl &dest, const QString &groupName=QString(), bool start=false, const QDomElement *e=0)
static void delGroup(TransferGroupHandler *group, bool askUser=true)
Removes a group from the KGet.
Definition: kget.cpp:115
static TransferHistoryStore * getStore()
Definition: transferhistorystore.cpp:150
Definition: transfer.h:97
void groupAddedEvent(TransferGroupHandler *handler)
Definition: kget.cpp:1313
void groupRemovedEvent(TransferGroupHandler *handler)
Definition: kget.cpp:1319
void create()
This functions gets called whenever a Transfer gets created.
Definition: transfer.cpp:76
static void checkSystemTray()
Run this function for enabling the systemTray (will be automatically done, if there is download runni...
Definition: kget.cpp:700
TransferHandler * transferHandler()
Definition: transfertreemodel.cpp:138
virtual TransferDataSource * createTransferDataSource(const KUrl &srcUrl, const QDomElement &type, QObject *parent)
Returns a Data Source.
Definition: transferfactory.cpp:64
Definition: kget.h:77
static void setSchedulerRunning(bool running=true)
if running == true starts the scheduler if running == false stops the scheduler
Definition: kget.cpp:636
static bool delTransfer(TransferHandler *transfer, DeleteMode mode=AutoDelete)
Removes a transfer from the KGet.
Definition: kget.cpp:362
virtual Transfer * createTransfer(const KUrl &srcUrl, const KUrl &destUrl, TransferGroup *parent, Scheduler *scheduler, const QDomElement *n=0)
Definition: transferfactory.cpp:26
static bool schedulerRunning()
Returns true if the scheduler has running jobs.
Definition: kget.cpp:647
Definition: transfer.h:36
Definition: kget.h:76
Definition: kuiserverjobs.h:29
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:17 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:17 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.