Skip to content

fix(cpn): google earth export#7384

Open
elecpower wants to merge 2 commits into
mainfrom
elecpower/cpn-fix-google-earth-export
Open

fix(cpn): google earth export#7384
elecpower wants to merge 2 commits into
mainfrom
elecpower/cpn-fix-google-earth-export

Conversation

@elecpower
Copy link
Copy Markdown
Collaborator

@elecpower elecpower commented May 23, 2026

Fixes #7381

Summary of changes:

  • broken by fix(cpn): log viewer performance #7205 which added a hidden date & time column at index 0
  • use selection list label to data column labels matching for extra data to avoid index assumptions and changes over time

Summary by CodeRabbit

  • Bug Fixes
    • Google Earth export functionality now dynamically identifies Date and Time columns from CSV headers instead of relying on fixed column positions, enabling better compatibility with CSV files that have varying column arrangements.

Review Change Stack

@elecpower elecpower added this to the 3.0 milestone May 23, 2026
@elecpower elecpower added companion Related to the companion software bug/regression ↩️ A new version of EdgeTX broke something backport/2.12 To be backported to a 2.12 release also. labels May 23, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2026

📝 Walkthrough

Walkthrough

The KML export now scans the CSV header to find Date and Time columns and builds extradataCols from header-matched user-selected fields; schema generation, per-point <when> timestamps, and extended-data emission use these detected column indices instead of fixed offsets.

Changes

Dynamic column detection for KML export

Layer / File(s) Summary
Header scan and column mapping
companion/src/logsdialog.cpp
Scans CSV header to set datecol and timecol and builds extradataCols by matching UI-selected field names against header columns while excluding base fields.
KML schema, timestamps, and extended-data emission
companion/src/logsdialog.cpp
Emits gx:SimpleArrayField entries for each extradataCols; constructs per-point <when> as Date + "T" + Time + "Z" using datecol/timecol; iterates extradataCols to output per-point gx:SimpleArrayData/gx:value entries. GPSSpeed remains conditional on speedcol.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(cpn): google earth export' directly addresses the main fix—resolving the regression in Google Earth export functionality for the Companion log viewer.
Linked Issues check ✅ Passed The code changes directly address issue #7381 by adjusting column detection logic to dynamically locate 'Date' and 'Time' columns, accommodating the hidden column introduced in PR #7205 that broke Google Earth export.
Out of Scope Changes check ✅ Passed All changes in logsdialog.cpp are focused on fixing the Google Earth export regression by improving CSV header-based column detection. No unrelated modifications were introduced.
Description check ✅ Passed The pull request description is minimal but addresses the core issue and includes a clear summary of the fix related to the regression introduced by PR #7205.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch elecpower/cpn-fix-google-earth-export

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@companion/src/logsdialog.cpp`:
- Around line 349-355: The current loop in Logsdialog (around the incExtraData
block) matches selected extra fields by header text which breaks when headers
are duplicated; instead, store the original CSV column index on each
QTableWidgetItem (e.g., using item->setData(originalIndex, Qt::UserRole) when
populating ui->FieldsTW) and here read that back
(item->data(Qt::UserRole).toInt()) to push into extradataCols; keep the existing
selection check (item->isSelected()) but replace the DisplayRole comparison with
reading the stored original index and append that index to extradataCols so
selection is resolved by column index not by header text.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cbe1c65e-15b6-4c34-9ca2-6cffa456c65c

📥 Commits

Reviewing files that changed from the base of the PR and between 6a74a2e and 97346ad.

📒 Files selected for processing (1)
  • companion/src/logsdialog.cpp

Comment on lines +349 to +355
if (incExtraData) {
for (int j = 0; j < ui->FieldsTW->rowCount(); j++) {
if (ui->FieldsTW->item(j, 0) && ui->FieldsTW->item(j, 0)->isSelected() &&
ui->FieldsTW->item(j, 0)->data(Qt::DisplayRole).toString() == dataPoints.at(0).at(i)) {
extradataCols << i; // save data index not selection list index
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Preserve extra-field identity by column index, not header text.

Line 352 resolves selected extras by display text only. If a log has duplicate column labels, selecting one row here will add every matching header to extradataCols, so the KML schema/data can include unintended fields. Store the original CSV column index on each FieldsTW item and read that back here instead of re-matching by name.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@companion/src/logsdialog.cpp` around lines 349 - 355, The current loop in
Logsdialog (around the incExtraData block) matches selected extra fields by
header text which breaks when headers are duplicated; instead, store the
original CSV column index on each QTableWidgetItem (e.g., using
item->setData(originalIndex, Qt::UserRole) when populating ui->FieldsTW) and
here read that back (item->data(Qt::UserRole).toInt()) to push into
extradataCols; keep the existing selection check (item->isSelected()) but
replace the DisplayRole comparison with reading the stored original index and
append that index to extradataCols so selection is resolved by column index not
by header text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/2.12 To be backported to a 2.12 release also. bug/regression ↩️ A new version of EdgeTX broke something companion Related to the companion software

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Companion 2.12.1 does not send GPS track to Google Earth

1 participant