┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphinmainwindow.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2009-12-17 21:07:18 +0000
committerPeter Penz <[email protected]>2009-12-17 21:07:18 +0000
commite15a9f3a8da1907b26195a1833588fc86a9d50ca (patch)
treee140f643669f97e4e51ddbbe4c547e2b2a429e8e /src/dolphinmainwindow.cpp
parentd613313b064ce75b2537f3d0cf08b563ed915574 (diff)
* respect the --select startup option
* minor cleanups related to selecting items in general svn path=/trunk/KDE/kdebase/apps/; revision=1063329
Diffstat (limited to 'src/dolphinmainwindow.cpp')
-rw-r--r--src/dolphinmainwindow.cpp65
1 files changed, 58 insertions, 7 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index 5e08a9e2e..7fcbe498f 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -151,6 +151,64 @@ DolphinMainWindow::~DolphinMainWindow()
DolphinApplication::app()->removeMainWindow(this);
}
+void DolphinMainWindow::openDirectories(const QList<KUrl>& dirs)
+{
+ if (dirs.isEmpty()) {
+ return;
+ }
+
+ const int oldOpenTabsCount = m_viewTab.count();
+
+ const GeneralSettings* generalSettings = DolphinSettings::instance().generalSettings();
+ const bool hasSplitView = generalSettings->splitView();
+
+ // Open each directory inside a new tab. If the "split view" option has been enabled,
+ // always show two directories within one tab.
+ QList<KUrl>::const_iterator it = dirs.begin();
+ while (it != dirs.end()) {
+ openNewTab(*it);
+ ++it;
+
+ if (hasSplitView && (it != dirs.end())) {
+ const int tabIndex = m_viewTab.count() - 1;
+ m_viewTab[tabIndex].secondaryView->setUrl(*it);
+ ++it;
+ }
+ }
+
+ // remove the previously opened tabs
+ for (int i = 0; i < oldOpenTabsCount; ++i) {
+ closeTab(0);
+ }
+}
+
+void DolphinMainWindow::openFiles(const QList<KUrl>& files)
+{
+ // Get all distinct directories from 'files' and open a tab
+ // for each directory. If the "split view" option is enabled, two
+ // directories are shown inside one tab (see openDirectories()).
+ QList<KUrl> dirs;
+ foreach (const KUrl& url, files) {
+ const KUrl dir(url.directory());
+ if (!dirs.contains(dir)) {
+ dirs.append(dir);
+ }
+ }
+
+ openDirectories(dirs);
+
+ // Select the files. Although the files can be split between several
+ // tabs, there is no need to split 'files' accordingly, as
+ // the DolphinView will just ignore invalid selections.
+ const int tabCount = m_viewTab.count();
+ for (int i = 0; i < tabCount; ++i) {
+ m_viewTab[i].primaryView->view()->markUrlsAsSelected(files);
+ if (m_viewTab[i].secondaryView != 0) {
+ m_viewTab[i].secondaryView->view()->markUrlsAsSelected(files);
+ }
+ }
+}
+
void DolphinMainWindow::toggleViews()
{
if (m_viewTab[m_tabIndex].primaryView == 0) {
@@ -251,11 +309,6 @@ void DolphinMainWindow::changeUrl(const KUrl& url)
}
}
-void DolphinMainWindow::changeSelection(const KFileItemList& selection)
-{
- activeViewContainer()->view()->changeSelection(selection);
-}
-
void DolphinMainWindow::slotEditableStateChanged(bool editable)
{
KToggleAction* editableLocationAction =
@@ -1406,8 +1459,6 @@ void DolphinMainWindow::setupDockWidgets()
foldersPanel, SLOT(setUrl(KUrl)));
connect(foldersPanel, SIGNAL(changeUrl(KUrl, Qt::MouseButtons)),
this, SLOT(handlePlacesClick(KUrl, Qt::MouseButtons)));
- connect(foldersPanel, SIGNAL(changeSelection(KFileItemList)),
- this, SLOT(changeSelection(KFileItemList)));
// setup "Terminal"
#ifndef Q_OS_WIN