mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-27 21:24:47 +01:00
Allow only odd window sizes for moving average filter
This commit is contained in:
parent
d54f22d3f0
commit
aff7b1c13f
@ -93,7 +93,8 @@ HEADERS += src/config.h \
|
||||
src/ozf.h \
|
||||
src/datum.h \
|
||||
src/maplist.h \
|
||||
src/albersequal.h
|
||||
src/albersequal.h \
|
||||
src/oddspinbox.h
|
||||
SOURCES += src/main.cpp \
|
||||
src/gui.cpp \
|
||||
src/poi.cpp \
|
||||
@ -160,7 +161,8 @@ SOURCES += src/main.cpp \
|
||||
src/ozf.cpp \
|
||||
src/datum.cpp \
|
||||
src/maplist.cpp \
|
||||
src/albersequal.cpp
|
||||
src/albersequal.cpp \
|
||||
src/oddspinbox.cpp
|
||||
RESOURCES += gpxsee.qrc
|
||||
TRANSLATIONS = lang/gpxsee_cs.ts \
|
||||
lang/gpxsee_sv.ts \
|
||||
|
22
src/oddspinbox.cpp
Normal file
22
src/oddspinbox.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include "oddspinbox.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
OddSpinBox::OddSpinBox(QWidget *parent) : QSpinBox(parent)
|
||||
{
|
||||
setSingleStep(2);
|
||||
setMinimum(1);
|
||||
}
|
||||
|
||||
QValidator::State OddSpinBox::validate(QString &text, int &pos) const
|
||||
{
|
||||
Q_UNUSED(pos);
|
||||
bool ok;
|
||||
int val;
|
||||
|
||||
val = text.toInt(&ok);
|
||||
if (!ok || val < 0 || val % 2 == 0)
|
||||
return QValidator::Invalid;
|
||||
|
||||
return QValidator::Acceptable;
|
||||
}
|
15
src/oddspinbox.h
Normal file
15
src/oddspinbox.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef ODDSPINBOX_H
|
||||
#define ODDSPINBOX_H
|
||||
|
||||
#include <QSpinBox>
|
||||
|
||||
class OddSpinBox : public QSpinBox
|
||||
{
|
||||
public:
|
||||
OddSpinBox(QWidget *parent = 0);
|
||||
|
||||
protected:
|
||||
QValidator::State validate(QString &text, int &pos) const;
|
||||
};
|
||||
|
||||
#endif // ODDSPINBOX_H
|
@ -14,6 +14,7 @@
|
||||
#include "icons.h"
|
||||
#include "colorbox.h"
|
||||
#include "stylecombobox.h"
|
||||
#include "oddspinbox.h"
|
||||
#include "optionsdialog.h"
|
||||
|
||||
#define MENU_MARGIN 20
|
||||
@ -122,19 +123,19 @@ QWidget *OptionsDialog::createDataPage()
|
||||
{
|
||||
QString filterToolTip = tr("Moving average window size");
|
||||
|
||||
_elevationFilter = new QSpinBox();
|
||||
_elevationFilter = new OddSpinBox();
|
||||
_elevationFilter->setValue(_options->elevationFilter);
|
||||
_elevationFilter->setToolTip(filterToolTip);
|
||||
_speedFilter = new QSpinBox();
|
||||
_speedFilter = new OddSpinBox();
|
||||
_speedFilter->setValue(_options->speedFilter);
|
||||
_speedFilter->setToolTip(filterToolTip);
|
||||
_heartRateFilter = new QSpinBox();
|
||||
_heartRateFilter = new OddSpinBox();
|
||||
_heartRateFilter->setValue(_options->heartRateFilter);
|
||||
_heartRateFilter->setToolTip(filterToolTip);
|
||||
_cadenceFilter = new QSpinBox();
|
||||
_cadenceFilter = new OddSpinBox();
|
||||
_cadenceFilter->setValue(_options->cadenceFilter);
|
||||
_cadenceFilter->setToolTip(filterToolTip);
|
||||
_powerFilter = new QSpinBox();
|
||||
_powerFilter = new OddSpinBox();
|
||||
_powerFilter->setValue(_options->powerFilter);
|
||||
_powerFilter->setToolTip(filterToolTip);
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
class ColorBox;
|
||||
class StyleComboBox;
|
||||
class OddSpinBox;
|
||||
class QSpinBox;
|
||||
class QDoubleSpinBox;
|
||||
class QComboBox;
|
||||
@ -78,11 +79,11 @@ private:
|
||||
QSpinBox *_graphWidth;
|
||||
QCheckBox *_graphAA;
|
||||
// Data
|
||||
QSpinBox *_elevationFilter;
|
||||
QSpinBox *_speedFilter;
|
||||
QSpinBox *_heartRateFilter;
|
||||
QSpinBox *_cadenceFilter;
|
||||
QSpinBox *_powerFilter;
|
||||
OddSpinBox *_elevationFilter;
|
||||
OddSpinBox *_speedFilter;
|
||||
OddSpinBox *_heartRateFilter;
|
||||
OddSpinBox *_cadenceFilter;
|
||||
OddSpinBox *_powerFilter;
|
||||
QCheckBox *_outlierEliminate;
|
||||
QDoubleSpinBox *_pauseSpeed;
|
||||
QSpinBox *_pauseInterval;
|
||||
|
Loading…
Reference in New Issue
Block a user