Don't reload volume if bookmark is in the same volume.
[dorian] / selectionsuppressor.h
1 #ifndef SELECTIONSUPPRESSOR_H
2 #define SELECTIONSUPPRESSOR_H
3
4 #include <QWebView>
5 #include <QEvent>
6 #include <QMouseEvent>
7
8 class SelectionSuppressor: public QObject
9 {
10     Q_OBJECT
11
12 public:
13     SelectionSuppressor(QWebView *view): QObject(view), mousePressed(false)
14     {
15         view->installEventFilter(this);
16     }
17
18 protected:
19     inline bool eventFilter(QObject *, QEvent *e);
20
21 private:
22     bool mousePressed;
23 };
24
25 bool SelectionSuppressor::eventFilter(QObject *, QEvent *e)
26 {
27     switch (e->type()) {
28     case QEvent::MouseButtonPress:
29         mousePressed = true;
30         break;
31     case QEvent::MouseButtonRelease:
32         mousePressed = false;
33         break;
34     case QEvent::MouseMove:
35         if (mousePressed) {
36             return true;
37         }
38         break;
39     case QEvent::MouseButtonDblClick:
40         return true;
41     default:
42         break;
43     }
44     return false;
45 }
46
47 #endif // SELECTIONSUPPRESSOR_H