Changeset View
Changeset View
Standalone View
Standalone View
lib/contextmanager.cpp
Show All 29 Lines | |||||
30 | #include <KFileItem> | 30 | #include <KFileItem> | ||
31 | #include <KProtocolManager> | 31 | #include <KProtocolManager> | ||
32 | 32 | | |||
33 | // Local | 33 | // Local | ||
34 | #include <lib/document/documentfactory.h> | 34 | #include <lib/document/documentfactory.h> | ||
35 | #include <lib/gvdebug.h> | 35 | #include <lib/gvdebug.h> | ||
36 | #include <lib/gwenviewconfig.h> | 36 | #include <lib/gwenviewconfig.h> | ||
37 | #include <lib/semanticinfo/sorteddirmodel.h> | 37 | #include <lib/semanticinfo/sorteddirmodel.h> | ||
38 | #include <lib/urlutils.h> | ||||
38 | 39 | | |||
39 | namespace Gwenview | 40 | namespace Gwenview | ||
40 | { | 41 | { | ||
41 | 42 | | |||
42 | struct ContextManagerPrivate | 43 | struct ContextManagerPrivate | ||
43 | { | 44 | { | ||
44 | SortedDirModel* mDirModel; | 45 | SortedDirModel* mDirModel; | ||
45 | QItemSelectionModel* mSelectionModel; | 46 | QItemSelectionModel* mSelectionModel; | ||
▲ Show 20 Lines • Show All 249 Lines • ▼ Show 20 Line(s) | |||||
295 | { | 296 | { | ||
296 | return d->mUrlToSelect; | 297 | return d->mUrlToSelect; | ||
297 | } | 298 | } | ||
298 | 299 | | |||
299 | void ContextManager::setUrlToSelect(const QUrl &url) | 300 | void ContextManager::setUrlToSelect(const QUrl &url) | ||
300 | { | 301 | { | ||
301 | GV_RETURN_IF_FAIL(url.isValid()); | 302 | GV_RETURN_IF_FAIL(url.isValid()); | ||
302 | d->mUrlToSelect = url; | 303 | d->mUrlToSelect = url; | ||
304 | | ||||
305 | // Make sure that an url passed as command line argument is loaded | ||||
tommo: This connect should be moved to the constructor. Otherwise every call to `setUrlToSelect()`… | |||||
hoffmannrobert: Yes, right, moved. | |||||
306 | // and shown before a possibly long running dirlister on a slow | ||||
307 | // network device is started. So start the dirlister with a delay. | ||||
308 | if (UrlUtils::urlIsFastLocalFile(url.adjusted(QUrl::RemoveFilename))) { | ||||
309 | setCurrentDirUrl(url.adjusted(QUrl::RemoveFilename)); | ||||
310 | } | ||||
311 | else { | ||||
312 | QTimer::singleShot(1000, [=]() { | ||||
303 | setCurrentDirUrl(url.adjusted(QUrl::RemoveFilename)); | 313 | setCurrentDirUrl(url.adjusted(QUrl::RemoveFilename)); | ||
314 | }); | ||||
315 | } | ||||
316 | | ||||
304 | setCurrentUrl(url); | 317 | setCurrentUrl(url); | ||
305 | selectUrlToSelect(); | 318 | selectUrlToSelect(); | ||
306 | } | 319 | } | ||
307 | 320 | | |||
308 | QUrl ContextManager::targetDirUrl() const | 321 | QUrl ContextManager::targetDirUrl() const | ||
309 | { | 322 | { | ||
310 | return d->mTargetDirUrl; | 323 | return d->mTargetDirUrl; | ||
311 | } | 324 | } | ||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |
This connect should be moved to the constructor. Otherwise every call to setUrlToSelect() will connect the signal again, causing it to be emitted multiple times.