diff --git a/src/database/output.cpp b/src/database/output.cpp index 3c6f47dd..91b73efc 100644 --- a/src/database/output.cpp +++ b/src/database/output.cpp @@ -43,6 +43,7 @@ Output::Output(OutputType output, BoardRenderingFunc renderer, const QString& pa case Html: m_options.createDefaultOptions(""); break; + case LocalPgn: case Pgn: m_options.createDefaultOptions(""); break; @@ -66,7 +67,7 @@ Output::~Output() void Output::initialize() { - if(m_outputType == Pgn) + if(isPgnType(m_outputType)) { m_newlineChar = "\n"; } @@ -233,9 +234,10 @@ QMap& Output::getFormats() { m_outputMap.clear(); m_outputMap[Html] = "Html Output"; - m_outputMap[Pgn] = "Pgn Output"; + m_outputMap[Pgn] = "PGN Output"; m_outputMap[Latex] = "Latex Output"; m_outputMap[NotationWidget] = "Notation Widget Output"; + m_outputMap[LocalPgn] = "Local PGN Output"; return m_outputMap; } @@ -299,10 +301,10 @@ QString Output::writeMove(MoveToWrite moveToWrite) } // Read comments if(m_game.canHaveStartAnnotation(moveId)) - precommentString = (m_outputType == Pgn) ? m_game.annotation(moveId, GameX::BeforeMove) : + precommentString = isPgnType(m_outputType) ? m_game.annotation(moveId, GameX::BeforeMove) : m_game.textAnnotation(moveId, GameX::BeforeMove, m_game.textFilter2()); - QString commentString = (m_outputType == Pgn) ? m_game.annotation(moveId) : + QString commentString = isPgnType(m_outputType) ? m_game.annotation(moveId) : m_game.textAnnotation(moveId, GameX::AfterMove, m_game.textFilter2()); // Write precomment if any @@ -325,7 +327,7 @@ QString Output::writeMove(MoveToWrite moveToWrite) // *** Determine actual san QString san; - GameX::MoveStringFlags flags = (m_outputType == NotationWidget) ? GameX::TranslatePiece : GameX::MoveOnly; + GameX::MoveStringFlags flags = isLocalized(m_outputType) ? GameX::TranslatePiece : GameX::MoveOnly; if(moveToWrite == NextMove) { san = m_game.moveToSan(flags); @@ -446,7 +448,7 @@ QString Output::writeMove(MoveToWrite moveToWrite) if (imageString.isEmpty() && commentString.isEmpty() && !san.isEmpty()) { if((!((m_options.getOptionAsBool("ColumnStyle")) && - (m_currentVariationLevel == 0))) || (m_outputType == Pgn)) + (m_currentVariationLevel == 0))) || isPgnType(m_outputType)) { if (m_game.hasNextMove()) { @@ -803,7 +805,7 @@ QString Output::outputGame(const GameX* g, bool upToCurrentMove) text += m_startTagMap[MarkupColumnStyleMainline]; } - QString gameComment = (m_outputType == Pgn) ? m_game.annotation(0) : m_game.textAnnotation(0, GameX::AfterMove, m_game.textFilter2()); + QString gameComment = isPgnType(m_outputType) ? m_game.annotation(0) : m_game.textAnnotation(0, GameX::AfterMove, m_game.textFilter2()); text += writeGameComment(gameComment); text += writeMainLine(mainId); @@ -1043,7 +1045,7 @@ void Output::output(const QString& filename, Database& database) return; } if((m_outputType == Html) || (m_outputType == NotationWidget) || - (m_outputType == Pgn && database.isUtf8())) + (isPgnType(m_outputType) && database.isUtf8())) { QTextStream out(&f); outputUtf8(out, database); @@ -1132,6 +1134,7 @@ void Output::setTemplateFile(QString filename) filename = DEFAULT_NOTATION_TEMPLATE; break; case Pgn: + case LocalPgn: filename = DEFAULT_PGN_TEMPLATE; break; default : diff --git a/src/database/output.h b/src/database/output.h index c85d78a4..da950192 100644 --- a/src/database/output.h +++ b/src/database/output.h @@ -88,8 +88,12 @@ class Output : public QObject Html, /**< Exports the game in Html format */ Pgn, /**< Exports the game in PGN format */ Latex, /**< Exports the game in Latex format */ - NotationWidget /**< Exports the game in format appropriate for the notation widget */ + NotationWidget, /**< Exports the game in format appropriate for the notation widget */ + LocalPgn }; + inline bool isPgnType(OutputType o) const { return ((o==Pgn) || (o==LocalPgn)); } + inline bool isLocalized(OutputType o) const { return ((o==NotationWidget) || (o==LocalPgn)); } + enum MoveToWrite { PreviousMove, diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index c6a4b0af..92058bd5 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -1461,7 +1461,8 @@ QString MainWindow::exportFileName(int& format) QStringList filters; filters << tr("PGN file (*.pgn)") << tr("HTML page (*.html)") - << tr("LaTeX document (*.tex)"); + << tr("LaTeX document (*.tex)") + << tr("Localized PGN (*.txt)"); fd.setNameFilters(filters); if(fd.exec() != QDialog::Accepted) { @@ -1475,6 +1476,10 @@ QString MainWindow::exportFileName(int& format) { format = Output::Html; } + else if(fd.selectedNameFilter().contains("*.txt")) + { + format = Output::LocalPgn; + } else { format = Output::Pgn; diff --git a/src/gui/testadapter.cpp b/src/gui/testadapter.cpp index c1da0e84..d393667f 100644 --- a/src/gui/testadapter.cpp +++ b/src/gui/testadapter.cpp @@ -43,6 +43,9 @@ bool TestAdapter::dispatchTests() QCommandLineOption enOption(QStringList() << "en" << "eco-no-classify", QCoreApplication::translate("TestAdapter", "Never classify games.")); parser.addOption(enOption); + QCommandLineOption lcOption(QStringList() << "lc" << "locale", + QCoreApplication::translate("TestAdapter", "Output Locale."), + QCoreApplication::translate("TestAdapter", "Locale")); // Do not start the GUI after processing the files QCommandLineOption exitOption(QStringList() << "x" << "exit", @@ -67,6 +70,7 @@ bool TestAdapter::dispatchTests() QString inputFile = parser.value(inputOption); QString outputFile = parser.value(outputOption); + QString lc = parser.value(lcOption); bool ec = parser.isSet("ec"); bool ek = parser.isSet("ek"); @@ -81,6 +85,11 @@ bool TestAdapter::dispatchTests() AppSettings->setValue("/General/preserveECO", ek); } + if (!lc.isEmpty()) + { + AppSettings->setValue("/GameText/PieceString", lc); + } + if (!inputFile.isEmpty()) { if (outputFile.isEmpty()) @@ -106,6 +115,7 @@ void TestAdapter::convertPgn(const QString& filename, const QString& outfile, QC bool rv = parser.isSet("rv"); bool rc = parser.isSet("rc"); bool rt = parser.isSet("rt"); + bool lc = parser.isSet("lc"); if (db.open(filename, true) && ((Database*)(&db))->parseFile()) { @@ -122,7 +132,7 @@ void TestAdapter::convertPgn(const QString& filename, const QString& outfile, QC } } - Output output(Output::Pgn); + Output output(lc ? Output::LocalPgn : Output::Pgn); output.outputLatin1(outfile, db); } }