fix logic
[personal-kdelibs.git] / khtml / khtml_iface.cc
blobaa30f743a46071725b38e7b5cdc346ebc1374f0b
1 /* This file is part of the KDE project
3 * Copyright (C) 2002 Stephan Kulow <coolo@kde.org>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
21 #include "khtml_iface.h"
22 #include "khtml_part.h"
23 #include "khtmlview.h"
24 #include "khtml_ext.h"
25 #include <kio/global.h>
26 #include <QtGui/QApplication>
27 #include <QtCore/QVariant>
29 KHTMLPartIface::KHTMLPartIface( KHTMLPart *_part )
30 : QDBusAbstractAdaptor( _part ), part(_part)
34 KHTMLPartIface::~KHTMLPartIface()
38 QString KHTMLPartIface::url() const
40 return part->url().url();
43 void KHTMLPartIface::setJScriptEnabled( bool enable )
45 part->setJScriptEnabled(enable);
48 bool KHTMLPartIface::jScriptEnabled() const
50 return part->jScriptEnabled();
53 bool KHTMLPartIface::closeUrl()
55 return part->closeUrl();
58 bool KHTMLPartIface::metaRefreshEnabled() const
60 return part->metaRefreshEnabled();
63 void KHTMLPartIface::setDndEnabled( bool b )
65 part->setDNDEnabled(b);
68 bool KHTMLPartIface::dndEnabled() const
70 return part->dndEnabled();
73 void KHTMLPartIface::setJavaEnabled( bool enable )
75 part->setJavaEnabled( enable );
78 bool KHTMLPartIface::javaEnabled() const
80 return part->javaEnabled();
83 void KHTMLPartIface::setPluginsEnabled( bool enable )
85 part->setPluginsEnabled( enable );
88 bool KHTMLPartIface::pluginsEnabled() const
90 return part->pluginsEnabled();
93 void KHTMLPartIface::setAutoloadImages( bool enable )
95 part->setAutoloadImages( enable );
98 bool KHTMLPartIface::autoloadImages() const
100 return part->autoloadImages();
103 void KHTMLPartIface::setOnlyLocalReferences(bool enable)
105 part->setOnlyLocalReferences(enable);
108 void KHTMLPartIface::setMetaRefreshEnabled( bool enable )
110 part->setMetaRefreshEnabled(enable);
113 bool KHTMLPartIface::onlyLocalReferences() const
115 return part->onlyLocalReferences();
118 bool KHTMLPartIface::setEncoding( const QString &name )
120 return part->setEncoding(name);
123 QString KHTMLPartIface::encoding() const
125 return part->encoding();
128 void KHTMLPartIface::setFixedFont( const QString &name )
130 part->setFixedFont(name);
134 bool KHTMLPartIface::gotoAnchor( const QString &name )
136 return part->gotoAnchor(name);
139 bool KHTMLPartIface::nextAnchor()
141 return part->nextAnchor();
144 bool KHTMLPartIface::prevAnchor()
146 return part->prevAnchor();
149 void KHTMLPartIface::activateNode()
151 KParts::ReadOnlyPart* p = part->currentFrame();
152 if ( p && p->widget() ) {
153 QKeyEvent ev( QKeyEvent::KeyPress, Qt::Key_Return, 0, "\n" );
154 QApplication::sendEvent( p->widget(), &ev );
158 void KHTMLPartIface::selectAll()
160 part->selectAll();
163 QString KHTMLPartIface::lastModified() const
165 return part->lastModified();
168 void KHTMLPartIface::debugRenderTree()
170 part->slotDebugRenderTree();
173 void KHTMLPartIface::debugDOMTree()
175 part->slotDebugDOMTree();
178 void KHTMLPartIface::stopAnimations()
180 part->slotStopAnimations();
183 void KHTMLPartIface::viewDocumentSource()
185 part->slotViewDocumentSource();
188 void KHTMLPartIface::saveBackground(const QString &destination)
190 KUrl back = part->backgroundURL();
191 if (back.isEmpty())
192 return;
194 KIO::MetaData metaData;
195 metaData["referrer"] = part->referrer();
196 KHTMLPopupGUIClient::saveURL( part->widget(), back, KUrl( destination ), metaData );
199 void KHTMLPartIface::saveDocument(const QString &destination)
201 KUrl srcURL( part->url() );
203 if ( srcURL.fileName(KUrl::ObeyTrailingSlash).isEmpty() )
204 srcURL.setFileName( "index.html" );
206 KIO::MetaData metaData;
207 // Referrer unknown?
208 KHTMLPopupGUIClient::saveURL( part->widget(), srcURL, KUrl( destination ), metaData, part->cacheId() );
211 void KHTMLPartIface::setUserStyleSheet(const QString &styleSheet)
213 part->setUserStyleSheet(styleSheet);
216 QString KHTMLPartIface::selectedText() const
218 return part->selectedText();
221 void KHTMLPartIface::viewFrameSource()
223 part->slotViewFrameSource();
226 QString KHTMLPartIface::evalJS(const QString &script)
228 return part->executeScript(DOM::Node(), script).toString();
231 void KHTMLPartIface::print( bool quick ) {
232 part->view()->print( quick );
235 #include "khtml_iface.moc"