File: articlewebview.hh

package info (click to toggle)
goldendict 0.9.1~git20100719-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 8,992 kB
  • ctags: 3,672
  • sloc: cpp: 22,301; ansic: 10,244; makefile: 53; sh: 9
file content (47 lines) | stat: -rw-r--r-- 1,484 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* This file is (c) 2008-2010 Konstantin Isakov <ikm@users.berlios.de>
 * Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */

#ifndef __ARTICLEWEBVIEW_HH_INCLUDED__
#define __ARTICLEWEBVIEW_HH_INCLUDED__

#include <QWebView>

/// A thin wrapper around QWebView to accomodate to some ArticleView's needs.
/// Currently the only added feature is an ability to know if the middle mouse
/// button is pressed or not according to the view's current state. This is used
/// to open links in new tabs when they are clicked with middle button.
/// There's also an added posibility to get double-click events after the fact
/// with the doubleClicked() signal.
class ArticleWebView: public QWebView
{
  Q_OBJECT

public:

  ArticleWebView( QWidget * parent ): QWebView( parent ),
                                      midButtonPressed( false )
  {}

  bool isMidButtonPressed() const
  { return midButtonPressed; }

signals:

  /// Signals that the user has just double-clicked. The signal is delivered
  /// after the event was processed by the view -- that's the difference from
  /// installing an event filter. This is used for translating the double-clicked
  /// word, which gets selected by the view in response to double-click.
  void doubleClicked();

protected:

  void mousePressEvent( QMouseEvent * event );
  void mouseReleaseEvent( QMouseEvent * event );
  void mouseDoubleClickEvent( QMouseEvent * event );

private:

  bool midButtonPressed;
};

#endif