void DataFileExporter::guessFormatFromSuffix(const QString& name)
{
- QString suffix = getFileNameSuffix(name);
+ QString suffix = Helpers::getFileNameSuffix(name);
if (suffix.length() == 0)
return;
#include "gui/graphviewcontextmenu.h"
#include "signaldrawer.h"
-#include "helpers.h"
#include "metatypes.h"
#include <QtGui/QMouseEvent>
#include <QtWidgets/QWidget>
#include "gui/signalview.h"
#include "ui_signalview.h"
-#include "helpers.h"
#include <cmath>
#include <QtGui/QFontMetrics>
#include <QtGui/QPainter>
#include <QtCore/QString>
-template <typename T> static T average(T* vals, size_t len) {
- T sum = 0;
- for (size_t i = 0; i < len; i++)
- sum += vals[i];
- return sum / len;
-}
-template <typename T> static T clamp(T in, T min, T max) {
- if (in < min)
- return min;
- if (in > max)
- return max;
-}
+class Helpers {
-static QString getFileNameSuffix(const QString& name)
-{
- int dotIdx = name.lastIndexOf('.');
+public:
+ template <typename T> static T average(T* vals, size_t len) {
+ T sum = 0;
+ for (size_t i = 0; i < len; i++)
+ sum += vals[i];
+ return sum / len;
+ }
- if (dotIdx < 0)
- return "";
+ template <typename T> static T clamp(T in, T min, T max) {
+ if (in < min)
+ return min;
+ if (in > max)
+ return max;
+ }
- return name.mid(dotIdx+1).toLower();
-}
+ static QString getFileNameSuffix(const QString& name)
+ {
+ int dotIdx = name.lastIndexOf('.');
+ if (dotIdx < 0)
+ return "";
+ return name.mid(dotIdx+1).toLower();
+ }
+
+};
#endif // MATHHELPERS_H
int ImageDrawer::guessFormatFromSuffix(const QString& name)
{
QList<QByteArray> formats = ImageDrawer::supportedImageFormats();
- QString suffix = getFileNameSuffix(name);
+ QString suffix = Helpers::getFileNameSuffix(name);
if (suffix.length() == 0)
return -1;