Changeset View
Changeset View
Standalone View
Standalone View
src/dolphintabwidget.cpp
Show First 20 Lines • Show All 171 Lines • ▼ Show 20 Line(s) | |||||
172 | 172 | | |||
173 | void DolphinTabWidget::openDirectories(const QList<QUrl>& dirs, bool splitView) | 173 | void DolphinTabWidget::openDirectories(const QList<QUrl>& dirs, bool splitView) | ||
174 | { | 174 | { | ||
175 | Q_ASSERT(dirs.size() > 0); | 175 | Q_ASSERT(dirs.size() > 0); | ||
176 | 176 | | |||
177 | QList<QUrl>::const_iterator it = dirs.constBegin(); | 177 | QList<QUrl>::const_iterator it = dirs.constBegin(); | ||
178 | while (it != dirs.constEnd()) { | 178 | while (it != dirs.constEnd()) { | ||
179 | const QUrl& primaryUrl = *(it++); | 179 | const QUrl& primaryUrl = *(it++); | ||
180 | const int index = getIndexByURL(primaryUrl); | ||||
181 | if (index >= 0) { | ||||
182 | setCurrentIndex(index); | ||||
183 | continue; | ||||
184 | } | ||||
180 | if (splitView && (it != dirs.constEnd())) { | 185 | if (splitView && (it != dirs.constEnd())) { | ||
181 | const QUrl& secondaryUrl = *(it++); | 186 | const QUrl& secondaryUrl = *(it++); | ||
182 | openNewTab(primaryUrl, secondaryUrl); | 187 | openNewActivatedTab(primaryUrl, secondaryUrl); | ||
183 | } else { | 188 | } else { | ||
184 | openNewTab(primaryUrl); | 189 | openNewActivatedTab(primaryUrl); | ||
185 | } | 190 | } | ||
186 | } | 191 | } | ||
187 | } | 192 | } | ||
188 | 193 | | |||
189 | void DolphinTabWidget::openFiles(const QList<QUrl>& files, bool splitView) | 194 | void DolphinTabWidget::openFiles(const QList<QUrl>& files, bool splitView) | ||
190 | { | 195 | { | ||
191 | Q_ASSERT(files.size() > 0); | 196 | Q_ASSERT(files.size() > 0); | ||
192 | 197 | | |||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Line(s) | 278 | { | |||
276 | QStringList args; | 281 | QStringList args; | ||
277 | 282 | | |||
278 | const DolphinTabPage* tabPage = tabPageAt(index); | 283 | const DolphinTabPage* tabPage = tabPageAt(index); | ||
279 | args << tabPage->primaryViewContainer()->url().url(); | 284 | args << tabPage->primaryViewContainer()->url().url(); | ||
280 | if (tabPage->splitViewEnabled()) { | 285 | if (tabPage->splitViewEnabled()) { | ||
281 | args << tabPage->secondaryViewContainer()->url().url(); | 286 | args << tabPage->secondaryViewContainer()->url().url(); | ||
282 | args << QStringLiteral("--split"); | 287 | args << QStringLiteral("--split"); | ||
283 | } | 288 | } | ||
289 | args << QStringLiteral("--new-window"); | ||||
284 | 290 | | |||
285 | const QString command = QStringLiteral("dolphin %1").arg(KShell::joinArgs(args)); | 291 | const QString command = QStringLiteral("dolphin %1").arg(KShell::joinArgs(args)); | ||
286 | KRun::runCommand(command, this); | 292 | KRun::runCommand(command, this); | ||
287 | 293 | | |||
288 | closeTab(index); | 294 | closeTab(index); | ||
289 | } | 295 | } | ||
290 | 296 | | |||
291 | void DolphinTabWidget::openNewActivatedTab(int index) | 297 | void DolphinTabWidget::openNewActivatedTab(int index) | ||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | 365 | { | |||
360 | if (!tabPage) { | 366 | if (!tabPage) { | ||
361 | return QString(); | 367 | return QString(); | ||
362 | } | 368 | } | ||
363 | QString name = tabPage->activeViewContainer()->caption(); | 369 | QString name = tabPage->activeViewContainer()->caption(); | ||
364 | // Make sure that a '&' inside the directory name is displayed correctly | 370 | // Make sure that a '&' inside the directory name is displayed correctly | ||
365 | // and not misinterpreted as a keyboard shortcut in QTabBar::setTabText() | 371 | // and not misinterpreted as a keyboard shortcut in QTabBar::setTabText() | ||
366 | return name.replace('&', QLatin1String("&&")); | 372 | return name.replace('&', QLatin1String("&&")); | ||
367 | } | 373 | } | ||
374 | | ||||
375 | int DolphinTabWidget::getIndexByURL(const QUrl& url) | ||||
376 | { | ||||
377 | const int num_tabs = count(); | ||||
elvisangelaccio: Coding style: missing camelcase
Do we actually need this variable, though? | |||||
378 | for (int i = 0; i < num_tabs; i++) { | ||||
379 | // Conversion to display string is necessary to deal with the '~' alias. | ||||
380 | // i.e. to acknowledge that ~/ is equivalent to /home/user/ | ||||
381 | if (url == tabPageAt(i)->activeViewContainer()->url() || | ||||
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… | |||||
382 | url.toDisplayString(QUrl::StripTrailingSlash) == | ||||
383 | tabPageAt(i)->activeViewContainer()->url().toDisplayString(QUrl::StripTrailingSlash)) | ||||
384 | { | ||||
elvisangelaccio: Coding style: opening brace should go to previous line. | |||||
385 | return i; | ||||
386 | } | ||||
387 | } | ||||
388 | return -1; | ||||
389 | } |
Coding style: missing camelcase
Do we actually need this variable, though?