X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/dcbf1a11783d47e7e4fa30d488ac93a8bc547e71..313cacd4489ba4525409c6f1851bee8ff9829e83:/src/dolphincontroller.cpp diff --git a/src/dolphincontroller.cpp b/src/dolphincontroller.cpp index fe8c426f3..caa0aa74f 100644 --- a/src/dolphincontroller.cpp +++ b/src/dolphincontroller.cpp @@ -26,13 +26,16 @@ #include #include +Qt::MouseButtons DolphinController::m_mouseButtons = Qt::NoButton; + DolphinController::DolphinController(DolphinView* dolphinView) : QObject(dolphinView), m_zoomLevel(0), - m_mouseButtons(Qt::NoButton), + m_nameFilter(), m_url(), m_dolphinView(dolphinView), - m_itemView(0) + m_itemView(0), + m_versionControlActions() { } @@ -44,10 +47,16 @@ void DolphinController::setUrl(const KUrl& url) { if (m_url != url) { m_url = url; + emit cancelPreviews(); emit urlChanged(url); } } +void DolphinController::redirectToUrl(const KUrl& url) +{ + m_url = url; +} + void DolphinController::setItemView(QAbstractItemView* view) { if (m_itemView != 0) { @@ -59,7 +68,7 @@ void DolphinController::setItemView(QAbstractItemView* 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(updateMouseButtonState())); @@ -73,10 +82,11 @@ void DolphinController::triggerUrlChangeRequest(const KUrl& url) } } -void DolphinController::triggerContextMenuRequest(const QPoint& pos) +void DolphinController::triggerContextMenuRequest(const QPoint& pos, + const QList& customActions) { emit activated(); - emit requestContextMenu(pos); + emit requestContextMenu(pos, customActions); } void DolphinController::requestActivation() @@ -102,6 +112,11 @@ void DolphinController::indicateSortOrderChange(Qt::SortOrder order) emit sortOrderChanged(order); } +void DolphinController::indicateSortFoldersFirstChange(bool foldersFirst) +{ + emit sortFoldersFirstChanged(foldersFirst); +} + void DolphinController::indicateAdditionalInfoChange(const KFileItemDelegate::InformationList& info) { emit additionalInfoChanged(info); @@ -112,6 +127,19 @@ void DolphinController::indicateActivationChange(bool active) emit activationChanged(active); } +void DolphinController::setNameFilter(const QString& nameFilter) +{ + if (nameFilter != m_nameFilter) { + m_nameFilter = nameFilter; + emit nameFilterChanged(nameFilter); + } +} + +QString DolphinController::nameFilter() const +{ + return m_nameFilter; +} + void DolphinController::setZoomLevel(int level) { Q_ASSERT(level >= ZoomLevelInfo::minimumLevel()); @@ -122,6 +150,20 @@ void DolphinController::setZoomLevel(int level) } } +void DolphinController::setVersionControlActions(QList actions) +{ + m_versionControlActions = actions; +} + +QList DolphinController::versionControlActions(const KFileItemList& items) +{ + emit requestVersionControlActions(items); + // All view implementations are connected with the signal requestVersionControlActions() + // (see ViewExtensionFactory) and will invoke DolphinController::setVersionControlActions(), + // so that the context dependent actions can be returned. + return m_versionControlActions; +} + void DolphinController::handleKeyPressEvent(QKeyEvent* event) { Q_ASSERT(m_itemView != 0); @@ -129,12 +171,32 @@ void DolphinController::handleKeyPressEvent(QKeyEvent* event) const QItemSelectionModel* selModel = m_itemView->selectionModel(); const QModelIndex currentIndex = selModel->currentIndex(); const bool trigger = currentIndex.isValid() - && (event->key() == Qt::Key_Return) - && (selModel->selectedIndexes().count() > 0); - if (trigger) { - const QModelIndexList indexList = selModel->selectedIndexes(); - foreach (const QModelIndex& index, indexList) { - triggerItem(index); + && ((event->key() == Qt::Key_Return) || (event->key() == Qt::Key_Enter)) + && !selModel->selectedIndexes().isEmpty(); + if (!trigger) { + return; + } + + // Emit the signal itemTriggered() for all selected files. + // Several selected directories are opened in separate tabs, + // one selected directory will get opened in the view. + QModelIndexList dirQueue; + const QModelIndexList indexList = selModel->selectedIndexes(); + foreach (const QModelIndex& index, indexList) { + if (itemForIndex(index).isDir()) { + dirQueue << index; + } else { + emit itemTriggered(itemForIndex(index)); + } + } + + if (dirQueue.length() == 1) { + // open directory in the view + emit itemTriggered(itemForIndex(dirQueue[0])); + } else { + // open directories in separate tabs + foreach(const QModelIndex& dir, dirQueue) { + emit tabRequested(itemForIndex(dir).url()); } } } @@ -158,6 +220,11 @@ void DolphinController::emitHideToolTip() emit hideToolTip(); } +void DolphinController::emitItemTriggered(const KFileItem& item) +{ + emit itemTriggered(item); +} + KFileItem DolphinController::itemForIndex(const QModelIndex& index) const { Q_ASSERT(m_itemView != 0); @@ -178,9 +245,6 @@ void DolphinController::triggerItem(const QModelIndex& index) m_itemView->clearSelection(); emit itemEntered(KFileItem()); } - m_mouseButtons = Qt::NoButton; - } else if (m_mouseButtons & Qt::RightButton) { - m_mouseButtons = Qt::NoButton; } } @@ -194,9 +258,6 @@ void DolphinController::requestTab(const QModelIndex& index) if (validRequest) { emit tabRequested(item.url()); } - m_mouseButtons = Qt::NoButton; - } else if (m_mouseButtons & Qt::RightButton) { - m_mouseButtons = Qt::NoButton; } }