diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index a159c29f8..8d1ad0a07 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -345,7 +345,9 @@ MainWindow::MainWindow(const QDir &home) : "background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1," "stop: 0 #CFCFCF, stop: 1.0 #A8A8A8);" "border: 1px solid rgba(255, 255, 255, 32);" +#if 0 "color: #535353;" +#endif "font-weight: bold; }"); toolBox->setFrameStyle(QFrame::NoFrame); @@ -459,7 +461,6 @@ MainWindow::MainWindow(const QDir &home) : splitter->setChildrenCollapsible(false); // QT BUG crash QTextLayout do not undo this splitter->setHandleWidth(1); splitter->setFrameStyle(QFrame::NoFrame); - splitter->setStyleSheet("QSplitter { border: 0px; background-color: #A8A8A8; }"); splitter->setContentsMargins(0, 0, 0, 0); // attempting to follow some UI guides setCentralWidget(splitter); diff --git a/src/RideEditor.cpp b/src/RideEditor.cpp index 916b9ebff..a258ad046 100644 --- a/src/RideEditor.cpp +++ b/src/RideEditor.cpp @@ -140,9 +140,34 @@ RideEditor::RideEditor(MainWindow *main) : GcWindow(main), data(NULL), ride(NULL connect(main, SIGNAL(rideDirty()), this, SLOT(rideDirty())); connect(main, SIGNAL(rideClean()), this, SLOT(rideClean())); - // our tool is the search dialog + // put find tool and anomaly list in the controls findTool = new FindDialog(this); - setControls(findTool); + + anomalyList = new QTableWidget(this); + anomalyList->setColumnCount(2); + anomalyList->setColumnHidden(0, true); + anomalyList->setSortingEnabled(false); + QStringList header; + header << "Id" << "Anomalies"; + anomalyList->setHorizontalHeaderLabels(header); + anomalyList->horizontalHeader()->setStretchLastSection(true); + anomalyList->verticalHeader()->hide(); + anomalyList->setShowGrid(false); + anomalyList->setSelectionMode(QAbstractItemView::SingleSelection); + anomalyList->setSelectionBehavior(QAbstractItemView::SelectRows); + + QSplitter *controlSplitter = new QSplitter(Qt::Vertical, main); + controlSplitter->setHandleWidth(1); + //controlSplitter->setStyleSheet("background-color: white; border: none;"); + controlSplitter->setFrameStyle(QFrame::NoFrame); + controlSplitter->setAutoFillBackground(true); + controlSplitter->setOrientation(Qt::Vertical); + controlSplitter->addWidget(findTool); + controlSplitter->addWidget(anomalyList); + setControls(controlSplitter); + + // allow us to jump to an anomaly + connect(anomalyList, SIGNAL(itemSelectionChanged()), this, SLOT(anomalySelected())); } void @@ -296,6 +321,12 @@ RideEditor::check() // run through all the available channels and find anomalies data->anomalies.clear(); + // clear the list + anomalyList->clear(); + QStringList header; + header << "Id" << "Anomalies"; + anomalyList->setHorizontalHeaderLabels(header); + QVector power; QVector secs; double lastdistance=9; @@ -378,6 +409,30 @@ RideEditor::check() } } + // now fill in the anomaly list + anomalyList->setRowCount(0); // <<< fixes crash at ZZZZ + anomalyList->setRowCount(data->anomalies.count()); // <<< ZZZZ + + int counter = 0; + QMapIterator f(data->anomalies); + while (f.hasNext()) { + + f.next(); + + QTableWidgetItem *t = new QTableWidgetItem; + t->setText(f.key()); + t->setFlags(t->flags() & (~Qt::ItemIsEditable)); + anomalyList->setItem(counter, 0, t); + + t = new QTableWidgetItem; + t->setText(f.value()); + t->setFlags(t->flags() & (~Qt::ItemIsEditable)); + t->setForeground(QBrush(Qt::red)); + anomalyList->setItem(counter, 1, t); + + counter++; + } + // redraw - even if no anomalies were found since // some may have been highlighted previouslt. This is // an expensive operation, but then so is the check() @@ -1134,6 +1189,18 @@ RideEditor::rideSelected() findTool->rideSelected(); } +void +RideEditor::anomalySelected() +{ + if (anomalyList->currentRow() < 0) return; + + // jump to the found item in the main table + int row; + RideFile::SeriesType series; + unxsstring(anomalyList->item(anomalyList->currentRow(), 0)->text(), row, series); + table->setCurrentIndex(model->index(row,model->columnFor(series))); +} + // We update the current selection on the table view // to reflect the actions performed on the data. This // is especially relevant when 'redo'ing a command diff --git a/src/RideEditor.h b/src/RideEditor.h index 5a02b4c8b..a7b3f782f 100644 --- a/src/RideEditor.h +++ b/src/RideEditor.h @@ -78,6 +78,9 @@ class RideEditor : public GcWindow void find(); void check(); + // anomaly list + void anomalySelected(); + // context menu functions void smooth(); void cut(); @@ -116,6 +119,7 @@ class RideEditor : public GcWindow RideFileTableModel *model; QStringList copyHeadings; FindDialog *findTool; + QTableWidget *anomalyList; private: MainWindow *main;