KParts
browserrun.h
Go to the documentation of this file.
00001 /* This file is part of the KDE project 00002 * 00003 * Copyright (C) 2002 David Faure <faure@kde.org> 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Library General Public 00006 * License version 2, as published by the Free Software Foundation. 00007 * 00008 * This library is distributed in the hope that it will be useful, 00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 * Library General Public License for more details. 00012 * 00013 * You should have received a copy of the GNU Library General Public License 00014 * along with this library; see the file COPYING.LIB. If not, write to 00015 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 * Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #ifndef kparts_browserrun_h 00020 #define kparts_browserrun_h 00021 00022 #include <krun.h> 00023 #include <kservice.h> 00024 #include <kparts/browserextension.h> 00025 00026 namespace KParts { 00027 00039 class KPARTS_EXPORT BrowserRun : public KRun 00040 { 00041 Q_OBJECT 00042 public: 00054 BrowserRun( const KUrl& url, 00055 const KParts::OpenUrlArguments& args, 00056 const KParts::BrowserArguments& browserArgs, 00057 KParts::ReadOnlyPart *part, 00058 QWidget *window, 00059 bool removeReferrer, bool trustedSource, bool hideErrorDialog = false ); 00060 00061 virtual ~BrowserRun(); 00062 00063 KParts::OpenUrlArguments& arguments(); 00064 KParts::BrowserArguments& browserArguments(); 00065 KParts::ReadOnlyPart* part() const; 00066 KUrl url() const; 00067 00068 bool hideErrorDialog() const; 00069 00073 QString contentDisposition() const; 00074 00078 bool serverSuggestsSave() const; 00079 00080 enum AskSaveResult { Save, Open, Cancel }; 00094 #ifndef KDE_NO_DEPRECATED 00095 static KDE_DEPRECATED AskSaveResult askSave( const KUrl & url, KService::Ptr offer, const QString& mimeType, const QString & suggestedFileName = QString() ); 00096 #endif 00097 00098 enum AskEmbedOrSaveFlags { InlineDisposition = 0, AttachmentDisposition = 1 }; 00114 #ifndef KDE_NO_DEPRECATED 00115 static KDE_DEPRECATED AskSaveResult askEmbedOrSave( const KUrl & url, const QString& mimeType, const QString & suggestedFileName = QString(), int flags = 0 ); 00116 #endif 00117 00118 // virtual so that KHTML can implement differently (HTML cache) 00119 virtual void save( const KUrl & url, const QString & suggestedFileName ); 00120 00121 // static so that it can be called from other classes 00122 static void simpleSave( const KUrl & url, const QString & suggestedFileName, 00123 QWidget* window =0 ); // KDE5: remove 00129 static void saveUrl(const KUrl & url, const QString & suggestedFileName, 00130 QWidget* window, const KParts::OpenUrlArguments& args); 00131 00136 static void saveUrlUsingKIO(const KUrl & srcUrl, const KUrl& destUrl, 00137 QWidget* window, const QMap<QString, QString> &metaData); 00138 00139 static bool allowExecution( const QString &mimeType, const KUrl &url ); 00140 00141 static bool isTextExecutable( const QString &mimeType ); 00142 00152 static KUrl makeErrorUrl(int error, const QString& errorText, const QString& initialUrl); 00153 00154 protected: 00158 virtual void scanFile(); 00162 virtual void init(); 00170 virtual void handleError( KJob * job ); 00171 00176 enum NonEmbeddableResult { Handled, NotHandled, Delayed }; 00177 00181 NonEmbeddableResult handleNonEmbeddable( const QString& mimeType ); // TODO KDE5: remove, and add =0 to the other overload 00182 00203 NonEmbeddableResult handleNonEmbeddable(const QString& mimeType, KService::Ptr* pSelectedService); 00204 00205 protected Q_SLOTS: 00206 void slotBrowserScanFinished(KJob *job); 00207 void slotBrowserMimetype(KIO::Job *job, const QString &type); 00208 void slotCopyToTempFileResult(KJob *job); 00209 virtual void slotStatResult( KJob *job ); 00210 00211 private: 00212 void redirectToError( int error, const QString& errorText ); 00213 class BrowserRunPrivate; 00214 BrowserRunPrivate* const d; 00215 00216 }; 00217 } 00218 #endif
KDE 4.6 API Reference