Salome HOME
b1adf3f459b7a51eaacbf87d68f3d3d976a7bce6
[modules/gui.git] / src / Qtx / QtxWebBrowser.h
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // File:      QtxWebBrowser.h
24 // Author:    Roman NIKOLAEV
25 //
26
27 #ifndef QTXWEBBROWSER_H
28 #define QTXWEBBROWSER_H
29
30 #include "Qtx.h"
31
32 #include <QDialog>
33 #include <QMainWindow>
34 #include <QMap>
35 #include <QUrl>
36
37 class QAction;
38 class QButtonGroup;
39 class QCheckBox;
40 class QLabel;
41 class QMenu;
42 class QPushButton;
43 class QToolBar;
44 class QWebView;
45 class QtxResourceMgr;
46 class QtxSearchTool;
47
48 class QTX_EXPORT QtxWebBrowser : public QMainWindow
49 {
50   Q_OBJECT
51
52   enum { File };
53   enum { Find, FindNext, FindPrev, Close };
54
55   class Downloader;
56   class Searcher;
57
58 private:
59   QtxWebBrowser();
60   
61 public:
62   virtual ~QtxWebBrowser();
63   
64   static QtxWebBrowser*           webBrowser();
65   static void                     loadUrl( const QString&, const QString& = QString() );
66   static void                     setData( const QString&, const QVariant& );
67   static void                     setResourceManager( QtxResourceMgr* );
68   static void                     shutdown();
69
70 private:
71   static QString                  getStringValue( const QString&, const QString& = QString() );
72   static QIcon                    getIconValue( const QString&, const QIcon& = QIcon() );
73   void                            updateData();
74   static void                     clearData();
75   void                            saveLink( const QString& );
76   void                            openLink( const QString&, bool = false );
77
78 protected slots:
79   virtual void                    linkClicked( const QUrl& );
80   virtual void                    linkHovered( const QString&, const QString&, const QString& );
81
82 private slots:
83   void                            adjustTitle();
84   void                            finished( bool );
85   void                            linkAction();
86   
87 private:
88   static QMap<QString, QVariant>  myData;
89   static QtxWebBrowser*           myBrowser;
90   static QtxResourceMgr*          myResourceMgr;
91   QWebView*                       myWebView;
92   QToolBar*                       myToolbar;
93   QMap<int, QMenu*>               myMenus;
94   QMap<int, QAction*>             myActions;
95   QtxSearchTool*                  myFindPanel;
96   QUrl                            myLastUrl;
97 };
98
99 class QtxWebBrowser::Downloader: public QDialog
100 {
101   Q_OBJECT;
102   
103   enum { mOpen, mSave };
104
105 public:
106   Downloader( const QString&, int = mOpen, const QString& = QString(), QWidget* = 0 );
107   ~Downloader();
108
109   int          action() const;
110   bool         isRepeatAction() const;
111   QString      program() const;
112
113 private slots:
114   void         setAction( int );
115   void         browse();
116
117 private:
118   QString       myProgram;
119   QLabel*       myFileName;
120   QButtonGroup* myAction;
121   QPushButton*  myBrowse;
122   QCheckBox*    myRepeat;
123
124   friend class QtxWebBrowser;
125 };
126
127 #endif // QTXWEBBROWSER_H