m_clearSelectionIfItemsAreNotDragged(false),
m_selectionBehavior(NoSelection),
m_autoActivationBehavior(ActivationAndExpansion),
+ m_mouseDoubleClickAction(ActivateItemOnly),
m_model(0),
m_view(0),
m_selectionManager(new KItemListSelectionManager(this)),
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);
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();
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 {
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.
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
bool m_clearSelectionIfItemsAreNotDragged;
SelectionBehavior m_selectionBehavior;
AutoActivationBehavior m_autoActivationBehavior;
+ MouseDoubleClickAction m_mouseDoubleClickAction;
KItemModelBase* m_model;
KItemListView* m_view;
KItemListSelectionManager* m_selectionManager;
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);