Browse Source

Follow project coding style. Issue #2192.

adaptive-webui-19844
sledgehammer999 9 years ago
parent
commit
cd4f288f67
  1. 27
      src/gui/properties/speedplotview.cpp
  2. 1
      src/gui/properties/speedplotview.h
  3. 5
      src/gui/properties/speedwidget.cpp

27
src/gui/properties/speedplotview.cpp

@ -85,16 +85,18 @@ void SpeedPlotView::pushPoint(SpeedPlotView::PointData point)
m_data5Min.push_back(point); m_data5Min.push_back(point);
if (m_counter30Min == 0) if (m_counter30Min == 0) {
m_data30Min.push_back(point); m_data30Min.push_back(point);
}
else { else {
m_data30Min.back().x = (m_data30Min.back().x * m_counter30Min + point.x) / (m_counter30Min + 1); m_data30Min.back().x = (m_data30Min.back().x * m_counter30Min + point.x) / (m_counter30Min + 1);
for (int id = UP; id < NB_GRAPHS; ++id) for (int id = UP; id < NB_GRAPHS; ++id)
m_data30Min.back().y[id] = (m_data30Min.back().y[id] * m_counter30Min + point.y[id]) / (m_counter30Min + 1); m_data30Min.back().y[id] = (m_data30Min.back().y[id] * m_counter30Min + point.y[id]) / (m_counter30Min + 1);
} }
if (m_counter6Hour == 0) if (m_counter6Hour == 0) {
m_data6Hour.push_back(point); m_data6Hour.push_back(point);
}
else { else {
m_data6Hour.back().x = (m_data6Hour.back().x * m_counter6Hour + point.x) / (m_counter6Hour + 1); m_data6Hour.back().x = (m_data6Hour.back().x * m_counter6Hour + point.x) / (m_counter6Hour + 1);
for (int id = UP; id < NB_GRAPHS; ++id) for (int id = UP; id < NB_GRAPHS; ++id)
@ -126,10 +128,10 @@ void SpeedPlotView::setViewableLastPoints(TimePeriod period)
void SpeedPlotView::replot() void SpeedPlotView::replot()
{ {
if (m_period == MIN1 if ((m_period == MIN1)
|| m_period == MIN5 || (m_period == MIN5)
|| (m_period == MIN30 && m_counter30Min == 2) || ((m_period == MIN30) && (m_counter30Min == 2))
|| (m_period == HOUR6 && m_counter6Hour == 5)) || ((m_period == HOUR6) && (m_counter6Hour == 5)))
viewport()->update(); viewport()->update();
} }
@ -157,11 +159,10 @@ int SpeedPlotView::maxYValue()
if (!m_properties[static_cast<GraphID>(id)].enable) if (!m_properties[static_cast<GraphID>(id)].enable)
continue; continue;
for (int i = queue.size() - 1, j = 0; i >= 0 && j <= m_viewablePointsCount; --i, ++j) { for (int i = queue.size() - 1, j = 0; i >= 0 && j <= m_viewablePointsCount; --i, ++j)
if (queue[i].y[id] > maxYValue) if (queue[i].y[id] > maxYValue)
maxYValue = queue[i].y[id]; maxYValue = queue[i].y[id];
} }
}
return maxYValue; return maxYValue;
} }
@ -190,10 +191,9 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
}; };
int yAxeWidth = 0; int yAxeWidth = 0;
for (const QString &label : speedLabels) { for (const QString &label : speedLabels)
if (fontMetrics.width(label) > yAxeWidth) if (fontMetrics.width(label) > yAxeWidth)
yAxeWidth = fontMetrics.width(label); yAxeWidth = fontMetrics.width(label);
}
int i = 0; int i = 0;
for (const QString &label : speedLabels) { for (const QString &label : speedLabels) {
@ -292,13 +292,10 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
SpeedPlotView::GraphProperties::GraphProperties() SpeedPlotView::GraphProperties::GraphProperties()
: enable(false) : enable(false)
{ {}
}
SpeedPlotView::GraphProperties::GraphProperties(const QString &name, const QPen &pen, bool enable) SpeedPlotView::GraphProperties::GraphProperties(const QString &name, const QPen &pen, bool enable)
: name(name) : name(name)
, pen(pen) , pen(pen)
, enable(enable) , enable(enable)
{ {}
}

1
src/gui/properties/speedplotview.h

@ -40,6 +40,7 @@ class QPen;
class SpeedPlotView: public QGraphicsView class SpeedPlotView: public QGraphicsView
{ {
Q_OBJECT Q_OBJECT
public: public:
enum GraphID enum GraphID
{ {

5
src/gui/properties/speedwidget.cpp

@ -45,8 +45,7 @@
ComboBoxMenuButton::ComboBoxMenuButton(QWidget *parent, QMenu *menu) ComboBoxMenuButton::ComboBoxMenuButton(QWidget *parent, QMenu *menu)
: QComboBox(parent) : QComboBox(parent)
, m_menu(menu) , m_menu(menu)
{ {}
}
void ComboBoxMenuButton::showPopup() void ComboBoxMenuButton::showPopup()
{ {
@ -55,7 +54,6 @@ void ComboBoxMenuButton::showPopup()
QComboBox::hidePopup(); QComboBox::hidePopup();
} }
SpeedWidget::SpeedWidget(PropertiesWidget *parent) SpeedWidget::SpeedWidget(PropertiesWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
@ -202,4 +200,3 @@ void SpeedWidget::saveSettings() const
preferences->setSpeedWidgetGraphEnable(id, action->isChecked()); preferences->setSpeedWidgetGraphEnable(id, action->isChecked());
} }
} }

Loading…
Cancel
Save