Before starting autoActivationTimer, check that we're hovering the item on top of a directory.
If we don't check for it, the the autoActivationTimer will try to open the hovered item
in it's default application, which can be distracting and break the actual action
the user was trying to do, like moving the file to a directory.
BUG:479960
return !item.isNull() && DragAndDropHelper::supportsDropping(item);
}
+bool KFileItemModel::canEnterOnHover(int index) const
+{
+ KFileItem item;
+ if (index == -1) {
+ item = rootItem();
+ } else {
+ item = fileItem(index);
+ }
+ return !item.isNull() && (item.isDir() || item.isDesktopFile());
+}
+
QString KFileItemModel::roleDescription(const QByteArray &role) const
{
static QHash<QByteArray, QString> description;
bool supportsDropping(int index) const override;
+ bool canEnterOnHover(int index) const override;
+
QString roleDescription(const QByteArray &role) const override;
QList<QPair<int, QVariant>> groups() const override;
Q_EMIT itemHovered(index);
}
- if (!m_autoActivationTimer->isActive() && m_autoActivationTimer->interval() >= 0) {
+ if (!m_autoActivationTimer->isActive() && m_autoActivationTimer->interval() >= 0 && m_model->canEnterOnHover(index)) {
m_autoActivationTimer->setProperty("index", index);
m_autoActivationTimer->start();
newHoveredWidget->startActivateSoonAnimation(m_autoActivationTimer->remainingTime());
}
+
} else {
m_autoActivationTimer->stop();
if (newHoveredWidget && newHoveredWidget->isHovered()) {
return false;
}
+bool KItemModelBase::canEnterOnHover(int index) const
+{
+ Q_UNUSED(index)
+ return false;
+}
+
QString KItemModelBase::blacklistItemDropEventMimeType() const
{
return QStringLiteral("application/x-dolphin-blacklist-drop");
// decision whether it accepts the drop?
virtual bool supportsDropping(int index) const;
+ /**
+ * @return True, if the item with the index \a index can be entered in during hover actions.
+ * Per default false is returned.
+ *
+ * This is used to check that if the item
+ * we're hovering on is either directory or a desktop file.
+ */
+ virtual bool canEnterOnHover(int index) const;
+
/**
* @return An internal mimetype to signal that an itemDropEvent() should be rejected by
* the receiving model.