summaryrefslogtreecommitdiff
path: root/src/pluginlistview.cpp
diff options
context:
space:
mode:
authorJeremy Rimpo <jrim@rimpo.org>2017-11-30 16:37:14 -0600
committerJeremy Rimpo <jrim@rimpo.org>2017-11-30 16:37:14 -0600
commitd7bc542b3d1a96a546d48850e61d3ecdc953c4cc (patch)
tree8a02758752b525a32876a687ae207962b7e5be9a /src/pluginlistview.cpp
parent977d562976a06b9d98e08197d28dfca7cb3d229e (diff)
Implement mod/plugin highlighting when pair is selected
Diffstat (limited to 'src/pluginlistview.cpp')
-rw-r--r--src/pluginlistview.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/pluginlistview.cpp b/src/pluginlistview.cpp
new file mode 100644
index 00000000..0fcf8183
--- /dev/null
+++ b/src/pluginlistview.cpp
@@ -0,0 +1,58 @@
+#include "pluginlistview.h"
+#include <QUrl>
+#include <QMimeData>
+#include <QProxyStyle>
+
+
+class PluginListViewStyle : public QProxyStyle {
+public:
+ PluginListViewStyle(QStyle *style, int indentation);
+
+ void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget = 0) const;
+private:
+ int m_Indentation;
+};
+
+PluginListViewStyle::PluginListViewStyle(QStyle *style, int indentation)
+ : QProxyStyle(style), m_Indentation(indentation)
+{
+}
+
+void PluginListViewStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const
+{
+ if (element == QStyle::PE_IndicatorItemViewItemDrop && !option->rect.isNull()) {
+ QStyleOption opt(*option);
+ opt.rect.setLeft(m_Indentation);
+ if (widget) {
+ opt.rect.setRight(widget->width() - 5); // 5 is an arbitrary value that seems to work ok
+ }
+ QProxyStyle::drawPrimitive(element, &opt, painter, widget);
+ }
+ else {
+ QProxyStyle::drawPrimitive(element, option, painter, widget);
+ }
+}
+
+PluginListView::PluginListView(QWidget *parent)
+ : QTreeView(parent)
+ , m_Scrollbar(new ViewMarkingScrollBar(this->model(), this))
+{
+ setVerticalScrollBar(m_Scrollbar);
+}
+
+void PluginListView::dragEnterEvent(QDragEnterEvent *event)
+{
+ emit dropModeUpdate(event->mimeData()->hasUrls());
+
+ QTreeView::dragEnterEvent(event);
+}
+
+void PluginListView::setModel(QAbstractItemModel *model)
+{
+ QTreeView::setModel(model);
+ setVerticalScrollBar(new ViewMarkingScrollBar(model, this));
+}
+
+#pragma once