1
//=============================================================================
3
// File : KvsObject_textBrowser.cpp
4
// Creation date : Fri Mar 18 14:30:48 CEST 2005
5
// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
7
// This file is part of the KVIrc irc client distribution
8
// Copyright (C) 2005-2008 Alessandro Carbone (elfonol at gmail dot com)
10
// This program is FREE software. You can redistribute it and/or
11
// modify it under the terms of the GNU General Public License
12
// as published by the Free Software Foundation; either version 2
13
// of the License, or (at your opinion) any later version.
15
// This program is distributed in the HOPE that it will be USEFUL,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18
// See the GNU General Public License for more details.
20
// You should have received a copy of the GNU General Public License
21
// along with this program. If not, write to the Free Software Foundation,
22
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24
//=============================================================================
27
#include "KvsObject_textBrowser.h"
29
#include "kvi_debug.h"
30
#include "KviLocale.h"
31
#include "KviIconManager.h"
33
#include <QTextBrowser>
39
textBrowser browser widget class,
45
Provides a class that can display html pages.
49
Provides a class that can display html pages with hypertext navigation.
51
!fn: $setSource(<file_name:string>)
52
With this you can display the page at szFile location (szFile include the path).
54
Changes the document displayed to the previous document in the list of documents built by navigating links.
56
Changes the document displayed to the next document in the list of documents built by navigating links.
58
Changes the document displayed to be the first document the browser displayed.
60
Reloads the current set source.
61
!fn: $linkClickedEvent(<link_href:string>)
62
Triggered when a link is clicked by the user. The default implementation of this function
63
emits the "linkClicked" signal.
65
!sg: $linkClicked(<link_href:string>)
66
This signal is emitted by the default implementation of the [classfnc]$linkClickedEvent[/classfnc]() function.
69
KVSO_BEGIN_REGISTERCLASS(KvsObject_textBrowser,"textBrowser","multilineedit")
70
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_textBrowser,setSource)
71
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_textBrowser,forward)
72
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_textBrowser,backward)
73
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_textBrowser,home)
74
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_textBrowser,reload)
75
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_textBrowser,linkClickedEvent)
76
KVSO_END_REGISTERCLASS(KvsObject_textBrowser)
78
KVSO_BEGIN_CONSTRUCTOR(KvsObject_textBrowser,KvsObject_textedit)
80
KVSO_END_CONSTRUCTOR(KvsObject_textBrowser)
83
KVSO_BEGIN_DESTRUCTOR(KvsObject_textBrowser)
85
KVSO_END_CONSTRUCTOR(KvsObject_textBrowser)
87
bool KvsObject_textBrowser::init(KviKvsRunTimeContext *,KviKvsVariantList *)
89
SET_OBJECT(QTextBrowser);
90
connect(obj,SIGNAL(anchorClicked(const QUrl &)),this,SLOT(anchorClicked(const QUrl &)));
94
KVSO_CLASS_FUNCTION(textBrowser,setSource)
96
CHECK_INTERNAL_POINTER(widget())
98
KVSO_PARAMETERS_BEGIN(c)
99
KVSO_PARAMETER("file_name",KVS_PT_STRING,0,szFile)
100
KVSO_PARAMETERS_END(c)
101
if(!QFile::exists(szFile))
103
c->warning(__tr2qs_ctx("I can't find the specified file '%Q'.","objects"),&szFile);
108
((QTextBrowser *)widget())->setSource(url);
112
KVSO_CLASS_FUNCTION(textBrowser,forward)
114
CHECK_INTERNAL_POINTER(widget())
115
((QTextBrowser *)widget())->forward();
119
KVSO_CLASS_FUNCTION(textBrowser,backward)
121
CHECK_INTERNAL_POINTER(widget())
122
((QTextBrowser *)widget())->backward();
126
KVSO_CLASS_FUNCTION(textBrowser,home)
128
CHECK_INTERNAL_POINTER(widget())
129
((QTextBrowser *)widget())->home();
133
KVSO_CLASS_FUNCTION(textBrowser,reload)
135
CHECK_INTERNAL_POINTER(widget())
136
((QTextBrowser *)widget())->reload();
140
void KvsObject_textBrowser::anchorClicked(const QUrl &url)
142
KviKvsVariantList parms(new KviKvsVariant(url.path()));
143
callFunction(this,"linkClickedEvent",0,&parms);
146
KVSO_CLASS_FUNCTION(textBrowser,linkClickedEvent)
148
emitSignal("linkClicked",c,c->params());
152
#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES
153
#include "m_KvsObject_textBrowser.moc"
154
#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES