Skip to content

Commit

Permalink
Merge branch 'develop' and move to version 3.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
flinco committed Sep 6, 2022
2 parents 9429507 + 101d742 commit 01c15ae
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

cmake_minimum_required(VERSION 3.20)
project(LBChronoRace
VERSION 3.0.4
VERSION 3.0.5
DESCRIPTION "Timings for Races"
HOMEPAGE_URL "http://github.com/flinco/LBChronoRace"
LANGUAGES CXX)
Expand Down
30 changes: 17 additions & 13 deletions lbchronorace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,18 +341,15 @@ void LBChronoRace::selectorFormat(QString const &arg1) const

void LBChronoRace::loadRace()
{
if (raceDataFileName.isEmpty()) {
raceDataFileName = QFileDialog::getOpenFileName(this, tr("Select Race Data File"),
lastSelectedPath.absolutePath(), tr("ChronoRace Data (*.crd)"));
}
raceDataFileName.clear();
raceDataFileName = QFileDialog::getOpenFileName(this, tr("Select Race Data File"),
lastSelectedPath.absolutePath(), tr("ChronoRace Data (*.crd)"));

if (!raceDataFileName.isEmpty()) {
QFile raceDataFile(raceDataFileName);
lastSelectedPath = QFileInfo(raceDataFileName).absoluteDir();

if (!raceDataFile.open(QIODevice::ReadOnly)) {
QMessageBox::information(this, tr("Unable to open file"), raceDataFile.errorString());
} else {
if (raceDataFile.open(QIODevice::ReadOnly)) {
quint32 binFmt;
QFileInfo raceDataFileInfo(raceDataFileName);

Expand Down Expand Up @@ -405,8 +402,10 @@ void LBChronoRace::loadRace()
QMessageBox::information(this, tr("Race Data File Error"), tr("Format version %1 not supported").arg(binFmt));
break;
}
} else {
QMessageBox::information(this, tr("Unable to open file"), raceDataFile.errorString());
raceDataFileName.clear();
}
raceDataFileName.clear();
}
}

Expand All @@ -416,16 +415,14 @@ void LBChronoRace::saveRace()
raceDataFileName = QFileDialog::getSaveFileName(this, tr("Select Race Data File"),
lastSelectedPath.absolutePath(), tr("ChronoRace Data (*.crd)"));

if (!raceDataFileName.endsWith(".crd", Qt::CaseInsensitive))
if (!raceDataFileName.isEmpty() && !raceDataFileName.endsWith(".crd", Qt::CaseInsensitive))
raceDataFileName.append(".crd");
}

if (!raceDataFileName.isEmpty()) {
QFile raceDataFile(raceDataFileName);

if (!raceDataFile.open(QIODevice::WriteOnly)) {
QMessageBox::information(this, tr("Unable to open file"), raceDataFile.errorString());
} else {
if (raceDataFile.open(QIODevice::WriteOnly)) {
QFileInfo raceDataFileInfo(raceDataFileName);
QDataStream out(&raceDataFile);

Expand All @@ -440,15 +437,22 @@ void LBChronoRace::saveRace()
lastSelectedPath = raceDataFileInfo.absoluteDir();
setWindowTitle(QString(tr(LBCHRONORACE_NAME) + " - " + raceDataFileInfo.fileName()));
appendInfoMessage(tr("Race saved: %1").arg(raceDataFileName));
} else {
QMessageBox::information(this, tr("Unable to open file"), raceDataFile.errorString());
raceDataFileName.clear();
}

}
}

void LBChronoRace::saveRaceAs()
{
QString oldRaceDataFileName(raceDataFileName);

raceDataFileName.clear();
saveRace();

if (raceDataFileName.isEmpty())
raceDataFileName = oldRaceDataFileName;
}

void LBChronoRace::makeStartList()
Expand Down
28 changes: 12 additions & 16 deletions pdfrankingprinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,16 @@ void PDFRankingPrinter::printRanking(const Category &category, QList<ClassEntry
//NOSONAR qDebug("Path: %s", qUtf8Printable(individualRankingFileName));

QPainter painter;
QPdfWriter writer(individualRankingFileName);
if (initPainter(painter, &writer)) {
if (QPdfWriter writer(individualRankingFileName); initPainter(painter, &writer)) {
makeRanking(painter, category.getFullDescription(), ranking, (individualLegs != 1));
if (painter.end()) {
emit info(tr("Generated Results '%1': %2").arg(category.getFullDescription(), QFileInfo(individualRankingFileName).absoluteFilePath()));
} else {
emit error(tr("Error: cannot write to %1").arg(individualRankingFileName));
}
} else {
emit error(tr("Error: cannot open %1").arg(individualRankingFileName));
}

if (!painter.end()) {
emit error(tr("Error: cannot write to %1").arg(individualRankingFileName));
} else {
emit info(tr("Generated Results '%1': %2").arg(category.getFullDescription(), QFileInfo(individualRankingFileName).absoluteFilePath()));
}
}
}

Expand All @@ -112,18 +110,16 @@ void PDFRankingPrinter::printRanking(const Category &category, QList<TeamClassEn
//NOSONAR qDebug("Path: %s", qUtf8Printable(individualRankingFileName));

QPainter painter;
QPdfWriter writer(teamRankingFileName);
if (initPainter(painter, &writer)) {
if (QPdfWriter writer(teamRankingFileName); initPainter(painter, &writer)) {
makeRanking(painter, category.getFullDescription(), ranking, (teamLegs != 1));
if (painter.end()) {
emit info(tr("Generated Results '%1': %2").arg(category.getFullDescription(), QFileInfo(teamRankingFileName).absoluteFilePath()));
} else {
emit error(tr("Error: cannot write to %1").arg(teamRankingFileName));
}
} else {
emit error(tr("Error: cannot open %1").arg(teamRankingFileName));
}

if (!painter.end()) {
emit error(tr("Error: cannot write to %1").arg(teamRankingFileName));
} else {
emit info(tr("Generated Results '%1': %2").arg(category.getFullDescription(), QFileInfo(teamRankingFileName).absoluteFilePath()));
}
}
}

Expand Down

0 comments on commit 01c15ae

Please sign in to comment.