📄 qurloperator.3qt
字号:
'\" t.TH QUrlOperator 3qt "11 October 2001" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQUrlOperator \- Common operations on URLs.PP\fC#include <qurloperator.h>\fR.PPInherits QObject and QUrl..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQUrlOperator\fR ()".br.ti -1c.BI "\fBQUrlOperator\fR ( const QString & url )".br.ti -1c.BI "\fBQUrlOperator\fR ( const QUrlOperator & url )".br.ti -1c.BI "\fBQUrlOperator\fR ( const QUrlOperator & url, const QString & relUrl, bool checkSlash = FALSE )".br.ti -1c.BI "virtual \fB~QUrlOperator\fR ()".br.ti -1c.BI "virtual const QNetworkOperation * \fBlistChildren\fR ()".br.ti -1c.BI "virtual const QNetworkOperation * \fBmkdir\fR ( const QString & dirname )".br.ti -1c.BI "virtual const QNetworkOperation * \fBremove\fR ( const QString & filename )".br.ti -1c.BI "virtual const QNetworkOperation * \fBrename\fR ( const QString & oldname, const QString & newname )".br.ti -1c.BI "virtual const QNetworkOperation * \fBget\fR ( const QString & location = QString::null )".br.ti -1c.BI "virtual const QNetworkOperation * \fBput\fR ( const QByteArray & data, const QString & location = QString::null )".br.ti -1c.BI "virtual QPtrList<QNetworkOperation> \fBcopy\fR ( const QString & from, const QString & to, bool move = FALSE, bool toPath = TRUE )".br.ti -1c.BI "virtual void \fBcopy\fR ( const QStringList & files, const QString & dest, bool move = FALSE )".br.ti -1c.BI "virtual bool \fBisDir\fR ( bool * ok = 0 )".br.ti -1c.BI "virtual void \fBsetNameFilter\fR ( const QString & nameFilter )".br.ti -1c.BI "QString \fBnameFilter\fR () const".br.ti -1c.BI "virtual QUrlInfo \fBinfo\fR ( const QString & entry ) const".br.ti -1c.BI "virtual void \fBstop\fR ()".br.in -1c.SS "Signals".in +1c.ti -1c.BI "void \fBnewChildren\fR ( const QValueList<QUrlInfo> & i, QNetworkOperation * op )".br.ti -1c.BI "void \fBfinished\fR ( QNetworkOperation * op )".br.ti -1c.BI "void \fBstart\fR ( QNetworkOperation * op )".br.ti -1c.BI "void \fBcreatedDirectory\fR ( const QUrlInfo & i, QNetworkOperation * op )".br.ti -1c.BI "void \fBremoved\fR ( QNetworkOperation * op )".br.ti -1c.BI "void \fBitemChanged\fR ( QNetworkOperation * op )".br.ti -1c.BI "void \fBdata\fR ( const QByteArray & data, QNetworkOperation * op )".br.ti -1c.BI "void \fBdataTransferProgress\fR ( int bytesDone, int bytesTotal, QNetworkOperation * op )".br.ti -1c.BI "void \fBstartedNextCopy\fR ( const QPtrList<QNetworkOperation> & lst )".br.ti -1c.BI "void \fBconnectionStateChanged\fR ( int state, const QString & data )".br.in -1c.SS "Protected Members".in +1c.ti -1c.BI "virtual void \fBclearEntries\fR ()".br.ti -1c.BI "void \fBgetNetworkProtocol\fR ()".br.ti -1c.BI "void \fBdeleteNetworkProtocol\fR ()".br.in -1c.SH RELATED FUNCTION DOCUMENTATION.in +1c.ti -1c.BI "void \fBqInitNetworkProtocols\fR ()".br.in -1c.SH DESCRIPTIONThe QUrlOperator class provides common operations on URLs..PPThis class operates on hierarchical structures (such as filesystems) using URLs. Its API allows all the common operations (listing children, removing children, renaming, etc.). The class uses the functionality of registered network protocols to perform these operations. Depending of the protocol of the URL, it uses an appropriate network protocol class for the operations. Each of the operation functions of QUrlOperator creates a QNetworkOperation object that describes the operation and puts it into the operation queue for the network protocol used. If no suitable protocol could be found (because no implementation of the necessary network protocol is registered), the URL operator emits errors. Not every protocol supports every operation, but error handling deals with this problem..PPA QUrlOperator can be used like this e.g. for downloading a file:.PP.nf.br QUrlOperator op;.br op.copy( QString("ftp://ftp.trolltech.com/qt/source/qt-2.1.0.tar.gz"),.br "file:/tmp" );.br.fi.PPYou will also need to connect to some signals of the QUrlOperator to be informed of success, errors, progress and more things..PPOf course an implementation for the FTP protocol has to be registered for this example to work, e.g. QFtp. You can use the function qInitNetworkProtocols() to register all the network protocols that are shipped with the Qt network extension (at the moment FTP, HTTP and local file system are supported)..PPFor more information about the Qt Network Architecture see the Qt Network Documentation..PPSee also QNetworkProtocol, QNetworkOperation, Input/Output and Networking and Miscellaneous Classes..SH MEMBER FUNCTION DOCUMENTATION.SH "QUrlOperator::QUrlOperator ()"Constructs a QUrlOperator with an empty (i.e. invalid) URL..SH "QUrlOperator::QUrlOperator ( const QString & url )"Constructs a QUrlOperator using \fIurl\fR and parses this string..PPIf you pass strings like "/home/qt" the "file" protocol is assumed..SH "QUrlOperator::QUrlOperator ( const QUrlOperator & url )"Constructs a copy of \fIurl\fR..SH "QUrlOperator::QUrlOperator ( const QUrlOperator & url, const QString & relUrl, bool checkSlash = FALSE )"Constructs a QUrlOperator. The URL on which this QUrlOperator operates is constructed out of the arguments \fIurl\fR, \fIrelUrl\fR and \fIcheckSlash\fR: see the corresponding QUrl constructor for an explanation of these arguments..SH "QUrlOperator::~QUrlOperator ()\fC [virtual]\fR"Destructor..SH "void QUrlOperator::clearEntries ()\fC [virtual protected]\fR"Clears the cache of children..SH "void QUrlOperator::connectionStateChanged ( int state, const QString & data )\fC [signal]\fR"This signal is emitted whenever the state of the connection of the network protocol of the URL operator changes. \fIstate\fR describes the new state, which is a QNetworkProtocol::ConnectionState value..PP\fIdata\fR is a string that describes the change of the connection. This can be used to display a message to the user..SH "QPtrList<QNetworkOperation> QUrlOperator::copy ( const QString & from, const QString & to, bool move = FALSE, bool toPath = TRUE )\fC [virtual]\fR"Copies the file \fIfrom\fR to \fIto\fR. If \fImove\fR is TRUE, the file is moved (copied and removed). \fIfrom\fR must point to a file and \fIto\fR points to a directory (into which \fIfrom\fR is copied) unless \fItoPath\fR is set to FALSE. If \fItoPath\fR is set to FALSE then the \fIto\fR variable is assumed to be the absolute file path (destination file path + file name). The copying is done using the get() and put() operations. If you want to be notified about the progress of the operation, connect to the dataTransferProgress() signal. Bear in mind that the get() and put() operations emit this signal through the QUrlOperator. The number of transferred bytes and the total bytes that you receive as arguments in this signal do not relate to the the whole copy operation; they relate first to the get() and then to the put() operation. Always check what type of operation the signal comes from; this is given in the signal's last argument..PPAt the end, finished() (with success or failure) is emitted, so check the state of the network operation object to see whether or not the operation was successful..PPBecause a move or copy operation consists of multiple operations (get(), put() and maybe remove()), this function doesn't return a single QNetworkOperation, but rather a list of them. They are in the order: get(), put() and (if applicable) remove()..PPSee also get() and put()..SH "void QUrlOperator::copy ( const QStringList & files, const QString & dest, bool move = FALSE )\fC [virtual]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPCopies \fIfiles\fR to the directory \fIdest\fR. If \fImove\fR is TRUE the files are moved, not copied. \fIdest\fR must point to a directory..PPThis function calls copy() for each entry in \fIfiles\fR one after the other. You don't get a result from this function; each time a new copy begins, startedNextCopy() is emitted, with a list of QNetworkOperations that describe the new copy operation..SH "void QUrlOperator::createdDirectory ( const QUrlInfo & i, QNetworkOperation * op )\fC [signal]\fR"This signal is emitted when mkdir() succeeds and the directory has been created. \fIi\fR holds the information about the new directory. \fIop\fR is the pointer to the operation object, which contains all the information about the operation, including the state. Using op->arg(0) you also get the file name of the new directory..PPSee also QNetworkOperation and QNetworkProtocol.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -