diff options
| author | Tannin <devnull@localhost> | 2013-04-04 21:51:13 +0200 |
|---|---|---|
| committer | Tannin <devnull@localhost> | 2013-04-04 21:51:13 +0200 |
| commit | 5b04f38345850db86d8f43a42dd946810bceba8a (patch) | |
| tree | 629940b34e536f1d8eca325f0c4296ea3be97507 /src/modlistview.cpp | |
| parent | de27ab391f5c56db9532e7cbc32145d21e5df97c (diff) | |
added modlist view class (updates drop behaviour on modlist depending on mime type)
Diffstat (limited to 'src/modlistview.cpp')
| -rw-r--r-- | src/modlistview.cpp | 47 |
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);
+}
|
