📄 qurloperator.3qt
字号:
'\" t.TH QUrlOperator 3qt "5 August 2004" "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 (.br.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 QList<QNetworkOperation> \fBcopy\fR ( const QString & " "from" ", const QString & " "to" ", bool " "move" " = FALSE ) ".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> &, QNetworkOperation * res ) ".br.ti -1c.BI "void \fBfinished\fR ( QNetworkOperation * res ) ".br.ti -1c.BI "void \fBstart\fR ( QNetworkOperation * res ) ".br.ti -1c.BI "void \fBcreatedDirectory\fR ( const QUrlInfo &, QNetworkOperation * res ) ".br.ti -1c.BI "void \fBremoved\fR ( QNetworkOperation * res ) ".br.ti -1c.BI "void \fBitemChanged\fR ( QNetworkOperation * res ) ".br.ti -1c.BI "void \fBdata\fR ( const QByteArray &, QNetworkOperation * res ) ".br.ti -1c.BI "void \fBdataTransferProgress\fR ( int " "bytesDone" ", int " "bytesTotal" ", QNetworkOperation * res ) ".br.ti -1c.BI "void \fBstartedNextCopy\fR ( const QList<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 DESCRIPTIONThe QUrlOperator class provides common operations on URLs (get() and more)..PPThis class operates on hierarchical structures (like filesystems) using URLs. Its API allows do all common operations on it (listing children, removing children, renaming, etc.). But the class itself contains no functionality for that. It uses the functionality of registered network protocols. This means, depending of the protocol of the URL, it uses a fitting network protocol class for the operations. In detail, each of the operation methods of QUrlOperator create a QNetworkOperation object which describes the operation and puts it into the operation queue of the used network protocol. If no fitting protocol could be found (because no implementation of the needed network protocol is registered), the url operator emits errors. Also not each protocol supports each operation - but the error handling deals with this problem..PPA QUrlOperator can be used like this (for e.g. downloading a file).PP.nf.br QUrlOperator op;.br op.copy( QString("ftp://ftp.trolltech.com/qt/source/qt-2.1.0.tar.gz"), "file:/tmp", FALSE );.fi.PPNow, you also will connect to some signals of the QUrlOperator to get informed about success, errors, progress and more things..PPOf course an implementation for the FTP protocol has to be registered for this example. In the Qt Network Extension Library there is an implementation of the FTP protocol..PPFor more information about the Qt Network Architecture take a look at the Qt Network Documentation..PPSee also QNetworkProtocol and QNetworkOperation..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..PPYou can pass strings such as "/home/qt": in this case the protocol "file" is assumed..SH "QUrlOperator::QUrlOperator ( const QUrlOperator & url )"Copy constructor..SH "QUrlOperator::QUrlOperator ( const QUrlOperator & url, const QString & relUrl, bool checkSlash = FALSE )"Constructs a QUrlOperator. The URL on which this QUrlOperator works on is constructed out of the arguments \fIurl, relUrl\fR and \fIcheckSlash;\fR the meaning of those arguments is the same as the corresponding QUrl constructor takes..SH "QUrlOperator::~QUrlOperator () \fC[virtual]\fR"Destructor..SH "bool QUrlOperator::cdUp () \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..SH "bool QUrlOperator::checkValid () \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..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 is changed. \fIstate\fR describes the new state, which is one of QNetworkProtocol::ConHostFound, QNetworkProtocol::ConConnected, QNetworkProtocol::ConClosed This enum is defined in QNetworkProtocol \fIdata\fR is a message text..SH "QList<QNetworkOperation> QUrlOperator::copy ( const QString & from, const QString & to, bool move = FALSE ) \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 has to point to a file and \fIto\fR must point to a directory (into which \fIfrom\fR is copied). The copying is done using get() and put() operations. If you want to get notified about the progress of the operation, connect to the dataTransferProgress() signal. But you have to know, that the get() and the put() operations emit this signal through the QUrlOperator! So, the number of transferred and total bytes which you get as argument in this signal isn't related to the the whole copy operation, but first to the get() and then to the put() operation. So always check for the type of the operation from which the signal comes (you get this by asking for the type of the QNetworkOperation pointer you also get as last argument of this signal)..PPAlso at the end finished() (on success or failure) is emitted, so check the state of the network operation object to see if the operation was successful or not..PPAs a copy operation consists of multiple operations (get(), put() and maybe remove() (depending if you copy or move)) this method doesn't return a single QNetworkOperation, but a list of them. They are in the order get(), put(), remove(). As discussed, the third one (remove) is optional..PPSee also get() and put()..SH "void QUrlOperator::copy ( const QStringList & files, const QString & dest, bool move = FALSE ) \fC[virtual]\fR"Copies \fIfiles\fR to the directory \fIdest.\fR If \fImove\fR is TRUE, the files are moved and not copied. \fIdest\fR has to point to a directory..PPThis method is just a convenience function of the copy method above. It calls the copy above for each entry in \fIfiles\fR one after the other. You don't get a result from this method, but each time a new copy is started, startedNextCopy() is emitted, with a list of QNetworkOperations which describe the new copy operation..SH "void QUrlOperator::createdDirectory ( const QUrlInfo & i, QNetworkOperation * op ) \fC[signal]\fR"This signal is emitted when mkdir() has been succesful 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 infos of the operation, including the state and so on and using op->arg( 0 ) you also get the filename of the new directory..PPSee also QNetworkOperation and QNetworkProtocol..SH "void QUrlOperator::data ( const QByteArray & data, QNetworkOperation * op ) \fC[signal]\fR"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -