Added json and csv format

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97
2023-06-27 16:57:30 +03:00
parent 515197fba2
commit 9a3931dac6
4 changed files with 92 additions and 2 deletions

View File

@ -89,6 +89,20 @@ void ExportToModListDialog::formatChanged(int index)
break;
}
case 3: {
ui->templateGroup->setDisabled(true);
ui->optionsGroup->setDisabled(false);
ui->resultText->hide();
format = ExportToModList::JSON;
break;
}
case 4: {
ui->templateGroup->setDisabled(true);
ui->optionsGroup->setDisabled(false);
ui->resultText->hide();
format = ExportToModList::CSV;
break;
}
case 5: {
ui->templateGroup->setDisabled(false);
ui->optionsGroup->setDisabled(true);
ui->resultText->hide();
@ -133,6 +147,12 @@ void ExportToModListDialog::triggerImp()
}
case ExportToModList::CUSTOM:
return;
case ExportToModList::JSON:
exampleLine = "{\"name\":\"{name}\",\"url\":\"{url}\",\"version\":\"{version}\",\"authors\":\"{authors}\"},";
break;
case ExportToModList::CSV:
exampleLine = "{name},{url},{version},\"{authors}\"";
break;
}
if (!m_template_selected) {
if (ui->templateText->toPlainText() != exampleLine)
@ -146,7 +166,7 @@ void ExportToModListDialog::done(int result)
const QString filename = FS::RemoveInvalidFilenameChars(name);
const QString output =
QFileDialog::getSaveFileName(this, tr("Export %1").arg(name), FS::PathCombine(QDir::homePath(), filename + extension()),
"File (*.txt *.html *.md)", nullptr);
"File (*.txt *.html *.md *.json *.csv)", nullptr);
if (output.isEmpty())
return;
@ -167,6 +187,10 @@ QString ExportToModListDialog::extension()
return ".txt";
case ExportToModList::CUSTOM:
return ".txt";
case ExportToModList::JSON:
return ".json";
case ExportToModList::CSV:
return ".csv";
}
return ".txt";
}

View File

@ -58,6 +58,16 @@
<string>Plaintext</string>
</property>
</item>
<item>
<property name="text">
<string>JSON</string>
</property>
</item>
<item>
<property name="text">
<string>CSV</string>
</property>
</item>
<item>
<property name="text">
<string>Custom</string>