Changeset View
Changeset View
Standalone View
Standalone View
lib/contextmanager.cpp
Show First 20 Lines • Show All 172 Lines • ▼ Show 20 Line(s) | 172 | { | |||
---|---|---|---|---|---|
173 | d->updateSelectedFileItemList(); | 173 | d->updateSelectedFileItemList(); | ||
174 | return d->mSelectedFileItemList; | 174 | return d->mSelectedFileItemList; | ||
175 | } | 175 | } | ||
176 | 176 | | |||
177 | void ContextManager::setCurrentDirUrl(const QUrl &_url) | 177 | void ContextManager::setCurrentDirUrl(const QUrl &_url) | ||
178 | { | 178 | { | ||
179 | const QUrl url = _url.adjusted(QUrl::StripTrailingSlash); | 179 | const QUrl url = _url.adjusted(QUrl::StripTrailingSlash); | ||
180 | if (url == d->mCurrentDirUrl) { | 180 | if (url == d->mCurrentDirUrl) { | ||
181 | return; | 181 | return; | ||
rkflx: `setCurrentDirUrl` can be called in all sort of situations and I'm not sure the fix (even if… | |||||
I did not dare to change this behaviour in selectUrlToSelect(), since I do not understand what could be the problem here with "dragging files". muhlenpfordt: I did not dare to change this behaviour in `selectUrlToSelect()`, since I do not understand… | |||||
182 | } | 182 | } | ||
183 | 183 | | |||
184 | if (url.isValid() && KProtocolManager::supportsListing(url)) { | 184 | if (url.isValid() && KProtocolManager::supportsListing(url)) { | ||
185 | d->mCurrentDirUrl = url; | 185 | d->mCurrentDirUrl = url; | ||
186 | d->mDirModel->dirLister()->openUrl(url); | 186 | d->mDirModel->dirLister()->openUrl(url); | ||
187 | d->mDirListerFinished = false; | 187 | d->mDirListerFinished = false; | ||
188 | } else { | 188 | } else { | ||
189 | d->mCurrentDirUrl.clear(); | 189 | d->mCurrentDirUrl.clear(); | ||
▲ Show 20 Lines • Show All 153 Lines • ▼ Show 20 Line(s) | 342 | if (index.isValid()) { | |||
343 | d->mSelectionModel->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect); | 343 | d->mSelectionModel->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect); | ||
344 | d->mUrlToSelect = QUrl(); | 344 | d->mUrlToSelect = QUrl(); | ||
345 | } else if (d->mDirListerFinished) { | 345 | } else if (d->mDirListerFinished) { | ||
346 | // Desired URL cannot be found in the directory | 346 | // Desired URL cannot be found in the directory | ||
347 | // Clear the selection to avoid dragging any local files into context | 347 | // Clear the selection to avoid dragging any local files into context | ||
348 | // and manually set current URL | 348 | // and manually set current URL | ||
349 | d->mSelectionModel->clearSelection(); | 349 | d->mSelectionModel->clearSelection(); | ||
350 | setCurrentUrl(d->mUrlToSelect); | 350 | setCurrentUrl(d->mUrlToSelect); | ||
351 | d->mUrlToSelect.clear(); | | |||
352 | } | 351 | } | ||
353 | } | 352 | } | ||
354 | 353 | | |||
355 | void ContextManager::slotDirListerRedirection(const QUrl &newUrl) | 354 | void ContextManager::slotDirListerRedirection(const QUrl &newUrl) | ||
356 | { | 355 | { | ||
357 | setCurrentDirUrl(newUrl); | 356 | setCurrentDirUrl(newUrl); | ||
358 | } | 357 | } | ||
359 | 358 | | |||
360 | void ContextManager::slotDirListerCompleted() | 359 | void ContextManager::slotDirListerCompleted() | ||
361 | { | 360 | { | ||
362 | d->mDirListerFinished = true; | 361 | d->mDirListerFinished = true; | ||
363 | } | 362 | } | ||
364 | 363 | | |||
365 | 364 | | |||
366 | } // namespace | 365 | } // namespace |
setCurrentDirUrl can be called in all sort of situations and I'm not sure the fix (even if guarded by the if) is needed in all of these, e.g. when going up to the parent directory. When debugging you might end up in selectUrlToSelect, where for Save As the new filename is in mUrlToSelect as expected. However, at this point mDirModel does not seem to have a correct index for us yet as you noted.
Should we update mDirModel somewhere else, then? Turns out we don't have to: Without your patch, simply disabling the else if clause in selectUrlToSelect is enough to fix the problem, because eventually the selection will be updated after all (it is just cleared too eagerly in the else if).
We could try to get rid of mDirListerFinished completely (it is a bit ugly, anyway). In D8196#160524 I have a long list of test cases, and there is a list of bugs in the summary as well. If you give me a couple of days, I can test those again and ask Valeriy what he thinks about this.