Changeset View
Changeset View
Standalone View
Standalone View
krusader/Panel/panelfunc.cpp
Show First 20 Lines • Show All 87 Lines • ▼ Show 20 Line(s) | |||||
88 | #include "../KViewer/krviewer.h" | 88 | #include "../KViewer/krviewer.h" | ||
89 | #include "../GUI/syncbrowsebutton.h" | 89 | #include "../GUI/syncbrowsebutton.h" | ||
90 | #include "../MountMan/kmountman.h" | 90 | #include "../MountMan/kmountman.h" | ||
91 | 91 | | |||
92 | QPointer<ListPanelFunc> ListPanelFunc::copyToClipboardOrigin; | 92 | QPointer<ListPanelFunc> ListPanelFunc::copyToClipboardOrigin; | ||
93 | 93 | | |||
94 | ListPanelFunc::ListPanelFunc(ListPanel *parent) : QObject(parent), | 94 | ListPanelFunc::ListPanelFunc(ListPanel *parent) : QObject(parent), | ||
95 | panel(parent), fileSystemP(0), urlManuallyEntered(false), | 95 | panel(parent), fileSystemP(0), urlManuallyEntered(false), | ||
96 | _ignoreFileSystemErrors(false), _isPaused(true), _refreshAfterPaused(true) | 96 | _isPaused(true), _refreshAfterPaused(true) | ||
97 | { | 97 | { | ||
98 | history = new DirHistoryQueue(panel); | 98 | history = new DirHistoryQueue(panel); | ||
99 | delayTimer.setSingleShot(true); | 99 | delayTimer.setSingleShot(true); | ||
100 | connect(&delayTimer, SIGNAL(timeout()), this, SLOT(doRefresh())); | 100 | connect(&delayTimer, SIGNAL(timeout()), this, SLOT(doRefresh())); | ||
101 | } | 101 | } | ||
102 | 102 | | |||
103 | ListPanelFunc::~ListPanelFunc() | 103 | ListPanelFunc::~ListPanelFunc() | ||
104 | { | 104 | { | ||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Line(s) | 240 | if (_isPaused) { | |||
244 | return; | 244 | return; | ||
245 | } else { | 245 | } else { | ||
246 | _refreshAfterPaused = false; | 246 | _refreshAfterPaused = false; | ||
247 | } | 247 | } | ||
248 | 248 | | |||
249 | const QUrl url = history->currentUrl(); | 249 | const QUrl url = history->currentUrl(); | ||
250 | 250 | | |||
251 | if(!url.isValid()) { | 251 | if(!url.isValid()) { | ||
252 | //FIXME go back in history here ? | | |||
253 | panel->slotStartUpdate(true); // refresh the panel | 252 | panel->slotStartUpdate(true); // refresh the panel | ||
254 | urlManuallyEntered = false; | 253 | urlManuallyEntered = false; | ||
255 | return ; | 254 | return ; | ||
256 | } | 255 | } | ||
257 | 256 | | |||
258 | panel->inlineRefreshCancel(); | 257 | panel->inlineRefreshCancel(); | ||
259 | 258 | | |||
260 | // if we are not refreshing to current URL | 259 | // if we are not refreshing to current URL | ||
261 | bool isEqualUrl = files()->currentDirectory().matches(url, QUrl::StripTrailingSlash); | 260 | const bool isEqualUrl = files()->currentDirectory().matches(url, QUrl::StripTrailingSlash); | ||
262 | 261 | | |||
263 | if (!isEqualUrl) { | 262 | if (!isEqualUrl) { | ||
264 | panel->setCursor(Qt::WaitCursor); | 263 | panel->setCursor(Qt::WaitCursor); | ||
265 | panel->view->clearSavedSelection(); | 264 | panel->view->clearSavedSelection(); | ||
266 | } | 265 | } | ||
267 | 266 | | |||
268 | if(panel->fileSystemError) | 267 | if (panel->fileSystemError) { | ||
269 | panel->fileSystemError->hide(); | 268 | panel->fileSystemError->hide(); | ||
269 | } | ||||
270 | 270 | | |||
271 | bool refreshFailed = false; | 271 | panel->setNavigatorUrl(url); | ||
272 | while (true) { | | |||
273 | QUrl url = history->currentUrl(); | | |||
274 | | ||||
275 | isEqualUrl = files()->currentDirectory().matches(url, QUrl::StripTrailingSlash); | | |||
276 | 272 | | |||
277 | // may get a new filesystem for this url | 273 | // may get a new filesystem for this url | ||
278 | FileSystem *fileSystem = FileSystemProvider::instance().getFilesystem(url, files()); | 274 | FileSystem *fileSystem = FileSystemProvider::instance().getFilesystem(url, files()); | ||
279 | fileSystem->setParentWindow(krMainWindow); | 275 | fileSystem->setParentWindow(krMainWindow); | ||
280 | connect(fileSystem, &FileSystem::aboutToOpenDir, &krMtMan, &KMountMan::autoMount, Qt::DirectConnection); | 276 | connect(fileSystem, &FileSystem::aboutToOpenDir, &krMtMan, &KMountMan::autoMount, Qt::DirectConnection); | ||
281 | if (fileSystem != fileSystemP) { | 277 | if (fileSystem != fileSystemP) { | ||
282 | panel->view->setFiles(0); | 278 | panel->view->setFiles(0); | ||
283 | 279 | | |||
Show All 23 Lines | 302 | if(!history->currentItem().isEmpty() && isEqualUrl) { | |||
307 | // if the url we're refreshing into is the current one, then the | 303 | // if the url we're refreshing into is the current one, then the | ||
308 | // partial refresh will not generate the needed signals to actually allow the | 304 | // partial refresh will not generate the needed signals to actually allow the | ||
309 | // view to use nameToMakeCurrent. do it here instead (patch by Thomas Jarosch) | 305 | // view to use nameToMakeCurrent. do it here instead (patch by Thomas Jarosch) | ||
310 | panel->view->setCurrentItem(history->currentItem()); | 306 | panel->view->setCurrentItem(history->currentItem()); | ||
311 | panel->view->makeItemVisible(panel->view->getCurrentKrViewItem()); | 307 | panel->view->makeItemVisible(panel->view->getCurrentKrViewItem()); | ||
312 | } | 308 | } | ||
313 | panel->view->setNameToMakeCurrent(history->currentItem()); | 309 | panel->view->setNameToMakeCurrent(history->currentItem()); | ||
314 | 310 | | |||
315 | int savedHistoryState = history->state(); | | |||
316 | | ||||
317 | // NOTE: this is blocking. Returns false on error or interruption (cancel requested or panel | 311 | // NOTE: this is blocking. Returns false on error or interruption (cancel requested or panel | ||
318 | // was deleted) | 312 | // was deleted) | ||
319 | const bool refreshed = fileSystemP->refresh(url); | 313 | const bool refreshed = fileSystemP->refresh(url); | ||
320 | if (refreshed) { | 314 | if (refreshed) { | ||
321 | // update the history as the actual url might differ from the one requested | 315 | // update the history and address bar, as the actual url might differ from the one requested | ||
322 | history->setCurrentUrl(url); | 316 | history->setCurrentUrl(fileSystemP->currentDirectory()); | ||
323 | break; // we have a valid refreshed URL now | 317 | panel->setNavigatorUrl(fileSystemP->currentDirectory()); | ||
324 | } | 318 | } | ||
325 | if (!panel || !panel->view) | | |||
326 | // this panel was deleted while refreshing | | |||
327 | return; | | |||
328 | | ||||
329 | refreshFailed = true; | | |||
330 | 319 | | |||
331 | panel->view->setNameToMakeCurrent(QString()); | 320 | panel->view->setNameToMakeCurrent(QString()); | ||
332 | 321 | | |||
333 | if(history->state() != savedHistoryState) // don't go back if the history was touched | | |||
334 | break; | | |||
335 | if(!history->goBack()) { | | |||
336 | // put the root dir to the beginning of history, if it's not there yet | | |||
337 | if (!url.matches(QUrl::fromLocalFile(ROOT_DIR), QUrl::StripTrailingSlash)) | | |||
338 | history->pushBackRoot(); | | |||
339 | else | | |||
340 | break; | | |||
341 | } | | |||
342 | _ignoreFileSystemErrors = true; | | |||
343 | } | | |||
344 | _ignoreFileSystemErrors = false; | | |||
345 | panel->view->setNameToMakeCurrent(QString()); | | |||
346 | | ||||
347 | panel->setCursor(Qt::ArrowCursor); | 322 | panel->setCursor(Qt::ArrowCursor); | ||
348 | 323 | | |||
349 | // on local file system change the working directory | 324 | // on local file system change the working directory | ||
350 | if (files()->isLocal()) | 325 | if (files()->isLocal()) | ||
351 | QDir::setCurrent(KrServices::urlToLocalPath(files()->currentDirectory())); | 326 | QDir::setCurrent(KrServices::urlToLocalPath(files()->currentDirectory())); | ||
352 | 327 | | |||
353 | // see if the open url operation failed, and if so, | 328 | // see if the open url operation failed, and if so, | ||
354 | // put the attempted url in the navigator bar and let the user change it | 329 | // put the attempted url in the navigator bar and let the user change it | ||
355 | if (refreshFailed) { | 330 | if (!refreshed) { | ||
356 | if(isSyncing(url)) | 331 | if(isSyncing(url)) | ||
357 | panel->otherPanel()->gui->syncBrowseButton->setChecked(false); | 332 | panel->otherPanel()->gui->syncBrowseButton->setChecked(false); | ||
358 | else if(urlManuallyEntered) { | 333 | else if(urlManuallyEntered) { | ||
359 | panel->setNavigatorUrl(url); | 334 | panel->setNavigatorUrl(url); | ||
360 | if(panel == ACTIVE_PANEL) | 335 | if(panel == ACTIVE_PANEL) | ||
361 | panel->editLocation(); | 336 | panel->editLocation(); | ||
362 | } | 337 | } | ||
363 | } | 338 | } | ||
▲ Show 20 Lines • Show All 902 Lines • Show Last 20 Lines |