diff options
Diffstat (limited to 'rbutil/rbutilqt/talkfile.cpp')
-rw-r--r-- | rbutil/rbutilqt/talkfile.cpp | 160 |
1 files changed, 80 insertions, 80 deletions
diff --git a/rbutil/rbutilqt/talkfile.cpp b/rbutil/rbutilqt/talkfile.cpp index 43993be436..6e872ad281 100644 --- a/rbutil/rbutilqt/talkfile.cpp +++ b/rbutil/rbutilqt/talkfile.cpp | |||
@@ -24,25 +24,25 @@ TalkFileCreator::TalkFileCreator(QObject* parent): QObject(parent) | |||
24 | 24 | ||
25 | } | 25 | } |
26 | 26 | ||
27 | //! \brief Creates Talkfiles. | 27 | //! \brief Creates Talkfiles. |
28 | //! | 28 | //! |
29 | //! \param logger A pointer to a Loggerobject | 29 | //! \param logger A pointer to a Loggerobject |
30 | bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger) | 30 | bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger) |
31 | { | 31 | { |
32 | m_abort = false; | 32 | m_abort = false; |
33 | m_logger = logger; | 33 | m_logger = logger; |
34 | 34 | ||
35 | QMultiMap<QString,QString> fileList; | 35 | QMultiMap<QString,QString> fileList; |
36 | QMultiMap<QString,QString> dirList; | 36 | QMultiMap<QString,QString> dirList; |
37 | QStringList toSpeakList, voicedEntries, encodedEntries; | 37 | QStringList toSpeakList, voicedEntries, encodedEntries; |
38 | QString errStr; | 38 | QString errStr; |
39 | 39 | ||
40 | m_logger->addItem(tr("Starting Talk file generation"),LOGINFO); | 40 | m_logger->addItem(tr("Starting Talk file generation"),LOGINFO); |
41 | 41 | ||
42 | //tts | 42 | //tts |
43 | m_tts = TTSBase::getTTS(settings->curTTS()); | 43 | m_tts = TTSBase::getTTS(settings->value(RbSettings::Tts).toString()); |
44 | m_tts->setCfg(settings); | 44 | m_tts->setCfg(settings); |
45 | 45 | ||
46 | if(!m_tts->start(&errStr)) | 46 | if(!m_tts->start(&errStr)) |
47 | { | 47 | { |
48 | m_logger->addItem(errStr.trimmed(),LOGERROR); | 48 | m_logger->addItem(errStr.trimmed(),LOGERROR); |
@@ -52,9 +52,9 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger) | |||
52 | } | 52 | } |
53 | 53 | ||
54 | // Encoder | 54 | // Encoder |
55 | m_enc = EncBase::getEncoder(settings->curEncoder()); | 55 | m_enc = EncBase::getEncoder(settings->value(RbSettings::CurEncoder).toString()); |
56 | m_enc->setCfg(settings); | 56 | m_enc->setCfg(settings); |
57 | 57 | ||
58 | if(!m_enc->start()) | 58 | if(!m_enc->start()) |
59 | { | 59 | { |
60 | m_logger->addItem(tr("Init of Encoder engine failed"),LOGERROR); | 60 | m_logger->addItem(tr("Init of Encoder engine failed"),LOGERROR); |
@@ -67,7 +67,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger) | |||
67 | 67 | ||
68 | connect(logger,SIGNAL(aborted()),this,SLOT(abort())); | 68 | connect(logger,SIGNAL(aborted()),this,SLOT(abort())); |
69 | m_logger->setProgressMax(0); | 69 | m_logger->setProgressMax(0); |
70 | 70 | ||
71 | // read in Maps of paths - file/dirnames | 71 | // read in Maps of paths - file/dirnames |
72 | m_logger->addItem(tr("Reading Filelist..."),LOGINFO); | 72 | m_logger->addItem(tr("Reading Filelist..."),LOGINFO); |
73 | if(createDirAndFileMaps(m_dir,&dirList,&fileList) == false) | 73 | if(createDirAndFileMaps(m_dir,&dirList,&fileList) == false) |
@@ -76,21 +76,21 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger) | |||
76 | doAbort(toSpeakList); | 76 | doAbort(toSpeakList); |
77 | return false; | 77 | return false; |
78 | } | 78 | } |
79 | 79 | ||
80 | // create List of all Files/Dirs to speak | 80 | // create List of all Files/Dirs to speak |
81 | QMapIterator<QString, QString> dirIt(dirList); | 81 | QMapIterator<QString, QString> dirIt(dirList); |
82 | while (dirIt.hasNext()) | 82 | while (dirIt.hasNext()) |
83 | { | 83 | { |
84 | dirIt.next(); | 84 | dirIt.next(); |
85 | // insert only non dublicate dir entries into list | 85 | // insert only non dublicate dir entries into list |
86 | if(!toSpeakList.contains(dirIt.value())) | 86 | if(!toSpeakList.contains(dirIt.value())) |
87 | { | 87 | { |
88 | qDebug() << "toSpeaklist dir:" << dirIt.value(); | 88 | qDebug() << "toSpeaklist dir:" << dirIt.value(); |
89 | toSpeakList.append(dirIt.value()); | 89 | toSpeakList.append(dirIt.value()); |
90 | } | 90 | } |
91 | } | 91 | } |
92 | QMapIterator<QString, QString> fileIt(fileList); | 92 | QMapIterator<QString, QString> fileIt(fileList); |
93 | while (fileIt.hasNext()) | 93 | while (fileIt.hasNext()) |
94 | { | 94 | { |
95 | fileIt.next(); | 95 | fileIt.next(); |
96 | // insert only non- dublictae file entries into list | 96 | // insert only non- dublictae file entries into list |
@@ -99,10 +99,10 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger) | |||
99 | if(m_stripExtensions) | 99 | if(m_stripExtensions) |
100 | toSpeakList.append(stripExtension(fileIt.value())); | 100 | toSpeakList.append(stripExtension(fileIt.value())); |
101 | else | 101 | else |
102 | toSpeakList.append(fileIt.value()); | 102 | toSpeakList.append(fileIt.value()); |
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | // Voice entries | 106 | // Voice entries |
107 | m_logger->addItem(tr("Voicing entries..."),LOGINFO); | 107 | m_logger->addItem(tr("Voicing entries..."),LOGINFO); |
108 | TTSStatus voiceStatus= voiceList(toSpeakList,voicedEntries); | 108 | TTSStatus voiceStatus= voiceList(toSpeakList,voicedEntries); |
@@ -111,7 +111,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger) | |||
111 | doAbort(toSpeakList); | 111 | doAbort(toSpeakList); |
112 | return false; | 112 | return false; |
113 | } | 113 | } |
114 | 114 | ||
115 | // Encoding Entries | 115 | // Encoding Entries |
116 | m_logger->addItem(tr("Encoding files..."),LOGINFO); | 116 | m_logger->addItem(tr("Encoding files..."),LOGINFO); |
117 | if(encodeList(voicedEntries,encodedEntries) == false) | 117 | if(encodeList(voicedEntries,encodedEntries) == false) |
@@ -119,25 +119,25 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger) | |||
119 | doAbort(toSpeakList); | 119 | doAbort(toSpeakList); |
120 | return false; | 120 | return false; |
121 | } | 121 | } |
122 | 122 | ||
123 | // Copying talk files | 123 | // Copying talk files |
124 | m_logger->addItem(tr("Copying Talkfile for Dirs..."),LOGINFO); | 124 | m_logger->addItem(tr("Copying Talkfile for Dirs..."),LOGINFO); |
125 | if(copyTalkDirFiles(dirList,&errStr) == false) | 125 | if(copyTalkDirFiles(dirList,&errStr) == false) |
126 | { | 126 | { |
127 | m_logger->addItem(errStr,LOGERROR); | 127 | m_logger->addItem(errStr,LOGERROR); |
128 | doAbort(toSpeakList); | 128 | doAbort(toSpeakList); |
129 | return false; | 129 | return false; |
130 | } | 130 | } |
131 | 131 | ||
132 | //Copying file talk files | 132 | //Copying file talk files |
133 | m_logger->addItem(tr("Copying Talkfile for Files..."),LOGINFO); | 133 | m_logger->addItem(tr("Copying Talkfile for Files..."),LOGINFO); |
134 | if(copyTalkFileFiles(fileList,&errStr) == false) | 134 | if(copyTalkFileFiles(fileList,&errStr) == false) |
135 | { | 135 | { |
136 | m_logger->addItem(errStr,LOGERROR); | 136 | m_logger->addItem(errStr,LOGERROR); |
137 | doAbort(toSpeakList); | 137 | doAbort(toSpeakList); |
138 | return false; | 138 | return false; |
139 | } | 139 | } |
140 | 140 | ||
141 | // Deleting left overs | 141 | // Deleting left overs |
142 | if( !cleanup(toSpeakList)) | 142 | if( !cleanup(toSpeakList)) |
143 | return false; | 143 | return false; |
@@ -184,7 +184,7 @@ void TalkFileCreator::doAbort(QStringList cleanupList) | |||
184 | m_logger->setProgressValue(0); | 184 | m_logger->setProgressValue(0); |
185 | m_logger->abort(); | 185 | m_logger->abort(); |
186 | m_tts->stop(); | 186 | m_tts->stop(); |
187 | m_enc->stop(); | 187 | m_enc->stop(); |
188 | } | 188 | } |
189 | 189 | ||
190 | //! \brief Creates MultiMaps (paths -> File/dir names) of all Dirs and Files in a Folder. | 190 | //! \brief Creates MultiMaps (paths -> File/dir names) of all Dirs and Files in a Folder. |
@@ -194,16 +194,16 @@ void TalkFileCreator::doAbort(QStringList cleanupList) | |||
194 | //! \param startDir The dir where it beginns scanning | 194 | //! \param startDir The dir where it beginns scanning |
195 | //! \param dirMap The MulitMap where the dirs are stored | 195 | //! \param dirMap The MulitMap where the dirs are stored |
196 | //! \param filMap The MultiMap where Files are stored | 196 | //! \param filMap The MultiMap where Files are stored |
197 | //! \returns true on Success, false if User aborted. | 197 | //! \returns true on Success, false if User aborted. |
198 | bool TalkFileCreator::createDirAndFileMaps(QDir startDir,QMultiMap<QString,QString> *dirMap,QMultiMap<QString,QString> *fileMap) | 198 | bool TalkFileCreator::createDirAndFileMaps(QDir startDir,QMultiMap<QString,QString> *dirMap,QMultiMap<QString,QString> *fileMap) |
199 | { | 199 | { |
200 | // create Iterator | 200 | // create Iterator |
201 | QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags; | 201 | QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags; |
202 | if(m_recursive) | 202 | if(m_recursive) |
203 | flags = QDirIterator::Subdirectories; | 203 | flags = QDirIterator::Subdirectories; |
204 | 204 | ||
205 | QDirIterator it(startDir,flags); | 205 | QDirIterator it(startDir,flags); |
206 | 206 | ||
207 | // read in Maps of paths - file/dirnames | 207 | // read in Maps of paths - file/dirnames |
208 | while (it.hasNext()) | 208 | while (it.hasNext()) |
209 | { | 209 | { |
@@ -212,14 +212,14 @@ bool TalkFileCreator::createDirAndFileMaps(QDir startDir,QMultiMap<QString,QStri | |||
212 | { | 212 | { |
213 | return false; | 213 | return false; |
214 | } | 214 | } |
215 | 215 | ||
216 | QFileInfo fileInf = it.fileInfo(); | 216 | QFileInfo fileInf = it.fileInfo(); |
217 | 217 | ||
218 | // its a dir | 218 | // its a dir |
219 | if(fileInf.isDir()) | 219 | if(fileInf.isDir()) |
220 | { | 220 | { |
221 | QDir dir = fileInf.dir(); | 221 | QDir dir = fileInf.dir(); |
222 | 222 | ||
223 | // insert into List | 223 | // insert into List |
224 | if(!dir.dirName().isEmpty() && m_talkFolders) | 224 | if(!dir.dirName().isEmpty() && m_talkFolders) |
225 | { | 225 | { |
@@ -238,7 +238,7 @@ bool TalkFileCreator::createDirAndFileMaps(QDir startDir,QMultiMap<QString,QStri | |||
238 | } | 238 | } |
239 | QCoreApplication::processEvents(); | 239 | QCoreApplication::processEvents(); |
240 | } | 240 | } |
241 | return true; | 241 | return true; |
242 | } | 242 | } |
243 | 243 | ||
244 | //! \brief Voices a List of string to the temp dir. Progress is handled inside. | 244 | //! \brief Voices a List of string to the temp dir. Progress is handled inside. |
@@ -259,37 +259,37 @@ TTSStatus TalkFileCreator::voiceList(QStringList toSpeak,QStringList& voicedEntr | |||
259 | m_logger->addItem(tr("Talk file creation aborted"), LOGERROR); | 259 | m_logger->addItem(tr("Talk file creation aborted"), LOGERROR); |
260 | return FatalError; | 260 | return FatalError; |
261 | } | 261 | } |
262 | 262 | ||
263 | QString filename = QDir::tempPath()+ "/"+ toSpeak[i] + ".wav"; | 263 | QString filename = QDir::tempPath()+ "/"+ toSpeak[i] + ".wav"; |
264 | 264 | ||
265 | QString error; | 265 | QString error; |
266 | TTSStatus status = m_tts->voice(toSpeak[i],filename, &error); | 266 | TTSStatus status = m_tts->voice(toSpeak[i],filename, &error); |
267 | if(status == Warning) | 267 | if(status == Warning) |
268 | { | 268 | { |
269 | warnings = true; | 269 | warnings = true; |
270 | m_logger->addItem(tr("Voicing of %1 failed: %2").arg(toSpeak[i]).arg(error), | 270 | m_logger->addItem(tr("Voicing of %1 failed: %2").arg(toSpeak[i]).arg(error), |
271 | LOGWARNING); | 271 | LOGWARNING); |
272 | } | 272 | } |
273 | else if (status == FatalError) | 273 | else if (status == FatalError) |
274 | { | 274 | { |
275 | m_logger->addItem(tr("Voicing of %1 failed: %2").arg(toSpeak[i]).arg(error), | 275 | m_logger->addItem(tr("Voicing of %1 failed: %2").arg(toSpeak[i]).arg(error), |
276 | LOGERROR); | 276 | LOGERROR); |
277 | return FatalError; | 277 | return FatalError; |
278 | } | 278 | } |
279 | else | 279 | else |
280 | voicedEntries.append(toSpeak[i]); | 280 | voicedEntries.append(toSpeak[i]); |
281 | m_logger->setProgressValue(++m_progress); | 281 | m_logger->setProgressValue(++m_progress); |
282 | QCoreApplication::processEvents(); | 282 | QCoreApplication::processEvents(); |
283 | } | 283 | } |
284 | if(warnings) | 284 | if(warnings) |
285 | return Warning; | 285 | return Warning; |
286 | else | 286 | else |
287 | return NoError; | 287 | return NoError; |
288 | } | 288 | } |
289 | 289 | ||
290 | 290 | ||
291 | //! \brief Encodes a List of strings from/to the temp dir. Progress is handled inside. | 291 | //! \brief Encodes a List of strings from/to the temp dir. Progress is handled inside. |
292 | //! It expects the inputfile in the temp dir with the name in the List appended with ".wav" | 292 | //! It expects the inputfile in the temp dir with the name in the List appended with ".wav" |
293 | //! | 293 | //! |
294 | //! \param toSpeak QStringList with the Entries to encode. | 294 | //! \param toSpeak QStringList with the Entries to encode. |
295 | //! \param errString pointer to where the Error cause is written | 295 | //! \param errString pointer to where the Error cause is written |
@@ -301,21 +301,21 @@ bool TalkFileCreator::encodeList(QStringList toEncode,QStringList& encodedEntrie | |||
301 | { | 301 | { |
302 | if(m_abort) | 302 | if(m_abort) |
303 | { | 303 | { |
304 | m_logger->addItem(tr("Talk file creation aborted"), LOGERROR); | 304 | m_logger->addItem(tr("Talk file creation aborted"), LOGERROR); |
305 | return false; | 305 | return false; |
306 | } | 306 | } |
307 | 307 | ||
308 | QString wavfilename = QDir::tempPath()+ "/"+ toEncode[i] + ".wav"; | 308 | QString wavfilename = QDir::tempPath()+ "/"+ toEncode[i] + ".wav"; |
309 | QString filename = QDir::tempPath()+ "/"+ toEncode[i] + ".talk"; | 309 | QString filename = QDir::tempPath()+ "/"+ toEncode[i] + ".talk"; |
310 | 310 | ||
311 | if(!m_enc->encode(wavfilename,filename)) | 311 | if(!m_enc->encode(wavfilename,filename)) |
312 | { | 312 | { |
313 | m_logger->addItem(tr("Encoding of %1 failed").arg(filename), LOGERROR); | 313 | m_logger->addItem(tr("Encoding of %1 failed").arg(filename), LOGERROR); |
314 | return false; | 314 | return false; |
315 | } | 315 | } |
316 | encodedEntries.append(toEncode[i]); | 316 | encodedEntries.append(toEncode[i]); |
317 | m_logger->setProgressValue(++m_progress); | 317 | m_logger->setProgressValue(++m_progress); |
318 | QCoreApplication::processEvents(); | 318 | QCoreApplication::processEvents(); |
319 | } | 319 | } |
320 | return true; | 320 | return true; |
321 | } | 321 | } |
@@ -324,16 +324,16 @@ bool TalkFileCreator::encodeList(QStringList toEncode,QStringList& encodedEntrie | |||
324 | //! | 324 | //! |
325 | //! \param dirMap a MultiMap of Paths -> Dirnames | 325 | //! \param dirMap a MultiMap of Paths -> Dirnames |
326 | //! \param errString Pointer to a QString where the error cause is written. | 326 | //! \param errString Pointer to a QString where the error cause is written. |
327 | //! \returns true on success, false on error or user abort | 327 | //! \returns true on success, false on error or user abort |
328 | bool TalkFileCreator::copyTalkDirFiles(QMultiMap<QString,QString> dirMap,QString* errString) | 328 | bool TalkFileCreator::copyTalkDirFiles(QMultiMap<QString,QString> dirMap,QString* errString) |
329 | { | 329 | { |
330 | resetProgress(dirMap.size()); | 330 | resetProgress(dirMap.size()); |
331 | 331 | ||
332 | QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0); | 332 | QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0); |
333 | installlog.beginGroup("talkfiles"); | 333 | installlog.beginGroup("talkfiles"); |
334 | 334 | ||
335 | QMapIterator<QString, QString> it(dirMap); | 335 | QMapIterator<QString, QString> it(dirMap); |
336 | while (it.hasNext()) | 336 | while (it.hasNext()) |
337 | { | 337 | { |
338 | it.next(); | 338 | it.next(); |
339 | if(m_abort) | 339 | if(m_abort) |
@@ -341,51 +341,51 @@ bool TalkFileCreator::copyTalkDirFiles(QMultiMap<QString,QString> dirMap,QString | |||
341 | *errString = tr("Talk file creation aborted"); | 341 | *errString = tr("Talk file creation aborted"); |
342 | return false; | 342 | return false; |
343 | } | 343 | } |
344 | 344 | ||
345 | QString source = QDir::tempPath()+ "/"+ it.value() + ".talk"; | 345 | QString source = QDir::tempPath()+ "/"+ it.value() + ".talk"; |
346 | 346 | ||
347 | if(!QFileInfo(source).exists()) | 347 | if(!QFileInfo(source).exists()) |
348 | continue; // this file was skipped in one of the previous steps | 348 | continue; // this file was skipped in one of the previous steps |
349 | 349 | ||
350 | QString target = it.key() + "/" + "_dirname.talk"; | 350 | QString target = it.key() + "/" + "_dirname.talk"; |
351 | 351 | ||
352 | // remove target if it exists, and if we should overwrite it | 352 | // remove target if it exists, and if we should overwrite it |
353 | if(m_overwriteTalk && QFile::exists(target)) | 353 | if(m_overwriteTalk && QFile::exists(target)) |
354 | QFile::remove(target); | 354 | QFile::remove(target); |
355 | 355 | ||
356 | // copying | 356 | // copying |
357 | if(!QFile::copy(source,target)) | 357 | if(!QFile::copy(source,target)) |
358 | { | 358 | { |
359 | *errString = tr("Copying of %1 to %2 failed").arg(source).arg(target); | 359 | *errString = tr("Copying of %1 to %2 failed").arg(source).arg(target); |
360 | return false; | 360 | return false; |
361 | } | 361 | } |
362 | 362 | ||
363 | // add to installlog | 363 | // add to installlog |
364 | QString now = QDate::currentDate().toString("yyyyMMdd"); | 364 | QString now = QDate::currentDate().toString("yyyyMMdd"); |
365 | installlog.setValue(target.remove(0,m_mountpoint.length()),now); | 365 | installlog.setValue(target.remove(0,m_mountpoint.length()),now); |
366 | 366 | ||
367 | m_logger->setProgressValue(++m_progress); | 367 | m_logger->setProgressValue(++m_progress); |
368 | QCoreApplication::processEvents(); | 368 | QCoreApplication::processEvents(); |
369 | } | 369 | } |
370 | installlog.endGroup(); | 370 | installlog.endGroup(); |
371 | installlog.sync(); | 371 | installlog.sync(); |
372 | return true; | 372 | return true; |
373 | } | 373 | } |
374 | 374 | ||
375 | //! \brief copys Talkfile for Files from the temp dir to the target. Progress and installlog is handled inside | 375 | //! \brief copys Talkfile for Files from the temp dir to the target. Progress and installlog is handled inside |
376 | //! | 376 | //! |
377 | //! \param fileMap a MultiMap of Paths -> Filenames | 377 | //! \param fileMap a MultiMap of Paths -> Filenames |
378 | //! \param errString Pointer to a QString where the error cause is written. | 378 | //! \param errString Pointer to a QString where the error cause is written. |
379 | //! \returns true on success, false on error or user abort | 379 | //! \returns true on success, false on error or user abort |
380 | bool TalkFileCreator::copyTalkFileFiles(QMultiMap<QString,QString> fileMap,QString* errString) | 380 | bool TalkFileCreator::copyTalkFileFiles(QMultiMap<QString,QString> fileMap,QString* errString) |
381 | { | 381 | { |
382 | resetProgress(fileMap.size()); | 382 | resetProgress(fileMap.size()); |
383 | 383 | ||
384 | QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0); | 384 | QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0); |
385 | installlog.beginGroup("talkfiles"); | 385 | installlog.beginGroup("talkfiles"); |
386 | 386 | ||
387 | QMapIterator<QString, QString> it(fileMap); | 387 | QMapIterator<QString, QString> it(fileMap); |
388 | while (it.hasNext()) | 388 | while (it.hasNext()) |
389 | { | 389 | { |
390 | it.next(); | 390 | it.next(); |
391 | if(m_abort) | 391 | if(m_abort) |
@@ -393,58 +393,58 @@ bool TalkFileCreator::copyTalkFileFiles(QMultiMap<QString,QString> fileMap,QStri | |||
393 | *errString = tr("Talk file creation aborted"); | 393 | *errString = tr("Talk file creation aborted"); |
394 | return false; | 394 | return false; |
395 | } | 395 | } |
396 | 396 | ||
397 | QString source; | 397 | QString source; |
398 | QString target = it.key() + "/" + it.value() + ".talk"; | 398 | QString target = it.key() + "/" + it.value() + ".talk"; |
399 | 399 | ||
400 | // correct source if we hav stripExtension enabled | 400 | // correct source if we hav stripExtension enabled |
401 | if(m_stripExtensions) | 401 | if(m_stripExtensions) |
402 | source = QDir::tempPath()+ "/"+ stripExtension(it.value()) + ".talk"; | 402 | source = QDir::tempPath()+ "/"+ stripExtension(it.value()) + ".talk"; |
403 | else | 403 | else |
404 | source = QDir::tempPath()+ "/"+ it.value() + ".talk"; | 404 | source = QDir::tempPath()+ "/"+ it.value() + ".talk"; |
405 | 405 | ||
406 | if(!QFileInfo(source).exists()) | 406 | if(!QFileInfo(source).exists()) |
407 | continue; // this file was skipped in one of the previous steps | 407 | continue; // this file was skipped in one of the previous steps |
408 | 408 | ||
409 | // remove target if it exists, and if we should overwrite it | 409 | // remove target if it exists, and if we should overwrite it |
410 | if(m_overwriteTalk && QFile::exists(target)) | 410 | if(m_overwriteTalk && QFile::exists(target)) |
411 | QFile::remove(target); | 411 | QFile::remove(target); |
412 | 412 | ||
413 | // copy file | 413 | // copy file |
414 | qDebug() << "copying: " << source << " to " << target; | 414 | qDebug() << "copying: " << source << " to " << target; |
415 | if(!QFile::copy(source,target)) | 415 | if(!QFile::copy(source,target)) |
416 | { | 416 | { |
417 | *errString = tr("Copying of %1 to %2 failed").arg(source).arg(target); | 417 | *errString = tr("Copying of %1 to %2 failed").arg(source).arg(target); |
418 | return false; | 418 | return false; |
419 | } | 419 | } |
420 | 420 | ||
421 | // add to Install log | 421 | // add to Install log |
422 | QString now = QDate::currentDate().toString("yyyyMMdd"); | 422 | QString now = QDate::currentDate().toString("yyyyMMdd"); |
423 | installlog.setValue(target.remove(0,m_mountpoint.length()),now); | 423 | installlog.setValue(target.remove(0,m_mountpoint.length()),now); |
424 | 424 | ||
425 | m_logger->setProgressValue(++m_progress); | 425 | m_logger->setProgressValue(++m_progress); |
426 | QCoreApplication::processEvents(); | 426 | QCoreApplication::processEvents(); |
427 | } | 427 | } |
428 | installlog.endGroup(); | 428 | installlog.endGroup(); |
429 | installlog.sync(); | 429 | installlog.sync(); |
430 | return true; | 430 | return true; |
431 | } | 431 | } |
432 | 432 | ||
433 | 433 | ||
434 | //! \brief Cleans up Files potentially left in the temp dir | 434 | //! \brief Cleans up Files potentially left in the temp dir |
435 | //! | 435 | //! |
436 | //! \param list List of file to try to delete in the temp dir. Function appends ".wav" and ".talk" to the filenames | 436 | //! \param list List of file to try to delete in the temp dir. Function appends ".wav" and ".talk" to the filenames |
437 | bool TalkFileCreator::cleanup(QStringList list) | 437 | bool TalkFileCreator::cleanup(QStringList list) |
438 | { | 438 | { |
439 | m_logger->addItem(tr("Cleaning up.."),LOGINFO); | 439 | m_logger->addItem(tr("Cleaning up.."),LOGINFO); |
440 | 440 | ||
441 | for(int i=0; i < list.size(); i++) | 441 | for(int i=0; i < list.size(); i++) |
442 | { | 442 | { |
443 | if(QFile::exists(QDir::tempPath()+ "/"+ list[i] + ".wav")) | 443 | if(QFile::exists(QDir::tempPath()+ "/"+ list[i] + ".wav")) |
444 | QFile::remove(QDir::tempPath()+ "/"+ list[i] + ".wav"); | 444 | QFile::remove(QDir::tempPath()+ "/"+ list[i] + ".wav"); |
445 | if(QFile::exists(QDir::tempPath()+ "/"+ list[i] + ".talk")) | 445 | if(QFile::exists(QDir::tempPath()+ "/"+ list[i] + ".talk")) |
446 | QFile::remove(QDir::tempPath()+ "/"+ list[i] + ".talk"); | 446 | QFile::remove(QDir::tempPath()+ "/"+ list[i] + ".talk"); |
447 | 447 | ||
448 | QCoreApplication::processEvents(); | 448 | QCoreApplication::processEvents(); |
449 | } | 449 | } |
450 | return true; | 450 | return true; |