#include <kdirmodel.h>
#include <QAbstractProxyModel>
+#include <QApplication>
DolphinController::DolphinController(DolphinView* dolphinView) :
QObject(dolphinView),
m_zoomInPossible(false),
m_zoomOutPossible(false),
+ m_openTab(false),
m_url(),
m_dolphinView(dolphinView),
m_itemView(0)
void DolphinController::setItemView(QAbstractItemView* view)
{
+ if (m_itemView != 0) {
+ disconnect(m_itemView, SIGNAL(pressed(const QModelIndex&)),
+ this, SLOT(updateOpenTabState()));
+ }
+
m_itemView = view;
+
+ // TODO: this is a workaround until Qt-issue 176832 has been fixed
+ connect(m_itemView, SIGNAL(pressed(const QModelIndex&)),
+ this, SLOT(updateOpenTabState()));
}
void DolphinController::triggerUrlChangeRequest(const KUrl& url)
void DolphinController::triggerItem(const QModelIndex& index)
{
+ const bool openTab = m_openTab;
+ m_openTab = false;
+
const KFileItem item = itemForIndex(index);
if (index.isValid() && (index.column() == KDirModel::Name)) {
- emit itemTriggered(item);
+ if (openTab && item.isDir()) {
+ emit tabRequested(item.url());
+ } else {
+ emit itemTriggered(item);
+ }
} else {
m_itemView->clearSelection();
- emit itemEntered(item);
+ if (!openTab) {
+ emit itemEntered(item);
+ }
}
}
emit viewportEntered();
}
+void DolphinController::updateOpenTabState()
+{
+ m_openTab = QApplication::mouseButtons() & Qt::MidButton;
+}
+
#include "dolphincontroller.moc"
*/
void itemEntered(const KFileItem& item);
+ /**
+ * Is emitted if a new tab should be opened for the URL \a url.
+ */
+ void tabRequested(const KUrl& url);
+
/**
* Is emitted if the mouse cursor has entered
* the viewport (see emitViewportEntered().
*/
void zoomOut();
+private slots:
+ void updateOpenTabState();
+
private:
bool m_zoomInPossible;
bool m_zoomOutPossible;
+ bool m_openTab; // TODO: this is a workaround until Qt-issue 176832 has been fixed
KUrl m_url;
DolphinView* m_dolphinView;
QAbstractItemView* m_itemView;
m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
}
+void DolphinMainWindow::openNewTab(const KUrl& url)
+{
+ if (m_viewTab.count() == 1) {
+ // Only one view is open currently and hence no tab is shown at
+ // all. Before creating a tab for 'url', provide a tab for the current URL.
+ m_tabBar->addTab(KIcon("folder"), m_activeViewContainer->url().fileName());
+ }
+
+ m_tabBar->addTab(KIcon("folder"), url.fileName());
+
+ ViewTab viewTab;
+ viewTab.splitter = new QSplitter(this);
+ viewTab.primaryView = new DolphinViewContainer(this, viewTab.splitter, url);
+ connectViewSignals(viewTab.primaryView);
+ viewTab.primaryView->view()->reload();
+
+ m_viewTab.append(viewTab);
+}
+
void DolphinMainWindow::toggleActiveView()
{
if (m_viewTab[m_tabIndex].secondaryView == 0) {
this, SLOT(toggleActiveView()));
connect(view, SIGNAL(doingOperation(KonqFileUndoManager::CommandType)),
this, SLOT(slotDoingOperation(KonqFileUndoManager::CommandType)));
+ connect(view, SIGNAL(tabRequested(const KUrl&)),
+ this, SLOT(openNewTab(const KUrl&)));
const KUrlNavigator* navigator = container->urlNavigator();
connect(navigator, SIGNAL(urlChanged(const KUrl&)),
}
}
-void DolphinMainWindow::openNewTab(const KUrl& url)
-{
- if (m_viewTab.count() == 1) {
- // Only one view is open currently and hence no tab is shown at
- // all. Before creating a tab for 'url', provide a tab for the current URL.
- m_tabBar->addTab(KIcon("folder"), m_activeViewContainer->url().fileName());
- }
-
- m_tabBar->addTab(KIcon("folder"), url.fileName());
-
- ViewTab viewTab;
- viewTab.splitter = new QSplitter(this);
- viewTab.primaryView = new DolphinViewContainer(this, viewTab.splitter, url);
- connectViewSignals(viewTab.primaryView);
- viewTab.primaryView->view()->reload();
-
- m_viewTab.append(viewTab);
-}
-
DolphinMainWindow::UndoUiInterface::UndoUiInterface(DolphinMainWindow* mainWin) :
KonqFileUndoManager::UiInterface(mainWin),
m_mainWin(mainWin)
/** Open a new main window. */
void openNewMainWindow();
- /** Opens a new empty view that is part of a tab. */
+ /** Opens a new view with the current URL that is part of a tab. */
void openNewTab();
+ /**
+ * Opens a new tab showing the URL \a url.
+ */
+ void openNewTab(const KUrl& url);
+
/** Toggles the active view if two views are shown within the main window. */
void toggleActiveView();
*/
void updateSplitAction();
- /**
- * Opens a new tab showing the URL \a url.
- */
- void openNewTab(const KUrl& url);
-
private:
/**
* Implements a custom error handling for the undo manager. This
this, SLOT(updateAdditionalInfo(const KFileItemDelegate::InformationList&)));
connect(m_controller, SIGNAL(itemTriggered(const KFileItem&)),
this, SLOT(triggerItem(const KFileItem&)));
+ connect(m_controller, SIGNAL(tabRequested(const KUrl&)),
+ this, SIGNAL(tabRequested(const KUrl&)));
connect(m_controller, SIGNAL(activated()),
this, SLOT(activate()));
connect(m_controller, SIGNAL(itemEntered(const KFileItem&)),
void urlChanged(const KUrl& url);
/**
- * Is emitted when clicking on an item
+ * Is emitted when clicking on an item with the left mouse button.
*/
void itemTriggered(const KFileItem& item);
+ /**
+ * Is emitted if a new tab should be opened for the URL \a url.
+ */
+ void tabRequested(const KUrl& url);
+
/**
* Is emitted if the view mode (IconsView, DetailsView,
* PreviewsView) has been changed.