~ubuntu-branches/ubuntu/trusty/kvirc/trusty

« back to all changes in this revision

Viewing changes to src/modules/objects/KvsObject_textBrowser.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Kai Wasserbäch, Kai Wasserbäch, Raúl Sánchez Siles
  • Date: 2011-02-12 10:40:21 UTC
  • mfrom: (14.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110212104021-5mh4f75jlku20mnt
The combined "Twisted Experiment" and "Nocturnal Raid" release.

[ Kai Wasserbäch ]
* Synced to upstream's SVN revision 5467.
* debian/rules:
  - Added .PHONY line.
  - Resurrect -DMANUAL_REVISION, got lost somewhere and we build SVN
    revisions again.
  - Replace "-DWITH_NO_EMBEDDED_CODE=YES" with "-DWANT_CRYPTOPP=YES".
  - Change the remaining -DWITH/-DWITHOUT to the new -DWANT syntax.
* debian/control:
  - Removed DMUA, I'm a DD now.
  - Changed my e-mail address.
  - Removed unneeded relationships (no upgrades over two releases are
    supported).
  - Fix Suggests for kvirc-dbg.
  - kvirc-data: Make the "Suggests: kvirc" a Recommends, doesn't make much
    sense to install the -data package without the program.
* debian/source/local-options: Added with "unapply-patches".
* debian/kvirc.lintian-overrides: Updated to work for 4.1.1.
* debian/patches/21_make_shared-mime-info_B-D_superfluous.patch: Updated.
* debian/kvirc-data.install: Added .notifyrc.

[ Raúl Sánchez Siles ]
* Stating the right version where kvirc-data break and replace should happen.
* Fixing link to license file.
* Added French and Portuguese man pages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//=============================================================================
 
2
//
 
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)
 
6
//
 
7
//   This file is part of the KVIrc irc client distribution
 
8
//   Copyright (C) 2005-2008 Alessandro Carbone (elfonol at gmail dot com)
 
9
//
 
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.
 
14
//
 
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.
 
19
//
 
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.
 
23
//
 
24
//=============================================================================
 
25
 
 
26
 
 
27
#include "KvsObject_textBrowser.h"
 
28
#include "KviError.h"
 
29
#include "kvi_debug.h"
 
30
#include "KviLocale.h"
 
31
#include "KviIconManager.h"
 
32
 
 
33
#include <QTextBrowser>
 
34
#include <QFile>
 
35
#include <QUrl>
 
36
/*
 
37
        @doc: textBrowser
 
38
        @keyterms:
 
39
                textBrowser browser widget class,
 
40
        @title:
 
41
                textBrowser class
 
42
        @type:
 
43
                class
 
44
        @short:
 
45
                Provides a class that can display html pages.
 
46
        @inherits:
 
47
                [class]widget[/class]
 
48
        @description:
 
49
                Provides a class that can display html pages with hypertext navigation.
 
50
        @functions:
 
51
                !fn: $setSource(<file_name:string>)
 
52
                With this you can display the page at szFile location (szFile include the path).
 
53
                !fn: $backward()
 
54
                Changes the document displayed to the previous document in the list of documents built by navigating links.
 
55
                !fn: $forward()
 
56
                Changes the document displayed to the next document in the list of documents built by navigating links.
 
57
                !fn: $home()
 
58
                Changes the document displayed to be the first document the browser displayed.
 
59
                !fn: $reload()
 
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.
 
64
        @signals:
 
65
                !sg: $linkClicked(<link_href:string>)
 
66
                This signal is emitted by the default implementation of the [classfnc]$linkClickedEvent[/classfnc]() function.
 
67
*/
 
68
 
 
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)
 
77
 
 
78
KVSO_BEGIN_CONSTRUCTOR(KvsObject_textBrowser,KvsObject_textedit)
 
79
 
 
80
KVSO_END_CONSTRUCTOR(KvsObject_textBrowser)
 
81
 
 
82
 
 
83
KVSO_BEGIN_DESTRUCTOR(KvsObject_textBrowser)
 
84
 
 
85
KVSO_END_CONSTRUCTOR(KvsObject_textBrowser)
 
86
 
 
87
bool KvsObject_textBrowser::init(KviKvsRunTimeContext *,KviKvsVariantList *)
 
88
{
 
89
        SET_OBJECT(QTextBrowser);
 
90
        connect(obj,SIGNAL(anchorClicked(const QUrl &)),this,SLOT(anchorClicked(const QUrl &)));
 
91
        return true;
 
92
}
 
93
 
 
94
KVSO_CLASS_FUNCTION(textBrowser,setSource)
 
95
{
 
96
        CHECK_INTERNAL_POINTER(widget())
 
97
        QString szFile;
 
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))
 
102
        {
 
103
                c->warning(__tr2qs_ctx("I can't find the specified file '%Q'.","objects"),&szFile);
 
104
                return true;
 
105
        }
 
106
        QUrl url;
 
107
        url.setPath(szFile);
 
108
        ((QTextBrowser *)widget())->setSource(url);
 
109
        return true;
 
110
}
 
111
 
 
112
KVSO_CLASS_FUNCTION(textBrowser,forward)
 
113
{
 
114
        CHECK_INTERNAL_POINTER(widget())
 
115
        ((QTextBrowser *)widget())->forward();
 
116
        return true;
 
117
}
 
118
 
 
119
KVSO_CLASS_FUNCTION(textBrowser,backward)
 
120
{
 
121
        CHECK_INTERNAL_POINTER(widget())
 
122
        ((QTextBrowser *)widget())->backward();
 
123
        return true;
 
124
}
 
125
 
 
126
KVSO_CLASS_FUNCTION(textBrowser,home)
 
127
{
 
128
        CHECK_INTERNAL_POINTER(widget())
 
129
        ((QTextBrowser *)widget())->home();
 
130
        return true;
 
131
}
 
132
 
 
133
KVSO_CLASS_FUNCTION(textBrowser,reload)
 
134
{
 
135
        CHECK_INTERNAL_POINTER(widget())
 
136
        ((QTextBrowser *)widget())->reload();
 
137
        return true;
 
138
}
 
139
 
 
140
void KvsObject_textBrowser::anchorClicked(const QUrl &url)
 
141
{
 
142
        KviKvsVariantList parms(new KviKvsVariant(url.path()));
 
143
        callFunction(this,"linkClickedEvent",0,&parms);
 
144
}
 
145
 
 
146
KVSO_CLASS_FUNCTION(textBrowser,linkClickedEvent)
 
147
{
 
148
        emitSignal("linkClicked",c,c->params());
 
149
        return true;
 
150
}
 
151
 
 
152
#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES
 
153
#include "m_KvsObject_textBrowser.moc"
 
154
#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES
 
155