summaryrefslogtreecommitdiff
path: root/src/modlistview.cpp
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2013-05-10 11:00:09 +0200
committerTannin <devnull@localhost>2013-05-10 11:00:09 +0200
commitfc3753dcc5b7d55bf99674e7d17962f477053921 (patch)
tree54fef6cd5b57533fd84f04cc58259c242600efed /src/modlistview.cpp
parent4fbfc9aa54ed4499f54eb7b3cd942337f6b49e58 (diff)
parent9bc123e8e2dbd17508a68e4afc2eb881873601bd (diff)
Merge
Diffstat (limited to 'src/modlistview.cpp')
-rw-r--r--src/modlistview.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/modlistview.cpp b/src/modlistview.cpp
new file mode 100644
index 00000000..88adcceb
--- /dev/null
+++ b/src/modlistview.cpp
@@ -0,0 +1,47 @@
+#include "modlistview.h"
+#include <QUrl>
+#include <QProxyStyle>
+
+
+class ModListViewStyle: public QProxyStyle{
+public:
+ ModListViewStyle(QStyle *style, int indentation);
+
+ void drawPrimitive (PrimitiveElement element, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget = 0) const;
+private:
+ int m_Indentation;
+};
+
+ModListViewStyle::ModListViewStyle(QStyle *style, int indentation)
+ : QProxyStyle(style), m_Indentation(indentation)
+{
+}
+
+void ModListViewStyle::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);
+ }
+}
+
+ModListView::ModListView(QWidget *parent)
+ : QTreeView(parent)
+{
+ setStyle(new ModListViewStyle(style(), indentation()));
+}
+
+void ModListView::dragEnterEvent(QDragEnterEvent *event)
+{
+ emit dropModeUpdate(event->mimeData()->hasUrls());
+
+ QTreeView::dragEnterEvent(event);
+}