Commit 3cb15ca7 authored by Emmanuel Pescosta's avatar Emmanuel Pescosta

Restore old behavior: Navigating by double-clicking in folder panel...

Restore old behavior: Navigating by double-clicking in folder panel (Double-Click - show folder content and expand folder)

BUG: 295573
REVIEW: 106497
FIXED-IN: 4.9.2
parent 068b6297
......@@ -48,6 +48,7 @@ KItemListController::KItemListController(KItemModelBase* model, KItemListView* v
m_clearSelectionIfItemsAreNotDragged(false),
m_selectionBehavior(NoSelection),
m_autoActivationBehavior(ActivationAndExpansion),
m_mouseDoubleClickAction(ActivateItemOnly),
m_model(0),
m_view(0),
m_selectionManager(new KItemListSelectionManager(this)),
......@@ -168,6 +169,16 @@ KItemListController::AutoActivationBehavior KItemListController::autoActivationB
return m_autoActivationBehavior;
}
void KItemListController::setMouseDoubleClickAction(MouseDoubleClickAction action)
{
m_mouseDoubleClickAction = action;
}
KItemListController::MouseDoubleClickAction KItemListController::mouseDoubleClickAction() const
{
return m_mouseDoubleClickAction;
}
void KItemListController::setAutoActivationDelay(int delay)
{
m_autoActivationTimer->setInterval(delay);
......@@ -755,6 +766,14 @@ bool KItemListController::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event,
const QPointF pos = transform.map(event->pos());
const int index = m_view->itemAt(pos);
// Expand item if desired - See Bug 295573
if (m_mouseDoubleClickAction != ActivateItemOnly) {
if (m_view && m_model && m_view->supportsItemExpanding() && m_model->isExpandable(index)) {
const bool expanded = m_model->isExpanded(index);
m_model->setExpanded(index, !expanded);
}
}
bool emitItemActivated = !m_singleClickActivation &&
(event->button() & Qt::LeftButton) &&
index >= 0 && index < m_model->count();
......
......@@ -65,6 +65,7 @@ class LIBDOLPHINPRIVATE_EXPORT KItemListController : public QObject
Q_PROPERTY(KItemListView *view READ view WRITE setView)
Q_PROPERTY(SelectionBehavior selectionBehavior READ selectionBehavior WRITE setSelectionBehavior)
Q_PROPERTY(AutoActivationBehavior autoActivationBehavior READ autoActivationBehavior WRITE setAutoActivationBehavior)
Q_PROPERTY(MouseDoubleClickAction mouseDoubleClickAction READ mouseDoubleClickAction WRITE setMouseDoubleClickAction)
public:
enum SelectionBehavior {
......@@ -78,6 +79,11 @@ public:
ExpansionOnly
};
enum MouseDoubleClickAction {
ActivateAndExpandItem,
ActivateItemOnly
};
/**
* @param model Model of the controller. The ownership is passed to the controller.
* @param view View of the controller. The ownership is passed to the controller.
......@@ -100,6 +106,9 @@ public:
void setAutoActivationBehavior(AutoActivationBehavior behavior);
AutoActivationBehavior autoActivationBehavior() const;
void setMouseDoubleClickAction(MouseDoubleClickAction action);
MouseDoubleClickAction mouseDoubleClickAction() const;
/**
* Sets the delay in milliseconds when dragging an object above an item
* until the item gets activated automatically. A value of -1 indicates
......@@ -297,6 +306,7 @@ private:
bool m_clearSelectionIfItemsAreNotDragged;
SelectionBehavior m_selectionBehavior;
AutoActivationBehavior m_autoActivationBehavior;
MouseDoubleClickAction m_mouseDoubleClickAction;
KItemModelBase* m_model;
KItemListView* m_view;
KItemListSelectionManager* m_selectionManager;
......
......@@ -141,6 +141,7 @@ void FoldersPanel::showEvent(QShowEvent* event)
m_controller = new KItemListController(m_model, view, this);
m_controller->setSelectionBehavior(KItemListController::SingleSelection);
m_controller->setAutoActivationBehavior(KItemListController::ExpansionOnly);
m_controller->setMouseDoubleClickAction(KItemListController::ActivateAndExpandItem);
m_controller->setAutoActivationDelay(750);
m_controller->setSingleClickActivation(true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment