#include "keduvocdocument.h"
+#include <kio/copyjob.h>
+#include <kio/job.h>
#include <klocale.h>
#include <kstandarddirs.h>
// add it's comment to the comment list
this->m_commentList.append(doc->documentRemark());
}
+ // plug a memory leak
+ delete doc;
}
void SharedKvtmlFiles::rescan()
return retlist;
}
+
+void SharedKvtmlFiles::sortDownloadedFiles()
+{
+ QStringList unsortedFiles = KGlobal::dirs()->findAllResources("data",
+ QString("kvtml/*.kvtml"));
+
+ KEduVocDocument *doc = new KEduVocDocument();
+
+ while (unsortedFiles.size() > 0)
+ {
+ KUrl fileUrl(KUrl::fromPath(unsortedFiles.first()));
+ // find the file's locale
+ // open the file
+ doc->open(fileUrl);
+
+ QString locale = doc->identifier(0);
+
+ // make sure the locale sub-folder exists
+ KUrl pathUrl(fileUrl);
+ pathUrl.setFileName(QString());
+ pathUrl.addPath(locale);
+ KIO::mkdir(pathUrl);
+
+ // move the file into the locale sub-folder
+ KIO::move(fileUrl, pathUrl);
+
+ // take off the one we just did
+ unsortedFiles.removeFirst();
+ }
+
+ rescan();
+}
/** rescan the shared kvtml locations */
KEDUVOCDOCUMENT_EXPORT void rescan();
+
+ /** sort files downloaded to kvtml top-level dir into locale sub-folders */
+ KEDUVOCDOCUMENT_EXPORT void sortDownloadedFiles();
}
#endif