1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qurloperator.cpp:88 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>QUrlOperator Class</title>
|
---|
7 | <style type="text/css"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { background: #ffffff; color: black; }
|
---|
12 | --></style>
|
---|
13 | </head>
|
---|
14 | <body>
|
---|
15 |
|
---|
16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
17 | <tr bgcolor="#E5E5E5">
|
---|
18 | <td valign=center>
|
---|
19 | <a href="index.html">
|
---|
20 | <font color="#004faf">Home</font></a>
|
---|
21 | | <a href="classes.html">
|
---|
22 | <font color="#004faf">All Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main Classes</font></a>
|
---|
25 | | <a href="annotated.html">
|
---|
26 | <font color="#004faf">Annotated</font></a>
|
---|
27 | | <a href="groups.html">
|
---|
28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
29 | | <a href="functions.html">
|
---|
30 | <font color="#004faf">Functions</font></a>
|
---|
31 | </td>
|
---|
32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QUrlOperator Class Reference<br><small>[<a href="network.html">network module</a>]</small></h1>
|
---|
33 |
|
---|
34 | <p>The QUrlOperator class provides common operations on URLs.
|
---|
35 | <a href="#details">More...</a>
|
---|
36 | <p><tt>#include <<a href="qurloperator-h.html">qurloperator.h</a>></tt>
|
---|
37 | <p>Inherits <a href="qobject.html">QObject</a> and <a href="qurl.html">QUrl</a>.
|
---|
38 | <p><a href="qurloperator-members.html">List of all member functions.</a>
|
---|
39 | <h2>Public Members</h2>
|
---|
40 | <ul>
|
---|
41 | <li class=fn><a href="#QUrlOperator"><b>QUrlOperator</b></a> ()</li>
|
---|
42 | <li class=fn><a href="#QUrlOperator-2"><b>QUrlOperator</b></a> ( const QString & url )</li>
|
---|
43 | <li class=fn><a href="#QUrlOperator-3"><b>QUrlOperator</b></a> ( const QUrlOperator & url )</li>
|
---|
44 | <li class=fn><a href="#QUrlOperator-4"><b>QUrlOperator</b></a> ( const QUrlOperator & url, const QString & relUrl, bool checkSlash = FALSE )</li>
|
---|
45 | <li class=fn>virtual <a href="#~QUrlOperator"><b>~QUrlOperator</b></a> ()</li>
|
---|
46 | <li class=fn>virtual const QNetworkOperation * <a href="#listChildren"><b>listChildren</b></a> ()</li>
|
---|
47 | <li class=fn>virtual const QNetworkOperation * <a href="#mkdir"><b>mkdir</b></a> ( const QString & dirname )</li>
|
---|
48 | <li class=fn>virtual const QNetworkOperation * <a href="#remove"><b>remove</b></a> ( const QString & filename )</li>
|
---|
49 | <li class=fn>virtual const QNetworkOperation * <a href="#rename"><b>rename</b></a> ( const QString & oldname, const QString & newname )</li>
|
---|
50 | <li class=fn>virtual const QNetworkOperation * <a href="#get"><b>get</b></a> ( const QString & location = QString::null )</li>
|
---|
51 | <li class=fn>virtual const QNetworkOperation * <a href="#put"><b>put</b></a> ( const QByteArray & data, const QString & location = QString::null )</li>
|
---|
52 | <li class=fn>virtual QPtrList<QNetworkOperation> <a href="#copy"><b>copy</b></a> ( const QString & from, const QString & to, bool move = FALSE, bool toPath = TRUE )</li>
|
---|
53 | <li class=fn>virtual void <a href="#copy-2"><b>copy</b></a> ( const QStringList & files, const QString & dest, bool move = FALSE )</li>
|
---|
54 | <li class=fn>virtual bool <a href="#isDir"><b>isDir</b></a> ( bool * ok = 0 )</li>
|
---|
55 | <li class=fn>virtual void <a href="#setNameFilter"><b>setNameFilter</b></a> ( const QString & nameFilter )</li>
|
---|
56 | <li class=fn>QString <a href="#nameFilter"><b>nameFilter</b></a> () const</li>
|
---|
57 | <li class=fn>virtual QUrlInfo <a href="#info"><b>info</b></a> ( const QString & entry ) const</li>
|
---|
58 | <li class=fn>virtual void <a href="#stop"><b>stop</b></a> ()</li>
|
---|
59 | </ul>
|
---|
60 | <h2>Signals</h2>
|
---|
61 | <ul>
|
---|
62 | <li class=fn>void <a href="#newChildren"><b>newChildren</b></a> ( const QValueList<QUrlInfo> & i, QNetworkOperation * op )</li>
|
---|
63 | <li class=fn>void <a href="#finished"><b>finished</b></a> ( QNetworkOperation * op )</li>
|
---|
64 | <li class=fn>void <a href="#start"><b>start</b></a> ( QNetworkOperation * op )</li>
|
---|
65 | <li class=fn>void <a href="#createdDirectory"><b>createdDirectory</b></a> ( const QUrlInfo & i, QNetworkOperation * op )</li>
|
---|
66 | <li class=fn>void <a href="#removed"><b>removed</b></a> ( QNetworkOperation * op )</li>
|
---|
67 | <li class=fn>void <a href="#itemChanged"><b>itemChanged</b></a> ( QNetworkOperation * op )</li>
|
---|
68 | <li class=fn>void <a href="#data"><b>data</b></a> ( const QByteArray & data, QNetworkOperation * op )</li>
|
---|
69 | <li class=fn>void <a href="#dataTransferProgress"><b>dataTransferProgress</b></a> ( int bytesDone, int bytesTotal, QNetworkOperation * op )</li>
|
---|
70 | <li class=fn>void <a href="#startedNextCopy"><b>startedNextCopy</b></a> ( const QPtrList<QNetworkOperation> & lst )</li>
|
---|
71 | <li class=fn>void <a href="#connectionStateChanged"><b>connectionStateChanged</b></a> ( int state, const QString & data )</li>
|
---|
72 | </ul>
|
---|
73 | <h2>Protected Members</h2>
|
---|
74 | <ul>
|
---|
75 | <li class=fn>virtual void <a href="#clearEntries"><b>clearEntries</b></a> ()</li>
|
---|
76 | <li class=fn>void <a href="#getNetworkProtocol"><b>getNetworkProtocol</b></a> ()</li>
|
---|
77 | <li class=fn>void <a href="#deleteNetworkProtocol"><b>deleteNetworkProtocol</b></a> ()</li>
|
---|
78 | </ul>
|
---|
79 | <h2>Related Functions</h2>
|
---|
80 | <ul>
|
---|
81 | <li class=fn>void <a href="#qInitNetworkProtocols"><b>qInitNetworkProtocols</b></a> ()</li>
|
---|
82 | </ul>
|
---|
83 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
84 |
|
---|
85 |
|
---|
86 | <p> The QUrlOperator class provides common operations on URLs.
|
---|
87 |
|
---|
88 | <p>
|
---|
89 |
|
---|
90 |
|
---|
91 | <p>
|
---|
92 | <p> This class operates on hierarchical structures (such as
|
---|
93 | filesystems) using URLs. Its API facilitates all the common
|
---|
94 | operations:
|
---|
95 | <center><table cellpadding="4" cellspacing="2" border="0">
|
---|
96 | <tr bgcolor="#a2c511"> <th valign="top">Operation <th valign="top">Function
|
---|
97 | <tr bgcolor="#f0f0f0"> <td valign="top">List files <td valign="top"><a href="#listChildren">listChildren</a>()
|
---|
98 | <tr bgcolor="#d0d0d0"> <td valign="top">Make a directory <td valign="top"><a href="#mkdir">mkdir</a>()
|
---|
99 | <tr bgcolor="#f0f0f0"> <td valign="top">Remove a file <td valign="top"><a href="#remove">remove</a>()
|
---|
100 | <tr bgcolor="#d0d0d0"> <td valign="top">Rename a file <td valign="top"><a href="#rename">rename</a>()
|
---|
101 | <tr bgcolor="#f0f0f0"> <td valign="top">Get a file <td valign="top"><a href="#get">get</a>()
|
---|
102 | <tr bgcolor="#d0d0d0"> <td valign="top">Put a file <td valign="top"><a href="#put">put</a>()
|
---|
103 | <tr bgcolor="#f0f0f0"> <td valign="top">Copy a file <td valign="top"><a href="#copy">copy</a>()
|
---|
104 | </table></center>
|
---|
105 | <p> You can obtain additional information about the URL with <a href="#isDir">isDir</a>()
|
---|
106 | and <a href="#info">info</a>(). If a directory is to be traversed using
|
---|
107 | <a href="#listChildren">listChildren</a>(), a name filter can be set with <a href="#setNameFilter">setNameFilter</a>().
|
---|
108 | <p> A QUrlOperator can be used like this, for example to download a
|
---|
109 | file (and assuming that the FTP protocol is <a href="#qInitNetworkProtocols">registered</a>):
|
---|
110 | <pre>
|
---|
111 | QUrlOperator *op = new QUrlOperator();
|
---|
112 | op-><a href="#copy">copy</a>( QString("ftp://ftp.trolltech.com/qt/source/qt-2.1.0.tar.gz"),
|
---|
113 | "file:/tmp" );
|
---|
114 | </pre>
|
---|
115 |
|
---|
116 | <p> If you want to be notified about success/failure, progress, etc.,
|
---|
117 | you can connect to QUrlOperator's signals, e.g. to <a href="#start">start</a>(),
|
---|
118 | <a href="#newChildren">newChildren</a>(), <a href="#createdDirectory">createdDirectory</a>(), <a href="#removed">removed</a>(), <a href="#data">data</a>(),
|
---|
119 | <a href="#dataTransferProgress">dataTransferProgress</a>(), <a href="#startedNextCopy">startedNextCopy</a>(),
|
---|
120 | <a href="#connectionStateChanged">connectionStateChanged</a>(), <a href="#finished">finished</a>(), etc. A network operation can
|
---|
121 | be stopped with <a href="#stop">stop</a>().
|
---|
122 | <p> The class uses the functionality of registered network protocols
|
---|
123 | to perform these operations. Depending of the protocol of the URL,
|
---|
124 | it uses an appropriate network protocol class for the operations.
|
---|
125 | Each of the operation functions of QUrlOperator creates a
|
---|
126 | <a href="qnetworkoperation.html">QNetworkOperation</a> object that describes the operation and puts it
|
---|
127 | into the operation queue for the network protocol used. If no
|
---|
128 | suitable protocol could be found (because no implementation of the
|
---|
129 | necessary network protocol is registered), the URL operator emits
|
---|
130 | errors. Not every protocol supports every operation, but error
|
---|
131 | handling deals with this problem.
|
---|
132 | <p> To register the available network protocols, use the
|
---|
133 | <a href="#qInitNetworkProtocols">qInitNetworkProtocols</a>() function. The protocols currently
|
---|
134 | supported are:
|
---|
135 | <ul>
|
---|
136 | <li> <a href="qftp.html">FTP</a>,
|
---|
137 | <li> <a href="qhttp.html">HTTP</a>,
|
---|
138 | <li> <a href="qlocalfs.html">local file system</a>.
|
---|
139 | </ul>
|
---|
140 | <p> For more information about the Qt Network Architecture see the
|
---|
141 | <a href="network.html">Qt Network Documentation</a>.
|
---|
142 | <p> <p>See also <a href="qnetworkprotocol.html">QNetworkProtocol</a>, <a href="qnetworkoperation.html">QNetworkOperation</a>, <a href="io.html">Input/Output and Networking</a>, and <a href="misc.html">Miscellaneous Classes</a>.
|
---|
143 |
|
---|
144 | <hr><h2>Member Function Documentation</h2>
|
---|
145 | <h3 class=fn><a name="QUrlOperator"></a>QUrlOperator::QUrlOperator ()
|
---|
146 | </h3>
|
---|
147 | Constructs a QUrlOperator with an empty (i.e. invalid) URL.
|
---|
148 |
|
---|
149 | <h3 class=fn><a name="QUrlOperator-2"></a>QUrlOperator::QUrlOperator ( const <a href="qstring.html">QString</a> & url )
|
---|
150 | </h3>
|
---|
151 | Constructs a QUrlOperator using <em>url</em> and parses this string.
|
---|
152 | <p> If you pass strings like "/home/qt" the "file" protocol is
|
---|
153 | assumed.
|
---|
154 |
|
---|
155 | <h3 class=fn><a name="QUrlOperator-3"></a>QUrlOperator::QUrlOperator ( const <a href="qurloperator.html">QUrlOperator</a> & url )
|
---|
156 | </h3>
|
---|
157 | Constructs a copy of <em>url</em>.
|
---|
158 |
|
---|
159 | <h3 class=fn><a name="QUrlOperator-4"></a>QUrlOperator::QUrlOperator ( const <a href="qurloperator.html">QUrlOperator</a> & url, const <a href="qstring.html">QString</a> & relUrl, bool checkSlash = FALSE )
|
---|
160 | </h3>
|
---|
161 | Constructs a QUrlOperator. The URL on which this QUrlOperator
|
---|
162 | operates is constructed out of the arguments <em>url</em>, <em>relUrl</em> and
|
---|
163 | <em>checkSlash</em>: see the corresponding <a href="qurl.html">QUrl</a> constructor for an
|
---|
164 | explanation of these arguments.
|
---|
165 |
|
---|
166 | <h3 class=fn><a name="~QUrlOperator"></a>QUrlOperator::~QUrlOperator ()<tt> [virtual]</tt>
|
---|
167 | </h3>
|
---|
168 | Destructor.
|
---|
169 |
|
---|
170 | <h3 class=fn>void <a name="clearEntries"></a>QUrlOperator::clearEntries ()<tt> [virtual protected]</tt>
|
---|
171 | </h3>
|
---|
172 | Clears the cache of children.
|
---|
173 |
|
---|
174 | <h3 class=fn>void <a name="connectionStateChanged"></a>QUrlOperator::connectionStateChanged ( int state, const <a href="qstring.html">QString</a> & data )<tt> [signal]</tt>
|
---|
175 | </h3>
|
---|
176 |
|
---|
177 | <p> This signal is emitted whenever the URL operator's connection
|
---|
178 | state changes. <em>state</em> describes the new state, which is a
|
---|
179 | <a href="qnetworkprotocol.html#ConnectionState-enum">QNetworkProtocol::ConnectionState</a> value.
|
---|
180 | <p> <em>data</em> is a string that describes the change of the connection.
|
---|
181 | This can be used to display a message to the user.
|
---|
182 |
|
---|
183 | <h3 class=fn><a href="qptrlist.html">QPtrList</a><QNetworkOperation> <a name="copy"></a>QUrlOperator::copy ( const <a href="qstring.html">QString</a> & from, const <a href="qstring.html">QString</a> & to, bool move = FALSE, bool toPath = TRUE )<tt> [virtual]</tt>
|
---|
184 | </h3>
|
---|
185 | Copies the file <em>from</em> to <em>to</em>. If <em>move</em> is TRUE, the file is
|
---|
186 | moved (copied and removed). <em>from</em> must point to a file and <em>to</em>
|
---|
187 | must point to a directory (into which <em>from</em> is copied) unless <em>toPath</em> is set to FALSE. If <em>toPath</em> is set to FALSE then the <em>to</em> variable is assumed to be the absolute file path (destination
|
---|
188 | file path + file name). The copying is done using the <a href="#get">get</a>() and
|
---|
189 | <a href="#put">put</a>() operations. If you want to be notified about the progress of
|
---|
190 | the operation, connect to the <a href="#dataTransferProgress">dataTransferProgress</a>() signal. Bear
|
---|
191 | in mind that the get() and put() operations emit this signal
|
---|
192 | through the QUrlOperator. The number of transferred bytes and the
|
---|
193 | total bytes that you receive as arguments in this signal do not
|
---|
194 | relate to the the whole copy operation; they relate first to the
|
---|
195 | get() and then to the put() operation. Always check what type of
|
---|
196 | operation the signal comes from; this is given in the signal's
|
---|
197 | last argument.
|
---|
198 | <p> At the end, <a href="#finished">finished</a>() (with success or failure) is emitted, so
|
---|
199 | check the state of the network operation object to see whether or
|
---|
200 | not the operation was successful.
|
---|
201 | <p> Because a move or copy operation consists of multiple operations
|
---|
202 | (get(), put() and maybe <a href="#remove">remove</a>()), this function doesn't return a
|
---|
203 | single <a href="qnetworkoperation.html">QNetworkOperation</a>, but rather a list of them. They are in
|
---|
204 | the order: <a href="#get">get</a>(), <a href="#put">put</a>() and (if applicable) remove().
|
---|
205 | <p> <p>See also <a href="#get">get</a>() and <a href="#put">put</a>().
|
---|
206 |
|
---|
207 | <h3 class=fn>void <a name="copy-2"></a>QUrlOperator::copy ( const <a href="qstringlist.html">QStringList</a> & files, const <a href="qstring.html">QString</a> & dest, bool move = FALSE )<tt> [virtual]</tt>
|
---|
208 | </h3>
|
---|
209 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
210 | <p> Copies the <em>files</em> to the directory <em>dest</em>. If <em>move</em> is TRUE
|
---|
211 | the files are moved, not copied. <em>dest</em> must point to a
|
---|
212 | directory.
|
---|
213 | <p> This function calls <a href="#copy">copy</a>() for each entry in <em>files</em> in turn. You
|
---|
214 | don't get a result from this function; each time a new copy
|
---|
215 | begins, <a href="#startedNextCopy">startedNextCopy</a>() is emitted, with a list of
|
---|
216 | QNetworkOperations that describe the new copy operation.
|
---|
217 |
|
---|
218 | <h3 class=fn>void <a name="createdDirectory"></a>QUrlOperator::createdDirectory ( const <a href="qurlinfo.html">QUrlInfo</a> & i, <a href="qnetworkoperation.html">QNetworkOperation</a> * op )<tt> [signal]</tt>
|
---|
219 | </h3>
|
---|
220 |
|
---|
221 | <p> This signal is emitted when <a href="#mkdir">mkdir</a>() succeeds and the directory has
|
---|
222 | been created. <em>i</em> holds the information about the new directory.
|
---|
223 | <p> <em>op</em> is a pointer to the operation object, which contains all the
|
---|
224 | information about the operation, including the state.
|
---|
225 | <tt>op->arg(0)</tt> holds the new directory's name.
|
---|
226 | <p> <p>See also <a href="qnetworkoperation.html">QNetworkOperation</a> and <a href="qnetworkprotocol.html">QNetworkProtocol</a>.
|
---|
227 |
|
---|
228 | <h3 class=fn>void <a name="data"></a>QUrlOperator::data ( const <a href="qbytearray.html">QByteArray</a> & data, <a href="qnetworkoperation.html">QNetworkOperation</a> * op )<tt> [signal]</tt>
|
---|
229 | </h3>
|
---|
230 |
|
---|
231 | <p> This signal is emitted when new <em>data</em> has been received after calling
|
---|
232 | <a href="#get">get</a>() or <a href="#put">put</a>().
|
---|
233 | <em>op</em> is a pointer to the operation object which contains all
|
---|
234 | the information about the operation, including the state.
|
---|
235 | <tt>op->arg(0)</tt> holds the name of the file whose data is retrieved
|
---|
236 | and op->rawArg(1) holds the (raw) data.
|
---|
237 | <p> <p>See also <a href="qnetworkoperation.html">QNetworkOperation</a> and <a href="qnetworkprotocol.html">QNetworkProtocol</a>.
|
---|
238 |
|
---|
239 | <h3 class=fn>void <a name="dataTransferProgress"></a>QUrlOperator::dataTransferProgress ( int bytesDone, int bytesTotal, <a href="qnetworkoperation.html">QNetworkOperation</a> * op )<tt> [signal]</tt>
|
---|
240 | </h3>
|
---|
241 |
|
---|
242 | <p> This signal is emitted during data transfer (using <a href="#put">put</a>() or
|
---|
243 | <a href="#get">get</a>()). <em>bytesDone</em> specifies how many bytes of <em>bytesTotal</em> have
|
---|
244 | been transferred. More information about the operation is stored in
|
---|
245 | <em>op</em>, a pointer to the network operation that is processed.
|
---|
246 | <em>bytesTotal</em> may be -1, which means that the total number of bytes
|
---|
247 | is not known.
|
---|
248 | <p> <p>See also <a href="qnetworkoperation.html">QNetworkOperation</a> and <a href="qnetworkprotocol.html">QNetworkProtocol</a>.
|
---|
249 |
|
---|
250 | <h3 class=fn>void <a name="deleteNetworkProtocol"></a>QUrlOperator::deleteNetworkProtocol ()<tt> [protected]</tt>
|
---|
251 | </h3>
|
---|
252 | Deletes the currently used network protocol.
|
---|
253 |
|
---|
254 | <h3 class=fn>void <a name="finished"></a>QUrlOperator::finished ( <a href="qnetworkoperation.html">QNetworkOperation</a> * op )<tt> [signal]</tt>
|
---|
255 | </h3>
|
---|
256 |
|
---|
257 | <p> This signal is emitted when an operation of some sort finishes,
|
---|
258 | whether with success or failure. <em>op</em> is a pointer to the
|
---|
259 | operation object, which contains all the information, including
|
---|
260 | the state, of the operation which has been finished. Check the
|
---|
261 | state and error code of the operation object to see whether or not
|
---|
262 | the operation was successful.
|
---|
263 | <p> <p>See also <a href="qnetworkoperation.html">QNetworkOperation</a> and <a href="qnetworkprotocol.html">QNetworkProtocol</a>.
|
---|
264 |
|
---|
265 | <h3 class=fn>const <a href="qnetworkoperation.html">QNetworkOperation</a> * <a name="get"></a>QUrlOperator::get ( const <a href="qstring.html">QString</a> & location = QString::null )<tt> [virtual]</tt>
|
---|
266 | </h3>
|
---|
267 | Tells the network protocol to get data from <em>location</em> or, if
|
---|
268 | this is <a href="qstring.html#QString-null">QString::null</a>, to get data from the location to which this
|
---|
269 | URL points (see <a href="qurl.html#fileName">QUrl::fileName</a>() and <a href="qurl.html#encodedPathAndQuery">QUrl::encodedPathAndQuery</a>()).
|
---|
270 | What happens then depends on the network protocol. The <a href="#data">data</a>()
|
---|
271 | signal is emitted when data comes in. Because it's unlikely that
|
---|
272 | all data will come in at once, it is common for multiple data()
|
---|
273 | signals to be emitted. The <a href="#dataTransferProgress">dataTransferProgress</a>() signal is
|
---|
274 | emitted while processing the operation. At the end, <a href="#finished">finished</a>()
|
---|
275 | (with success or failure) is emitted, so check the state of the
|
---|
276 | network operation object to see whether or not the operation was
|
---|
277 | successful.
|
---|
278 | <p> If <em>location</em> is QString::null, the path of this QUrlOperator
|
---|
279 | should point to a file when you use this operation. If <em>location</em>
|
---|
280 | is not empty, it can be a relative URL (a child of the path to
|
---|
281 | which the QUrlOperator points) or an absolute URL.
|
---|
282 | <p> For example, to get a web page you might do something like this:
|
---|
283 | <p> <pre>
|
---|
284 | QUrlOperator op( "http://www.whatever.org/cgi-bin/search.pl?cmd=Hello" );
|
---|
285 | op.<a href="#get">get</a>();
|
---|
286 | </pre>
|
---|
287 |
|
---|
288 | <p> For most other operations, the path of the QUrlOperator must point
|
---|
289 | to a directory. If you want to download a file you could do the
|
---|
290 | following:
|
---|
291 | <p> <pre>
|
---|
292 | QUrlOperator op( "ftp://ftp.whatever.org/pub" );
|
---|
293 | // do some other stuff like op.<a href="#listChildren">listChildren</a>() or op.<a href="#mkdir">mkdir</a>( "new_dir" )
|
---|
294 | op.<a href="#get">get</a>( "a_file.txt" );
|
---|
295 | </pre>
|
---|
296 |
|
---|
297 | <p> This will get the data of ftp://ftp.whatever.org/pub/a_file.txt.
|
---|
298 | <p> <em>Never</em> do anything like this:
|
---|
299 | <pre>
|
---|
300 | QUrlOperator op( "http://www.whatever.org/cgi-bin" );
|
---|
301 | op.<a href="#get">get</a>( "search.pl?cmd=Hello" ); // WRONG!
|
---|
302 | </pre>
|
---|
303 |
|
---|
304 | <p> If <em>location</em> is not empty and relative it must not contain any
|
---|
305 | queries or references, just the name of a child. So if you need to
|
---|
306 | specify a query or reference, do it as shown in the first example
|
---|
307 | or specify the full URL (such as
|
---|
308 | http://www.whatever.org/cgi-bin/search.pl?cmd=Hello) as <em>location</em>.
|
---|
309 | <p> <p>See also <a href="#copy">copy</a>().
|
---|
310 |
|
---|
311 | <h3 class=fn>void <a name="getNetworkProtocol"></a>QUrlOperator::getNetworkProtocol ()<tt> [protected]</tt>
|
---|
312 | </h3>
|
---|
313 | Finds a network protocol for the URL and deletes the old network protocol.
|
---|
314 |
|
---|
315 | <h3 class=fn><a href="qurlinfo.html">QUrlInfo</a> <a name="info"></a>QUrlOperator::info ( const <a href="qstring.html">QString</a> & entry ) const<tt> [virtual]</tt>
|
---|
316 | </h3>
|
---|
317 | Returns the URL information for the child <em>entry</em>, or returns an
|
---|
318 | empty <a href="qurlinfo.html">QUrlInfo</a> object if there is no information available about
|
---|
319 | <em>entry</em>. Information about <em>entry</em> is only available after a successfully
|
---|
320 | finished <a href="#listChildren">listChildren</a>() operation.
|
---|
321 |
|
---|
322 | <h3 class=fn>bool <a name="isDir"></a>QUrlOperator::isDir ( bool * ok = 0 )<tt> [virtual]</tt>
|
---|
323 | </h3>
|
---|
324 | Returns TRUE if the URL is a directory; otherwise returns FALSE.
|
---|
325 | This may not always work correctly, if the protocol of the URL is
|
---|
326 | something other than file (local filesystem). If you pass a bool
|
---|
327 | pointer as the <em>ok</em> argument, <em>*ok</em> is set to TRUE if the result
|
---|
328 | of this function is known to be correct, and to FALSE otherwise.
|
---|
329 |
|
---|
330 | <h3 class=fn>void <a name="itemChanged"></a>QUrlOperator::itemChanged ( <a href="qnetworkoperation.html">QNetworkOperation</a> * op )<tt> [signal]</tt>
|
---|
331 | </h3>
|
---|
332 |
|
---|
333 | <p> This signal is emitted whenever a file which is a child of the URL
|
---|
334 | has been changed, for example by successfully calling <a href="#rename">rename</a>().
|
---|
335 | <em>op</em> is a pointer to the operation object which contains all the
|
---|
336 | information about the operation, including the state.
|
---|
337 | <tt>op->arg(0)</tt> holds the original file name and <tt>op->arg(1)</tt> holds
|
---|
338 | the new file name (if it was changed).
|
---|
339 | <p> <p>See also <a href="qnetworkoperation.html">QNetworkOperation</a> and <a href="qnetworkprotocol.html">QNetworkProtocol</a>.
|
---|
340 |
|
---|
341 | <h3 class=fn>const <a href="qnetworkoperation.html">QNetworkOperation</a> * <a name="listChildren"></a>QUrlOperator::listChildren ()<tt> [virtual]</tt>
|
---|
342 | </h3>
|
---|
343 | Starts listing the children of this URL (e.g. the files in the
|
---|
344 | directory). The <a href="#start">start</a>() signal is emitted before the first entry
|
---|
345 | is listed and <a href="#finished">finished</a>() is emitted after the last one. The
|
---|
346 | <a href="#newChildren">newChildren</a>() signal is emitted for each list of new entries. If
|
---|
347 | an error occurs, the signal finished() is emitted, so be sure to
|
---|
348 | check the state of the network operation pointer.
|
---|
349 | <p> Because the operation may not be executed immediately, a pointer
|
---|
350 | to the <a href="qnetworkoperation.html">QNetworkOperation</a> object created by this function is
|
---|
351 | returned. This object contains all the data about the operation
|
---|
352 | and is used to refer to this operation later (e.g. in the signals
|
---|
353 | that are emitted by the QUrlOperator). The return value can also
|
---|
354 | be 0 if the operation object couldn't be created.
|
---|
355 | <p> The path of this QUrlOperator must to point to a directory
|
---|
356 | (because the children of this directory will be listed), not to a
|
---|
357 | file.
|
---|
358 |
|
---|
359 | <h3 class=fn>const <a href="qnetworkoperation.html">QNetworkOperation</a> * <a name="mkdir"></a>QUrlOperator::mkdir ( const <a href="qstring.html">QString</a> & dirname )<tt> [virtual]</tt>
|
---|
360 | </h3>
|
---|
361 | Tries to create a directory (child) with the name <em>dirname</em>. If
|
---|
362 | it is successful, a <a href="#newChildren">newChildren</a>() signal with the new child is
|
---|
363 | emitted, and the <a href="#createdDirectory">createdDirectory</a>() signal with the information
|
---|
364 | about the new child is also emitted. The <a href="#finished">finished</a>() signal (with
|
---|
365 | success or failure) is emitted after the operation has been
|
---|
366 | processed, so check the state of the network operation object to
|
---|
367 | see whether or not the operation was successful.
|
---|
368 | <p> Because the operation will not be executed immediately, a pointer
|
---|
369 | to the <a href="qnetworkoperation.html">QNetworkOperation</a> object created by this function is
|
---|
370 | returned. This object contains all the data about the operation
|
---|
371 | and is used to refer to this operation later (e.g. in the signals
|
---|
372 | that are emitted by the QUrlOperator). The return value can also
|
---|
373 | be 0 if the operation object couldn't be created.
|
---|
374 | <p> The path of this QUrlOperator must to point to a directory (not a
|
---|
375 | file) because the new directory will be created in this path.
|
---|
376 |
|
---|
377 | <h3 class=fn><a href="qstring.html">QString</a> <a name="nameFilter"></a>QUrlOperator::nameFilter () const
|
---|
378 | </h3>
|
---|
379 | Returns the name filter of the URL.
|
---|
380 | <p> <p>See also <a href="#setNameFilter">QUrlOperator::setNameFilter</a>() and <a href="qdir.html#nameFilter">QDir::nameFilter</a>().
|
---|
381 |
|
---|
382 | <h3 class=fn>void <a name="newChildren"></a>QUrlOperator::newChildren ( const <a href="qvaluelist.html">QValueList</a><QUrlInfo> & i, <a href="qnetworkoperation.html">QNetworkOperation</a> * op )<tt> [signal]</tt>
|
---|
383 | </h3>
|
---|
384 |
|
---|
385 | <p> This signal is emitted after <a href="#listChildren">listChildren</a>() was called and new
|
---|
386 | children (i.e. files) have been read from a list of files. <em>i</em>
|
---|
387 | holds the information about the new files. <em>op</em> is a pointer
|
---|
388 | to the operation object which contains all the information about
|
---|
389 | the operation, including the state.
|
---|
390 | <p> <p>See also <a href="qnetworkoperation.html">QNetworkOperation</a> and <a href="qnetworkprotocol.html">QNetworkProtocol</a>.
|
---|
391 |
|
---|
392 | <h3 class=fn>const <a href="qnetworkoperation.html">QNetworkOperation</a> * <a name="put"></a>QUrlOperator::put ( const <a href="qbytearray.html">QByteArray</a> & data, const <a href="qstring.html">QString</a> & location = QString::null )<tt> [virtual]</tt>
|
---|
393 | </h3>
|
---|
394 | This function tells the network protocol to put <em>data</em> in <em>location</em>. If <em>location</em> is empty (QString::null), it puts the <em>data</em> in the location to which the URL points. What happens depends
|
---|
395 | on the network protocol. Depending on the network protocol, some
|
---|
396 | data might come back after putting data, in which case the <a href="#data">data</a>()
|
---|
397 | signal is emitted. The <a href="#dataTransferProgress">dataTransferProgress</a>() signal is emitted
|
---|
398 | during processing of the operation. At the end, <a href="#finished">finished</a>() (with
|
---|
399 | success or failure) is emitted, so check the state of the network
|
---|
400 | operation object to see whether or not the operation was
|
---|
401 | successful.
|
---|
402 | <p> If <em>location</em> is <a href="qstring.html#QString-null">QString::null</a>, the path of this QUrlOperator
|
---|
403 | should point to a file when you use this operation. If <em>location</em>
|
---|
404 | is not empty, it can be a relative (a child of the path to which
|
---|
405 | the QUrlOperator points) or an absolute URL.
|
---|
406 | <p> For putting some data to a file you can do the following:
|
---|
407 | <p> <pre>
|
---|
408 | QUrlOperator op( "ftp://ftp.whatever.com/home/me/filename.dat" );
|
---|
409 | op.<a href="#put">put</a>( data );
|
---|
410 | </pre>
|
---|
411 |
|
---|
412 | <p> For most other operations, the path of the QUrlOperator must point
|
---|
413 | to a directory. If you want to upload data to a file you could do
|
---|
414 | the following:
|
---|
415 | <p> <pre>
|
---|
416 | QUrlOperator op( "ftp://ftp.whatever.com/home/me" );
|
---|
417 | // do some other stuff like op.<a href="#listChildren">listChildren</a>() or op.<a href="#mkdir">mkdir</a>( "new_dir" )
|
---|
418 | op.<a href="#put">put</a>( data, "filename.dat" );
|
---|
419 | </pre>
|
---|
420 |
|
---|
421 | <p> This will upload the data to ftp://ftp.whatever.com/home/me/filename.dat.
|
---|
422 | <p> <p>See also <a href="#copy">copy</a>().
|
---|
423 |
|
---|
424 | <h3 class=fn>const <a href="qnetworkoperation.html">QNetworkOperation</a> * <a name="remove"></a>QUrlOperator::remove ( const <a href="qstring.html">QString</a> & filename )<tt> [virtual]</tt>
|
---|
425 | </h3>
|
---|
426 | Tries to remove the file (child) <em>filename</em>. If it succeeds the
|
---|
427 | <a href="#removed">removed</a>() signal is emitted. <a href="#finished">finished</a>() (with success or failure)
|
---|
428 | is also emitted after the operation has been processed, so check
|
---|
429 | the state of the network operation object to see whether or not
|
---|
430 | the operation was successful.
|
---|
431 | <p> Because the operation will not be executed immediately, a pointer
|
---|
432 | to the <a href="qnetworkoperation.html">QNetworkOperation</a> object created by this function is
|
---|
433 | returned. This object contains all the data about the operation
|
---|
434 | and is used to refer to this operation later (e.g. in the signals
|
---|
435 | that are emitted by the QUrlOperator). The return value can also
|
---|
436 | be 0 if the operation object couldn't be created.
|
---|
437 | <p> The path of this QUrlOperator must point to a directory; because
|
---|
438 | if <em>filename</em> is relative, it will try to remove it in this
|
---|
439 | directory.
|
---|
440 |
|
---|
441 | <h3 class=fn>void <a name="removed"></a>QUrlOperator::removed ( <a href="qnetworkoperation.html">QNetworkOperation</a> * op )<tt> [signal]</tt>
|
---|
442 | </h3>
|
---|
443 |
|
---|
444 | <p> This signal is emitted when <a href="#remove">remove</a>() has been succesful and the
|
---|
445 | file has been removed.
|
---|
446 | <p> <em>op</em> is a pointer to the operation object which contains all the
|
---|
447 | information about the operation, including the state.
|
---|
448 | <tt>op->arg(0)</tt> holds the name of the file that was removed.
|
---|
449 | <p> <p>See also <a href="qnetworkoperation.html">QNetworkOperation</a> and <a href="qnetworkprotocol.html">QNetworkProtocol</a>.
|
---|
450 |
|
---|
451 | <h3 class=fn>const <a href="qnetworkoperation.html">QNetworkOperation</a> * <a name="rename"></a>QUrlOperator::rename ( const <a href="qstring.html">QString</a> & oldname, const <a href="qstring.html">QString</a> & newname )<tt> [virtual]</tt>
|
---|
452 | </h3>
|
---|
453 | Tries to rename the file (child) called <em>oldname</em> to <em>newname</em>.
|
---|
454 | If it succeeds, the <a href="#itemChanged">itemChanged</a>() signal is emitted. <a href="#finished">finished</a>()
|
---|
455 | (with success or failure) is also emitted after the operation has
|
---|
456 | been processed, so check the state of the network operation object
|
---|
457 | to see whether or not the operation was successful.
|
---|
458 | <p> Because the operation may not be executed immediately, a pointer
|
---|
459 | to the <a href="qnetworkoperation.html">QNetworkOperation</a> object created by this function is
|
---|
460 | returned. This object contains all the data about the operation
|
---|
461 | and is used to refer to this operation later (e.g. in the signals
|
---|
462 | that are emitted by the QUrlOperator). The return value can also
|
---|
463 | be 0 if the operation object couldn't be created.
|
---|
464 | <p> This path of this QUrlOperator must to point to a directory
|
---|
465 | because <em>oldname</em> and <em>newname</em> are handled relative to this
|
---|
466 | directory.
|
---|
467 |
|
---|
468 | <h3 class=fn>void <a name="setNameFilter"></a>QUrlOperator::setNameFilter ( const <a href="qstring.html">QString</a> & nameFilter )<tt> [virtual]</tt>
|
---|
469 | </h3>
|
---|
470 | Sets the name filter of the URL to <em>nameFilter</em>.
|
---|
471 | <p> <p>See also <a href="qdir.html#setNameFilter">QDir::setNameFilter</a>().
|
---|
472 |
|
---|
473 | <h3 class=fn>void <a name="start"></a>QUrlOperator::start ( <a href="qnetworkoperation.html">QNetworkOperation</a> * op )<tt> [signal]</tt>
|
---|
474 | </h3>
|
---|
475 |
|
---|
476 | <p> Some operations (such as <a href="#listChildren">listChildren</a>()) emit this signal when
|
---|
477 | they start processing the operation. <em>op</em> is a pointer to the
|
---|
478 | operation object which contains all the information about the
|
---|
479 | operation, including the state.
|
---|
480 | <p> <p>See also <a href="qnetworkoperation.html">QNetworkOperation</a> and <a href="qnetworkprotocol.html">QNetworkProtocol</a>.
|
---|
481 |
|
---|
482 | <h3 class=fn>void <a name="startedNextCopy"></a>QUrlOperator::startedNextCopy ( const <a href="qptrlist.html">QPtrList</a><QNetworkOperation> & lst )<tt> [signal]</tt>
|
---|
483 | </h3>
|
---|
484 |
|
---|
485 | <p> This signal is emitted if <a href="#copy">copy</a>() starts a new copy operation. <em>lst</em> contains all QNetworkOperations related to this copy
|
---|
486 | operation.
|
---|
487 | <p> <p>See also <a href="#copy">copy</a>().
|
---|
488 |
|
---|
489 | <h3 class=fn>void <a name="stop"></a>QUrlOperator::stop ()<tt> [virtual]</tt>
|
---|
490 | </h3>
|
---|
491 | Stops the current network operation and removes all this
|
---|
492 | QUrlOperator's waiting network operations.
|
---|
493 |
|
---|
494 | <hr><h2>Related Functions</h2>
|
---|
495 | <h3 class=fn>void <a name="qInitNetworkProtocols"></a>qInitNetworkProtocols ()
|
---|
496 | </h3>
|
---|
497 |
|
---|
498 | <p> This function registers the network protocols for FTP and HTTP.
|
---|
499 | You must call this function before you use QUrlOperator for
|
---|
500 | these protocols.
|
---|
501 | <p> This function is declared in <a href="qnetwork-h.html">qnetwork.h</a>.
|
---|
502 |
|
---|
503 | <!-- eof -->
|
---|
504 | <hr><p>
|
---|
505 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
506 | Copyright © 1995-2007
|
---|
507 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
508 | <table width=100% cellspacing=0 border=0><tr>
|
---|
509 | <td>Copyright © 2007
|
---|
510 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
511 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
512 | </table></div></address></body>
|
---|
513 | </html>
|
---|