Skip to content

Commit

Permalink
Refactor: No manual specification of breadcrumbs for some composite c…
Browse files Browse the repository at this point in the history
…olumn types
  • Loading branch information
svetter committed Mar 11, 2024
1 parent 1c8aaf3 commit fab69a7
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 96 deletions.
32 changes: 16 additions & 16 deletions src/comp_tables/comp_ascents_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,39 +101,39 @@ class CompositeAscentsTable : public CompositeTable {
*/
inline CompositeAscentsTable(Database& db, QTableView* tableView) :
CompositeTable(db, db.ascentsTable, tableView),
// name uiName suffix fold op [breadcrumbs +] content column
// name uiName suffix fold op content column / breadcrumbs / sorting passes
indexColumn (IndexCompositeColumn (*this, "index", tr("Index"), noSuffix, { {db.ascentsTable.dateColumn, Qt::AscendingOrder}, {db.ascentsTable.peakOnDayColumn, Qt::AscendingOrder}, {db.ascentsTable.timeColumn, Qt::AscendingOrder} })),
dateColumn (DirectCompositeColumn (*this, noSuffix, db.ascentsTable.dateColumn)),
peakColumn (ReferenceCompositeColumn (*this, "peak", tr("Peak"), noSuffix, crumbsTo(db, db.peaksTable), db.peaksTable.nameColumn)),
peakColumn (ReferenceCompositeColumn (*this, "peak", tr("Peak"), noSuffix, db.peaksTable.nameColumn)),
titleColumn (DirectCompositeColumn (*this, noSuffix, db.ascentsTable.titleColumn)),
peakHeightColumn (ReferenceCompositeColumn (*this, "peakHeight", tr("Height"), mSuffix, crumbsTo(db, db.peaksTable), db.peaksTable.heightColumn)),
countryColumn (ReferenceCompositeColumn (*this, "country", tr("Country"), noSuffix, crumbsTo(db, db.countriesTable), db.countriesTable.nameColumn)),
regionColumn (ReferenceCompositeColumn (*this, "region", tr("Region"), noSuffix, crumbsTo(db, db.regionsTable), db.regionsTable.nameColumn)),
rangeColumn (ReferenceCompositeColumn (*this, "range", tr("Mountain range"), noSuffix, crumbsTo(db, db.rangesTable), db.rangesTable.nameColumn)),
continentColumn (ReferenceCompositeColumn (*this, "continent", tr("Continent"), noSuffix, crumbsTo(db, db.rangesTable), db.rangesTable.continentColumn)),
peakHeightColumn (ReferenceCompositeColumn (*this, "peakHeight", tr("Height"), mSuffix, db.peaksTable.heightColumn)),
countryColumn (ReferenceCompositeColumn (*this, "country", tr("Country"), noSuffix, db.countriesTable.nameColumn)),
regionColumn (ReferenceCompositeColumn (*this, "region", tr("Region"), noSuffix, db.regionsTable.nameColumn)),
rangeColumn (ReferenceCompositeColumn (*this, "range", tr("Mountain range"), noSuffix, db.rangesTable.nameColumn)),
continentColumn (ReferenceCompositeColumn (*this, "continent", tr("Continent"), noSuffix, db.rangesTable.continentColumn)),
elevationGainColumn (DirectCompositeColumn (*this, mSuffix, db.ascentsTable.elevationGainColumn)),
hikersColumn (HikerListFoldCompositeColumn (*this, "hikers", tr("Participants"), crumbsTo(db, db.hikersTable), db.hikersTable.nameColumn)),
tripColumn (ReferenceCompositeColumn (*this, "trip", tr("Trip"), noSuffix, crumbsTo(db, db.tripsTable), db.tripsTable.nameColumn)),
hikersColumn (HikerListFoldCompositeColumn (*this, "hikers", tr("Participants"), db.hikersTable.nameColumn)),
tripColumn (ReferenceCompositeColumn (*this, "trip", tr("Trip"), noSuffix, db.tripsTable.nameColumn)),
hikeKindColumn (DirectCompositeColumn (*this, noSuffix, db.ascentsTable.hikeKindColumn)),
traverseColumn (DirectCompositeColumn (*this, noSuffix, db.ascentsTable.traverseColumn)),
difficultyColumn (DependentEnumCompositeColumn (*this, "difficulty", tr("Difficulty"), db.ascentsTable.difficultySystemColumn, db.ascentsTable.difficultyGradeColumn)),
volcanoColumn (ReferenceCompositeColumn (*this, "volcano", tr("Volcano"), noSuffix, crumbsTo(db, db.peaksTable), db.peaksTable.volcanoColumn)),
volcanoColumn (ReferenceCompositeColumn (*this, "volcano", tr("Volcano"), noSuffix, db.peaksTable.volcanoColumn)),
peakOrdinalColumn (OrdinalCompositeColumn (*this, "peakOrdinal", tr("Nth ascent of peak"), ".", { {db.ascentsTable.peakIDColumn, Qt::AscendingOrder}, {db.ascentsTable.dateColumn, Qt::AscendingOrder}, {db.ascentsTable.peakOnDayColumn, Qt::AscendingOrder}, {db.ascentsTable.timeColumn, Qt::AscendingOrder} })),
numPhotosColumn (NumericFoldCompositeColumn (*this, "numPhotos", tr("Num. photos"), noSuffix, CountFold, crumbsTo(db, db.photosTable))),
numPhotosColumn (NumericFoldCompositeColumn (*this, "numPhotos", tr("Num. photos"), noSuffix, CountFold, crumbsTo(db.photosTable))),

// === BACKEND COLUMNS ===

// Export-only columns (unbuffered)
peakOnDayColumn (DirectCompositeColumn (*this, noSuffix, db.ascentsTable.peakOnDayColumn)),
timeColumn (DirectCompositeColumn (*this, noSuffix, db.ascentsTable.timeColumn)),
descriptionColumn (DirectCompositeColumn (*this, noSuffix, db.ascentsTable.descriptionColumn)),
tripStartDateColumn (ReferenceCompositeColumn (*this, "tripStartDate", tr("Trip start date"), noSuffix, crumbsTo(db, db.tripsTable), db.tripsTable.startDateColumn)),
tripEndDateColumn (ReferenceCompositeColumn (*this, "tripEndDate", tr("Trip end date"), noSuffix, crumbsTo(db, db.tripsTable), db.tripsTable.endDateColumn)),
tripDescriptionColumn (ReferenceCompositeColumn (*this, "tripDescription", tr("Trip description"), noSuffix, crumbsTo(db, db.tripsTable), db.tripsTable.descriptionColumn)),
tripStartDateColumn (ReferenceCompositeColumn (*this, "tripStartDate", tr("Trip start date"), noSuffix, db.tripsTable.startDateColumn)),
tripEndDateColumn (ReferenceCompositeColumn (*this, "tripEndDate", tr("Trip end date"), noSuffix, db.tripsTable.endDateColumn)),
tripDescriptionColumn (ReferenceCompositeColumn (*this, "tripDescription", tr("Trip description"), noSuffix, db.tripsTable.descriptionColumn)),

// Filter-only columns
rangeIDColumn (ReferenceCompositeColumn (*this, "rangeID", tr("Range ID"), noSuffix, crumbsTo(db, db.rangesTable), db.rangesTable.primaryKeyColumn)),
hikerIDsColumn (NumericFoldCompositeColumn (*this, "hikerIDs", tr("Hiker IDs"), noSuffix, IDListFold, crumbsTo(db, db.hikersTable), db.hikersTable.primaryKeyColumn))
rangeIDColumn (ReferenceCompositeColumn (*this, "rangeID", tr("Range ID"), noSuffix, db.rangesTable.primaryKeyColumn)),
hikerIDsColumn (NumericFoldCompositeColumn (*this, "hikerIDs", tr("Hiker IDs"), noSuffix, IDListFold, db.hikersTable.primaryKeyColumn))
{
addColumn(indexColumn);
addColumn(dateColumn);
Expand Down
12 changes: 6 additions & 6 deletions src/comp_tables/comp_countries_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ class CompositeCountriesTable : public CompositeTable {
*/
inline CompositeCountriesTable(Database& db, QTableView* tableView) :
CompositeTable(db, db.countriesTable, tableView),
// name uiName suffix fold op [breadcrumbs +] content column
// name uiName suffix fold op content column / breadcrumbs
nameColumn (DirectCompositeColumn (*this, noSuffix, db.countriesTable.nameColumn)),
numAscentsColumn (NumericFoldCompositeColumn (*this, "numAscents", tr("Num. ascents"), noSuffix, CountFold, crumbsTo(db, db.ascentsTable))),
numRegionsColumn (NumericFoldCompositeColumn (*this, "numRegions", tr("Num. regions"), noSuffix, CountFold, crumbsTo(db, db.regionsTable))),
numPeaksColumn (NumericFoldCompositeColumn (*this, "numPeaks", tr("Num. peaks"), noSuffix, CountFold, crumbsTo(db, db.peaksTable))),
avgPeakHeightColumn (NumericFoldCompositeColumn (*this, "avgPeakHeight", tr("Avg. peak height"), mSuffix, AverageFold, crumbsTo(db, db.peaksTable), db.peaksTable.heightColumn)),
maxPeakHeightColumn (NumericFoldCompositeColumn (*this, "maxPeakHeight", tr("Max. peak height"), mSuffix, MaxFold, crumbsTo(db, db.peaksTable), db.peaksTable.heightColumn))
numAscentsColumn (NumericFoldCompositeColumn (*this, "numAscents", tr("Num. ascents"), noSuffix, CountFold, crumbsTo(db.ascentsTable))),
numRegionsColumn (NumericFoldCompositeColumn (*this, "numRegions", tr("Num. regions"), noSuffix, CountFold, crumbsTo(db.regionsTable))),
numPeaksColumn (NumericFoldCompositeColumn (*this, "numPeaks", tr("Num. peaks"), noSuffix, CountFold, crumbsTo(db.peaksTable))),
avgPeakHeightColumn (NumericFoldCompositeColumn (*this, "avgPeakHeight", tr("Avg. peak height"), mSuffix, AverageFold, db.peaksTable.heightColumn)),
maxPeakHeightColumn (NumericFoldCompositeColumn (*this, "maxPeakHeight", tr("Max. peak height"), mSuffix, MaxFold, db.peaksTable.heightColumn))
{
addColumn(nameColumn);
addColumn(numAscentsColumn);
Expand Down
12 changes: 6 additions & 6 deletions src/comp_tables/comp_hikers_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ class CompositeHikersTable : public CompositeTable {
*/
inline CompositeHikersTable(Database& db, QTableView* tableView) :
CompositeTable(db, db.hikersTable, tableView),
// name uiName suffix fold op [breadcrumbs +] content column
// name uiName suffix fold op content column / breadcrumbs
nameColumn (DirectCompositeColumn (*this, noSuffix, db.hikersTable.nameColumn)),
numAscentsColumn (NumericFoldCompositeColumn (*this, "numAscents", tr("Num. ascents"), noSuffix, CountFold, crumbsTo(db, db.ascentsTable))),
numTripsColumn (NumericFoldCompositeColumn (*this, "numTrips", tr("Num. trips"), noSuffix, CountFold, crumbsTo(db, db.tripsTable))),
avgElevationGainColumn (NumericFoldCompositeColumn (*this, "avgElevationGain", tr("Avg. elev. gain"), mSuffix, AverageFold, crumbsTo(db, db.ascentsTable), db.ascentsTable.elevationGainColumn)),
maxElevationGainColumn (NumericFoldCompositeColumn (*this, "maxElevationGain", tr("Max. elev. gain"), mSuffix, MaxFold, crumbsTo(db, db.ascentsTable), db.ascentsTable.elevationGainColumn)),
sumElevationGainColumn (NumericFoldCompositeColumn (*this, "sumElevationGain", tr("Sum elev. gain"), mSuffix, SumFold, crumbsTo(db, db.ascentsTable), db.ascentsTable.elevationGainColumn))
numAscentsColumn (NumericFoldCompositeColumn (*this, "numAscents", tr("Num. ascents"), noSuffix, CountFold, crumbsTo(db.ascentsTable))),
numTripsColumn (NumericFoldCompositeColumn (*this, "numTrips", tr("Num. trips"), noSuffix, CountFold, crumbsTo(db.tripsTable))),
avgElevationGainColumn (NumericFoldCompositeColumn (*this, "avgElevationGain", tr("Avg. elev. gain"), mSuffix, AverageFold, db.ascentsTable.elevationGainColumn)),
maxElevationGainColumn (NumericFoldCompositeColumn (*this, "maxElevationGain", tr("Max. elev. gain"), mSuffix, MaxFold, db.ascentsTable.elevationGainColumn)),
sumElevationGainColumn (NumericFoldCompositeColumn (*this, "sumElevationGain", tr("Sum elev. gain"), mSuffix, SumFold, db.ascentsTable.elevationGainColumn))
{
addColumn(nameColumn);
addColumn(numAscentsColumn);
Expand Down
16 changes: 8 additions & 8 deletions src/comp_tables/comp_peaks_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@ class CompositePeaksTable : public CompositeTable {
*/
inline CompositePeaksTable(Database& db, QTableView* tableView) :
CompositeTable(db, db.peaksTable, tableView),
// name uiName suffix fold op [breadcrumbs +] content column
// name uiName suffix fold op content column / breadcrumbs
nameColumn (DirectCompositeColumn (*this, noSuffix, db.peaksTable.nameColumn)),
heightColumn (DirectCompositeColumn (*this, mSuffix, db.peaksTable.heightColumn)),
countryColumn (ReferenceCompositeColumn (*this, "country", tr("Country"), noSuffix, crumbsTo(db, db.countriesTable), db.countriesTable.nameColumn)),
regionColumn (ReferenceCompositeColumn (*this, "region", tr("Region"), noSuffix, crumbsTo(db, db.regionsTable), db.regionsTable.nameColumn)),
rangeColumn (ReferenceCompositeColumn (*this, "range", tr("Mountain range"), noSuffix, crumbsTo(db, db.rangesTable), db.rangesTable.nameColumn)),
continentColumn (ReferenceCompositeColumn (*this, "continent", tr("Continent"), noSuffix, crumbsTo(db, db.rangesTable), db.rangesTable.continentColumn)),
numAscentsColumn (NumericFoldCompositeColumn (*this, "numAscents", tr("Num. ascents"), noSuffix, CountFold, crumbsTo(db, db.ascentsTable))),
listHikersColumn (HikerListFoldCompositeColumn (*this, "listHikers", tr("Scaled by"), crumbsTo(db, db.hikersTable), db.hikersTable.nameColumn)),
sumElevationGainColumn (NumericFoldCompositeColumn (*this, "sumElevationGain", tr("Sum elev. gain"), mSuffix, SumFold, crumbsTo(db, db.ascentsTable), db.ascentsTable.elevationGainColumn)),
countryColumn (ReferenceCompositeColumn (*this, "country", tr("Country"), noSuffix, db.countriesTable.nameColumn)),
regionColumn (ReferenceCompositeColumn (*this, "region", tr("Region"), noSuffix, db.regionsTable.nameColumn)),
rangeColumn (ReferenceCompositeColumn (*this, "range", tr("Mountain range"), noSuffix, db.rangesTable.nameColumn)),
continentColumn (ReferenceCompositeColumn (*this, "continent", tr("Continent"), noSuffix, db.rangesTable.continentColumn)),
numAscentsColumn (NumericFoldCompositeColumn (*this, "numAscents", tr("Num. ascents"), noSuffix, CountFold, crumbsTo(db.ascentsTable))),
listHikersColumn (HikerListFoldCompositeColumn (*this, "listHikers", tr("Scaled by"), db.hikersTable.nameColumn)),
sumElevationGainColumn (NumericFoldCompositeColumn (*this, "sumElevationGain", tr("Sum elev. gain"), mSuffix, SumFold, db.ascentsTable.elevationGainColumn)),
volcanoColumn (DirectCompositeColumn (*this, noSuffix, db.peaksTable.volcanoColumn))
{
addColumn(nameColumn);
Expand Down
12 changes: 6 additions & 6 deletions src/comp_tables/comp_ranges_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ class CompositeRangesTable : public CompositeTable {
*/
inline CompositeRangesTable(Database& db, QTableView* tableView) :
CompositeTable(db, db.rangesTable, tableView),
// name uiName suffix fold op [breadcrumbs +] content column
// name uiName suffix fold op content column / breadcrumbs
nameColumn (DirectCompositeColumn (*this, noSuffix, db.rangesTable.nameColumn)),
continentColumn (DirectCompositeColumn (*this, noSuffix, db.rangesTable.continentColumn)),
numRegionsColumn (NumericFoldCompositeColumn (*this, "numRegions", tr("Num. regions"), noSuffix, CountFold, crumbsTo(db, db.regionsTable))),
numPeaksColumn (NumericFoldCompositeColumn (*this, "numPeaks", tr("Num. peaks"), noSuffix, CountFold, crumbsTo(db, db.peaksTable))),
avgPeakHeightColumn (NumericFoldCompositeColumn (*this, "avgPeakHeight", tr("Avg. peak height"), mSuffix, AverageFold, crumbsTo(db, db.peaksTable), db.peaksTable.heightColumn)),
maxPeakHeightColumn (NumericFoldCompositeColumn (*this, "maxPeakHeight", tr("Max. peak height"), mSuffix, MaxFold, crumbsTo(db, db.peaksTable), db.peaksTable.heightColumn)),
numAscentsColumn (NumericFoldCompositeColumn (*this, "numAscents", tr("Num. ascents"), noSuffix, CountFold, crumbsTo(db, db.ascentsTable)))
numRegionsColumn (NumericFoldCompositeColumn (*this, "numRegions", tr("Num. regions"), noSuffix, CountFold, crumbsTo(db.regionsTable))),
numPeaksColumn (NumericFoldCompositeColumn (*this, "numPeaks", tr("Num. peaks"), noSuffix, CountFold, crumbsTo(db.peaksTable))),
avgPeakHeightColumn (NumericFoldCompositeColumn (*this, "avgPeakHeight", tr("Avg. peak height"), mSuffix, AverageFold, db.peaksTable.heightColumn)),
maxPeakHeightColumn (NumericFoldCompositeColumn (*this, "maxPeakHeight", tr("Max. peak height"), mSuffix, MaxFold, db.peaksTable.heightColumn)),
numAscentsColumn (NumericFoldCompositeColumn (*this, "numAscents", tr("Num. ascents"), noSuffix, CountFold, crumbsTo(db.ascentsTable)))
{
addColumn(nameColumn);
addColumn(continentColumn);
Expand Down
16 changes: 8 additions & 8 deletions src/comp_tables/comp_regions_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ class CompositeRegionsTable : public CompositeTable {
*/
inline CompositeRegionsTable(Database& db, QTableView* tableView) :
CompositeTable(db, db.regionsTable, tableView),
// name uiName suffix fold op [breadcrumbs +] content column
// name uiName suffix fold op content column / breadcrumbs
nameColumn (DirectCompositeColumn (*this, noSuffix, db.regionsTable.nameColumn)),
rangeColumn (ReferenceCompositeColumn (*this, "range", tr("Mountain range"), noSuffix, crumbsTo(db, db.rangesTable), db.rangesTable.nameColumn)),
countryColumn (ReferenceCompositeColumn (*this, "country", tr("Country"), noSuffix, crumbsTo(db, db.countriesTable), db.countriesTable.nameColumn)),
continentColumn (ReferenceCompositeColumn (*this, "continent", tr("Continent"), noSuffix, crumbsTo(db, db.rangesTable), db.rangesTable.continentColumn)),
numPeaksColumn (NumericFoldCompositeColumn (*this, "numPeaks", tr("Num. peaks"), noSuffix, CountFold, crumbsTo(db, db.peaksTable))),
avgPeakHeightColumn (NumericFoldCompositeColumn (*this, "avgPeakHeight", tr("Avg. peak height"), mSuffix, AverageFold, crumbsTo(db, db.peaksTable), db.peaksTable.heightColumn)),
maxPeakHeightColumn (NumericFoldCompositeColumn (*this, "maxPeakHeight", tr("Max. peak height"), mSuffix, MaxFold, crumbsTo(db, db.peaksTable), db.peaksTable.heightColumn)),
numAscentsColumn (NumericFoldCompositeColumn (*this, "numAscents", tr("Num. ascents"), noSuffix, CountFold, crumbsTo(db, db.ascentsTable)))
rangeColumn (ReferenceCompositeColumn (*this, "range", tr("Mountain range"), noSuffix, db.rangesTable.nameColumn)),
countryColumn (ReferenceCompositeColumn (*this, "country", tr("Country"), noSuffix, db.countriesTable.nameColumn)),
continentColumn (ReferenceCompositeColumn (*this, "continent", tr("Continent"), noSuffix, db.rangesTable.continentColumn)),
numPeaksColumn (NumericFoldCompositeColumn (*this, "numPeaks", tr("Num. peaks"), noSuffix, CountFold, crumbsTo(db.peaksTable))),
avgPeakHeightColumn (NumericFoldCompositeColumn (*this, "avgPeakHeight", tr("Avg. peak height"), mSuffix, AverageFold, db.peaksTable.heightColumn)),
maxPeakHeightColumn (NumericFoldCompositeColumn (*this, "maxPeakHeight", tr("Max. peak height"), mSuffix, MaxFold, db.peaksTable.heightColumn)),
numAscentsColumn (NumericFoldCompositeColumn (*this, "numAscents", tr("Num. ascents"), noSuffix, CountFold, crumbsTo(db.ascentsTable)))
{
addColumn(nameColumn);
addColumn(rangeColumn);
Expand Down
Loading

0 comments on commit fab69a7

Please sign in to comment.