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); | ||||
190 | if (index >= 0) { | ||||
191 | setCurrentIndex(index); | ||||
192 | continue; | ||||
193 | } | ||||
189 | if (splitView && (it != dirs.constEnd())) { | 194 | if (splitView && (it != dirs.constEnd())) { | ||
190 | const QUrl& secondaryUrl = *(it++); | 195 | const QUrl& secondaryUrl = *(it++); | ||
191 | openNewTab(primaryUrl, secondaryUrl); | 196 | openNewActivatedTab(primaryUrl, secondaryUrl); | ||
192 | } else { | 197 | } else { | ||
193 | openNewTab(primaryUrl); | 198 | openNewActivatedTab(primaryUrl); | ||
194 | } | 199 | } | ||
195 | } | 200 | } | ||
196 | } | 201 | } | ||
197 | 202 | | |||
198 | void DolphinTabWidget::openFiles(const QList<QUrl>& files, bool splitView) | 203 | void DolphinTabWidget::openFiles(const QList<QUrl>& files, bool splitView) | ||
199 | { | 204 | { | ||
200 | Q_ASSERT(files.size() > 0); | 205 | Q_ASSERT(files.size() > 0); | ||
201 | 206 | | |||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Line(s) | 287 | { | |||
285 | QStringList args; | 290 | QStringList args; | ||
286 | 291 | | |||
287 | const DolphinTabPage* tabPage = tabPageAt(index); | 292 | const DolphinTabPage* tabPage = tabPageAt(index); | ||
288 | args << tabPage->primaryViewContainer()->url().url(); | 293 | args << tabPage->primaryViewContainer()->url().url(); | ||
289 | if (tabPage->splitViewEnabled()) { | 294 | if (tabPage->splitViewEnabled()) { | ||
290 | args << tabPage->secondaryViewContainer()->url().url(); | 295 | args << tabPage->secondaryViewContainer()->url().url(); | ||
291 | args << QStringLiteral("--split"); | 296 | args << QStringLiteral("--split"); | ||
292 | } | 297 | } | ||
298 | args << QStringLiteral("--new-window"); | ||||
293 | 299 | | |||
294 | const QString command = QStringLiteral("dolphin %1").arg(KShell::joinArgs(args)); | 300 | const QString command = QStringLiteral("dolphin %1").arg(KShell::joinArgs(args)); | ||
295 | KRun::runCommand(command, this); | 301 | KRun::runCommand(command, this); | ||
296 | 302 | | |||
297 | closeTab(index); | 303 | closeTab(index); | ||
298 | } | 304 | } | ||
299 | 305 | | |||
300 | void DolphinTabWidget::openNewActivatedTab(int index) | 306 | void DolphinTabWidget::openNewActivatedTab(int index) | ||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | 374 | { | |||
369 | if (!tabPage) { | 375 | if (!tabPage) { | ||
370 | return QString(); | 376 | return QString(); | ||
371 | } | 377 | } | ||
372 | QString name = tabPage->activeViewContainer()->caption(); | 378 | QString name = tabPage->activeViewContainer()->caption(); | ||
373 | // Make sure that a '&' inside the directory name is displayed correctly | 379 | // Make sure that a '&' inside the directory name is displayed correctly | ||
374 | // and not misinterpreted as a keyboard shortcut in QTabBar::setTabText() | 380 | // and not misinterpreted as a keyboard shortcut in QTabBar::setTabText() | ||
375 | return name.replace('&', QLatin1String("&&")); | 381 | return name.replace('&', QLatin1String("&&")); | ||
376 | } | 382 | } | ||
383 | | ||||
384 | int DolphinTabWidget::getIndexByUrl(const QUrl& url) const | ||||
385 | { | ||||
386 | for (int i = 0; i < count(); i++) { | ||||
elvisangelaccio: Coding style: missing camelcase
Do we actually need this variable, though? | |||||
387 | // Conversion to display string is necessary to deal with the '~' alias. | ||||
388 | // i.e. to acknowledge that ~/ is equivalent to /home/user/ | ||||
389 | const QUrl tabUrl = tabPageAt(i)->activeViewContainer()->url(); | ||||
390 | if (url == tabUrl || | ||||
Please put tabPageAt(i)->activeViewContainer()->url() in a variable to simplify this condition. elvisangelaccio: Please put `tabPageAt(i)->activeViewContainer()->url()` in a variable to simplify this… | |||||
391 | url.toDisplayString(QUrl::StripTrailingSlash) == tabUrl.toDisplayString(QUrl::StripTrailingSlash)) { | ||||
392 | return i; | ||||
393 | } | ||||
elvisangelaccio: Coding style: opening brace should go to previous line. | |||||
394 | } | ||||
395 | return -1; | ||||
396 | } |
Coding style: missing camelcase
Do we actually need this variable, though?