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 | |
| parent | de27ab391f5c56db9532e7cbc32145d21e5df97c (diff) | |
added modlist view class (updates drop behaviour on modlist depending on mime type)
Diffstat (limited to 'src')
| -rw-r--r-- | src/modlistview.cpp | 47 | ||||
| -rw-r--r-- | src/modlistview.h | 20 |
2 files changed, 67 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);
+}
diff --git a/src/modlistview.h b/src/modlistview.h new file mode 100644 index 00000000..e501a660 --- /dev/null +++ b/src/modlistview.h @@ -0,0 +1,20 @@ +#ifndef MODLISTVIEW_H
+#define MODLISTVIEW_H
+
+#include <QTreeView>
+#include <QDragEnterEvent>
+
+class ModListView : public QTreeView
+{
+ Q_OBJECT
+public:
+ explicit ModListView(QWidget *parent = 0);
+ virtual void dragEnterEvent(QDragEnterEvent *event);
+signals:
+ void dropModeUpdate(bool dropOnRows);
+
+public slots:
+
+};
+
+#endif // MODLISTVIEW_H
|
