summaryrefslogtreecommitdiff
path: root/src/pluginlistview.cpp
diff options
context:
space:
mode:
authorJeremy Rimpo <jeremy.rimpo@servermonkey.com>2017-11-30 20:55:00 -0600
committerGitHub <noreply@github.com>2017-11-30 20:55:00 -0600
commitc55a923bb8b9b66661f32beed8445602400ef318 (patch)
tree850ead2730c8ab50babc865a505a513d8fba5f46 /src/pluginlistview.cpp
parent7ec0b79eb49a27a3516d799a80d57000cde344da (diff)
parent797a007eab2695c231a00240225d77b3a9928992 (diff)
Merge pull request #132 from Silarn/mainline_dev
Numerous updates
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