📄 jobclasses.h
字号:
/* This file is part of the KDE project Copyright (C) 2000-2001 Simon Hausmann <hausmann@kde.org> Copyright (C) 2001 Dirk Mueller <mueller@kde.org> Copyright (C) 2002-2003 Paul Chitescu <paulc-devel@null.ro> Copyright (C) 2002-2003 Luciano Montanaro <mikelima@cirulla.net> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.*/#ifndef __kio_job_h__#define __kio_job_h__class QWidget;#include <qobject.h>#include <qcstring.h>#include <qguardedptr.h>#include <kurl.h>#include <kio/global.h>#include <kio/mimehandler.h>// Hack! XXX // #define StatJob TransferJobnamespace KIO{ class Slave; class TransferJob; class Job : public QObject { Q_OBJECT protected: Job( bool showProgressInfo ); public: virtual ~Job(); virtual void kill(); void setWindow( QWidget *window ) { m_widget = window; } QWidget *window() const { return m_widget; } int error() const { return m_error; } QString errorText() { return m_errorText; } QString errorString() const; void showErrorDialog( QWidget *parent = 0 ); void putOnHold() {} // ### check whether this belongs into another job class void setTaskNumber(int task) { m_task = task; } int taskNumber() const { return m_task; } void addMetaData(const QString &key, const QString &value); MetaData metaData() const; QString queryMetaData(const QString &key); signals: void result( KIO::Job *job ); void infoMessage( KIO::Job *, const QString &msg ); void connect( KIO::Job * ); void percent( KIO::Job *job, unsigned long percent ); void totalSize( KIO::Job *, unsigned long size ); void processedSize( KIO::Job *, unsigned long size ); void speed( KIO::Job *, unsigned long bytesPerSecond ); protected: int m_error; unsigned long m_percent; QString m_errorText; void emitPercent( unsigned long size, unsigned long total ); inline void recurseEnter() { m_reenter++; } bool recurseExit(); bool isDestructing() const { return m_destruct; } MetaData m_outgoingMetaData; MetaData m_incomingMetaData; private: QWidget *m_widget; bool m_showProgressInfo; int m_task; int m_reenter; bool m_destruct; }; class SimpleJob : public KIO::Job { Q_OBJECT public: SimpleJob( const KURL &url, int command, const QByteArray &packedArgs, bool showProgressInfo ); virtual ~SimpleJob(); KURL url() const { return m_url; } virtual void start( Slave *slave ); virtual void kill(); public slots: void slotProcessedSize( KIO::filesize_t ); void slotTotalSize( KIO::filesize_t ); void slotPercent( unsigned long ); protected slots: virtual void receiveData( const QByteArray &dat ); virtual void slaveFinished(); virtual void dataReq(); virtual void slaveRedirection( const KURL &url ); virtual void slotInfoMessage( const QString &msg ); virtual void slotError( int id, const QString &text ); virtual void slotMetaData( const KIO::MetaData &_metaData); protected: void storeSSLSessionFromJob(const KURL &m_redirectionURL); Slave *m_slave; KURL m_url; int m_command; QByteArray m_packedArgs; unsigned long m_totalSize; }; class TransferJob : public KIO::SimpleJob { Q_OBJECT public: TransferJob( const KURL &, int command, const QByteArray &packedArgs, const QByteArray &_staticData, bool showProgressInfo ); virtual ~TransferJob(); void setMetaData( const KIO::MetaData &data ); void addMetaData( const QString &key, const QString &value ); void addMetaData( const QMap<QString,QString> &values ); MetaData metaData(); MetaData outgoingMetaData(); QString queryMetaData( const QString &key ); bool isErrorPage() { return false; } virtual void start( Slave *slave ); virtual void kill(); void detach( const QByteArray &cachedData = QByteArray() ); void attach(); static TransferJob *findDetachedJobForURL( const KURL &url ); QString mimetype() const { return m_mimetype; } bool AddFilter( const MimeFilter* filter ); // Needed by kdelibs 3.1.3 XXX Should these be implemented for real? void suspend() {} // Needed by kdelibs 3.1.3 XXX Should these be implemented for real? void resume() {} protected slots: void setIncomingMetaData( const KIO::MetaData &dat ); virtual void dataReq(); virtual void slaveRedirection( const KURL &url ); virtual void slaveFinished(); virtual void receiveData( const QByteArray &dat ); virtual void filteredData( const QByteArray &dat ); virtual void slotMimetype( const QString& type ); virtual void slotMetaData( const KIO::MetaData &_metaData); signals: void redirection( KIO::Job *, const KURL & ); void data( KIO::Job *job, const QByteArray &data ); void mimetype( KIO::Job *, const QString &type ); private slots: void slotRedirectDelayed(); void slotEmitCachedData(); private: MetaData m_outgoingMetaData; MetaData m_incomingMetaData; QByteArray m_staticData; KURL::List m_redirectionList; KURL m_redirectionURL; bool m_detached; bool m_finishAfterCacheEmit; QValueList<QByteArray> m_cachedData; bool m_cachedDataEmitted; QString m_mimetype; static QPtrList<TransferJob> *s_detachedJobs; DataFilter *m_filter; bool m_firstdata; void mimeRules( const MimeHandler* mime ); }; class StatJob : public KIO::TransferJob { public: StatJob( const KURL &url, int command, const QByteArray &packedArgs, bool showProgressInfo ); const UDSEntry &statResult() const; }; inline const UDSEntry & StatJob::statResult() const { static UDSEntry empty; // XXX Fix this properly! return empty; }}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -