KItemListController::KItemListController(QObject* parent) :
QObject(parent),
+ m_singleClickActivation(KGlobalSettings::singleClick()),
m_selectionTogglePressed(false),
m_selectionBehavior(NoSelection),
m_model(0),
m_autoActivationTimer(0),
m_oldSelection(),
m_keyboardAnchorIndex(-1),
- m_keyboardAnchorXPos(0)
+ m_keyboardAnchorPos(0)
{
connect(m_keyboardManager, SIGNAL(changeCurrentItem(QString,bool)),
this, SLOT(slotChangeCurrentItem(QString,bool)));
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);
if (index > 0) {
--index;
m_keyboardAnchorIndex = index;
- m_keyboardAnchorXPos = keyboardAnchorPos(index);
+ m_keyboardAnchorPos = keyboardAnchorPos(index);
}
break;
if (index < itemCount - 1) {
++index;
m_keyboardAnchorIndex = index;
- m_keyboardAnchorXPos = keyboardAnchorPos(index);
+ m_keyboardAnchorPos = keyboardAnchorPos(index);
}
break;
} 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) {
const QPixmap pixmap = m_view->createDragPixmap(selectedItems);
drag->setPixmap(pixmap);
- drag->exec(Qt::MoveAction | Qt::CopyAction | Qt::LinkAction, Qt::IgnoreAction);
+ drag->exec(Qt::CopyAction);
}
KItemListWidget* KItemListController::hoveredWidget() const
{
const bool validAnchor = m_keyboardAnchorIndex >= 0 &&
m_keyboardAnchorIndex < m_model->count() &&
- keyboardAnchorPos(m_keyboardAnchorIndex) == m_keyboardAnchorXPos;
+ keyboardAnchorPos(m_keyboardAnchorIndex) == m_keyboardAnchorPos;
if (!validAnchor) {
const int index = m_selectionManager->currentItem();
m_keyboardAnchorIndex = index;
- m_keyboardAnchorXPos = keyboardAnchorPos(index);
+ m_keyboardAnchorPos = keyboardAnchorPos(index);
}
}
// that is below the current index
int nextRowIndex = lastColumnIndex + 1;
int searchIndex = nextRowIndex;
- qreal minDiff = qAbs(m_keyboardAnchorXPos - keyboardAnchorPos(nextRowIndex));
+ qreal minDiff = qAbs(m_keyboardAnchorPos - keyboardAnchorPos(nextRowIndex));
while (searchIndex < maxIndex && keyboardAnchorPos(searchIndex + 1) > keyboardAnchorPos(searchIndex)) {
++searchIndex;
- const qreal searchDiff = qAbs(m_keyboardAnchorXPos - keyboardAnchorPos(searchIndex));
+ const qreal searchDiff = qAbs(m_keyboardAnchorPos - keyboardAnchorPos(searchIndex));
if (searchDiff < minDiff) {
minDiff = searchDiff;
nextRowIndex = searchIndex;
// that is above the current index
int previousRowIndex = firstColumnIndex - 1;
int searchIndex = previousRowIndex;
- qreal minDiff = qAbs(m_keyboardAnchorXPos - keyboardAnchorPos(previousRowIndex));
+ qreal minDiff = qAbs(m_keyboardAnchorPos - keyboardAnchorPos(previousRowIndex));
while (searchIndex > 0 && keyboardAnchorPos(searchIndex - 1) < keyboardAnchorPos(searchIndex)) {
--searchIndex;
- const qreal searchDiff = qAbs(m_keyboardAnchorXPos - keyboardAnchorPos(searchIndex));
+ const qreal searchDiff = qAbs(m_keyboardAnchorPos - keyboardAnchorPos(searchIndex));
if (searchDiff < minDiff) {
minDiff = searchDiff;
previousRowIndex = searchIndex;