Commit 8f98f58c8dbb7df5a62b26f6da685e602a4c2871

Authored by Josh Klontz
1 parent 14594c8f

improved file parsing logic

Showing 1 changed file with 11 additions and 11 deletions
sdk/openbr_plugin.cpp
@@ -84,7 +84,7 @@ QList<File> File::split() const @@ -84,7 +84,7 @@ QList<File> File::split() const
84 QList<File> File::split(const QString &separator) const 84 QList<File> File::split(const QString &separator) const
85 { 85 {
86 QList<File> files; 86 QList<File> files;
87 - foreach (const QString &word, name.split(separator)) { 87 + foreach (const QString &word, name.split(separator, QString::SkipEmptyParts)) {
88 File file(word); 88 File file(word);
89 file.append(m_metadata); 89 file.append(m_metadata);
90 files.append(file); 90 files.append(file);
@@ -373,25 +373,25 @@ TemplateList TemplateList::fromInput(const br::File &amp;input) @@ -373,25 +373,25 @@ TemplateList TemplateList::fromInput(const br::File &amp;input)
373 { 373 {
374 TemplateList templates; 374 TemplateList templates;
375 375
376 - int z = 0;  
377 -  
378 foreach (const br::File &file, input.split()) { 376 foreach (const br::File &file, input.split()) {
379 QScopedPointer<Gallery> i(Gallery::make(file)); 377 QScopedPointer<Gallery> i(Gallery::make(file));
380 TemplateList newTemplates = i->read(); 378 TemplateList newTemplates = i->read();
381 379
  380 + // Propogate metadata
  381 + for (int i=0; i<newTemplates.size(); i++) {
  382 + newTemplates[i].file.append(input.localMetadata());
  383 + newTemplates[i].file.append(file.localMetadata());
  384 + newTemplates[i].file.insert("Input_Index", i+templates.size());
  385 + }
  386 +
382 if (!templates.isEmpty() && input.getBool("merge")) { 387 if (!templates.isEmpty() && input.getBool("merge")) {
383 - if (newTemplates.size() != templates.size()) qFatal("Inputs must be the same size in order to merge."); 388 + if (newTemplates.size() != templates.size())
  389 + qFatal("Inputs must be the same size in order to merge.");
384 for (int i=0; i<templates.size(); i++) 390 for (int i=0; i<templates.size(); i++)
385 templates[i].merge(newTemplates[i]); 391 templates[i].merge(newTemplates[i]);
386 } else { 392 } else {
387 - templates+=newTemplates; 393 + templates += newTemplates;
388 } 394 }
389 - z+=1;  
390 - }  
391 -  
392 - for (int i=0; i<templates.size(); i++) {  
393 - templates[i].file.append(input.localMetadata());  
394 - templates[i].file.insert("Input_Index", i);  
395 } 395 }
396 396
397 return templates; 397 return templates;