Distinguish planned activities in navigator

Reused the inactivated isRun logic to display planned
activities on a darker background.
Part 1 of #4670
This commit is contained in:
Alejandro Martinez
2025-07-18 18:51:37 -03:00
parent b2e0cf875e
commit 5e7fdca415
3 changed files with 17 additions and 17 deletions

View File

@@ -76,7 +76,7 @@ RideCacheModel::data(const QModelIndex &index, int role) const
case 2 : return item->dateTime;
case 3 : return item->present;
case 4 : return item->color.name();
case 5 : return item->isRun;
case 5 : return item->planned;
default:
{
@@ -196,7 +196,7 @@ RideCacheModel::configChanged(qint32)
// 2 QDateTime dateTime;
// 3 QString present;
// 4 QColor color;
// 5 bool isRun;
// 5 bool planned;
columns_ = 5 + factory->metricCount() + metadata.count();
headings_.clear();
@@ -209,7 +209,7 @@ RideCacheModel::configChanged(qint32)
case 2 : headings_<< QString("ride_date"); break;
case 3 : headings_<< QString("Data"); break;
case 4 : headings_<< QString("color"); break;
case 5 : headings_<< QString("isRun"); break;
case 5 : headings_<< QString("planned"); break;
default:
{

View File

@@ -1095,7 +1095,7 @@ void NavigatorCellDelegate::paint(QPainter *painter, const QStyleOptionViewItem
bool hover = false; //disable this, its annoying option.state & QStyle::State_MouseOver;
bool selected = option.state & QStyle::State_Selected;
bool focus = option.state & QStyle::State_HasFocus;
//bool isRun = rideNavigator->tableView->model()->data(index, Qt::UserRole+2).toBool();
bool planned = rideNavigator->tableView->model()->data(index, Qt::UserRole+2).toBool();
// format the cell depending upon what it is...
QString columnName = rideNavigator->tableView->model()->headerData(index.column(), Qt::Horizontal).toString();
@@ -1158,11 +1158,11 @@ void NavigatorCellDelegate::paint(QPainter *painter, const QStyleOptionViewItem
// basic background
QBrush background = QBrush(GColor(CPLOTBACKGROUND));
// runs are darker
//if (isRun) {
//background.setColor(background.color().darker(150));
//userColor = userColor.darker(150);
//}
// planned activities are darker
if (planned) {
background.setColor(background.color().darker(150));
userColor = userColor.darker(150);
}
if (columnName != "*") {

View File

@@ -68,7 +68,7 @@ private:
int calendarText;
int colorColumn;
int fileIndex;
int isRunIndex;
int plannedIndex;
int tempIndex;
int dateColumn;
@@ -110,15 +110,15 @@ public:
calendarText = -1;
colorColumn = -1;
fileIndex = -1;
isRunIndex = -1;
plannedIndex = -1;
tempIndex = -1;
for(int i=0; i<model->columnCount(); i++) {
if (model->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString() == "average_temp") {
tempIndex = i;
}
if (model->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString() == "isRun") {
isRunIndex = i;
if (model->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString() == "planned") {
plannedIndex = i;
}
if (model->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString() == "filename" ||
model->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString() == tr("File")) {
@@ -342,17 +342,17 @@ public:
} else if (role == (Qt::UserRole+2)) { // isRUN ?
if (isRunIndex != -1 && proxyIndex.internalPointer()) {
if (plannedIndex != -1 && proxyIndex.internalPointer()) {
bool isRun = false;
bool planned = false;
// hideous code, sorry
int groupNo = ((QModelIndex*)proxyIndex.internalPointer())->row();
if (groupNo < 0 || groupNo >= groups.count() || proxyIndex.column() == 0)
returning = false;
else isRun = sourceModel()->data(sourceModel()->index(groupToSourceRow.value(groups[groupNo])->at(proxyIndex.row()), isRunIndex)).toBool();
else planned = sourceModel()->data(sourceModel()->index(groupToSourceRow.value(groups[groupNo])->at(proxyIndex.row()), plannedIndex)).toBool();
returning = isRun;
returning = planned;
} else {
returning = false;
}