KItemListController::KItemListController(QObject* parent) :
QObject(parent),
+ m_singleClickActivation(KGlobalSettings::singleClick()),
m_selectionTogglePressed(false),
m_selectionBehavior(NoSelection),
m_model(0),
return m_autoActivationTimer->interval();
}
+void KItemListController::setSingleClickActivation(bool singleClick)
+{
+ m_singleClickActivation = singleClick;
+}
+
+bool KItemListController::singleClickActivation() const
+{
+ return m_singleClickActivation;
+}
+
bool KItemListController::showEvent(QShowEvent* event)
{
Q_UNUSED(event);
} else if (shiftOrControlPressed) {
// The mouse click should only update the selection, not trigger the item
emitItemActivated = false;
- } else if (!KGlobalSettings::singleClick()) {
+ } else if (!m_singleClickActivation) {
emitItemActivated = false;
}
if (emitItemActivated) {
const QPointF pos = transform.map(event->pos());
const int index = m_view->itemAt(pos);
- bool emitItemActivated = !KGlobalSettings::singleClick() &&
+ bool emitItemActivated = !m_singleClickActivation &&
(event->button() & Qt::LeftButton) &&
index >= 0 && index < m_model->count();
if (emitItemActivated) {
void setAutoActivationDelay(int delay);
int autoActivationDelay() const;
+ /**
+ * If set to true, the signals itemActivated() and itemsActivated() are emitted
+ * after a single-click of the left mouse button. If set to false, a double-click
+ * is required. Per default the setting from KGlobalSettings::singleClick() is
+ * used.
+ */
+ void setSingleClickActivation(bool singleClick);
+ bool singleClickActivation() const;
+
virtual bool showEvent(QShowEvent* event);
virtual bool hideEvent(QHideEvent* event);
virtual bool keyPressEvent(QKeyEvent* event);
qreal keyboardAnchorPos(int index) const;
private:
+ bool m_singleClickActivation;
bool m_selectionTogglePressed;
SelectionBehavior m_selectionBehavior;
KItemModelBase* m_model;
m_controller->setModel(model);
m_controller->setSelectionBehavior(KItemListController::SingleSelection);
m_controller->setAutoActivationDelay(750);
+ m_controller->setSingleClickActivation(true);
connect(m_controller, SIGNAL(itemActivated(int)), this, SLOT(slotItemActivated(int)));
connect(m_controller, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int)));