Skip to content

Commit

Permalink
Merge branch 'develop' and move to version 2025
Browse files Browse the repository at this point in the history
  • Loading branch information
flinco committed Aug 28, 2024
2 parents 32bbb06 + 3fa8d8c commit 5021e56
Show file tree
Hide file tree
Showing 100 changed files with 4,907 additions and 2,093 deletions.
27 changes: 21 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@

cmake_minimum_required(VERSION 3.20)
project(LBChronoRace
VERSION 2024
VERSION 2025
DESCRIPTION "Timings and Rankings for Races"
HOMEPAGE_URL "http://github.com/flinco/LBChronoRace"
LANGUAGES CXX)
set(PROJECT_UPDATE 3)
set(PROJECT_UPDATE 0)
string(TIMESTAMP BUILD_DATE "%Y-%m-%d" UTC)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
Expand All @@ -53,8 +53,6 @@ set(PROJECT_SOURCES
categoriesmodel.hpp
category.cpp
category.hpp
catsexdelegate.cpp
catsexdelegate.hpp
cattypedelegate.cpp
cattypedelegate.hpp
chronorace.ui
Expand All @@ -75,6 +73,10 @@ set(PROJECT_SOURCES
clubdelegate.hpp
competitor.cpp
competitor.hpp
compsexdelegate.cpp
compsexdelegate.hpp
crhelper.cpp
crhelper.hpp
crloader.cpp
crloader.hpp
crtablemodel.hpp
Expand All @@ -84,12 +86,20 @@ set(PROJECT_SOURCES
lbchronorace.hpp
lbcrexception.cpp
lbcrexception.hpp
multiselectcombobox.cpp
multiselectcombobox.hpp
pdfrankingprinter.cpp
pdfrankingprinter.hpp
ranking.cpp
ranking.hpp
rankingcatsdelegate.cpp
rankingcatsdelegate.hpp
rankingsbuilder.cpp
rankingsbuilder.hpp
rankingprinter.cpp
rankingprinter.hpp
rankingsmodel.cpp
rankingsmodel.hpp
rankingswizard.cpp
rankingswizard.hpp
rankingswizardformat.cpp
Expand All @@ -98,8 +108,8 @@ set(PROJECT_SOURCES
rankingswizardmode.hpp
rankingswizardselection.cpp
rankingswizardselection.hpp
sexdelegate.cpp
sexdelegate.hpp
rankingtypedelegate.cpp
rankingtypedelegate.hpp
startlistmodel.cpp
startlistmodel.hpp
teamclassentry.cpp
Expand All @@ -110,6 +120,8 @@ set(PROJECT_SOURCES
timing.hpp
timingsmodel.cpp
timingsmodel.hpp
timingstatusdelegate.cpp
timingstatusdelegate.hpp
txtrankingprinter.cpp
txtrankingprinter.hpp)

Expand Down Expand Up @@ -153,6 +165,9 @@ set_property(SOURCE icons.qrc PROPERTY SKIP_AUTORCC ON)
# Google Material Icons (as standard resource)
list(APPEND PROJECT_SOURCES materialicons.qrc)

# Images (as standard resource)
list(APPEND PROJECT_SOURCES images.qrc)

if(WIN32)
set(APP_ICON_RESOURCE_WINDOWS "${CMAKE_SOURCE_DIR}/icons/LBChronoRace.rc")
qt_add_executable(${CMAKE_PROJECT_NAME} WIN32
Expand Down
96 changes: 48 additions & 48 deletions categoriesmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
*****************************************************************************/

#include "lbchronorace.hpp"
#include "categoriesmodel.hpp"
#include "lbcrexception.hpp"
#include "crhelper.hpp"

QDataStream &operator<<(QDataStream &out, CategoriesModel const &data)
{
Expand Down Expand Up @@ -63,10 +65,8 @@ QVariant CategoriesModel::data(QModelIndex const &index, int role) const

if ((role == Qt::DisplayRole) || (role == Qt::EditRole))
switch (index.column()) {
case static_cast<int>(Category::Field::CTF_TEAM):
return QVariant(categories.at(index.row()).isTeam() ? tr("T") : tr("I"));
case static_cast<int>(Category::Field::CTF_SEX):
return QVariant(Competitor::toSexString(categories.at(index.row()).getSex()));
case static_cast<int>(Category::Field::CTF_TYPE):
return QVariant(CRHelper::toTypeString(categories.at(index.row()).getType()));
case static_cast<int>(Category::Field::CTF_TO_YEAR):
return QVariant(categories.at(index.row()).getToYear());
case static_cast<int>(Category::Field::CTF_FROM_YEAR):
Expand All @@ -80,10 +80,8 @@ QVariant CategoriesModel::data(QModelIndex const &index, int role) const
}
else if (role == Qt::ToolTipRole)
switch (index.column()) {
case static_cast<int>(Category::Field::CTF_TEAM):
return QVariant(tr("Individual (I) or Team (T)"));
case static_cast<int>(Category::Field::CTF_SEX):
return QVariant(tr("Men (M), Women (F), Mixed (X) or All (U)"));
case static_cast<int>(Category::Field::CTF_TYPE):
return QVariant(tr("Male Individual/Relay (M), Female Individual/Relay (F), Mixed M/F Relay (X), Male Mixed Clubs Relay (Y), or Female Mixed Clubs Relay (Y)"));
case static_cast<int>(Category::Field::CTF_TO_YEAR):
return QVariant(tr("The category will include competitors born up to and including this year (i.e. 2000); 0 to disable"));
case static_cast<int>(Category::Field::CTF_FROM_YEAR):
Expand All @@ -101,47 +99,51 @@ QVariant CategoriesModel::data(QModelIndex const &index, int role) const

bool CategoriesModel::setData(QModelIndex const &index, QVariant const &value, int role)
{

bool retval = false;
if (index.isValid() && role == Qt::EditRole) {

uint uval;
switch (index.column()) {
case static_cast<int>(Category::Field::CTF_TEAM):
categories[index.row()].setTeam(QString::compare(value.toString().trimmed(), "T", Qt::CaseInsensitive) == 0);
break;
case static_cast<int>(Category::Field::CTF_SEX):
try {
auto sex = Competitor::toSex(value.toString().trimmed());
categories[index.row()].setSex(sex);
retval = true;
} catch (ChronoRaceException &ex) {
emit error(ex.getMessage());
retval = false;
}
break;
case static_cast<int>(Category::Field::CTF_TO_YEAR):
uval = value.toUInt(&retval);
if (retval) categories[index.row()].setToYear(uval);
break;
case static_cast<int>(Category::Field::CTF_FROM_YEAR):
uval = value.toUInt(&retval);
if (retval) categories[index.row()].setFromYear(uval);
break;
case static_cast<int>(Category::Field::CTF_FULL_DESCR):
categories[index.row()].setFullDescription(value.toString().simplified());
retval = true;
break;
case static_cast<int>(Category::Field::CTF_SHORT_DESCR):
categories[index.row()].setShortDescription(value.toString().simplified());
if (!index.isValid())
return retval;

if (role != Qt::EditRole)
return retval;

if (value.toString().contains(LBChronoRace::csvFilter))
return retval;

uint uval;
switch (index.column()) {
case static_cast<int>(Category::Field::CTF_TYPE):
try {
auto type = CRHelper::toCategoryType(value.toString().trimmed());
categories[index.row()].setType(type);
retval = true;
break;
default:
break;
} catch (ChronoRaceException &e) {
emit error(e.getMessage());
retval = false;
}

if (retval) emit dataChanged(index, index);
break;
case static_cast<int>(Category::Field::CTF_TO_YEAR):
uval = value.toUInt(&retval);
if (retval) categories[index.row()].setToYear(uval);
break;
case static_cast<int>(Category::Field::CTF_FROM_YEAR):
uval = value.toUInt(&retval);
if (retval) categories[index.row()].setFromYear(uval);
break;
case static_cast<int>(Category::Field::CTF_FULL_DESCR):
categories[index.row()].setFullDescription(value.toString().simplified());
retval = true;
break;
case static_cast<int>(Category::Field::CTF_SHORT_DESCR):
categories[index.row()].setShortDescription(value.toString().simplified());
retval = true;
break;
default:
break;
}

if (retval) emit dataChanged(index, index);

return retval;
}

Expand All @@ -152,10 +154,8 @@ QVariant CategoriesModel::headerData(int section, Qt::Orientation orientation, i

if (orientation == Qt::Horizontal)
switch (section) {
case static_cast<int>(Category::Field::CTF_TEAM):
return QString("%1").arg(tr("Individual/Team"));
case static_cast<int>(Category::Field::CTF_SEX):
return QString("%1").arg(tr("Sex"));
case static_cast<int>(Category::Field::CTF_TYPE):
return QString("%1").arg(tr("Type"));
case static_cast<int>(Category::Field::CTF_TO_YEAR):
return QString("%1").arg(tr("Up to"));
case static_cast<int>(Category::Field::CTF_FROM_YEAR):
Expand Down
Loading

0 comments on commit 5021e56

Please sign in to comment.