| 78 | } |
| 79 | |
| 80 | void train(const QList<TemplateList> &data) |
| 81 | { |
| 82 | if (QFileInfo(getFileName()).exists()) |
| 83 | return; |
| 84 | |
| 85 | transform->train(data); |
| 86 | |
| 87 | qDebug("Storing %s", qPrintable(fileName)); |
| 88 | QtUtils::BlockCompression compressedOut; |
| 89 | QFile fout(fileName); |
| 90 | QtUtils::touchDir(fout); |
| 91 | compressedOut.setBasis(&fout); |
| 92 | |
| 93 | QDataStream stream(&compressedOut); |
| 94 | QString desc = transform->description(); |
| 95 | |
| 96 | if (!compressedOut.open(QFile::WriteOnly)) |
| 97 | qFatal("Failed to open %s for writing.", qPrintable(file)); |
| 98 | |
| 99 | stream << desc; |
| 100 | transform->store(stream); |
| 101 | compressedOut.close(); |
| 102 | } |
| 103 | |
| 104 | void project(const Template &src, Template &dst) const |
| 105 | { |