* Instead of setting and resetting GeneralSettings's split view option, just pass it on to openFiles/openDirectories.
* Require at least one url in openFiles/openDirectories
REVIEW: 123395
{
}
-void DolphinMainWindow::openDirectories(const QList<QUrl>& dirs)
+void DolphinMainWindow::openDirectories(const QList<QUrl>& dirs, bool splitView)
{
- m_tabWidget->openDirectories(dirs);
+ m_tabWidget->openDirectories(dirs, splitView);
}
-void DolphinMainWindow::openFiles(const QList<QUrl>& files)
+void DolphinMainWindow::openFiles(const QList<QUrl>& files, bool splitView)
{
- m_tabWidget->openFiles(files);
+ m_tabWidget->openFiles(files, splitView);
}
void DolphinMainWindow::showCommand(CommandType command)
m_tabWidget->openNewTab(url);
}
-void DolphinMainWindow::openNewActivatedTab(const QUrl& url)
-{
- m_tabWidget->openNewActivatedTab(url);
-}
-
void DolphinMainWindow::openInNewTab()
{
const KFileItemList& list = m_activeViewContainer->view()->selectedItems();
DolphinViewContainer* activeViewContainer() const;
/**
- * Opens each directory in \p dirs in a separate tab. If the "split view"
- * option is enabled, 2 directories are collected within one tab.
+ * Opens each directory in \p dirs in a separate tab. If \a splitView is set,
+ * 2 directories are collected within one tab.
+ * \pre \a dirs must contain at least one url.
*/
- void openDirectories(const QList<QUrl> &dirs);
+ void openDirectories(const QList<QUrl> &dirs, bool splitView);
/**
- * Opens the directory which contains the files \p files
- * and selects all files (implements the --select option
- * of Dolphin).
+ * Opens the directories which contain the files \p files and selects all files.
+ * If \a splitView is set, 2 directories are collected within one tab.
+ * \pre \a files must contain at least one url.
*/
- void openFiles(const QList<QUrl>& files);
+ void openFiles(const QList<QUrl>& files, bool splitView);
/**
* Returns the 'Create New...' sub menu which also can be shared
/** Stores all settings and quits Dolphin. */
void quit();
- /**
- * Opens a new tab showing the URL \a url and activates the tab.
- */
- void openNewActivatedTab(const QUrl& url);
-
signals:
/**
* Is sent if the selection of the currently active view has
#include "dolphintabbar.h"
#include "dolphintabpage.h"
#include "dolphinviewcontainer.h"
-#include "dolphin_generalsettings.h"
#include <QApplication>
#include <KConfigGroup>
}
}
-void DolphinTabWidget::openDirectories(const QList<QUrl>& dirs)
+void DolphinTabWidget::openDirectories(const QList<QUrl>& dirs, bool splitView)
{
- const bool hasSplitView = GeneralSettings::splitView();
+ Q_ASSERT(dirs.size() > 0);
- // Open each directory inside a new tab. If the "split view" option has been enabled,
- // always show two directories within one tab.
QList<QUrl>::const_iterator it = dirs.constBegin();
while (it != dirs.constEnd()) {
const QUrl& primaryUrl = *(it++);
- if (hasSplitView && (it != dirs.constEnd())) {
+ if (splitView && (it != dirs.constEnd())) {
const QUrl& secondaryUrl = *(it++);
openNewTab(primaryUrl, secondaryUrl);
} else {
}
}
-void DolphinTabWidget::openFiles(const QList<QUrl>& files)
+void DolphinTabWidget::openFiles(const QList<QUrl>& files, bool splitView)
{
- if (files.isEmpty()) {
- return;
- }
+ Q_ASSERT(files.size() > 0);
// Get all distinct directories from 'files' and open a tab
// for each directory. If the "split view" option is enabled, two
}
const int oldTabCount = count();
- openDirectories(dirs);
+ openDirectories(dirs, splitView);
const int tabCount = count();
// Select the files. Although the files can be split between several
void openNewTab(const QUrl &primaryUrl, const QUrl &secondaryUrl = QUrl());
/**
- * Opens each directory in \p dirs in a separate tab. If the "split view"
- * option is enabled, 2 directories are collected within one tab.
+ * Opens each directory in \p dirs in a separate tab. If \a splitView is set,
+ * 2 directories are collected within one tab.
+ * \pre \a dirs must contain at least one url.
*/
- void openDirectories(const QList<QUrl>& dirs);
+ void openDirectories(const QList<QUrl>& dirs, bool splitView);
/**
- * Opens the directory which contains the files \p files
- * and selects all files (implements the --select option
- * of Dolphin).
+ * Opens the directories which contain the files \p files and selects all files.
+ * If \a splitView is set, 2 directories are collected within one tab.
+ * \pre \a files must contain at least one url.
*/
- void openFiles(const QList<QUrl> &files);
+ void openFiles(const QList<QUrl> &files, bool splitView);
/**
* Closes the currently active tab.
const QStringList args = parser.positionalArguments();
QList<QUrl> urls = Dolphin::validateUris(args);
- bool resetSplitSettings = false;
- if (parser.isSet("split") && !GeneralSettings::splitView()) {
- // Dolphin should be opened with a split view although this is not
- // set in the GeneralSettings. Temporary adjust the setting until
- // all passed URLs have been opened.
- GeneralSettings::setSplitView(true);
- resetSplitSettings = true;
-
- // We need 2 URLs to open Dolphin in split view mode
- if (urls.isEmpty()) { // No URL given - Open home URL in all two views
- urls.append(GeneralSettings::homeUrl());
- urls.append(GeneralSettings::homeUrl());
- } else if (urls.length() == 1) { // Only 1 URL given - Open given URL in all two views
- urls.append(urls.at(0));
- }
+ if (urls.isEmpty()) {
+ // We need at least one URL to open Dolphin
+ const QUrl homeUrl(QUrl::fromLocalFile(GeneralSettings::homeUrl()));
+ urls.append(homeUrl);
}
- if (!urls.isEmpty()) {
- if (parser.isSet("select")) {
- m_mainWindow->openFiles(urls);
- } else {
- m_mainWindow->openDirectories(urls);
- }
- } else {
- const QUrl homeUrl(QUrl::fromLocalFile(GeneralSettings::homeUrl()));
- m_mainWindow->openNewActivatedTab(homeUrl);
+ const bool splitView = parser.isSet("split") || GeneralSettings::splitView();
+ if (splitView && urls.size() < 2) {
+ // Split view does only make sense if we have at least 2 URLs
+ urls.append(urls.last());
}
- if (resetSplitSettings) {
- GeneralSettings::setSplitView(false);
+ if (parser.isSet("select")) {
+ m_mainWindow->openFiles(urls, splitView);
+ } else {
+ m_mainWindow->openDirectories(urls, splitView);
}
m_mainWindow->show();