#include "dolphintabbar.h"
#include "dolphintabpage.h"
#include "dolphinviewcontainer.h"
-#include "dolphin_generalsettings.h"
-#include "views/draganddrophelper.h"
#include <QApplication>
#include <KConfigGroup>
+#include <KShell>
#include <kio/global.h>
#include <KRun>
}
}
-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
{
Q_ASSERT(index >= 0);
- const QString separator(QLatin1Char(' '));
- QString command = QLatin1String("dolphin");
+ QStringList args;
const DolphinTabPage* tabPage = tabPageAt(index);
- command += separator + tabPage->primaryViewContainer()->url().url();
+ args << tabPage->primaryViewContainer()->url().url();
if (tabPage->splitViewEnabled()) {
- command += separator + tabPage->secondaryViewContainer()->url().url();
- command += separator + QLatin1String("-split");
+ args << tabPage->secondaryViewContainer()->url().url();
+ args << QStringLiteral("--split");
}
+ const QString command = QStringLiteral("dolphin %1").arg(KShell::joinArgs(args));
KRun::runCommand(command, this);
closeTab(index);
void DolphinTabWidget::tabDropEvent(int index, QDropEvent* event)
{
if (index >= 0) {
- const DolphinView* view = tabPageAt(index)->activeViewContainer()->view();
-
- QString error;
- DragAndDropHelper::dropUrls(view->rootItem(), view->url(), event, error);
- if (!error.isEmpty()) {
- currentTabPage()->activeViewContainer()->showMessage(error, DolphinViewContainer::Error);
- }
+ DolphinView* view = tabPageAt(index)->activeViewContainer()->view();
+ view->dropUrls(view->url(), event);
}
}