+void DolphinMainWindow::closeTab()
+{
+ closeTab(m_tabBar->currentIndex());
+}
+
+void DolphinMainWindow::closeTab(int index)
+{
+ Q_ASSERT(index >= 0);
+ Q_ASSERT(index < m_viewTab.count());
+ if (m_viewTab.count() == 1) {
+ // the last tab may never get closed
+ return;
+ }
+
+ if (index == m_tabIndex) {
+ // The tab that should be closed is the active tab. Activate the
+ // previous tab before closing the tab.
+ m_tabBar->setCurrentIndex((index > 0) ? index - 1 : 1);
+ }
+
+ // delete tab
+ m_viewTab[index].primaryView->deleteLater();
+ if (m_viewTab[index].secondaryView != 0) {
+ m_viewTab[index].secondaryView->deleteLater();
+ }
+ m_viewTab[index].splitter->deleteLater();
+ m_viewTab.erase(m_viewTab.begin() + index);
+
+ m_tabBar->blockSignals(true);
+ m_tabBar->removeTab(index);
+
+ if (m_tabIndex > index) {
+ m_tabIndex--;
+ Q_ASSERT(m_tabIndex >= 0);
+ }
+
+ // if only one tab is left, also remove the tab entry so that
+ // closing the last tab is not possible
+ if (m_viewTab.count() == 1) {
+ m_tabBar->removeTab(0);
+ actionCollection()->action("close_tab")->setEnabled(false);
+ } else {
+ m_tabBar->blockSignals(false);
+ }
+}
+
+void DolphinMainWindow::openTabContextMenu(int index, const QPoint& pos)
+{
+ KMenu menu(this);
+
+ QAction* newTabAction = menu.addAction(KIcon("tab-new"), i18nc("@action:inmenu", "New Tab"));
+ newTabAction->setShortcut(actionCollection()->action("new_tab")->shortcut());
+
+ QAction* closeOtherTabsAction = menu.addAction(KIcon("tab-close-other"), i18nc("@action:inmenu", "Close Other Tabs"));
+
+ QAction* closeTabAction = menu.addAction(KIcon("tab-close"), i18nc("@action:inmenu", "Close Tab"));
+ closeTabAction->setShortcut(actionCollection()->action("close_tab")->shortcut());
+
+ QAction* selectedAction = menu.exec(pos);
+ if (selectedAction == newTabAction) {
+ const ViewTab& tab = m_viewTab[index];
+ Q_ASSERT(tab.primaryView != 0);
+ const KUrl url = (tab.secondaryView != 0) && tab.secondaryView->isActive() ?
+ tab.secondaryView->url() : tab.primaryView->url();
+ openNewTab(url);
+ m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
+ } else if (selectedAction == closeOtherTabsAction) {
+ const int count = m_tabBar->count();
+ for (int i = 0; i < index; ++i) {
+ closeTab(0);
+ }
+ for (int i = index + 1; i < count; ++i) {
+ closeTab(1);
+ }
+ } else if (selectedAction == closeTabAction) {
+ closeTab(index);
+ }
+}
+
+void DolphinMainWindow::handlePlacesClick(const KUrl& url, Qt::MouseButtons buttons)
+{
+ if (buttons & Qt::MidButton) {
+ openNewTab(url);
+ m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
+ } else {
+ changeUrl(url);
+ }
+}
+
+void DolphinMainWindow::slotTestCanDecode(const QDragMoveEvent* event, bool& canDecode)
+{
+ canDecode = KUrl::List::canDecode(event->mimeData());
+}
+
+void DolphinMainWindow::searchItems(const KUrl& url)
+{
+ m_activeViewContainer->setUrl(url);
+}
+
+