Changeset View
Changeset View
Standalone View
Standalone View
krusader/Splitter/splitter.cpp
Show First 20 Lines • Show All 83 Lines • ▼ Show 20 Line(s) | 65 | { | |||
---|---|---|---|---|---|
84 | 84 | | |||
85 | if (file.isDir()) { | 85 | if (file.isDir()) { | ||
86 | KMessageBox::error(0, i18n("Cannot split a folder.")); | 86 | KMessageBox::error(0, i18n("Cannot split a folder.")); | ||
87 | return; | 87 | return; | ||
88 | } | 88 | } | ||
89 | 89 | | |||
90 | splitReadJob = KIO::get(fileName, KIO::NoReload, KIO::HideProgressInfo); | 90 | splitReadJob = KIO::get(fileName, KIO::NoReload, KIO::HideProgressInfo); | ||
91 | 91 | | |||
92 | connect(splitReadJob, SIGNAL(data(KIO::Job*,QByteArray)), | 92 | connect(splitReadJob, &KIO::TransferJob::data, this, &Splitter::splitDataReceived); | ||
93 | this, SLOT(splitDataReceived(KIO::Job*,QByteArray))); | 93 | connect(splitReadJob, &KIO::TransferJob::result, this, &Splitter::splitReceiveFinished); | ||
94 | connect(splitReadJob, SIGNAL(result(KJob*)), | | |||
95 | this, SLOT(splitReceiveFinished(KJob*))); | | |||
96 | connect(splitReadJob, SIGNAL(percent(KJob*,ulong)), | 94 | connect(splitReadJob, SIGNAL(percent(KJob*,ulong)), | ||
97 | this, SLOT(splitReceivePercent(KJob*,ulong))); | 95 | this, SLOT(splitReceivePercent(KJob*,ulong))); | ||
98 | 96 | | |||
99 | exec(); | 97 | exec(); | ||
100 | } | 98 | } | ||
101 | 99 | | |||
102 | void Splitter::splitDataReceived(KIO::Job *, const QByteArray &byteArray) | 100 | void Splitter::splitDataReceived(KIO::Job *, const QByteArray &byteArray) | ||
103 | { | 101 | { | ||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | 151 | { | |||
164 | writeURL = destinationDir; | 162 | writeURL = destinationDir; | ||
165 | writeURL = writeURL.adjusted(QUrl::StripTrailingSlash); | 163 | writeURL = writeURL.adjusted(QUrl::StripTrailingSlash); | ||
166 | writeURL.setPath(writeURL.path() + '/' + (outFileName)); | 164 | writeURL.setPath(writeURL.path() + '/' + (outFileName)); | ||
167 | 165 | | |||
168 | if (overwrite) | 166 | if (overwrite) | ||
169 | openOutputFile(); | 167 | openOutputFile(); | ||
170 | else { | 168 | else { | ||
171 | statJob = KIO::stat(writeURL, KIO::StatJob::DestinationSide, 0, KIO::HideProgressInfo); | 169 | statJob = KIO::stat(writeURL, KIO::StatJob::DestinationSide, 0, KIO::HideProgressInfo); | ||
172 | connect(statJob, SIGNAL(result(KJob*)), SLOT(statOutputFileResult(KJob*))); | 170 | connect(statJob, &KIO::Job::result, this, &Splitter::statOutputFileResult); | ||
173 | } | 171 | } | ||
174 | } | 172 | } | ||
175 | 173 | | |||
176 | void Splitter::statOutputFileResult(KJob* job) | 174 | void Splitter::statOutputFileResult(KJob* job) | ||
177 | { | 175 | { | ||
178 | statJob = 0; | 176 | statJob = 0; | ||
179 | 177 | | |||
180 | if (job->error()) { | 178 | if (job->error()) { | ||
Show All 19 Lines | 185 | } else { // destination already exists | |||
200 | } | 198 | } | ||
201 | } | 199 | } | ||
202 | } | 200 | } | ||
203 | 201 | | |||
204 | void Splitter::openOutputFile() | 202 | void Splitter::openOutputFile() | ||
205 | { | 203 | { | ||
206 | // create write job | 204 | // create write job | ||
207 | splitWriteJob = KIO::put(writeURL, permissions, KIO::HideProgressInfo | KIO::Overwrite); | 205 | splitWriteJob = KIO::put(writeURL, permissions, KIO::HideProgressInfo | KIO::Overwrite); | ||
208 | connect(splitWriteJob, SIGNAL(dataReq(KIO::Job*,QByteArray&)), | 206 | connect(splitWriteJob, &KIO::TransferJob::dataReq, this, &Splitter::splitDataSend); | ||
209 | this, SLOT(splitDataSend(KIO::Job*,QByteArray&))); | 207 | connect(splitWriteJob, &KIO::TransferJob::result, this, &Splitter::splitSendFinished); | ||
210 | connect(splitWriteJob, SIGNAL(result(KJob*)), | | |||
211 | this, SLOT(splitSendFinished(KJob*))); | | |||
212 | 208 | | |||
213 | } | 209 | } | ||
214 | 210 | | |||
215 | void Splitter::splitDataSend(KIO::Job *, QByteArray &byteArray) | 211 | void Splitter::splitDataSend(KIO::Job *, QByteArray &byteArray) | ||
216 | { | 212 | { | ||
217 | KIO::filesize_t bufferLen = transferArray.size(); | 213 | KIO::filesize_t bufferLen = transferArray.size(); | ||
218 | 214 | | |||
219 | if (!outputFileRemaining) { // current output file needs to be closed ? | 215 | if (!outputFileRemaining) { // current output file needs to be closed ? | ||
Show All 34 Lines | 237 | { | |||
254 | else if (splitReadJob) | 250 | else if (splitReadJob) | ||
255 | splitReadJob->resume(); | 251 | splitReadJob->resume(); | ||
256 | else { // read job is finished and transfer buffer is empty -> splitting is finished | 252 | else { // read job is finished and transfer buffer is empty -> splitting is finished | ||
257 | /* writing the split information file out */ | 253 | /* writing the split information file out */ | ||
258 | writeURL = destinationDir; | 254 | writeURL = destinationDir; | ||
259 | writeURL = writeURL.adjusted(QUrl::StripTrailingSlash); | 255 | writeURL = writeURL.adjusted(QUrl::StripTrailingSlash); | ||
260 | writeURL.setPath(writeURL.path() + '/' + (fileName.fileName() + ".crc")); | 256 | writeURL.setPath(writeURL.path() + '/' + (fileName.fileName() + ".crc")); | ||
261 | splitWriteJob = KIO::put(writeURL, permissions, KIO::HideProgressInfo | KIO::Overwrite); | 257 | splitWriteJob = KIO::put(writeURL, permissions, KIO::HideProgressInfo | KIO::Overwrite); | ||
262 | connect(splitWriteJob, SIGNAL(dataReq(KIO::Job*,QByteArray&)), | 258 | connect(splitWriteJob, &KIO::TransferJob::dataReq, this, &Splitter::splitFileSend); | ||
263 | this, SLOT(splitFileSend(KIO::Job*,QByteArray&))); | 259 | connect(splitWriteJob, &KIO::TransferJob::result, | ||
264 | connect(splitWriteJob, SIGNAL(result(KJob*)), | 260 | this, &Splitter::splitFileFinished); | ||
265 | this, SLOT(splitFileFinished(KJob*))); | | |||
266 | } | 261 | } | ||
267 | } | 262 | } | ||
268 | 263 | | |||
269 | void Splitter::splitAbortJobs() | 264 | void Splitter::splitAbortJobs() | ||
270 | { | 265 | { | ||
271 | if (statJob) | 266 | if (statJob) | ||
272 | statJob->kill(KJob::Quietly); | 267 | statJob->kill(KJob::Quietly); | ||
273 | if (splitReadJob) | 268 | if (splitReadJob) | ||
Show All 27 Lines |