use raw string in post template

This commit is contained in:
Ren Tatsumoto 2023-03-23 00:55:19 +03:00 committed by xiaoyifang
parent 06946e559a
commit 94fefe8ce9

View file

@ -19,23 +19,21 @@ AnkiConnector::AnkiConnector( QObject * parent, Config::Class const & _cfg ) : Q
void AnkiConnector::sendToAnki( QString const & word, QString const & text, QString const & sentence ) void AnkiConnector::sendToAnki( QString const & word, QString const & text, QString const & sentence )
{ {
//for simplicity. maybe use QJsonDocument in future? QString postTemplate = R"anki({
QString postTemplate = QString( "{" "action": "addNote",
"\"action\": \"addNote\"," "version": 6,
"\"version\": 6," "params": {
"\"params\": {" "note": {
" \"note\": {" "deckName": "%1",
" \"deckName\": \"%1\"," "modelName": "%2",
" \"modelName\": \"%2\"," "fields": %3,
" \"fields\":%3," "options": {
" \"options\": {" "allowDuplicate": true
" \"allowDuplicate\": true" },
" }," "tags": []
" \"tags\": []" }
"}" }
"}" })anki";
"}"
"" );
QJsonObject fields; QJsonObject fields;
fields.insert( cfg.preferences.ankiConnectServer.word, word ); fields.insert( cfg.preferences.ankiConnectServer.word, word );