File indexing completed on 2024-09-15 04:09:58
0001 /*************************************************************************** 0002 * Copyright 2007 Niko Sams <niko.sams@gmail.com> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify * 0005 * it under the terms of the GNU General Public License as published by * 0006 * the Free Software Foundation; either version 2 of the License, or * 0007 * (at your option) any later version. * 0008 * * 0009 ***************************************************************************/ 0010 0011 #ifndef UPLOADJOB_H 0012 #define UPLOADJOB_H 0013 0014 #include <QDialog> 0015 #include <QModelIndex> 0016 0017 class QProgressDialog; 0018 class KJob; 0019 namespace KIO { 0020 class Job; 0021 class CopyJob; 0022 class JobUiDelegate; 0023 class NetAccess; 0024 } 0025 namespace KDevelop { 0026 class IProject; 0027 class ProjectBaseItem; 0028 } 0029 class QStandardItemModel; 0030 class QStandardItem; 0031 class UploadProjectModel; 0032 class UploadPlugin; 0033 0034 /** 0035 * Class that does the Uploading. 0036 * Used for Quick-Upload and in UploadDialog 0037 */ 0038 class UploadJob : public QObject 0039 { 0040 Q_OBJECT 0041 0042 public: 0043 UploadJob(KDevelop::IProject* project, UploadProjectModel* model, QWidget *parent = nullptr); 0044 ~UploadJob() override; 0045 0046 /** 0047 * Sets if the files should only be marked as uploaded 0048 */ 0049 void setOnlyMarkUploaded(bool v) { 0050 m_onlyMarkUploaded = v; 0051 } 0052 bool onlyMarkUploaded() { 0053 return m_onlyMarkUploaded; 0054 } 0055 0056 /** 0057 * Sets if the upload is a quick upload. 0058 * If true, unmodified files will be logged too 0059 */ 0060 void setQuickUpload(bool q); 0061 bool isQuickUpload(); 0062 0063 0064 /** 0065 * Sets the output model that should be used to output the log messages 0066 */ 0067 void setOutputModel(QStandardItemModel* model); 0068 QStandardItemModel* outputModel(); 0069 0070 public Q_SLOTS: 0071 /** 0072 * Starts the upload 0073 */ 0074 void start(); 0075 0076 private Q_SLOTS: 0077 /** 0078 * Upload the next (or first) item 0079 */ 0080 void uploadNext(); 0081 0082 /** 0083 * Called when current job is finished 0084 */ 0085 void uploadResult(KJob*); 0086 0087 /** 0088 * Updates the progress bar 0089 */ 0090 void processedSize(KJob*, qulonglong); 0091 0092 /** 0093 * Updates the progress text 0094 */ 0095 void uploadInfoMessage(KJob*, const QString& plain); 0096 0097 /** 0098 * Cancel button in the ProgressDialog clicked 0099 */ 0100 void cancelClicked(); 0101 0102 Q_SIGNALS: 0103 /** 0104 * Signal is emitted when the upload successfully finished 0105 */ 0106 void uploadFinished(); 0107 0108 private: 0109 /** 0110 * Appends a message to the current outputModel. 0111 * @return the QStandardItem* to modify it further (to eg. change color) 0112 */ 0113 QStandardItem* appendLog(const QString& message); 0114 0115 QModelIndex m_uploadIndex; ///< current index when the upload is running 0116 0117 KDevelop::IProject* m_project; ///< the project of this job 0118 UploadProjectModel* m_uploadProjectModel; 0119 0120 QProgressDialog* m_progressDialog; ///< progress-dialog when the upload is running 0121 int m_progressBytesDone; ///< uploaded bytes, incremented when a file is fully uploaded. used for progress. 0122 0123 bool m_onlyMarkUploaded; ///< if files should be only marked as uploaded 0124 bool m_quickUpload; ///< if it is a quick upload 0125 0126 QStandardItemModel* m_outputModel; 0127 }; 0128 0129 0130 #endif 0131 // kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on