From caec4ee0fe58fb3787e9bdb8f5c28ed81d7ccd21 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Mon, 11 Feb 2013 15:00:00 +0000 Subject: [PATCH] Code Cleanup: Remove #if 0 code As a personal habit I tend to use the C pre-processor to comment out code blocks I don't want to remove. This is in case the code will be required in the future. I think it is now safe to say the code commented out is not required -- most of it is legacy and marks the transition from earlier designs or legacy code. I've done this in one big commit since in theory it has no functional change, and in future can look in this commit for any code we may want to reinstate. --- src/ANT.cpp | 12 ----- src/ANTChannel.cpp | 9 +--- src/AllPlot.cpp | 5 -- src/CalendarDownload.cpp | 30 ------------ src/CriticalPowerWindow.cpp | 3 -- src/DataFilter.cpp | 9 ---- src/DeviceTypes.cpp | 18 ------- src/DiaryWindow.cpp | 93 ++++++------------------------------- src/ErgFilePlot.cpp | 23 --------- src/Fortius.cpp | 7 --- src/GcBubble.cpp | 9 ---- src/LTMWindow.cpp | 20 +------- src/ModelPlot.cpp | 9 ---- src/RideEditor.cpp | 5 -- src/RideImportWizard.cpp | 29 ------------ src/RideItem.cpp | 77 ------------------------------ src/SmallPlot.cpp | 52 --------------------- 17 files changed, 15 insertions(+), 395 deletions(-) diff --git a/src/ANT.cpp b/src/ANT.cpp index 57b991cc8..0ca9ae269 100644 --- a/src/ANT.cpp +++ b/src/ANT.cpp @@ -57,18 +57,6 @@ const ant_sensor_type_t ANT::ant_sensor_types[] = { ANT_SPORT_FREQUENCY, ANT_SPORT_NETWORK_NUMBER, "Cadence", 'c', ":images/IconCadence.png" }, { ANTChannel::CHANNEL_TYPE_SandC, ANT_SPORT_SandC_PERIOD, ANT_SPORT_SandC_TYPE, ANT_SPORT_FREQUENCY, ANT_SPORT_NETWORK_NUMBER, "Speed + Cadence", 'd', ":images/IconCadence.png" }, - - // We comment out these Quarq specials -- they appear to be experimental - // but kept in the code incase they re-appear :) -#if 0 - { ANTChannel::CHANNEL_TYPE_QUARQ, ANT_QUARQ_PERIOD, ANT_QUARQ_TYPE, - ANT_QUARQ_FREQUENCY, DEFAULT_NETWORK_NUMBER, "Quarq Channel", 'Q', ":images/IconPower.png" }, - { ANTChannel::CHANNEL_TYPE_FAST_QUARQ, ANT_FAST_QUARQ_PERIOD, ANT_FAST_QUARQ_TYPE, - ANT_FAST_QUARQ_FREQUENCY, DEFAULT_NETWORK_NUMBER, "Fast Quarq", 'q', ":images/IconPower.png" }, - { ANTChannel::CHANNEL_TYPE_FAST_QUARQ_NEW, ANT_FAST_QUARQ_PERIOD, ANT_FAST_QUARQ_TYPE_WAS, - ANT_FAST_QUARQ_FREQUENCY, DEFAULT_NETWORK_NUMBER, "Fast Quarq New", 'n', ":images/IconPower.png" }, -#endif - { ANTChannel::CHANNEL_TYPE_GUARD, 0, 0, 0, 0, "", '\0', "" } }; diff --git a/src/ANTChannel.cpp b/src/ANTChannel.cpp index 44b920d60..f5ae4477f 100644 --- a/src/ANTChannel.cpp +++ b/src/ANTChannel.cpp @@ -93,16 +93,9 @@ void ANTChannel::open(int device, int chan_type) channel_type=chan_type; channel_type_flags = CHANNEL_TYPE_QUICK_SEARCH ; device_number=device; - setId(); -#if 0 - if (channel_assigned) { - parent->sendMessage(ANTMessage::unassignChannel(number)); - } else { -#endif - attemptTransition(ANT_UNASSIGN_CHANNEL); - //} + attemptTransition(ANT_UNASSIGN_CHANNEL); } // close an ant channel assignment diff --git a/src/AllPlot.cpp b/src/AllPlot.cpp index 0a67839ea..7088eec94 100644 --- a/src/AllPlot.cpp +++ b/src/AllPlot.cpp @@ -858,13 +858,8 @@ AllPlot::setYMax() QwtValueList xytick[QwtScaleDiv::NTickTypes]; for (int i=0;i 2)); // true if is number } } - -#if 0 - QMapIteratorr(lookupMap); - while(r.hasNext()) { - - r.next(); - qDebug()<<"Lookup"<addStretch(); controls->addWidget(title, Qt::AlignCenter | Qt::AlignVCenter); controls->addStretch(); -#if 0 - controls->addWidget(viewMode); -#endif vlayout->addLayout(controls); @@ -120,97 +117,35 @@ DiaryWindow::rideSelected() QDate when = ride->dateTime.date(); int month = when.month(); int year = when.year(); -#if 0 - int weekNumber = when.weekNumber(); -#endif // monthly view updates calendarModel->setMonth(when.month(), when.year()); when = when.addDays(Qt::Monday - when.dayOfWeek()); -#if 0 - // ok update title - switch (viewMode->currentIndex()) { - case 0 : // monthly -#endif - title->setText(QString("%1 %2").arg(QDate::longMonthName(month)).arg(year)); - next->show(); - prev->show(); -#if 0 - break; - case 1 : // weekly - title->setText(QString("Week %1 %2").arg(weekNumber).arg(year)); - next->show(); - prev->show(); - break; - - default: - case 2 : //ride - title->setText(""); - next->hide(); - prev->hide(); - break; - } -#endif + title->setText(QString("%1 %2").arg(QDate::longMonthName(month)).arg(year)); + next->show(); + prev->show(); } void DiaryWindow::prevClicked() { -#if 0 - switch (viewMode->currentIndex()) { - case 0 : // monthly - { -#endif - int month = calendarModel->getMonth(); - int year = calendarModel->getYear(); - QDate when = QDate(year, month, 1).addDays(-1); - calendarModel->setMonth(when.month(), when.year()); - title->setText(QString("%1 %2").arg(QDate::longMonthName(when.month())).arg(when.year())); -#if 0 - } - break; - case 1 : // weekly - { - QDateTime when = weeklyView->getStartTime(); - when = when.addDays(-7); - weeklyView->setDateRange(when.date(), when.addDays(6).date()); - weeklyView->setViewMode(QxtScheduleView::DayView); - title->setText(QString("Week %1 %2").arg(when.date().weekNumber()).arg(when.date().year())); - } - break; - } -#endif + int month = calendarModel->getMonth(); + int year = calendarModel->getYear(); + QDate when = QDate(year, month, 1).addDays(-1); + calendarModel->setMonth(when.month(), when.year()); + title->setText(QString("%1 %2").arg(QDate::longMonthName(when.month())).arg(when.year())); } void DiaryWindow::nextClicked() { -#if 0 - switch (viewMode->currentIndex()) { - case 0 : // monthly - { -#endif - int month = calendarModel->getMonth(); - int year = calendarModel->getYear(); - QDate when = QDate(year, month, 1).addMonths(1); - calendarModel->setMonth(when.month(), when.year()); - title->setText(QString("%1 %2").arg(QDate::longMonthName(when.month())).arg(when.year())); -#if 0 - } - break; - case 1 : // weekly - { - QDateTime when = weeklyView->getStartTime(); - when = when.addDays(7); - weeklyView->setDateRange(when.date(), when.addDays(6).date()); - weeklyView->setViewMode(QxtScheduleView::DayView); - title->setText(QString("Week %1 %2").arg(when.date().weekNumber()).arg(when.date().year())); - } - break; - } -#endif + int month = calendarModel->getMonth(); + int year = calendarModel->getYear(); + QDate when = QDate(year, month, 1).addMonths(1); + calendarModel->setMonth(when.month(), when.year()); + title->setText(QString("%1 %2").arg(QDate::longMonthName(when.month())).arg(when.year())); } bool @@ -220,8 +155,6 @@ DiaryWindow::eventFilter(QObject *object, QEvent *e) if (e->type() != QEvent::ToolTip && e->type() != QEvent::Paint && e->type() != QEvent::Destroy) mainWindow->setBubble(""); - //if (object != (QObject *)monthlyView) return false; - switch (e->type()) { case QEvent::MouseButtonPress: { diff --git a/src/ErgFilePlot.cpp b/src/ErgFilePlot.cpp index d5fc613c1..2f3ca800f 100644 --- a/src/ErgFilePlot.cpp +++ b/src/ErgFilePlot.cpp @@ -422,29 +422,6 @@ ErgFilePlot::performancePlot(RealtimeData rtdata) if (!cadData->count()) cadData->append(&zero, &cad, 1); cadData->append(&x, &cad, 1); cadCurve->setData(cadData->x(), cadData->y(), cadData->count()); - - //const bool cacheMode = canvas()->testPaintAttribute(QwtPlotCanvas::PaintCached); - -#if 0 -#if QT_VERSION >= 0x040000 && defined(Q_WS_X11) - // Even if not recommended by TrollTech, Qt::WA_PaintOutsidePaintEvent - // works on X11. This has an tremendous effect on the performance.. - - canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true); -#endif - - canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false); - wattsCurve->draw(0, wattsCurve->dataSize() - 1); - hrCurve->draw(0, hrCurve->dataSize() - 1); - cadCurve->draw(0, cadCurve->dataSize() - 1); - speedCurve->draw(0, speedCurve->dataSize() - 1); - canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, cacheMode); - -#if QT_VERSION >= 0x040000 && defined(Q_WS_X11) - canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, false); -#endif -#endif - } void diff --git a/src/Fortius.cpp b/src/Fortius.cpp index 45f84ad3a..3aacfd916 100644 --- a/src/Fortius.cpp +++ b/src/Fortius.cpp @@ -362,13 +362,6 @@ void Fortius::run() // heartrate curHeartRate = buf[12]; -#if 0 - // debug - fprintf(stderr,"%08d:", timer.elapsed()); - for(int i=0; i<48; i++) fprintf(stderr, "%02x ", buf[i]); - fprintf(stderr, "\n"); -#endif - } else { // no data available!? It should block in libusb.. but lets sleep anyway diff --git a/src/GcBubble.cpp b/src/GcBubble.cpp index fc2854f4f..5b776fce1 100644 --- a/src/GcBubble.cpp +++ b/src/GcBubble.cpp @@ -203,15 +203,6 @@ GcBubble::paintEvent(QPaintEvent *) // draw the background painter.drawPath(path); - -#if 0 - // debugging - painter.setBrush(Qt::NoBrush); - painter.setPen(Qt::red); - painter.drawRect(1,1,width()-2, height()-2); - painter.setPen(Qt::blue); - painter.drawRect(display->geometry()); -#endif } void diff --git a/src/LTMWindow.cpp b/src/LTMWindow.cpp index 7b1634475..ac59d957f 100644 --- a/src/LTMWindow.cpp +++ b/src/LTMWindow.cpp @@ -165,25 +165,7 @@ LTMWindow::~LTMWindow() } void -LTMWindow::rideSelected() -{ -#if 0 - if (active == true) { - - // mimic user first selection now that - // we are active - choose a chart and - // use the first available date range - ltmTool->selectDateRange(0); - chartSelected(0); - if (amVisible() == true && dirty == true) { - - // plot needs to be redrawn - refresh(); - } else if (amVisible() == false) { - popup->hide(); - } -#endif -} +LTMWindow::rideSelected() { } // deprecated void LTMWindow::refreshPlot() diff --git a/src/ModelPlot.cpp b/src/ModelPlot.cpp index 095f3a9e5..8b4502885 100644 --- a/src/ModelPlot.cpp +++ b/src/ModelPlot.cpp @@ -47,15 +47,6 @@ using namespace Qwt3D; // namespace ref is only visible in this file (is not in // util function to create an x/y key for QHash, effective and quick enough static QString xystring(double x, double y) { return QString("%1:%2").arg((int)x).arg((int)y); } -#if 0 -static void unxystring(QString val, double &x, double &y) -{ - QRegExp it("^([^:]*):([^:]*)$"); - it.exactMatch(val); - x = it.cap(1).toDouble(); - y = it.cap(2).toDouble(); -} -#endif // returns the color for an xyz point class ModelDataColor : public Color diff --git a/src/RideEditor.cpp b/src/RideEditor.cpp index 796043438..d30f69bc3 100644 --- a/src/RideEditor.cpp +++ b/src/RideEditor.cpp @@ -1983,11 +1983,6 @@ PasteSpecialDialog::PasteSpecialDialog(RideEditor *rideEditor, QWidget *parent) contents->setLayout(contentsLayout); contents->setFlat(false); -#if 0 - QDoubleSpinBox *atRow; - QComboBox *textDelimeter; -#endif - okButton = new QPushButton(tr("OK")); cancelButton = new QPushButton(tr("Cancel")); QHBoxLayout *buttons = new QHBoxLayout; diff --git a/src/RideImportWizard.cpp b/src/RideImportWizard.cpp index c37553aba..903b9906a 100644 --- a/src/RideImportWizard.cpp +++ b/src/RideImportWizard.cpp @@ -886,35 +886,6 @@ RideImportWizard::abortClicked() this->repaint(); } -#if 0 // NOT UNTIL CPINTPLOT.CPP IS REFACTORED TO SEPERATE CPI FILES MAINTENANCE FROM CP PLOT CODE - // if done when labelled save we copy the files and run the cpi calculator - phaseLabel->setText(tr("Step 5 of 5: Calculating Critical Powers")); - - abortButton->setText(tr("Abort")); - aborted = false; - - for (int i=0; i< filenames.count(); i++) { - - if (!tableWidget->item(i,5)->text().startsWith(tr("Error"))) { - tableWidget->item(i,5)->setText(tr("Calculating...")); - tableWidget->setCurrentCell(i,5); - QApplication::processEvents(); - if (aborted) { done(0); } - this->repaint(); - - // calculated - - // change status - tableWidget->item(i,5)->setText(tr("Completed.")); - } - QApplication::processEvents(); - if (aborted) { done(0); } - progressBar->setValue(progressBar->value()+1); - this->repaint(); - } -#endif // not until CPINTPLOT IS REFACTORED - - // how did we get on in the end then ... int completed = 0; for (int i=0; i< filenames.count(); i++) diff --git a/src/RideItem.cpp b/src/RideItem.cpp index 766ad8393..774fa3678 100644 --- a/src/RideItem.cpp +++ b/src/RideItem.cpp @@ -146,28 +146,6 @@ int RideItem::numHrZones() return (hr_zone_range >= 0) ? hrZones->numZones(hr_zone_range) : 0; } -#if 0 - -double RideItem::timeInZone(int zone) -{ - if (!ride()) - return 0.0; - assert(zone < numZones()); - //return time_in_zone[zone]; - return 0; -} - - -double RideItem::timeInHrZone(int zone) -{ - computeMetrics(); - if (!ride()) - return 0.0; - assert(zone < numHrZones()); - return time_in_hr_zone[zone]; -} -#endif - void RideItem::freeMemory() { @@ -177,61 +155,6 @@ RideItem::freeMemory() } } -#if 0 -void -RideItem::computeMetrics() -{ - const QDateTime nilTime; - if ((computeMetricsTime != nilTime) && - (computeMetricsTime >= zones->modificationTime)) { - return; - } - - if (!ride()) return; - - computeMetricsTime = QDateTime::currentDateTime(); - - int zone_range = zoneRange(); - int num_zones = numZones(); - time_in_zone.clear(); - if (zone_range >= 0) { - num_zones = zones->numZones(zone_range); - time_in_zone.resize(num_zones); - } - int hr_zone_range = hrZoneRange(); - int num_hr_zones = numHrZones(); - time_in_hr_zone.clear(); - if (hr_zone_range >= 0) { - num_hr_zones = hrZones->numZones(hr_zone_range); - time_in_hr_zone.resize(num_hr_zones); - } - - double secs_delta = ride()->recIntSecs(); - foreach (const RideFilePoint *point, ride()->dataPoints()) { - if (point->watts >= 0.0) { - if (num_zones > 0) { - int zone = zones->whichZone(zone_range, point->watts); - if (zone >= 0) - time_in_zone[zone] += secs_delta; - } - } - if (point->hr >= 0.0) { - if (num_hr_zones > 0) { - int hrZone = hrZones->whichZone(hr_zone_range, point->hr); - if (hrZone >= 0) - time_in_hr_zone[hrZone] += secs_delta; - } - } - } - - QStringList allMetrics; - const RideMetricFactory &factory = RideMetricFactory::instance(); - for (int i = 0; i < factory.metricCount(); ++i) - allMetrics.append(factory.metricName(i)); - metrics = RideMetric::computeMetrics(ride(), zones, hrZones, allMetrics); -} -#endif - void RideItem::setStartTime(QDateTime newDateTime) { diff --git a/src/SmallPlot.cpp b/src/SmallPlot.cpp index 4a8fcb9f9..4036aaae7 100644 --- a/src/SmallPlot.cpp +++ b/src/SmallPlot.cpp @@ -102,31 +102,6 @@ SmallPlot::recalc() return; } -#if 0 - int nbpoints2 = (int)floor(rideTimeSecs/60/36)+2; - //fprintf(stderr, "rideTimeSecs : %d, nbpoints2 : %d",rideTimeSecs/60, nbpoints2); - - QVectordatatime(nbpoints2); - double *time[36]; - - for (int i = 0; i < 36; ++i) { - time[i]= new double[nbpoints2]; - } - - for (int secs = 0; secs < nbpoints2; ++secs) { - datatime[secs] = 1; - - for (int i = 0; i < 36; ++i) { - //fprintf(stderr, "\ni : %d, time : %d",i, secs + i*(nbpoints2-1)); - time[i][secs] = secs + i*(nbpoints2-1); - } - } - - for (int i = 0; i < 36; ++i) { - timeCurves[i]->setData(time[i], datatime, nbpoints2); - } -#endif - double totalWatts = 0.0; double totalHr = 0.0; QList list; @@ -183,33 +158,6 @@ SmallPlot::recalc() setAxisScale(xBottom, 0.0, smoothTime[rideTimeSecs]); setYMax(); - - -#if 0 - QString label[interList.size()]; - QwtText text[interList.size()]; - - // arrays are safe since not passed - // as a conyiguous array - if (d_mrk) delete [] d_mrk; - d_mrk = new QwtPlotMarker[interList.size()]; - for(int x = 0; x < interList.size(); x++) { - // marker - d_mrk[x].setValue(0,0); - d_mrk[x].setLineStyle(QwtPlotMarker::VLine); - d_mrk[x].setLabelAlignment(Qt::AlignRight | Qt::AlignTop); - d_mrk[x].setLinePen(QPen(Qt::black, 0, Qt::DashDotLine)); - d_mrk[x].attach(this); - label[x].setNum(x+1); - text[x] = QwtText(label[x]); - text[x].setFont(QFont("Helvetica", 10, QFont::Bold)); - text[x].setColor(Qt::black); - - d_mrk[x].setValue(interList.at(x), 0.0); - d_mrk[x].setLabel(text[x]); - } -#endif - replot(); }