• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • sources
  • kde-4.12
  • kdelibs
  • khtml
khtml_run.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE project
2  *
3  * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
4  * 1999 Lars Knoll <knoll@kde.org>
5  * 1999 Antti Koivisto <koivisto@kde.org>
6  * 2000 Simon Hausmann <hausmann@kde.org>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public License
19  * along with this library; see the file COPYING.LIB. If not, write to
20  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  */
23 #include "khtml_run.h"
24 #include "khtmlpart_p.h"
25 #include <kio/job.h>
26 #include <kdebug.h>
27 #include <klocale.h>
28 #include "khtml_ext.h"
29 #include <QtGui/QImage>
30 
31 KHTMLRun::KHTMLRun( KHTMLPart *part, khtml::ChildFrame *child, const KUrl &url,
32  const KParts::OpenUrlArguments& args,
33  const KParts::BrowserArguments &browserArgs,
34  bool hideErrorDialog )
35  : KParts::BrowserRun( url, args, browserArgs, part, part->widget() ? part->widget()->topLevelWidget() : 0,
36  false, false, hideErrorDialog ),
37  m_child( child )
38 {
39  // Don't use an external browser for parts of a webpage we are rendering. (iframes at least are one example)
40  setEnableExternalBrowser(false);
41 
42  // get the wheel to start spinning
43  part->started(0L);
44 }
45 
46 //KHTMLPart *KHTMLRun::htmlPart() const
47 //{ return static_cast<KHTMLPart *>(part()); }
48 
49 void KHTMLRun::foundMimeType( const QString &_type )
50 {
51  //kDebug(6050) << this << _type;
52  Q_ASSERT(!hasFinished());
53  QString mimeType = _type; // this ref comes from the job, we lose it when using KIO again
54 
55  bool requestProcessed = static_cast<KHTMLPart *>(part())->processObjectRequest( m_child, KRun::url(), mimeType );
56 
57  if ( requestProcessed )
58  setFinished( true );
59  else {
60  if ( hasFinished() ) // abort was called (this happens with the activex fallback for instance)
61  return;
62  // Couldn't embed -> call BrowserRun::handleNonEmbeddable()
63  KService::Ptr selectedService;
64  KParts::BrowserRun::NonEmbeddableResult res = handleNonEmbeddable( mimeType, &selectedService );
65  if ( res == KParts::BrowserRun::Delayed )
66  return;
67  setFinished( res == KParts::BrowserRun::Handled );
68  if ( hasFinished() ) { // saved or canceled -> flag completed
69  m_child->m_bCompleted = true;
70  static_cast<KHTMLPart *>(part())->checkCompleted();
71  } else {
72  // "Open" selected, possible with a specific application
73  if (selectedService) {
74  KRun::setPreferredService(selectedService->desktopEntryName());
75  } else {
76  KRun::displayOpenWithDialog(url(), part()->widget(), false /*tempfile*/, suggestedFileName());
77  setFinished(true);
78  }
79  }
80  }
81 
82  if ( hasFinished() ) {
83  kDebug() << "finished";
84  return;
85  }
86 
87  //kDebug(6050) << _type << " couldn't open";
88  KRun::foundMimeType( mimeType );
89 
90  // "open" is finished -> flag completed
91  m_child->m_bCompleted = true;
92  static_cast<KHTMLPart *>(part())->checkCompleted();
93 }
94 
95 void KHTMLRun::handleError(KJob*)
96 {
97  // Tell KHTML that loading failed.
98  static_cast<KHTMLPart *>(part())->processObjectRequest( m_child, KUrl(), QString() );
99  setJob(0);
100 }
101 
102 void KHTMLRun::save( const KUrl & url, const QString & suggestedFilename )
103 {
104  KHTMLPopupGUIClient::saveURL( part()->widget(), i18n( "Save As" ), url, arguments().metaData(), QString(), 0, suggestedFilename );
105 }
106 
107 #include "khtml_run.moc"
i18n
QString i18n(const char *text)
KSharedPtr< KService >
KHTMLRun::save
virtual void save(const KUrl &url, const QString &suggestedFilename)
Definition: khtml_run.cpp:102
KRun::setEnableExternalBrowser
void setEnableExternalBrowser(bool b)
KRun::foundMimeType
virtual void foundMimeType(const QString &type)
kdebug.h
khtml::ChildFrame
Definition: khtml_childframe_p.h:40
KHTMLPopupGUIClient::saveURL
static void saveURL(QWidget *parent, const QString &caption, const KUrl &url, const QMap< QString, QString > &metaData=KIO::MetaData(), const QString &filter=QString(), long cacheId=0, const QString &suggestedFilename=QString())
Definition: khtml_ext.cpp:859
KParts::BrowserArguments
KHTMLPart
This class is khtml's main class.
Definition: khtml_part.h:206
KParts::BrowserRun::arguments
KParts::OpenUrlArguments & arguments()
KRun::url
KUrl url() const
KHTMLRun::foundMimeType
virtual void foundMimeType(const QString &mimetype)
Definition: khtml_run.cpp:49
khtml_ext.h
QString
KParts::BrowserRun::NonEmbeddableResult
NonEmbeddableResult
kDebug
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
klocale.h
KParts::ReadOnlyPart::started
void started(KIO::Job *)
KUrl
KParts::BrowserRun::url
KUrl url() const
KHTMLRun::KHTMLRun
KHTMLRun(KHTMLPart *part, khtml::ChildFrame *child, const KUrl &url, const KParts::OpenUrlArguments &args, const KParts::BrowserArguments &browserArgs, bool hideErrorDialog)
Definition: khtml_run.cpp:31
KParts::BrowserRun::part
KParts::ReadOnlyPart * part() const
KParts::BrowserRun::Delayed
khtml_run.h
KRun::displayOpenWithDialog
static bool displayOpenWithDialog(const KUrl::List &lst, QWidget *window, bool tempFiles=false, const QString &suggestedFileName=QString(), const QByteArray &asn=QByteArray())
KParts::BrowserRun::Handled
job.h
KHTMLRun::handleError
virtual void handleError(KJob *job)
Definition: khtml_run.cpp:95
KRun::setPreferredService
void setPreferredService(const QString &desktopEntryName)
KRun::suggestedFileName
QString suggestedFileName() const
KService::desktopEntryName
QString desktopEntryName() const
KRun::setJob
void setJob(KIO::Job *job)
KRun::setFinished
void setFinished(bool finished)
khtml::ChildFrame::m_bCompleted
bool m_bCompleted
Definition: khtml_childframe_p.h:61
khtmlpart_p.h
KParts::BrowserRun::handleNonEmbeddable
NonEmbeddableResult handleNonEmbeddable(const QString &mimeType)
KJob
KParts::OpenUrlArguments
KRun::hasFinished
bool hasFinished() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:51:21 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal