aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2017-05-07 09:41:27 +0300
committerGravatar Miika Turkia <miika.turkia@gmail.com>2017-05-07 09:41:27 +0300
commitab1813a4454cbe639e99eaee7cd1115bfed1cf8f (patch)
tree68dce25edb02c9539887ef0ce544da8ca5fa315e
parent0d36b6e4e8305699f35ee57ceae5a2a00f429195 (diff)
downloadsubsurface-ab1813a4454cbe639e99eaee7cd1115bfed1cf8f.tar.gz
Move intdup to qthelper
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
-rw-r--r--core/qthelper.cpp9
-rw-r--r--core/qthelper.h1
-rw-r--r--desktop-widgets/divelogimportdialog.cpp10
-rw-r--r--tests/testparse.cpp10
4 files changed, 12 insertions, 18 deletions
diff --git a/core/qthelper.cpp b/core/qthelper.cpp
index 79fc0effc..993ecbf7d 100644
--- a/core/qthelper.cpp
+++ b/core/qthelper.cpp
@@ -1509,3 +1509,12 @@ QString getUUID()
uuidString.replace("{", "").replace("}", "");
return uuidString;
}
+
+char *intdup(int index)
+{
+ char tmpbuf[21];
+
+ snprintf(tmpbuf, sizeof(tmpbuf) - 2, "%d", index);
+ tmpbuf[20] = 0;
+ return strdup(tmpbuf);
+}
diff --git a/core/qthelper.h b/core/qthelper.h
index 9788bb55d..a85294963 100644
--- a/core/qthelper.h
+++ b/core/qthelper.h
@@ -46,5 +46,6 @@ extern "C" enum deco_mode decoMode();
extern "C" void subsurface_mkdir(const char *dir);
void init_proxy();
QString getUUID();
+char *intdup(int index);
#endif // QTHELPER_H
diff --git a/desktop-widgets/divelogimportdialog.cpp b/desktop-widgets/divelogimportdialog.cpp
index 5e019958f..9a455fcdb 100644
--- a/desktop-widgets/divelogimportdialog.cpp
+++ b/desktop-widgets/divelogimportdialog.cpp
@@ -7,6 +7,7 @@
#include <QDrag>
#include <QMimeData>
#include <QRegExp>
+#include "core/qthelper.h"
static QString subsurface_mimedata = "subsurface/csvcolumns";
static QString subsurface_index = "subsurface/csvindex";
@@ -742,15 +743,6 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
resultModel->setData(resultModel->index(0, i),headers.at(i),Qt::EditRole);
}
-char *intdup(int index)
-{
- char tmpbuf[21];
-
- snprintf(tmpbuf, sizeof(tmpbuf) - 2, "%d", index);
- tmpbuf[20] = 0;
- return strdup(tmpbuf);
-}
-
int DiveLogImportDialog::setup_csv_params(QStringList r, char **params, int pnr)
{
params[pnr++] = strdup("dateField");
diff --git a/tests/testparse.cpp b/tests/testparse.cpp
index 7195af75a..cb98e051f 100644
--- a/tests/testparse.cpp
+++ b/tests/testparse.cpp
@@ -4,6 +4,7 @@
#include "core/file.h"
#include "core/divelist.h"
#include <QTextStream>
+#include "core/qthelper.h"
/* We have to use a macro since QCOMPARE
* can only be called from a test method
@@ -42,15 +43,6 @@ void TestParse::cleanup()
sqlite3_close(_sqlite3_handle);
}
-char *intdup(int index)
-{
- char tmpbuf[21];
-
- snprintf(tmpbuf, sizeof(tmpbuf) - 2, "%d", index);
- tmpbuf[20] = 0;
- return strdup(tmpbuf);
-}
-
int TestParse::parseCSV(int units, std::string file)
{
// some basic file parsing tests