X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/7ff8c0d89aecc356d66b2aed25804b5ff22fbff9..e15a9f3a8da1907b26195a1833588fc86a9d50ca:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index e55be1d30..7fcbe498f 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -24,6 +24,9 @@ #include "dolphinremoteencoding.h" #include +#ifdef HAVE_NEPOMUK +#include "search/dolphinsearchoptionsconfigurator.h" +#endif #include "dolphinapplication.h" #include "dolphinnewmenu.h" @@ -109,7 +112,9 @@ DolphinMainWindow::DolphinMainWindow(int id) : m_activeViewContainer(0), m_centralWidgetLayout(0), m_searchBox(0), +#ifdef HAVE_NEPOMUK m_searchOptionsConfigurator(0), +#endif m_id(id), m_tabIndex(0), m_viewTab(), @@ -146,6 +151,64 @@ DolphinMainWindow::~DolphinMainWindow() DolphinApplication::app()->removeMainWindow(this); } +void DolphinMainWindow::openDirectories(const QList& 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::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& 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 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) { @@ -246,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 = @@ -548,12 +606,14 @@ void DolphinMainWindow::readProperties(const KConfigGroup& group) void DolphinMainWindow::updateNewMenu() { + m_newMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->showHiddenFiles()); m_newMenu->slotCheckUpToDate(); m_newMenu->setPopupFiles(activeViewContainer()->url()); } void DolphinMainWindow::createDirectory() { + m_newMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->showHiddenFiles()); m_newMenu->setPopupFiles(activeViewContainer()->url()); m_newMenu->createDirectory(); } @@ -756,7 +816,7 @@ void DolphinMainWindow::goUp() void DolphinMainWindow::goBack(Qt::MouseButtons buttons) { // The default case (left button pressed) is handled in goBack(). - if(buttons == Qt::MidButton) { + if (buttons == Qt::MidButton) { KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator(); openNewTab(urlNavigator->historyUrl(urlNavigator->historyIndex() + 1)); } @@ -765,7 +825,7 @@ void DolphinMainWindow::goBack(Qt::MouseButtons buttons) void DolphinMainWindow::goForward(Qt::MouseButtons buttons) { // The default case (left button pressed) is handled in goForward(). - if(buttons == Qt::MidButton) { + if (buttons == Qt::MidButton) { KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator(); openNewTab(urlNavigator->historyUrl(urlNavigator->historyIndex() - 1)); } @@ -774,7 +834,7 @@ void DolphinMainWindow::goForward(Qt::MouseButtons buttons) void DolphinMainWindow::goUp(Qt::MouseButtons buttons) { // The default case (left button pressed) is handled in goUp(). - if(buttons == Qt::MidButton) { + if (buttons == Qt::MidButton) { openNewTab(activeViewContainer()->url().upUrl()); } } @@ -1001,9 +1061,12 @@ void DolphinMainWindow::slotTestCanDecode(const QDragMoveEvent* event, bool& can canDecode = KUrl::List::canDecode(event->mimeData()); } -void DolphinMainWindow::searchItems(const KUrl& url) +void DolphinMainWindow::searchItems() { - m_activeViewContainer->setUrl(url); +#ifdef HAVE_NEPOMUK + const KUrl nepomukSearchUrl = m_searchOptionsConfigurator->nepomukSearchUrl(); + m_activeViewContainer->setUrl(nepomukSearchUrl); +#endif } void DolphinMainWindow::slotTabMoved(int from, int to) @@ -1012,9 +1075,11 @@ void DolphinMainWindow::slotTabMoved(int from, int to) m_tabIndex = m_tabBar->currentIndex(); } -void DolphinMainWindow::slotSearchBoxTextChanged(const QString& text) +void DolphinMainWindow::showSearchOptions() { - m_searchOptionsConfigurator->setVisible(!text.isEmpty()); +#ifdef HAVE_NEPOMUK + m_searchOptionsConfigurator->show(); +#endif } void DolphinMainWindow::init() @@ -1057,8 +1122,13 @@ void DolphinMainWindow::init() connect(this, SIGNAL(urlChanged(const KUrl&)), m_remoteEncoding, SLOT(slotAboutToOpenUrl())); +#ifdef HAVE_NEPOMUK m_searchOptionsConfigurator = new DolphinSearchOptionsConfigurator(this); m_searchOptionsConfigurator->hide(); + connect(m_searchOptionsConfigurator, SIGNAL(searchOptionsChanged()), + this, SLOT(searchItems())); + connect(this, SIGNAL(urlChanged(KUrl)), m_searchOptionsConfigurator, SLOT(setDirectory(KUrl))); +#endif m_tabBar = new KTabBar(this); m_tabBar->setMovable(true); @@ -1086,7 +1156,9 @@ void DolphinMainWindow::init() m_centralWidgetLayout = new QVBoxLayout(centralWidget); m_centralWidgetLayout->setSpacing(0); m_centralWidgetLayout->setMargin(0); +#ifdef HAVE_NEPOMUK m_centralWidgetLayout->addWidget(m_searchOptionsConfigurator); +#endif m_centralWidgetLayout->addWidget(m_tabBar); m_centralWidgetLayout->addWidget(m_viewTab[m_tabIndex].splitter, 1); @@ -1098,8 +1170,12 @@ void DolphinMainWindow::init() m_searchBox->setParent(toolBar("searchToolBar")); m_searchBox->show(); - connect(m_searchBox, SIGNAL(textChanged(const QString&)), - this, SLOT(slotSearchBoxTextChanged(const QString&))); + connect(m_searchBox, SIGNAL(requestSearchOptions()), + this, SLOT(showSearchOptions())); +#ifdef HAVE_NEPOMUK + connect(m_searchBox, SIGNAL(searchTextChanged(QString)), + m_searchOptionsConfigurator, SLOT(setCustomSearchQuery(QString))); +#endif stateChanged("new_file"); @@ -1332,7 +1408,7 @@ void DolphinMainWindow::setupActions() // 'Search' toolbar m_searchBox = new DolphinSearchBox(this); - connect(m_searchBox, SIGNAL(search(KUrl)), this, SLOT(searchItems(KUrl))); + connect(m_searchBox, SIGNAL(search(QString)), this, SLOT(searchItems())); KAction* search = new KAction(this); actionCollection()->addAction("search_bar", search); @@ -1348,6 +1424,7 @@ void DolphinMainWindow::setupDockWidgets() infoDock->setObjectName("infoDock"); infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); Panel* infoPanel = new InformationPanel(infoDock); + connect(infoPanel, SIGNAL(urlActivated(KUrl)), this, SLOT(handleUrl(KUrl))); infoDock->setWidget(infoPanel); QAction* infoAction = infoDock->toggleViewAction(); @@ -1382,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 @@ -1633,10 +1708,20 @@ void DolphinMainWindow::setUrlAsCaption(const KUrl& url) caption = url.protocol(); } } - + setCaption(caption); } +void DolphinMainWindow::handleUrl(const KUrl& url) +{ + if (KProtocolManager::supportsListing(url)) { + activeViewContainer()->setUrl(url); + } + else { + new KRun(url, this); + } +} + QString DolphinMainWindow::squeezedText(const QString& text) const { const QFontMetrics fm = fontMetrics();