browserrun.h
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
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 BrowserRun : public KRun
00040     {
00041         Q_OBJECT
00042     public:
00052         BrowserRun( const KURL& url, const KParts::URLArgs& args,
00053                     KParts::ReadOnlyPart *part, QWidget *window,
00054                     bool removeReferrer, bool trustedSource );
00055 
00056         
00067         BrowserRun( const KURL& url, const KParts::URLArgs& args,
00068                     KParts::ReadOnlyPart *part, QWidget *window,
00069                     bool removeReferrer, bool trustedSource, bool hideErrorDialog );
00070 
00071         virtual ~BrowserRun();
00072 
00073         
00074         
00075         KURL url() const { return m_strURL; }
00076 
00077         bool hideErrorDialog() const;
00078         
00079         
00080         QString suggestedFilename() const { return m_suggestedFilename; }
00081         
00082         enum AskSaveResult { Save, Open, Cancel };
00091         static AskSaveResult askSave( const KURL & url, KService::Ptr offer, const QString& mimeType, const QString & suggestedFilename = QString::null );
00101         static AskSaveResult askEmbedOrSave( const KURL & url, const QString& mimeType, const QString & suggestedFilename = QString::null, int flags = 0 );
00102 
00103         
00104         virtual void save( const KURL & url, const QString & suggestedFilename );
00105 
00106         
00107         static void simpleSave( const KURL & url, const QString & suggestedFilename,
00108                                 QWidget* window );
00109 
00111         static void simpleSave( const KURL & url, const QString & suggestedFilename );
00112 
00113         static bool allowExecution( const QString &serviceType, const KURL &url );
00114 
00116         static bool isExecutable( const QString &serviceType );
00117         static bool isTextExecutable( const QString &serviceType );
00118 
00119     protected:
00123         virtual void scanFile();
00127         virtual void init();
00135         virtual void handleError( KIO::Job * job );
00136 
00141         enum NonEmbeddableResult { Handled, NotHandled, Delayed };
00142 
00146         NonEmbeddableResult handleNonEmbeddable( const QString& mimeType );
00147 
00148     protected slots:
00149         void slotBrowserScanFinished(KIO::Job *job);
00150         void slotBrowserMimetype(KIO::Job *job, const QString &type);
00151         void slotCopyToTempFileResult(KIO::Job *job);
00152         virtual void slotStatResult( KIO::Job *job );
00153 
00154     protected:
00155         KParts::URLArgs m_args;
00156         KParts::ReadOnlyPart *m_part; 
00157         QGuardedPtr<QWidget> m_window;
00158         
00159         
00160         QString m_suggestedFilename;
00161         QString m_sMimeType;
00162         bool m_bRemoveReferrer;
00163         bool m_bTrustedSource;
00164     private:
00165         void redirectToError( int error, const QString& errorText );
00166         class BrowserRunPrivate;
00167         BrowserRunPrivate* d;
00168 
00169     };
00170 }
00171 #endif
 
This file is part of the documentation for kparts Library Version 3.2.0.