93 * reading from the device). |
94 * reading from the device). |
94 * \a state is the new state of the reader. |
95 * \a state is the new state of the reader. |
95 */ |
96 */ |
96 |
97 |
97 /*! |
98 /*! |
98 * \fn QVersitReader::resultsAvailable(QList<QVersitDocument>& results) |
|
99 * \deprecated |
|
100 * The signal is emitted by the reader as it reads from the device when it has made more Versit |
|
101 * documents available. |
|
102 * \a results is the complete list of documents read so far. |
|
103 */ |
|
104 |
|
105 /*! |
|
106 * \fn QVersitReader::resultsAvailable() |
99 * \fn QVersitReader::resultsAvailable() |
107 * The signal is emitted by the reader as it reads from the device when it has made more Versit |
100 * The signal is emitted by the reader as it reads from the device when it has made more Versit |
108 * documents available. |
101 * documents available. |
109 */ |
102 */ |
110 |
103 |
111 /*! Constructs a new reader. */ |
104 /*! Constructs a new reader. */ |
112 QVersitReader::QVersitReader() : d(new QVersitReaderPrivate) |
105 QVersitReader::QVersitReader() : d(new QVersitReaderPrivate) |
113 { |
106 { |
114 connect(d, SIGNAL(stateChanged(QVersitReader::State)), |
107 d->init(this); |
115 this, SIGNAL(stateChanged(QVersitReader::State)),Qt::DirectConnection); |
108 } |
116 connect(d, SIGNAL(resultsAvailable(QList<QVersitDocument>&)), |
109 |
117 this, SIGNAL(resultsAvailable(QList<QVersitDocument>&)), Qt::DirectConnection); |
110 /*! Constructs a new reader that reads from \a inputDevice. */ |
118 connect(d, SIGNAL(resultsAvailable(QList<QVersitDocument>&)), |
111 QVersitReader::QVersitReader(QIODevice *inputDevice) : d(new QVersitReaderPrivate) |
119 this, SIGNAL(resultsAvailable()), Qt::DirectConnection); |
112 { |
|
113 d->init(this); |
|
114 d->mIoDevice = inputDevice; |
|
115 } |
|
116 |
|
117 /*! Constructs a new reader that reads from \a inputData. */ |
|
118 QVersitReader::QVersitReader(const QByteArray &inputData) : d(new QVersitReaderPrivate) |
|
119 { |
|
120 d->init(this); |
|
121 d->mInputBytes.reset(new QBuffer); |
|
122 d->mInputBytes->setData(inputData); |
|
123 d->mInputBytes->open(QIODevice::ReadOnly); |
|
124 d->mIoDevice = d->mInputBytes.data(); |
120 } |
125 } |
121 |
126 |
122 /*! |
127 /*! |
123 * Frees the memory used by the reader. |
128 * Frees the memory used by the reader. |
124 * Waits until a pending asynchronous reading has been completed. |
129 * Waits until a pending asynchronous reading has been completed. |
129 delete d; |
134 delete d; |
130 } |
135 } |
131 |
136 |
132 /*! |
137 /*! |
133 * Sets the device used for reading the input to be the given \a device. |
138 * Sets the device used for reading the input to be the given \a device. |
134 * Does not take ownership of the device. |
139 * Does not take ownership of the device. This overrides any byte array input source set with |
|
140 * setData(). |
135 */ |
141 */ |
136 void QVersitReader::setDevice(QIODevice* device) |
142 void QVersitReader::setDevice(QIODevice* device) |
137 { |
143 { |
|
144 d->mInputBytes.reset(0); |
138 d->mIoDevice = device; |
145 d->mIoDevice = device; |
139 } |
146 } |
140 |
147 |
141 /*! |
148 /*! |
142 * Returns the device used for reading input. |
149 * Returns the device used for reading input, or 0 if no device has been set (or if the input source |
|
150 * was set with setData(). |
143 */ |
151 */ |
144 QIODevice* QVersitReader::device() const |
152 QIODevice* QVersitReader::device() const |
145 { |
153 { |
146 return d->mIoDevice; |
154 if (d->mInputBytes.isNull()) |
|
155 return d->mIoDevice; |
|
156 else |
|
157 return 0; |
|
158 } |
|
159 |
|
160 /*! |
|
161 * Sets the data to read from to the byte array input source, \a inputData. |
|
162 * This overrides any device set with setDevice(). |
|
163 */ |
|
164 void QVersitReader::setData(const QByteArray &inputData) |
|
165 { |
|
166 if (d->mInputBytes.isNull()) |
|
167 d->mInputBytes.reset(new QBuffer); |
|
168 d->mInputBytes->setData(inputData); |
|
169 d->mIoDevice = d->mInputBytes.data(); |
147 } |
170 } |
148 |
171 |
149 /*! |
172 /*! |
150 * Sets \a codec as the codec for the reader to use when parsing the input stream to. |
173 * Sets \a codec as the codec for the reader to use when parsing the input stream to. |
151 * This codec is not used for values where the CHARSET Versit parameter occurs. |
174 * This codec is not used for values where the CHARSET Versit parameter occurs. |
163 * Returns the codec the reader uses when parsing the input stream. |
186 * Returns the codec the reader uses when parsing the input stream. |
164 */ |
187 */ |
165 QTextCodec* QVersitReader::defaultCodec() const |
188 QTextCodec* QVersitReader::defaultCodec() const |
166 { |
189 { |
167 return d->mDefaultCodec; |
190 return d->mDefaultCodec; |
|
191 } |
|
192 |
|
193 /*! |
|
194 * Returns the state of the reader. |
|
195 */ |
|
196 QVersitReader::State QVersitReader::state() const |
|
197 { |
|
198 return d->state(); |
|
199 } |
|
200 |
|
201 /*! |
|
202 * Returns the error encountered by the last operation. |
|
203 */ |
|
204 QVersitReader::Error QVersitReader::error() const |
|
205 { |
|
206 return d->error(); |
168 } |
207 } |
169 |
208 |
170 /*! |
209 /*! |
171 * Starts reading the input asynchronously. |
210 * Starts reading the input asynchronously. |
172 * Returns false if the input device has not been set or opened or |
211 * Returns false if the input device has not been set or opened or |
224 { |
263 { |
225 QMutexLocker locker(&d->mMutex); |
264 QMutexLocker locker(&d->mMutex); |
226 return d->mVersitDocuments; |
265 return d->mVersitDocuments; |
227 } |
266 } |
228 |
267 |
229 /*! |
|
230 * Returns the state of the reader. |
|
231 */ |
|
232 QVersitReader::State QVersitReader::state() const |
|
233 { |
|
234 return d->state(); |
|
235 } |
|
236 |
|
237 /*! |
|
238 * Returns the error encountered by the last operation. |
|
239 */ |
|
240 QVersitReader::Error QVersitReader::error() const |
|
241 { |
|
242 return d->error(); |
|
243 } |
|
244 |
|
245 #include "moc_qversitreader.cpp" |
268 #include "moc_qversitreader.cpp" |