Changeset View
Changeset View
Standalone View
Standalone View
krusader/VFS/default_vfs.cpp
Context not available. | |||||
52 | #include "../JobMan/jobman.h" | 52 | #include "../JobMan/jobman.h" | ||
---|---|---|---|---|---|
53 | #include "../JobMan/krjob.h" | 53 | #include "../JobMan/krjob.h" | ||
54 | 54 | | |||
55 | //FIXME | ||||
56 | #define NO_LOCAL_KIO 0 | ||||
57 | | ||||
55 | default_vfs::default_vfs(): vfs(), _watcher() | 58 | default_vfs::default_vfs(): vfs(), _watcher() | ||
56 | { | 59 | { | ||
57 | _type = VFS_DEFAULT; | 60 | _type = VFS_DEFAULT; | ||
Context not available. | |||||
208 | } | 211 | } | ||
209 | 212 | | |||
210 | delete _watcher; // stop watching the old dir | 213 | delete _watcher; // stop watching the old dir | ||
211 | 214 | #if NO_LOCAL_KIO | |||
212 | if (directory.isLocalFile()) { | 215 | if (directory.isLocalFile()) { | ||
213 | // we could read local directories with KIO but using Qt is a lot faster! | 216 | // we could read local directories with KIO but using Qt is a lot faster! | ||
214 | return refreshLocal(directory); | 217 | return refreshLocal(directory); | ||
215 | } | 218 | } | ||
216 | 219 | #endif | |||
217 | _currentDirectory = cleanUrl(directory); | 220 | _currentDirectory = cleanUrl(directory); | ||
218 | 221 | | |||
219 | // start the listing job | 222 | // start the listing job | ||
Context not available. | |||||
240 | return !_listError; | 243 | return !_listError; | ||
241 | } | 244 | } | ||
242 | 245 | | |||
246 | bool default_vfs::startRefreshInternal(const QUrl &directory, bool showHidden) | ||||
247 | { | ||||
248 | if (!KProtocolManager::supportsListing(directory)) { | ||||
249 | emit error(i18n("Protocol not supported by Krusader:\n%1", directory.url())); | ||||
250 | return false; | ||||
251 | } | ||||
252 | | ||||
253 | delete _watcher; // stop watching the old dir | ||||
254 | | ||||
255 | #if NO_LOCAL_KIO | ||||
256 | if (directory.isLocalFile()) { | ||||
257 | // we could read local directories with KIO but using Qt is a lot faster! | ||||
258 | return refreshLocal(directory); | ||||
259 | } | ||||
260 | #endif | ||||
261 | | ||||
262 | _currentDirectory = cleanUrl(directory); | ||||
263 | | ||||
264 | // start the listing job | ||||
265 | KIO::ListJob *job = KIO::listDir(_currentDirectory, KIO::HideProgressInfo, showHidden); | ||||
266 | connect(job, &KIO::ListJob::entries, this, &default_vfs::slotAddFiles); | ||||
267 | connect(job, &KIO::ListJob::redirection, this, &default_vfs::slotRedirection); | ||||
268 | connect(job, &KIO::ListJob::permanentRedirection, this, &default_vfs::slotRedirection); | ||||
269 | connect(job, &KIO::Job::result, this, [=] (KJob *job) { | ||||
270 | if (job->error()) { | ||||
271 | // we failed to refresh | ||||
272 | emit error(job->errorString()); // display error message (in panel) | ||||
273 | } | ||||
274 | refreshResult(!job->error()); | ||||
275 | }); | ||||
276 | | ||||
277 | // ensure connection credentials are asked only once | ||||
278 | if(!parentWindow.isNull()) { | ||||
279 | KIO::JobUiDelegate *ui = static_cast<KIO::JobUiDelegate*>(job->uiDelegate()); | ||||
280 | ui->setWindow(parentWindow); | ||||
281 | } | ||||
282 | | ||||
283 | emit refreshJobStarted(job); | ||||
284 | | ||||
285 | return true; | ||||
286 | } | ||||
287 | | ||||
243 | // ==== protected slots ==== | 288 | // ==== protected slots ==== | ||
244 | 289 | | |||
245 | void default_vfs::slotListResult(KJob *job) | 290 | void default_vfs::slotListResult(KJob *job) | ||
Context not available. | |||||
269 | const QUrl newUrl = preferLocalUrl(url); | 314 | const QUrl newUrl = preferLocalUrl(url); | ||
270 | 315 | | |||
271 | if (newUrl.scheme() != _currentDirectory.scheme()) { | 316 | if (newUrl.scheme() != _currentDirectory.scheme()) { | ||
317 | abort(); //FIXME | ||||
318 | #if 0 | ||||
272 | // abort and start over again, | 319 | // abort and start over again, | ||
273 | // some protocols (iso, zip, tar) do this on transition to local fs | 320 | // some protocols (iso, zip, tar) do this on transition to local fs | ||
274 | job->kill(); | 321 | job->kill(); | ||
275 | _isRefreshing = false; | 322 | _isRefreshing = false; | ||
276 | refresh(newUrl); | 323 | refresh(newUrl); | ||
277 | return; | 324 | return; | ||
325 | #endif | ||||
278 | } | 326 | } | ||
279 | 327 | | |||
280 | _currentDirectory = cleanUrl(newUrl); | 328 | _currentDirectory = cleanUrl(newUrl); | ||
Context not available. |