Changeset View
Changeset View
Standalone View
Standalone View
src/migration/tsv/TsvMigrate.cpp
Show First 20 Lines • Show All 202 Lines • ▼ Show 20 Line(s) | 189 | public: | |||
---|---|---|---|---|---|
203 | 203 | | |||
204 | //! Not needed for ImportTableWizard | 204 | //! Not needed for ImportTableWizard | ||
205 | inline KDbField* createField(const QString &tableName, int index) Q_DECL_OVERRIDE { | 205 | inline KDbField* createField(const QString &tableName, int index) Q_DECL_OVERRIDE { | ||
206 | Q_UNUSED(tableName); | 206 | Q_UNUSED(tableName); | ||
207 | Q_UNUSED(index); | 207 | Q_UNUSED(index); | ||
208 | return nullptr; | 208 | return nullptr; | ||
209 | } | 209 | } | ||
210 | 210 | | |||
211 | inline KDbSqlRecord* fetchRecord() Q_DECL_OVERRIDE { | 211 | inline QSharedPointer<KDbSqlRecord> fetchRecord() Q_DECL_OVERRIDE { | ||
212 | QSharedPointer<KDbSqlRecord> sqlRecord; | ||||
212 | QVector<QByteArray> record = readLine(m_info, &m_eof); | 213 | QVector<QByteArray> record = readLine(m_info, &m_eof); | ||
213 | if (m_eof) { | 214 | if (!m_eof) { | ||
214 | return nullptr; | 215 | sqlRecord.reset(new TsvRecord(record, *m_info)); | ||
215 | } | 216 | } | ||
216 | return new TsvRecord(record, *m_info); | 217 | return sqlRecord; | ||
217 | } | 218 | } | ||
218 | 219 | | |||
219 | inline KDbResult lastResult() Q_DECL_OVERRIDE { | 220 | inline KDbResult lastResult() Q_DECL_OVERRIDE { | ||
220 | return KDbResult(); | 221 | return KDbResult(); | ||
221 | } | 222 | } | ||
222 | 223 | | |||
223 | inline ~TsvResult() { | 224 | inline ~TsvResult() { | ||
224 | delete m_info; | 225 | delete m_info; | ||
225 | } | 226 | } | ||
226 | 227 | | |||
227 | private: | 228 | private: | ||
228 | FileInfo *m_info; | 229 | FileInfo *m_info; | ||
229 | bool m_eof; | 230 | bool m_eof; | ||
230 | }; | 231 | }; | ||
231 | 232 | | |||
232 | KDbSqlResult* TsvMigrate::drv_readFromTable(const QString &tableName) | 233 | QSharedPointer<KDbSqlResult> TsvMigrate::drv_readFromTable(const QString &tableName) | ||
233 | { | 234 | { | ||
234 | Q_UNUSED(tableName) | 235 | Q_UNUSED(tableName) | ||
236 | QSharedPointer<KDbSqlResult> sqlResult; | ||||
235 | QScopedPointer<FileInfo> info(new FileInfo); | 237 | QScopedPointer<FileInfo> info(new FileInfo); | ||
236 | if (!openFile(info.data())) { | 238 | if (openFile(info.data())) { | ||
237 | return nullptr; | 239 | sqlResult.reset(new TsvResult(info.take())); | ||
238 | } | 240 | } | ||
239 | return new TsvResult(info.take()); | 241 | return sqlResult; | ||
240 | } | 242 | } | ||
241 | 243 | | |||
242 | bool TsvMigrate::openFile(FileInfo *info) | 244 | bool TsvMigrate::openFile(FileInfo *info) | ||
243 | { | 245 | { | ||
244 | info->file.setFileName(data()->source->databaseName()); | 246 | info->file.setFileName(data()->source->databaseName()); | ||
245 | if (!info->file.open(QIODevice::ReadOnly | QIODevice::Text)) { | 247 | if (!info->file.open(QIODevice::ReadOnly | QIODevice::Text)) { | ||
246 | return false; | 248 | return false; | ||
247 | } | 249 | } | ||
Show All 20 Lines |