Commit 15bccd6a authored by Andrey Butirsky's avatar Andrey Butirsky
Browse files

fix draggable area not clearly signposted/misleading highlighting

BUG: 426499
parent 2c2f8f35
Pipeline #175405 passed with stage
in 1 minute and 27 seconds
......@@ -131,10 +131,9 @@ QVariant ArchiveModel::data(const QModelIndex &index, int role) const
Qt::ItemFlags ArchiveModel::flags(const QModelIndex &index) const
{
Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index);
if (index.isValid()) {
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | defaultFlags;
const auto itemFlags = Qt::ItemIsEnabled | Qt::ItemIsSelectable | QAbstractItemModel::flags(index);
return index.column() ? itemFlags : itemFlags | Qt::ItemIsDragEnabled;
}
return Qt::NoItemFlags;
......
......@@ -162,3 +162,16 @@ void ArchiveView::closeEntryEditor()
closePersistentEditor(m_editorIndex);
m_editorIndex = QModelIndex();
}
void NoHighlightSelectionDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
if (index.column() && option.state.testFlag(QStyle::State_Selected)) {
QStyleOptionViewItem myOption = option;
myOption.state |= QStyle::State_MouseOver;
myOption.state &= ~QStyle::State_Selected;
QStyledItemDelegate::paint(painter, myOption, index);
} else {
QStyledItemDelegate::paint(painter, option, index);
}
}
......@@ -9,6 +9,7 @@
#define ARCHIVEVIEW_H
#include <QTreeView>
#include <QStyledItemDelegate>
class QLineEdit;
......@@ -52,4 +53,14 @@ private:
QLineEdit *m_entryEditor = nullptr;
};
class NoHighlightSelectionDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
explicit NoHighlightSelectionDelegate(QObject* parent)
: QStyledItemDelegate(parent) {}
void paint(QPainter* painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
};
#endif /* ARCHIVEVIEW_H */
......@@ -329,6 +329,9 @@ void Part::setupView()
m_filterModel->setSourceModel(m_model);
m_view->setModel(m_filterModel);
m_view->setItemDelegate(new NoHighlightSelectionDelegate(this));
m_filterModel->setFilterKeyColumn(0);
m_filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
......
Supports Markdown
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