class library: PriorityQueue - implement removeValue, hide array
[supercollider.git] / QtCollider / widgets / QcWebView.h
blob5eb596c7893d8c327704331746314ef6ee127dfe
1 /************************************************************************
3 * Copyright 2011 Jakob Leben (jakob.leben@gmail.com)
5 * This file is part of SuperCollider Qt GUI.
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ************************************************************************/
22 #ifndef QC_WEB_VIEW_H
23 #define QC_WEB_VIEW_H
25 #include <QWebView>
26 #include <QWebPage>
28 namespace QtCollider {
30 class WebPage;
32 class WebView : public QWebView
34 Q_OBJECT
35 Q_PROPERTY( QString url READ url WRITE setUrl );
36 Q_PROPERTY( QString html READ html )
37 Q_PROPERTY( QString plainText READ plainText )
38 Q_PROPERTY( QWebPage::LinkDelegationPolicy linkDelegationPolicy
39 READ linkDelegationPolicy WRITE setLinkDelegationPolicy )
40 Q_PROPERTY( bool delegateReload READ delegateReload WRITE setDelegateReload );
41 Q_PROPERTY( bool enterInterpretsSelection
42 READ interpretSelection WRITE setInterpretSelection );
44 public:
45 Q_INVOKABLE void setHtml ( const QString &html, const QString &baseUrl = QString() );
46 Q_INVOKABLE void evaluateJavaScript ( const QString &script );
47 Q_INVOKABLE void setFontFamily( int genericFontFamily, const QString & fontFamily );
49 public Q_SLOTS:
50 void findText( const QString &searchText, bool reversed = false );
52 Q_SIGNALS:
53 void linkActivated( const QString & );
54 void reloadTriggered( const QString & );
55 void interpret( const QString & code );
57 public:
59 WebView( QWidget *parent = 0 );
61 QString url() const;
62 void setUrl( const QString & );
63 QString html () const;
64 QString plainText () const;
66 QWebPage::LinkDelegationPolicy linkDelegationPolicy () const;
67 void setLinkDelegationPolicy ( QWebPage::LinkDelegationPolicy );
68 bool delegateReload() const;
69 void setDelegateReload( bool );
70 bool interpretSelection() const { return _interpretSelection; }
71 void setInterpretSelection( bool b ) { _interpretSelection = b; }
73 inline static QUrl urlFromString( const QString & str ) {
74 QUrl url( str );
75 if( url.scheme().isEmpty() ) url.setScheme( "file" );
76 return url;
79 protected:
80 virtual void keyPressEvent( QKeyEvent * );
82 private Q_SLOTS:
83 void onLinkClicked( const QUrl & );
84 void onPageReload();
86 private:
87 bool _interpretSelection;
90 class WebPage : public QWebPage
92 Q_OBJECT
94 public:
96 WebPage( QObject *parent ) : QWebPage( parent ), _delegateReload(false) {}
97 virtual void triggerAction ( WebAction action, bool checked = false );
98 bool delegateReload() const { return _delegateReload; }
99 void setDelegateReload( bool flag ) { _delegateReload = flag; }
101 private:
103 bool _delegateReload;
106 } // namespace QtCollider
108 #endif // QC_WEB_VIEW_H