Changeset View
Changeset View
Standalone View
Standalone View
src/dolphintabwidget.cpp
Show First 20 Lines • Show All 180 Lines • ▼ Show 20 Line(s) | |||||
181 | 181 | | |||
182 | void DolphinTabWidget::openDirectories(const QList<QUrl>& dirs, bool splitView) | 182 | void DolphinTabWidget::openDirectories(const QList<QUrl>& dirs, bool splitView) | ||
183 | { | 183 | { | ||
184 | Q_ASSERT(dirs.size() > 0); | 184 | Q_ASSERT(dirs.size() > 0); | ||
185 | 185 | | |||
186 | QList<QUrl>::const_iterator it = dirs.constBegin(); | 186 | QList<QUrl>::const_iterator it = dirs.constBegin(); | ||
187 | while (it != dirs.constEnd()) { | 187 | while (it != dirs.constEnd()) { | ||
188 | const QUrl& primaryUrl = *(it++); | 188 | const QUrl& primaryUrl = *(it++); | ||
189 | const int index = getIndexByUrl(primaryUrl); | 189 | const QPair<int, bool> viewLocation = getIndexByUrl(primaryUrl); | ||
190 | if (index >= 0) { | 190 | if (viewLocation.first >= 0) { | ||
191 | setCurrentIndex(index); | 191 | setCurrentIndex(viewLocation.first); | ||
192 | const auto tabPage = tabPageAt(viewLocation.first); | ||||
193 | if (viewLocation.second) { | ||||
194 | tabPage->primaryViewContainer()->setActive(true); | ||||
195 | } else { | ||||
196 | tabPage->secondaryViewContainer()->setActive(true); | ||||
197 | } | ||||
192 | continue; | 198 | continue; | ||
193 | } | 199 | } | ||
194 | if (splitView && (it != dirs.constEnd())) { | 200 | if (splitView && (it != dirs.constEnd())) { | ||
195 | const QUrl& secondaryUrl = *(it++); | 201 | const QUrl& secondaryUrl = *(it++); | ||
196 | openNewActivatedTab(primaryUrl, secondaryUrl); | 202 | openNewActivatedTab(primaryUrl, secondaryUrl); | ||
197 | } else { | 203 | } else { | ||
198 | openNewActivatedTab(primaryUrl); | 204 | openNewActivatedTab(primaryUrl); | ||
199 | } | 205 | } | ||
▲ Show 20 Lines • Show All 176 Lines • ▼ Show 20 Line(s) | 381 | if (!tabPage) { | |||
376 | return QString(); | 382 | return QString(); | ||
377 | } | 383 | } | ||
378 | QString name = tabPage->activeViewContainer()->caption(); | 384 | QString name = tabPage->activeViewContainer()->caption(); | ||
379 | // Make sure that a '&' inside the directory name is displayed correctly | 385 | // Make sure that a '&' inside the directory name is displayed correctly | ||
380 | // and not misinterpreted as a keyboard shortcut in QTabBar::setTabText() | 386 | // and not misinterpreted as a keyboard shortcut in QTabBar::setTabText() | ||
381 | return name.replace('&', QLatin1String("&&")); | 387 | return name.replace('&', QLatin1String("&&")); | ||
382 | } | 388 | } | ||
383 | 389 | | |||
384 | int DolphinTabWidget::getIndexByUrl(const QUrl& url) const | 390 | QPair<int, bool> DolphinTabWidget::getIndexByUrl(const QUrl& url) const | ||
385 | { | 391 | { | ||
386 | for (int i = 0; i < count(); i++) { | 392 | for (int i = 0; i < count(); i++) { | ||
387 | // Conversion to display string is necessary to deal with the '~' alias. | 393 | const auto tabPage = tabPageAt(i); | ||
388 | // i.e. to acknowledge that ~/ is equivalent to /home/user/ | 394 | if (url == tabPage->primaryViewContainer()->url()) { | ||
389 | const QUrl tabUrl = tabPageAt(i)->activeViewContainer()->url(); | 395 | return qMakePair(i, true); | ||
390 | if (url == tabUrl || | 396 | } | ||
391 | url.toDisplayString(QUrl::StripTrailingSlash) == tabUrl.toDisplayString(QUrl::StripTrailingSlash)) { | 397 | | ||
elvisangelaccio: Please use `DolphinTabPage::splitViewEnabled()` (which makes the comment below redundant...)… | |||||
elvisangelaccio: > Please use DolphinTabPage::splitViewEnabled()
Still not fixed :P | |||||
elvisangelaccio: Going to fix it myself before pushing. | |||||
elvisangelaccio: Ah sorry, I didn't see latest version of the patch ;) | |||||
392 | return i; | 398 | if (tabPage->splitViewEnabled() && url == tabPage->secondaryViewContainer()->url()) { | ||
399 | return qMakePair(i, false); | ||||
elvisangelaccio: `const` | |||||
393 | } | 400 | } | ||
394 | } | 401 | } | ||
395 | return -1; | 402 | return qMakePair(-1, false); | ||
396 | } | 403 | } |
Please use DolphinTabPage::splitViewEnabled() (which makes the comment below redundant...)
Nitpick: else not necessary after return.