File: htmlviewer.cpp

package info (click to toggle)
socnetv 0.90-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,028 kB
  • sloc: cpp: 12,953; makefile: 75
file content (144 lines) | stat: -rwxr-xr-x 4,812 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/****************************************************************************
SocNetV: Social Networks Visualizer 
version: 0.90
Written in Qt 4.4 with KDevelop   

                          htmlviewer.cpp  -  description
                             -------------------
    copyright            : (C) 2005-2010 by Dimitris B. Kalamaras
    email                : dimitris.kalamaras@gmail.com

*****************************************************************************/

/*******************************************************************************
*     This program is free software: you can redistribute it and/or modify     *
*     it under the terms of the GNU General Public License as published by     *
*     the Free Software Foundation, either version 3 of the License, or        *
*     (at your option) any later version.                                      *
*                                                                              *
*     This program is distributed in the hope that it will be useful,          *
*     but WITHOUT ANY WARRANTY; without even the implied warranty of           *
*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
*     GNU General Public License for more details.                             *
*                                                                              *
*     You should have received a copy of the GNU General Public License        *
*     along with this program.  If not, see <http://www.gnu.org/licenses/>.    *
********************************************************************************/

#include "htmlviewer.h"
#include <QtGui>
#include <QtWebKit>

HTMLViewer::HTMLViewer( const QString& manPath,  QWidget* parent)
    :QMainWindow( parent ),
      pathCombo( 0 )
{
    view = new QWebView(this);
    view->load(QUrl(manPath));
  
    this->setCentralWidget( view);

    QMenu* file = new QMenu( this );
    file = menuBar()->addMenu(tr("&File"));

    fileOpen = new QAction(QIcon(":/images/open.png"), tr("&Open"), this);
    fileOpen->setShortcut(tr("Ctrl+O"));
    fileOpen->setStatusTip(tr("Opens another helpfile"));
    connect(fileOpen, SIGNAL(activated()), this, SLOT(openFile()));


    filePrint = new QAction(QIcon(":/images/print.png"), tr("&Print"), this);
    filePrint->setShortcut(tr("Ctrl+P"));
    filePrint->setStatusTip(tr("Prints out the actual network"));
    connect(filePrint, SIGNAL(activated()), this, SLOT(print()));

    fileQuit = new QAction(QIcon(":/images/exit.png"), tr("E&xit"), this);
    fileQuit->setShortcut(tr("Ctrl+X"));
    fileQuit->setStatusTip(tr("Close Manual"));
    connect(fileQuit, SIGNAL(activated()), this, SLOT(close()));

    QIcon icon_back( ":/images/back.png" );
    QIcon icon_forward( ":/images/forward.png" );
    QIcon icon_home( ":/images/home.png" );

    fileBack= new QAction(icon_back, tr("&Back"), this);
    fileBack->setShortcut(tr("Ctrl+B"));
    fileBack->setStatusTip(tr("&Backward") );
    connect(fileBack, SIGNAL(activated()), view, SLOT(back()));

    fileForward= new QAction(icon_forward, tr("&Forward"), this);
    fileForward->setShortcut(tr("Ctrl+F"));
    fileForward->setStatusTip(tr("&Forward") );
    connect(fileForward, SIGNAL(activated()), view, SLOT(forward()));

    fileHome= new QAction(icon_home, tr("&Home"), this);
    fileHome->setShortcut(tr("Ctrl+H"));
    fileHome->setStatusTip(tr("&Home") );
    connect(fileHome, SIGNAL(activated()), view, SLOT(reload()));


    file->addAction( fileOpen);
//    file->addAction( filePrint);
    file->addSeparator();
    file->addAction( fileQuit);


    QMenu* go = new QMenu( this );
    go = menuBar()->addMenu(tr("&Go"));
    go->addAction( fileBack );
    go->addAction( fileForward );
    go->addAction( fileHome);


//     QMenu* help = new QMenu( this );
//     help= menuBar()->addMenu(tr("&Help"));
//     help->addAction( tr("&About"), this, SLOT( about() ) );
//     help->addAction( tr("About &Qt"), this, SLOT( aboutQt() ) );



    QToolBar* toolbar = new QToolBar( this );
    addToolBar( Qt::TopToolBarArea, toolbar);

    pathCombo = new QComboBox( toolbar );
    connect( pathCombo, SIGNAL( activated( const QString & ) ),
	     this, SLOT( pathSelected( const QString & ) ) );

    pathCombo->addItem(manPath);

    toolbar->addAction(fileBack);
    toolbar->addAction(fileForward);
    toolbar->addAction(fileHome);
    toolbar->addWidget( pathCombo );

    view->setFocus();

	this-> resize(700,650);
}




HTMLViewer::~HTMLViewer()
{
}


void HTMLViewer::openFile()
{
#ifndef QT_NO_FILEDIALOG
    QString fn = QFileDialog::getOpenFileName( this, QString::null, QString::null );
    if ( !fn.isEmpty() )
	view->load(QUrl(fn));
#endif
}



void HTMLViewer::pathSelected( const QString &_path )
{
    	view->load(QUrl(_path));
}