setModified();
}
+
+QString KEduVocDocument::pattern(Mode mode)
+{
+ static const struct SupportedFilter
+ {
+ bool reading;
+ bool writing;
+ const char* extensions;
+ const char* description;
+ } filters[] = {
+ { true, true, "*.kvtml", I18N_NOOP("KDE Vocabulary Document") },
+ { true, false, "*.wql", I18N_NOOP("KWordQuiz Document") },
+ { true, false, "*.xml.qz *.pau.gz", I18N_NOOP("Pauker Lesson") },
+ { true, false, "*.voc", I18N_NOOP("Vokabeltrainer") },
+ { true, true, "*.csv", I18N_NOOP("Text") },
+ // last is marker for the end, do not remove it
+ { false, false, 0, 0 }
+ };
+ QStringList newfilters;
+ QStringList allext;
+ for (int i = 0; filters[i].extensions; ++i) {
+ if ((mode == Reading && filters[i].reading) ||
+ (mode == Writing && filters[i].writing)) {
+ newfilters.append(QLatin1String(filters[i].extensions) + '|' + i18n(filters[i].description));
+ allext.append(QLatin1String(filters[i].extensions));
+ }
+ }
+ newfilters.prepend(allext.join(" ") + '|' + i18n("All supported documents"));
+ return newfilters.join("\n");
+}
+
+
#include "keduvocdocument.moc"
FileType detectFileType(const QString &fileName);
+ enum Mode {
+ Reading,
+ Writing
+ };
+
+ /**
+ * Create a string with the supported document types, that can be used
+ * as filter in KFileDialog. It includes also an entry to match all the
+ * supported types.
+ *
+ * @param mode the mode for the supported document types
+ * @returns the filter string
+ */
+ static QString pattern(Mode mode);
+
Q_SIGNALS:
void progressChanged (KEduVocDocument *, int curr_percent);
void docModified (bool mod);