File indexing completed on 2024-04-14 04:51:58

0001 /* This file is part of the KDE project
0002 
0003    Copyright (C) 2008 Javier Goday <jgoday @ gmail.com>
0004 
0005    This program is free software; you can redistribute it and/or
0006    modify it under the terms of the GNU General Public
0007    License as published by the Free Software Foundation; either
0008    version 2 of the License, or (at your option) any later version.
0009 */
0010 #ifndef LINKIMPORTER_H
0011 #define LINKIMPORTER_H
0012 
0013 #include "kget_export.h"
0014 
0015 #include <QList>
0016 #include <QThread>
0017 
0018 #include <QUrl>
0019 
0020 class KLocalizedString;
0021 
0022 /**
0023  * Import a list of urls from a file (local or remote)
0024  */
0025 class KGET_EXPORT LinkImporter : public QThread
0026 {
0027     Q_OBJECT
0028 public:
0029     LinkImporter(const QUrl &source, QObject *parent);
0030     LinkImporter(QObject *parent);
0031     ~LinkImporter() override;
0032 
0033     /**
0034      * Check for urls in clipboard
0035      */
0036     void checkClipboard(const QString &clipboardContent);
0037 
0038     /**
0039      * Start reading the url contents
0040      */
0041     void run() override;
0042 
0043     /**
0044      * copy the remote file out of the thread
0045      */
0046     void copyRemoteFile();
0047 
0048     /**
0049      * Returns a list with the links of the selected url m_url
0050      */
0051     QList<QString> links()
0052     {
0053         return m_transfers;
0054     };
0055 
0056 Q_SIGNALS:
0057     void error(const KLocalizedString &);
0058     void progress(int progress);
0059 
0060 private Q_SLOTS:
0061     void slotReadFile(const QUrl &url);
0062 
0063 private:
0064     /**
0065      * Checks if an url is valid and adds it to the transfers lists
0066      */
0067     void addTransfer(QString &link);
0068 
0069 private:
0070     QUrl m_url;
0071     QList<QString> m_transfers;
0072     QString m_tempFile;
0073 };
0074 #endif