DolphinController::DolphinController(DolphinView* dolphinView) :
QObject(dolphinView),
m_zoomLevel(0),
- m_openTab(false),
+ m_mouseButtons(Qt::NoButton),
m_url(),
m_dolphinView(dolphinView),
m_itemView(0)
{
if (m_itemView != 0) {
disconnect(m_itemView, SIGNAL(pressed(const QModelIndex&)),
- this, SLOT(updateOpenTabState()));
+ this, SLOT(updateMouseButtonState()));
}
m_itemView = view;
if (m_itemView != 0) {
m_zoomLevel = ZoomLevelInfo::zoomLevelForIconSize(m_itemView->iconSize());
-
+
// TODO: this is a workaround until Qt-issue 176832 has been fixed
connect(m_itemView, SIGNAL(pressed(const QModelIndex&)),
- this, SLOT(updateOpenTabState()));
+ this, SLOT(updateMouseButtonState()));
}
}
const QItemSelectionModel* selModel = m_itemView->selectionModel();
const QModelIndex currentIndex = selModel->currentIndex();
const bool trigger = currentIndex.isValid()
- && (event->key() == Qt::Key_Return)
+ && ((event->key() == Qt::Key_Return)
+ || (event->key() == Qt::Key_Enter))
&& (selModel->selectedIndexes().count() > 0);
if (trigger) {
const QModelIndexList indexList = selModel->selectedIndexes();
foreach (const QModelIndex& index, indexList) {
- triggerItem(index);
+ emit itemTriggered(itemForIndex(index));
}
}
}
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)) {
- if (openTab && (item.isDir() || m_dolphinView->isTabsForFilesEnabled())) {
- emit tabRequested(item.url());
- } else {
+ if (m_mouseButtons & Qt::LeftButton) {
+ const KFileItem item = itemForIndex(index);
+ if (index.isValid() && (index.column() == KDirModel::Name)) {
emit itemTriggered(item);
- }
- } else {
- m_itemView->clearSelection();
- if (!openTab) {
+ } else {
+ m_itemView->clearSelection();
emit itemEntered(KFileItem());
}
}
}
+void DolphinController::requestTab(const QModelIndex& index)
+{
+ if (m_mouseButtons & Qt::MidButton) {
+ const KFileItem item = itemForIndex(index);
+ const bool validRequest = index.isValid() &&
+ (index.column() == KDirModel::Name) &&
+ (item.isDir() || m_dolphinView->isTabsForFilesEnabled());
+ if (validRequest) {
+ emit tabRequested(item.url());
+ }
+ }
+}
+
void DolphinController::emitItemEntered(const QModelIndex& index)
{
KFileItem item = itemForIndex(index);
emit viewportEntered();
}
-void DolphinController::updateOpenTabState()
+void DolphinController::updateMouseButtonState()
{
- m_openTab = QApplication::mouseButtons() & Qt::MidButton;
+ m_mouseButtons = QApplication::mouseButtons();
}
#include "dolphincontroller.moc"