diff options
| author | Elvis Angelaccio <[email protected]> | 2019-09-11 01:09:30 +0200 |
|---|---|---|
| committer | Elvis Angelaccio <[email protected]> | 2019-09-14 13:37:09 +0200 |
| commit | ef5732c89bc5a898941f959a7de33fa6a62b1723 (patch) | |
| tree | fa8af7dc7e9f0fed91b4f7bf0bd3e904f73330fb /src/dolphintabwidget.cpp | |
| parent | abbb98f57b67063dda973817985aefac6ee35409 (diff) | |
DolphinTabWidget: cleanup index-by-URL API usage
Summary:
Follow-up of D23655 where we didn't have time to polish the code:
- add a couple of variables to make the code more clear.
- remove the `get` prefix which we usually don't use in Qt code.
- make the function private since it's very tied to implementation.
- add a new isUrlOpen public method as wrapper.
Reviewers: feverfew
Subscribers: kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D23860
Diffstat (limited to 'src/dolphintabwidget.cpp')
| -rw-r--r-- | src/dolphintabwidget.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/dolphintabwidget.cpp b/src/dolphintabwidget.cpp index 0546316f7..ec0c783bc 100644 --- a/src/dolphintabwidget.cpp +++ b/src/dolphintabwidget.cpp @@ -130,6 +130,11 @@ void DolphinTabWidget::refreshViews() } } +bool DolphinTabWidget::isUrlOpen(const QUrl &url) const +{ + return indexByUrl(url).first >= 0; +} + void DolphinTabWidget::openNewActivatedTab() { const DolphinViewContainer* oldActiveViewContainer = currentTabPage()->activeViewContainer(); @@ -187,11 +192,13 @@ void DolphinTabWidget::openDirectories(const QList<QUrl>& dirs, bool splitView) QList<QUrl>::const_iterator it = dirs.constBegin(); while (it != dirs.constEnd()) { const QUrl& primaryUrl = *(it++); - const QPair<int, bool> viewLocation = getIndexByUrl(primaryUrl); - if (viewLocation.first >= 0) { - setCurrentIndex(viewLocation.first); - const auto tabPage = tabPageAt(viewLocation.first); - if (viewLocation.second) { + const QPair<int, bool> indexInfo = indexByUrl(primaryUrl); + const int index = indexInfo.first; + const bool isInPrimaryView = indexInfo.second; + if (index >= 0) { + setCurrentIndex(index); + const auto tabPage = tabPageAt(index); + if (isInPrimaryView) { tabPage->primaryViewContainer()->setActive(true); } else { tabPage->secondaryViewContainer()->setActive(true); @@ -400,7 +407,7 @@ QString DolphinTabWidget::tabName(DolphinTabPage* tabPage) const return name.replace('&', QLatin1String("&&")); } -QPair<int, bool> DolphinTabWidget::getIndexByUrl(const QUrl& url) const +QPair<int, bool> DolphinTabWidget::indexByUrl(const QUrl& url) const { for (int i = 0; i < count(); i++) { const auto tabPage = tabPageAt(i); |
