mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup: consistently use qPrintable()
Replace constructs of the kind s.toUtf8().data(), s.toUtf8().constData(), s.toLocal8Bit().data(), s.toLocal8Bit.constData() or qUtf8Printable(s) by qPrintable(s). This is concise, consistent and - in principle - more performant than the .data() versions. Sadly, owing to a suboptimal implementation, qPrintable(s) currently is a pessimization compared to s.toUtf8().data(). A fix is scheduled for new Qt versions: https://codereview.qt-project.org/#/c/221331/ Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
4e44fe7598
commit
b72cc1f317
33 changed files with 166 additions and 162 deletions
|
@ -52,7 +52,7 @@ static const char *system_default_path_append(const char *append)
|
||||||
if (append)
|
if (append)
|
||||||
path += QString("/%1").arg(append);
|
path += QString("/%1").arg(append);
|
||||||
|
|
||||||
return strdup(path.toUtf8().data());
|
return strdup(qPrintable(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *system_default_directory(void)
|
const char *system_default_directory(void)
|
||||||
|
|
|
@ -293,7 +293,7 @@ static dc_status_t write_suunto_vyper_settings(dc_device_t *device, DeviceDetail
|
||||||
|
|
||||||
rc = dc_device_write(device, SUUNTO_VYPER_CUSTOM_TEXT,
|
rc = dc_device_write(device, SUUNTO_VYPER_CUSTOM_TEXT,
|
||||||
// Convert the customText to a 30 char wide padded with " "
|
// Convert the customText to a 30 char wide padded with " "
|
||||||
(const unsigned char *)QString("%1").arg(m_deviceDetails->customText, -30, QChar(' ')).toUtf8().data(),
|
(const unsigned char *)qPrintable(QString("%1").arg(m_deviceDetails->customText, -30, QChar(' '))),
|
||||||
SUUNTO_VYPER_CUSTOM_TEXT_LENGTH);
|
SUUNTO_VYPER_CUSTOM_TEXT_LENGTH);
|
||||||
if (rc != DC_STATUS_SUCCESS)
|
if (rc != DC_STATUS_SUCCESS)
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -812,7 +812,7 @@ static dc_status_t write_ostc4_settings(dc_device_t *device, DeviceDetails *m_de
|
||||||
|
|
||||||
//write general settings
|
//write general settings
|
||||||
//custom text
|
//custom text
|
||||||
rc = hw_ostc3_device_customtext(device, m_deviceDetails->customText.toUtf8().data());
|
rc = hw_ostc3_device_customtext(device, qPrintable(m_deviceDetails->customText));
|
||||||
if (rc != DC_STATUS_SUCCESS)
|
if (rc != DC_STATUS_SUCCESS)
|
||||||
return rc;
|
return rc;
|
||||||
EMIT_PROGRESS();
|
EMIT_PROGRESS();
|
||||||
|
@ -1356,7 +1356,7 @@ static dc_status_t write_ostc3_settings(dc_device_t *device, DeviceDetails *m_de
|
||||||
|
|
||||||
//write general settings
|
//write general settings
|
||||||
//custom text
|
//custom text
|
||||||
rc = hw_ostc3_device_customtext(device, m_deviceDetails->customText.toUtf8().data());
|
rc = hw_ostc3_device_customtext(device, qPrintable(m_deviceDetails->customText));
|
||||||
if (rc != DC_STATUS_SUCCESS)
|
if (rc != DC_STATUS_SUCCESS)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
|
@ -1891,7 +1891,7 @@ static dc_status_t write_ostc_settings(dc_device_t *device, DeviceDetails *m_dev
|
||||||
} else {
|
} else {
|
||||||
data[64] = 1;
|
data[64] = 1;
|
||||||
// Copy the string to the right place in the memory, padded with 0x20 (" ")
|
// Copy the string to the right place in the memory, padded with 0x20 (" ")
|
||||||
strncpy((char *)data + 65, QString("%1").arg(m_deviceDetails->customText, -23, QChar(' ')).toUtf8().data(), 23);
|
strncpy((char *)data + 65, qPrintable(QString("%1").arg(m_deviceDetails->customText, -23, QChar(' '))), 23);
|
||||||
// And terminate the string.
|
// And terminate the string.
|
||||||
if (m_deviceDetails->customText.length() <= 23)
|
if (m_deviceDetails->customText.length() <= 23)
|
||||||
data[65 + m_deviceDetails->customText.length()] = '}';
|
data[65 + m_deviceDetails->customText.length()] = '}';
|
||||||
|
@ -2227,10 +2227,10 @@ void FirmwareUpdateThread::run()
|
||||||
switch (dc_device_get_type(m_data->device)) {
|
switch (dc_device_get_type(m_data->device)) {
|
||||||
#if DC_VERSION_CHECK(0, 5, 0)
|
#if DC_VERSION_CHECK(0, 5, 0)
|
||||||
case DC_FAMILY_HW_OSTC3:
|
case DC_FAMILY_HW_OSTC3:
|
||||||
rc = hw_ostc3_device_fwupdate(m_data->device, m_fileName.toUtf8().data());
|
rc = hw_ostc3_device_fwupdate(m_data->device, qPrintable(m_fileName));
|
||||||
break;
|
break;
|
||||||
case DC_FAMILY_HW_OSTC:
|
case DC_FAMILY_HW_OSTC:
|
||||||
rc = hw_ostc_device_fwupdate(m_data->device, m_fileName.toUtf8().data());
|
rc = hw_ostc_device_fwupdate(m_data->device, qPrintable(m_fileName));
|
||||||
break;
|
break;
|
||||||
#endif // divecomputer 0.5.0
|
#endif // divecomputer 0.5.0
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -57,11 +57,11 @@ const DiveComputerNode *DiveComputerList::get(const QString &m)
|
||||||
void DiveComputerNode::showchanges(const QString &n, const QString &s, const QString &f) const
|
void DiveComputerNode::showchanges(const QString &n, const QString &s, const QString &f) const
|
||||||
{
|
{
|
||||||
if (nickName != n)
|
if (nickName != n)
|
||||||
qDebug("new nickname %s for DC model %s deviceId 0x%x", n.toUtf8().data(), model.toUtf8().data(), deviceId);
|
qDebug("new nickname %s for DC model %s deviceId 0x%x", qPrintable(n), qPrintable(model), deviceId);
|
||||||
if (serialNumber != s)
|
if (serialNumber != s)
|
||||||
qDebug("new serial number %s for DC model %s deviceId 0x%x", s.toUtf8().data(), model.toUtf8().data(), deviceId);
|
qDebug("new serial number %s for DC model %s deviceId 0x%x", qPrintable(s), qPrintable(model), deviceId);
|
||||||
if (firmware != f)
|
if (firmware != f)
|
||||||
qDebug("new firmware version %s for DC model %s deviceId 0x%x", f.toUtf8().data(), model.toUtf8().data(), deviceId);
|
qDebug("new firmware version %s for DC model %s deviceId 0x%x", qPrintable(f), qPrintable(model), deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveComputerList::addDC(QString m, uint32_t d, QString n, QString s, QString f)
|
void DiveComputerList::addDC(QString m, uint32_t d, QString n, QString s, QString f)
|
||||||
|
@ -132,8 +132,8 @@ extern "C" void call_for_each_dc (void *f, void (*callback)(void *, const char *
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
if (found)
|
if (found)
|
||||||
callback(f, node->model.toUtf8().data(), node->deviceId, node->nickName.toUtf8().data(),
|
callback(f, qPrintable(node->model), node->deviceId, qPrintable(node->nickName),
|
||||||
node->serialNumber.toUtf8().data(), node->firmware.toUtf8().data());
|
qPrintable(node->serialNumber), qPrintable(node->firmware));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ void exportHtmlInitLogic(const QString &filename, struct htmlExportSetting &hes)
|
||||||
|
|
||||||
exportHTMLsettings(json_settings, hes);
|
exportHTMLsettings(json_settings, hes);
|
||||||
exportHTMLstatistics(stat_file, hes);
|
exportHTMLstatistics(stat_file, hes);
|
||||||
export_translation(translation.toUtf8().data());
|
export_translation(qPrintable(translation));
|
||||||
|
|
||||||
export_HTML(qPrintable(json_dive_data), qPrintable(photosDirectory), hes.selectedOnly, hes.listOnly);
|
export_HTML(qPrintable(json_dive_data), qPrintable(photosDirectory), hes.selectedOnly, hes.listOnly);
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
#define GET_TXT(name, field) \
|
#define GET_TXT(name, field) \
|
||||||
v = s.value(QString(name)); \
|
v = s.value(QString(name)); \
|
||||||
if (v.isValid()) \
|
if (v.isValid()) \
|
||||||
prefs.field = strdup(v.toString().toUtf8().constData()); \
|
prefs.field = strdup(qPrintable(v.toString())); \
|
||||||
else \
|
else \
|
||||||
prefs.field = copy_string(default_prefs.field)
|
prefs.field = copy_string(default_prefs.field)
|
||||||
|
|
||||||
|
|
|
@ -334,7 +334,7 @@ dc_status_t qt_ble_open(dc_custom_io_t *io, dc_context_t *context, const char *d
|
||||||
return DC_STATUS_IO;
|
return DC_STATUS_IO;
|
||||||
default:
|
default:
|
||||||
qDebug() << "failed to connect to the controller " << devaddr << "with error" << controller->errorString();
|
qDebug() << "failed to connect to the controller " << devaddr << "with error" << controller->errorString();
|
||||||
report_error("Failed to connect to %s: '%s'", devaddr, controller->errorString().toUtf8().data());
|
report_error("Failed to connect to %s: '%s'", devaddr, qPrintable(controller->errorString()));
|
||||||
delete controller;
|
delete controller;
|
||||||
return DC_STATUS_IO;
|
return DC_STATUS_IO;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,12 +94,12 @@ extern "C" const char *printGPSCoords(int lat, int lon)
|
||||||
latsec = (latmin % 1000000) * 60;
|
latsec = (latmin % 1000000) * 60;
|
||||||
lonsec = (lonmin % 1000000) * 60;
|
lonsec = (lonmin % 1000000) * 60;
|
||||||
result.sprintf("%u%s%02d\'%06.3f\"%s %u%s%02d\'%06.3f\"%s",
|
result.sprintf("%u%s%02d\'%06.3f\"%s %u%s%02d\'%06.3f\"%s",
|
||||||
latdeg, UTF8_DEGREE, latmin / 1000000, latsec / 1000000, lath.toUtf8().data(),
|
latdeg, UTF8_DEGREE, latmin / 1000000, latsec / 1000000, qPrintable(lath),
|
||||||
londeg, UTF8_DEGREE, lonmin / 1000000, lonsec / 1000000, lonh.toUtf8().data());
|
londeg, UTF8_DEGREE, lonmin / 1000000, lonsec / 1000000, qPrintable(lonh));
|
||||||
} else {
|
} else {
|
||||||
result.sprintf("%f %f", (double) lat / 1000000.0, (double) lon / 1000000.0);
|
result.sprintf("%f %f", (double) lat / 1000000.0, (double) lon / 1000000.0);
|
||||||
}
|
}
|
||||||
return strdup(result.toUtf8().data());
|
return strdup(qPrintable(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -354,7 +354,7 @@ extern "C" timestamp_t picture_get_timestamp(const char *filename)
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
// filename might not be the actual filename, so let's go via the hash.
|
// filename might not be the actual filename, so let's go via the hash.
|
||||||
if (readfile(localFilePath(QString(filename)).toUtf8().data(), &mem) <= 0)
|
if (readfile(qPrintable(localFilePath(QString(filename))), &mem) <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
retval = exif.parseFrom((const unsigned char *)mem.buffer, (unsigned)mem.size);
|
retval = exif.parseFrom((const unsigned char *)mem.buffer, (unsigned)mem.size);
|
||||||
free(mem.buffer);
|
free(mem.buffer);
|
||||||
|
@ -998,7 +998,7 @@ QString get_short_dive_date_string(timestamp_t when)
|
||||||
const char *get_dive_date_c_string(timestamp_t when)
|
const char *get_dive_date_c_string(timestamp_t when)
|
||||||
{
|
{
|
||||||
QString text = get_dive_date_string(when);
|
QString text = get_dive_date_string(when);
|
||||||
return strdup(text.toUtf8().data());
|
return strdup(qPrintable(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" const char *get_current_date()
|
extern "C" const char *get_current_date()
|
||||||
|
@ -1008,7 +1008,7 @@ extern "C" const char *get_current_date()
|
||||||
|
|
||||||
current_date = loc.toString(ts, QString(prefs.date_format_short));
|
current_date = loc.toString(ts, QString(prefs.date_format_short));
|
||||||
|
|
||||||
return strdup(current_date.toUtf8().data());
|
return strdup(qPrintable(current_date));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_same_day(timestamp_t trip_when, timestamp_t dive_when)
|
bool is_same_day(timestamp_t trip_when, timestamp_t dive_when)
|
||||||
|
@ -1066,7 +1066,7 @@ extern "C" void reverseGeoLookup(degrees_t latitude, degrees_t longitude, uint32
|
||||||
QJsonObject address = obj.value("address").toObject();
|
QJsonObject address = obj.value("address").toObject();
|
||||||
qDebug() << "found country:" << address.value("country").toString();
|
qDebug() << "found country:" << address.value("country").toString();
|
||||||
struct dive_site *ds = get_dive_site_by_uuid(uuid);
|
struct dive_site *ds = get_dive_site_by_uuid(uuid);
|
||||||
ds->notes = add_to_string(ds->notes, "countrytag: %s", address.value("country").toString().toUtf8().data());
|
ds->notes = add_to_string(ds->notes, "countrytag: %s", qPrintable(address.value("country").toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1098,7 +1098,7 @@ const QString hashfile_name()
|
||||||
|
|
||||||
extern "C" char *hashfile_name_string()
|
extern "C" char *hashfile_name_string()
|
||||||
{
|
{
|
||||||
return strdup(hashfile_name().toUtf8().data());
|
return strdup(qPrintable(hashfile_name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_hashes()
|
void read_hashes()
|
||||||
|
@ -1266,7 +1266,7 @@ const QString picturedir()
|
||||||
|
|
||||||
extern "C" char *picturedir_string()
|
extern "C" char *picturedir_string()
|
||||||
{
|
{
|
||||||
return strdup(picturedir().toUtf8().data());
|
return strdup(qPrintable(picturedir()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* when we get a picture from git storage (local or remote) and can't find the picture
|
/* when we get a picture from git storage (local or remote) and can't find the picture
|
||||||
|
@ -1293,7 +1293,7 @@ extern "C" void picture_load_exif_data(struct picture *p)
|
||||||
easyexif::EXIFInfo exif;
|
easyexif::EXIFInfo exif;
|
||||||
memblock mem;
|
memblock mem;
|
||||||
|
|
||||||
if (readfile(localFilePath(QString(p->filename)).toUtf8().data(), &mem) <= 0)
|
if (readfile(qPrintable(localFilePath(QString(p->filename))), &mem) <= 0)
|
||||||
goto picture_load_exit;
|
goto picture_load_exit;
|
||||||
if (exif.parseFrom((const unsigned char *)mem.buffer, (unsigned)mem.size) != PARSE_EXIF_SUCCESS)
|
if (exif.parseFrom((const unsigned char *)mem.buffer, (unsigned)mem.size) != PARSE_EXIF_SUCCESS)
|
||||||
goto picture_load_exit;
|
goto picture_load_exit;
|
||||||
|
@ -1458,7 +1458,7 @@ extern "C" char *cloud_url()
|
||||||
{
|
{
|
||||||
QString filename;
|
QString filename;
|
||||||
getCloudURL(filename);
|
getCloudURL(filename);
|
||||||
return strdup(filename.toUtf8().data());
|
return strdup(qPrintable(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" bool getProxyString(char **buffer)
|
extern "C" bool getProxyString(char **buffer)
|
||||||
|
@ -1558,7 +1558,7 @@ int parse_seabear_header(const char *filename, char **params, int pnr)
|
||||||
while ((parseLine = f.readLine().trimmed()).length() > 0 && !f.atEnd()) {
|
while ((parseLine = f.readLine().trimmed()).length() > 0 && !f.atEnd()) {
|
||||||
if (parseLine.contains("//DIVE NR: ")) {
|
if (parseLine.contains("//DIVE NR: ")) {
|
||||||
params[pnr++] = strdup("diveNro");
|
params[pnr++] = strdup("diveNro");
|
||||||
params[pnr++] = strdup(parseLine.replace(QString::fromLatin1("//DIVE NR: "), QString::fromLatin1("")).toUtf8().data());
|
params[pnr++] = strdup(qPrintable(parseLine.replace(QString::fromLatin1("//DIVE NR: "), QString::fromLatin1(""))));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1573,7 +1573,7 @@ int parse_seabear_header(const char *filename, char **params, int pnr)
|
||||||
while ((parseLine = f.readLine().trimmed()).length() > 0 && !f.atEnd()) {
|
while ((parseLine = f.readLine().trimmed()).length() > 0 && !f.atEnd()) {
|
||||||
if (parseLine.contains("//Hardware Version: ")) {
|
if (parseLine.contains("//Hardware Version: ")) {
|
||||||
params[pnr++] = strdup("hw");
|
params[pnr++] = strdup("hw");
|
||||||
params[pnr++] = strdup(parseLine.replace(QString::fromLatin1("//Hardware Version: "), QString::fromLatin1("\"Seabear ")).trimmed().append("\"").toUtf8().data());
|
params[pnr++] = strdup(qPrintable(parseLine.replace(QString::fromLatin1("//Hardware Version: "), QString::fromLatin1("\"Seabear ")).trimmed().append("\"")));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1586,7 +1586,7 @@ int parse_seabear_header(const char *filename, char **params, int pnr)
|
||||||
while ((parseLine = f.readLine().trimmed()).length() > 0 && !f.atEnd()) {
|
while ((parseLine = f.readLine().trimmed()).length() > 0 && !f.atEnd()) {
|
||||||
if (parseLine.contains("//Log interval: ")) {
|
if (parseLine.contains("//Log interval: ")) {
|
||||||
params[pnr++] = strdup("delta");
|
params[pnr++] = strdup("delta");
|
||||||
params[pnr++] = strdup(parseLine.remove(QString::fromLatin1("//Log interval: ")).trimmed().remove(QString::fromLatin1(" s")).toUtf8().data());
|
params[pnr++] = strdup(qPrintable(parseLine.remove(QString::fromLatin1("//Log interval: ")).trimmed().remove(QString::fromLatin1(" s"))));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1601,7 +1601,7 @@ int parse_seabear_header(const char *filename, char **params, int pnr)
|
||||||
QString needle = "//Mode: ";
|
QString needle = "//Mode: ";
|
||||||
if (parseLine.contains(needle)) {
|
if (parseLine.contains(needle)) {
|
||||||
params[pnr++] = strdup("diveMode");
|
params[pnr++] = strdup("diveMode");
|
||||||
params[pnr++] = strdup(parseLine.replace(needle, QString::fromLatin1("")).prepend("\"").append("\"").toUtf8().data());
|
params[pnr++] = strdup(qPrintable(parseLine.replace(needle, QString::fromLatin1("")).prepend("\"").append("\"")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f.seek(0);
|
f.seek(0);
|
||||||
|
@ -1614,7 +1614,7 @@ int parse_seabear_header(const char *filename, char **params, int pnr)
|
||||||
QString needle = "//Firmware Version: ";
|
QString needle = "//Firmware Version: ";
|
||||||
if (parseLine.contains(needle)) {
|
if (parseLine.contains(needle)) {
|
||||||
params[pnr++] = strdup("Firmware");
|
params[pnr++] = strdup("Firmware");
|
||||||
params[pnr++] = strdup(parseLine.replace(needle, QString::fromLatin1("")).prepend("\"").append("\"").toUtf8().data());
|
params[pnr++] = strdup(qPrintable(parseLine.replace(needle, QString::fromLatin1("")).prepend("\"").append("\"")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f.seek(0);
|
f.seek(0);
|
||||||
|
@ -1623,7 +1623,7 @@ int parse_seabear_header(const char *filename, char **params, int pnr)
|
||||||
QString needle = "//Serial number: ";
|
QString needle = "//Serial number: ";
|
||||||
if (parseLine.contains(needle)) {
|
if (parseLine.contains(needle)) {
|
||||||
params[pnr++] = strdup("Serial");
|
params[pnr++] = strdup("Serial");
|
||||||
params[pnr++] = strdup(parseLine.replace(needle, QString::fromLatin1("")).prepend("\"").append("\"").toUtf8().data());
|
params[pnr++] = strdup(qPrintable(parseLine.replace(needle, QString::fromLatin1("")).prepend("\"").append("\"")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f.seek(0);
|
f.seek(0);
|
||||||
|
@ -1632,7 +1632,7 @@ int parse_seabear_header(const char *filename, char **params, int pnr)
|
||||||
QString needle = "//GF: ";
|
QString needle = "//GF: ";
|
||||||
if (parseLine.contains(needle)) {
|
if (parseLine.contains(needle)) {
|
||||||
params[pnr++] = strdup("GF");
|
params[pnr++] = strdup("GF");
|
||||||
params[pnr++] = strdup(parseLine.replace(needle, QString::fromLatin1("")).prepend("\"").append("\"").toUtf8().data());
|
params[pnr++] = strdup(qPrintable(parseLine.replace(needle, QString::fromLatin1("")).prepend("\"").append("\"")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f.seek(0);
|
f.seek(0);
|
||||||
|
@ -1735,7 +1735,7 @@ extern "C" void cache_insert(int tissue, int timestep, enum inertgas inertgas, d
|
||||||
|
|
||||||
extern "C" void print_qt_versions()
|
extern "C" void print_qt_versions()
|
||||||
{
|
{
|
||||||
printf("%s\n", QStringLiteral("built with Qt Version %1, runtime from Qt Version %2").arg(QT_VERSION_STR).arg(qVersion()).toUtf8().data());
|
printf("%s\n", qPrintable(QStringLiteral("built with Qt Version %1, runtime from Qt Version %2").arg(QT_VERSION_STR).arg(qVersion())));
|
||||||
}
|
}
|
||||||
|
|
||||||
QMutex planLock;
|
QMutex planLock;
|
||||||
|
|
|
@ -1914,9 +1914,9 @@ void DisplaySettingsObjectWrapper::setDivelistFont(const QString& value)
|
||||||
s.beginGroup(group);
|
s.beginGroup(group);
|
||||||
s.setValue("divelist_font", value);
|
s.setValue("divelist_font", value);
|
||||||
|
|
||||||
if (!subsurface_ignore_font(newValue.toUtf8().constData())) {
|
if (!subsurface_ignore_font(qPrintable(newValue))) {
|
||||||
free((void *)prefs.divelist_font);
|
free((void *)prefs.divelist_font);
|
||||||
prefs.divelist_font = strdup(newValue.toUtf8().constData());
|
prefs.divelist_font = strdup(qPrintable(newValue));
|
||||||
qApp->setFont(QFont(newValue));
|
qApp->setFont(QFont(newValue));
|
||||||
}
|
}
|
||||||
emit divelistFontChanged(newValue);
|
emit divelistFontChanged(newValue);
|
||||||
|
@ -2265,11 +2265,11 @@ void SettingsObjectWrapper::load()
|
||||||
QString fontName = defaultFont.toString();
|
QString fontName = defaultFont.toString();
|
||||||
if (fontName.contains(","))
|
if (fontName.contains(","))
|
||||||
fontName = fontName.left(fontName.indexOf(","));
|
fontName = fontName.left(fontName.indexOf(","));
|
||||||
if (subsurface_ignore_font(fontName.toUtf8().constData())) {
|
if (subsurface_ignore_font(qPrintable(fontName))) {
|
||||||
defaultFont = QFont(prefs.divelist_font);
|
defaultFont = QFont(prefs.divelist_font);
|
||||||
} else {
|
} else {
|
||||||
free((void *)prefs.divelist_font);
|
free((void *)prefs.divelist_font);
|
||||||
prefs.divelist_font = strdup(fontName.toUtf8().constData());
|
prefs.divelist_font = strdup(qPrintable(fontName));
|
||||||
}
|
}
|
||||||
defaultFont.setPointSizeF(prefs.font_size);
|
defaultFont.setPointSizeF(prefs.font_size);
|
||||||
qApp->setFont(defaultFont);
|
qApp->setFont(defaultFont);
|
||||||
|
|
|
@ -910,9 +910,9 @@ void ConfigureDiveComputerDialog::getDeviceData()
|
||||||
#else
|
#else
|
||||||
QString device = ui.device->currentText();
|
QString device = ui.device->currentText();
|
||||||
#endif
|
#endif
|
||||||
device_data.devname = strdup(device.toUtf8().data());
|
device_data.devname = strdup(qPrintable(device));
|
||||||
device_data.vendor = strdup(selected_vendor.toUtf8().data());
|
device_data.vendor = strdup(qPrintable(selected_vendor));
|
||||||
device_data.product = strdup(selected_product.toUtf8().data());
|
device_data.product = strdup(qPrintable(selected_product));
|
||||||
|
|
||||||
device_data.descriptor = descriptorLookup.value(selected_vendor + selected_product);
|
device_data.descriptor = descriptorLookup.value(selected_vendor + selected_product);
|
||||||
device_data.deviceid = device_data.diveid = 0;
|
device_data.deviceid = device_data.diveid = 0;
|
||||||
|
@ -1479,7 +1479,7 @@ void ConfigureDiveComputerDialog::pickLogFile()
|
||||||
filename, tr("Log files") + " (*.log)");
|
filename, tr("Log files") + " (*.log)");
|
||||||
if (!logFile.isEmpty()) {
|
if (!logFile.isEmpty()) {
|
||||||
free(logfile_name);
|
free(logfile_name);
|
||||||
logfile_name = strdup(logFile.toUtf8().data());
|
logfile_name = strdup(qPrintable(logFile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -949,7 +949,7 @@ void DiveListView::matchImagesToDives(QStringList fileNames)
|
||||||
for_each_dive (j, dive) {
|
for_each_dive (j, dive) {
|
||||||
if (!dive->selected)
|
if (!dive->selected)
|
||||||
continue;
|
continue;
|
||||||
dive_create_picture(dive, copy_string(fileName.toUtf8().data()), shiftDialog.amount(), shiftDialog.matchAll());
|
dive_create_picture(dive, copy_string(qPrintable(fileName)), shiftDialog.amount(), shiftDialog.matchAll());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ void DiveLogExportDialog::on_buttonBox_accepted()
|
||||||
filename = QFileDialog::getSaveFileName(this, tr("Export world map"), lastDir,
|
filename = QFileDialog::getSaveFileName(this, tr("Export world map"), lastDir,
|
||||||
tr("HTML files") + " (*.html)");
|
tr("HTML files") + " (*.html)");
|
||||||
if (!filename.isNull() && !filename.isEmpty())
|
if (!filename.isNull() && !filename.isEmpty())
|
||||||
export_worldmap_HTML(filename.toUtf8().data(), ui->exportSelected->isChecked());
|
export_worldmap_HTML(qPrintable(filename), ui->exportSelected->isChecked());
|
||||||
} else if (ui->exportSubsurfaceXML->isChecked()) {
|
} else if (ui->exportSubsurfaceXML->isChecked()) {
|
||||||
filename = QFileDialog::getSaveFileName(this, tr("Export Subsurface XML"), lastDir,
|
filename = QFileDialog::getSaveFileName(this, tr("Export Subsurface XML"), lastDir,
|
||||||
tr("Subsurface files") + " (*.ssrf *.xml)");
|
tr("Subsurface files") + " (*.ssrf *.xml)");
|
||||||
|
@ -167,11 +167,11 @@ void DiveLogExportDialog::on_buttonBox_accepted()
|
||||||
} else if (ui->exportImageDepths->isChecked()) {
|
} else if (ui->exportImageDepths->isChecked()) {
|
||||||
filename = QFileDialog::getSaveFileName(this, tr("Save image depths"), lastDir);
|
filename = QFileDialog::getSaveFileName(this, tr("Save image depths"), lastDir);
|
||||||
if (!filename.isNull() && !filename.isEmpty())
|
if (!filename.isNull() && !filename.isEmpty())
|
||||||
export_depths(filename.toUtf8().data(), ui->exportSelected->isChecked());
|
export_depths(qPrintable(filename), ui->exportSelected->isChecked());
|
||||||
} else if (ui->exportTeX->isChecked()) {
|
} else if (ui->exportTeX->isChecked()) {
|
||||||
filename = QFileDialog::getSaveFileName(this, tr("Export to TeX file"), lastDir, tr("TeX files") + " (*.tex)");
|
filename = QFileDialog::getSaveFileName(this, tr("Export to TeX file"), lastDir, tr("TeX files") + " (*.tex)");
|
||||||
if (!filename.isNull() && !filename.isEmpty())
|
if (!filename.isNull() && !filename.isEmpty())
|
||||||
export_TeX(filename.toUtf8().data(), ui->exportSelected->isChecked());
|
export_TeX(qPrintable(filename), ui->exportSelected->isChecked());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -226,7 +226,7 @@ void DiveLogExportDialog::export_depths(const char *filename, const bool selecte
|
||||||
|
|
||||||
f = subsurface_fopen(filename, "w+");
|
f = subsurface_fopen(filename, "w+");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
report_error(tr("Can't open file %s").toUtf8().data(), filename);
|
report_error(qPrintable(tr("Can't open file %s")), filename);
|
||||||
} else {
|
} else {
|
||||||
flush_buffer(&buf, f); /*check for writing errors? */
|
flush_buffer(&buf, f); /*check for writing errors? */
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
@ -325,7 +325,7 @@ void DiveLogExportDialog::export_TeX(const char *filename, const bool selected_o
|
||||||
site ? put_format(&buf, "\\def\\gpslat{%f}\n", site->latitude.udeg / 1000000.0) : put_format(&buf, "\\def\\gpslat{}\n");
|
site ? put_format(&buf, "\\def\\gpslat{%f}\n", site->latitude.udeg / 1000000.0) : put_format(&buf, "\\def\\gpslat{}\n");
|
||||||
site ? put_format(&buf, "\\def\\gpslon{%f}\n", site->longitude.udeg / 1000000.0) : put_format(&buf, "\\def\\gpslon{}\n");
|
site ? put_format(&buf, "\\def\\gpslon{%f}\n", site->longitude.udeg / 1000000.0) : put_format(&buf, "\\def\\gpslon{}\n");
|
||||||
put_format(&buf, "\\def\\computer{%s}\n", dive->dc.model);
|
put_format(&buf, "\\def\\computer{%s}\n", dive->dc.model);
|
||||||
put_format(&buf, "\\def\\country{%s}\n", country.toUtf8().data());
|
put_format(&buf, "\\def\\country{%s}\n", qPrintable(country));
|
||||||
put_format(&buf, "\\def\\time{%u:%02u}\n", FRACTION(dive->duration.seconds, 60));
|
put_format(&buf, "\\def\\time{%u:%02u}\n", FRACTION(dive->duration.seconds, 60));
|
||||||
|
|
||||||
put_format(&buf, "\n%% Dive Profile Details:\n");
|
put_format(&buf, "\n%% Dive Profile Details:\n");
|
||||||
|
@ -337,8 +337,8 @@ void DiveLogExportDialog::export_TeX(const char *filename, const bool selected_o
|
||||||
dive->meandepth.mm ? put_format(&buf, "\\def\\meandepth{%.1f\\depthunit}\n", get_depth_units(dive->meandepth.mm, NULL, &unit)) : put_format(&buf, "\\def\\meandepth{}\n");
|
dive->meandepth.mm ? put_format(&buf, "\\def\\meandepth{%.1f\\depthunit}\n", get_depth_units(dive->meandepth.mm, NULL, &unit)) : put_format(&buf, "\\def\\meandepth{}\n");
|
||||||
|
|
||||||
put_format(&buf, "\\def\\type{%s}\n", dive->tag_list ? dive->tag_list->tag->name : "");
|
put_format(&buf, "\\def\\type{%s}\n", dive->tag_list ? dive->tag_list->tag->name : "");
|
||||||
put_format(&buf, "\\def\\viz{%s}\n", viz.toUtf8().data());
|
put_format(&buf, "\\def\\viz{%s}\n", qPrintable(viz));
|
||||||
put_format(&buf, "\\def\\rating{%s}\n", rating.toUtf8().data());
|
put_format(&buf, "\\def\\rating{%s}\n", qPrintable(rating));
|
||||||
put_format(&buf, "\\def\\plot{\\includegraphics[width=9cm,height=4cm]{profile%d}}\n", dive->number);
|
put_format(&buf, "\\def\\plot{\\includegraphics[width=9cm,height=4cm]{profile%d}}\n", dive->number);
|
||||||
put_format(&buf, "\\def\\comment{%s}\n", dive->notes ? dive->notes : "");
|
put_format(&buf, "\\def\\comment{%s}\n", dive->notes ? dive->notes : "");
|
||||||
put_format(&buf, "\\def\\buddy{%s}\n", dive->buddy ? dive->buddy : "");
|
put_format(&buf, "\\def\\buddy{%s}\n", dive->buddy ? dive->buddy : "");
|
||||||
|
@ -408,7 +408,7 @@ void DiveLogExportDialog::export_TeX(const char *filename, const bool selected_o
|
||||||
|
|
||||||
f = subsurface_fopen(filename, "w+");
|
f = subsurface_fopen(filename, "w+");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
report_error(tr("Can't open file %s").toUtf8().data(), filename);
|
report_error(qPrintable(tr("Can't open file %s")), filename);
|
||||||
} else {
|
} else {
|
||||||
flush_buffer(&buf, f); /*check for writing errors? */
|
flush_buffer(&buf, f); /*check for writing errors? */
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
|
@ -788,10 +788,10 @@ int DiveLogImportDialog::setup_csv_params(QStringList r, char **params, int pnr)
|
||||||
params[pnr++] = intdup(ui->CSVUnits->currentIndex());
|
params[pnr++] = intdup(ui->CSVUnits->currentIndex());
|
||||||
if (hw.length()) {
|
if (hw.length()) {
|
||||||
params[pnr++] = strdup("hw");
|
params[pnr++] = strdup("hw");
|
||||||
params[pnr++] = strdup(hw.toUtf8().data());
|
params[pnr++] = strdup(qPrintable(hw));
|
||||||
} else if (ui->knownImports->currentText().length() > 0) {
|
} else if (ui->knownImports->currentText().length() > 0) {
|
||||||
params[pnr++] = strdup("hw");
|
params[pnr++] = strdup("hw");
|
||||||
params[pnr++] = strdup(ui->knownImports->currentText().prepend("\"").append("\"").toUtf8().data());
|
params[pnr++] = strdup(qPrintable(ui->knownImports->currentText().prepend("\"").append("\"")));
|
||||||
}
|
}
|
||||||
params[pnr++] = NULL;
|
params[pnr++] = NULL;
|
||||||
|
|
||||||
|
@ -850,7 +850,7 @@ void DiveLogImportDialog::on_buttonBox_accepted()
|
||||||
for (int i = 0; i < fileNames.size(); ++i) {
|
for (int i = 0; i < fileNames.size(); ++i) {
|
||||||
if (ui->knownImports->currentText() == "Seabear CSV") {
|
if (ui->knownImports->currentText() == "Seabear CSV") {
|
||||||
|
|
||||||
parse_seabear_log(fileNames[i].toUtf8().data());
|
parse_seabear_log(qPrintable(fileNames[i]));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
char *params[49];
|
char *params[49];
|
||||||
|
@ -866,8 +866,8 @@ void DiveLogImportDialog::on_buttonBox_accepted()
|
||||||
params[pnr++] = strdup("1" + apdRe.cap(2).toLatin1());
|
params[pnr++] = strdup("1" + apdRe.cap(2).toLatin1());
|
||||||
}
|
}
|
||||||
pnr = setup_csv_params(r, params, pnr);
|
pnr = setup_csv_params(r, params, pnr);
|
||||||
parse_csv_file(fileNames[i].toUtf8().data(), params, pnr - 1,
|
parse_csv_file(qPrintable(fileNames[i]), params, pnr - 1,
|
||||||
specialCSV.contains(ui->knownImports->currentIndex()) ? CSVApps[ui->knownImports->currentIndex()].name.toUtf8().data() : "csv");
|
specialCSV.contains(ui->knownImports->currentIndex()) ? qPrintable(CSVApps[ui->knownImports->currentIndex()].name) : "csv");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -927,7 +927,7 @@ void DiveLogImportDialog::on_buttonBox_accepted()
|
||||||
params[pnr++] = intdup(r.indexOf(tr("Water temp.")));
|
params[pnr++] = intdup(r.indexOf(tr("Water temp.")));
|
||||||
params[pnr++] = NULL;
|
params[pnr++] = NULL;
|
||||||
|
|
||||||
parse_manual_file(fileNames[i].toUtf8().data(), params, pnr - 1);
|
parse_manual_file(qPrintable(fileNames[i]), params, pnr - 1);
|
||||||
} else {
|
} else {
|
||||||
char *params[51];
|
char *params[51];
|
||||||
int pnr = 0;
|
int pnr = 0;
|
||||||
|
@ -942,8 +942,8 @@ void DiveLogImportDialog::on_buttonBox_accepted()
|
||||||
params[pnr++] = strdup("1" + apdRe.cap(2).toLatin1());
|
params[pnr++] = strdup("1" + apdRe.cap(2).toLatin1());
|
||||||
}
|
}
|
||||||
pnr = setup_csv_params(r, params, pnr);
|
pnr = setup_csv_params(r, params, pnr);
|
||||||
parse_csv_file(fileNames[i].toUtf8().data(), params, pnr - 1,
|
parse_csv_file(qPrintable(fileNames[i]), params, pnr - 1,
|
||||||
specialCSV.contains(ui->knownImports->currentIndex()) ? CSVApps[ui->knownImports->currentIndex()].name.toUtf8().data() : "csv");
|
specialCSV.contains(ui->knownImports->currentIndex()) ? qPrintable(CSVApps[ui->knownImports->currentIndex()].name) : "csv");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -297,7 +297,7 @@ void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked()
|
||||||
#endif
|
#endif
|
||||||
if (data->vendor() == "Uemis") {
|
if (data->vendor() == "Uemis") {
|
||||||
char *colon;
|
char *colon;
|
||||||
char *devname = strdup(ui.device->currentText().toUtf8().data());
|
char *devname = strdup(qPrintable(ui.device->currentText()));
|
||||||
|
|
||||||
if ((colon = strstr(devname, ":\\ (UEMISSDA)")) != NULL) {
|
if ((colon = strstr(devname, ":\\ (UEMISSDA)")) != NULL) {
|
||||||
*(colon + 2) = '\0';
|
*(colon + 2) = '\0';
|
||||||
|
@ -362,7 +362,7 @@ void DownloadFromDCWidget::pickLogFile()
|
||||||
filename, tr("Log files") + " (*.log)");
|
filename, tr("Log files") + " (*.log)");
|
||||||
if (!logFile.isEmpty()) {
|
if (!logFile.isEmpty()) {
|
||||||
free(logfile_name);
|
free(logfile_name);
|
||||||
logfile_name = copy_string(logFile.toUtf8().data());
|
logfile_name = copy_string(qPrintable(logFile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,7 +388,7 @@ void DownloadFromDCWidget::pickDumpFile()
|
||||||
filename, tr("Dump files") + " (*.bin)");
|
filename, tr("Dump files") + " (*.bin)");
|
||||||
if (!dumpFile.isEmpty()) {
|
if (!dumpFile.isEmpty()) {
|
||||||
free(dumpfile_name);
|
free(dumpfile_name);
|
||||||
dumpfile_name = copy_string(dumpFile.toUtf8().data());
|
dumpfile_name = copy_string(qPrintable(dumpFile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -158,7 +158,7 @@ void LocationInformationWidget::acceptChanges()
|
||||||
{
|
{
|
||||||
char *uiString;
|
char *uiString;
|
||||||
struct dive_site *currentDs;
|
struct dive_site *currentDs;
|
||||||
uiString = copy_string(ui.diveSiteName->text().toUtf8().data());
|
uiString = copy_string(qPrintable(ui.diveSiteName->text()));
|
||||||
if (get_dive_site_by_uuid(displayed_dive_site.uuid) != NULL) {
|
if (get_dive_site_by_uuid(displayed_dive_site.uuid) != NULL) {
|
||||||
currentDs = get_dive_site_by_uuid(displayed_dive_site.uuid);
|
currentDs = get_dive_site_by_uuid(displayed_dive_site.uuid);
|
||||||
} else {
|
} else {
|
||||||
|
@ -175,14 +175,14 @@ void LocationInformationWidget::acceptChanges()
|
||||||
} else {
|
} else {
|
||||||
free(uiString);
|
free(uiString);
|
||||||
}
|
}
|
||||||
uiString = copy_string(ui.diveSiteDescription->text().toUtf8().data());
|
uiString = copy_string(qPrintable(ui.diveSiteDescription->text()));
|
||||||
if (!same_string(uiString, currentDs->description)) {
|
if (!same_string(uiString, currentDs->description)) {
|
||||||
free(currentDs->description);
|
free(currentDs->description);
|
||||||
currentDs->description = uiString;
|
currentDs->description = uiString;
|
||||||
} else {
|
} else {
|
||||||
free(uiString);
|
free(uiString);
|
||||||
}
|
}
|
||||||
uiString = copy_string(ui.diveSiteCountry->text().toUtf8().data());
|
uiString = copy_string(qPrintable(ui.diveSiteCountry->text()));
|
||||||
// if the user entered a different contriy, first update the taxonomy
|
// if the user entered a different contriy, first update the taxonomy
|
||||||
// for the displayed dive site; this below will get copied into the currentDs
|
// for the displayed dive site; this below will get copied into the currentDs
|
||||||
if (!same_string(uiString, taxonomy_get_country(&displayed_dive_site.taxonomy)) &&
|
if (!same_string(uiString, taxonomy_get_country(&displayed_dive_site.taxonomy)) &&
|
||||||
|
@ -193,7 +193,7 @@ void LocationInformationWidget::acceptChanges()
|
||||||
// now update the currentDs (which we then later copy back ontop of displayed_dive_site
|
// now update the currentDs (which we then later copy back ontop of displayed_dive_site
|
||||||
copy_dive_site_taxonomy(&displayed_dive_site, currentDs);
|
copy_dive_site_taxonomy(&displayed_dive_site, currentDs);
|
||||||
|
|
||||||
uiString = copy_string(ui.diveSiteNotes->document()->toPlainText().toUtf8().data());
|
uiString = copy_string(qPrintable(ui.diveSiteNotes->document()->toPlainText()));
|
||||||
if (!same_string(uiString, currentDs->notes)) {
|
if (!same_string(uiString, currentDs->notes)) {
|
||||||
free(currentDs->notes);
|
free(currentDs->notes);
|
||||||
currentDs->notes = uiString;
|
currentDs->notes = uiString;
|
||||||
|
|
|
@ -623,12 +623,12 @@ void MainWindow::on_actionCloudstoragesave_triggered()
|
||||||
information()->acceptChanges();
|
information()->acceptChanges();
|
||||||
|
|
||||||
showProgressBar();
|
showProgressBar();
|
||||||
int error = save_dives(filename.toUtf8().data());
|
int error = save_dives(qPrintable(filename));
|
||||||
hideProgressBar();
|
hideProgressBar();
|
||||||
if (error)
|
if (error)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setCurrentFile(filename.toUtf8().data());
|
setCurrentFile(qPrintable(filename));
|
||||||
mark_divelist_changed(false);
|
mark_divelist_changed(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -935,7 +935,7 @@ void MainWindow::updateVariations(QString variations)
|
||||||
{
|
{
|
||||||
QString notes = QString(displayed_dive.notes);
|
QString notes = QString(displayed_dive.notes);
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
displayed_dive.notes = strdup(notes.replace("VARIATIONS", variations).toUtf8().data());
|
displayed_dive.notes = strdup(qPrintable(notes.replace("VARIATIONS", variations)));
|
||||||
plannerDetails()->divePlanOutput()->setHtml(displayed_dive.notes);
|
plannerDetails()->divePlanOutput()->setHtml(displayed_dive.notes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1683,10 +1683,10 @@ int MainWindow::file_save_as(void)
|
||||||
if (information()->isEditing())
|
if (information()->isEditing())
|
||||||
information()->acceptChanges();
|
information()->acceptChanges();
|
||||||
|
|
||||||
if (save_dives(filename.toUtf8().data()))
|
if (save_dives(qPrintable(filename)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
setCurrentFile(filename.toUtf8().data());
|
setCurrentFile(qPrintable(filename));
|
||||||
mark_divelist_changed(false);
|
mark_divelist_changed(false);
|
||||||
addRecentFile(filename, true);
|
addRecentFile(filename, true);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -324,7 +324,7 @@ void TankUseDelegate::setEditorData(QWidget * editor, const QModelIndex & index)
|
||||||
{
|
{
|
||||||
QComboBox *comboBox = qobject_cast<QComboBox*>(editor);
|
QComboBox *comboBox = qobject_cast<QComboBox*>(editor);
|
||||||
QString indexString = index.data().toString();
|
QString indexString = index.data().toString();
|
||||||
comboBox->setCurrentIndex(cylinderuse_from_text(indexString.toUtf8().data()));
|
comboBox->setCurrentIndex(cylinderuse_from_text(qPrintable(indexString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TankUseDelegate::setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const
|
void TankUseDelegate::setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const
|
||||||
|
|
|
@ -319,7 +319,7 @@ void ShiftImageTimesDialog::syncCameraClicked()
|
||||||
scene->addPixmap(picture.scaled(ui.DCImage->size()));
|
scene->addPixmap(picture.scaled(ui.DCImage->size()));
|
||||||
ui.DCImage->setScene(scene);
|
ui.DCImage->setScene(scene);
|
||||||
|
|
||||||
dcImageEpoch = picture_get_timestamp(fileNames.at(0).toUtf8().data());
|
dcImageEpoch = picture_get_timestamp(qPrintable(fileNames.at(0)));
|
||||||
QDateTime dcDateTime = QDateTime::fromTime_t(dcImageEpoch, Qt::UTC);
|
QDateTime dcDateTime = QDateTime::fromTime_t(dcImageEpoch, Qt::UTC);
|
||||||
ui.dcTime->setDateTime(dcDateTime);
|
ui.dcTime->setDateTime(dcDateTime);
|
||||||
connect(ui.dcTime, SIGNAL(dateTimeChanged(const QDateTime &)), this, SLOT(dcDateTimeChanged(const QDateTime &)));
|
connect(ui.dcTime, SIGNAL(dateTimeChanged(const QDateTime &)), this, SLOT(dcDateTimeChanged(const QDateTime &)));
|
||||||
|
@ -393,11 +393,11 @@ void ShiftImageTimesDialog::updateInvalid()
|
||||||
ui.invalidFilesText->append(tr("\nFiles with inappropriate date/time") + ":");
|
ui.invalidFilesText->append(tr("\nFiles with inappropriate date/time") + ":");
|
||||||
|
|
||||||
Q_FOREACH (const QString &fileName, fileNames) {
|
Q_FOREACH (const QString &fileName, fileNames) {
|
||||||
if (picture_check_valid(fileName.toUtf8().data(), m_amount))
|
if (picture_check_valid(qPrintable(fileName), m_amount))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// We've found invalid image
|
// We've found invalid image
|
||||||
timestamp = picture_get_timestamp(fileName.toUtf8().data());
|
timestamp = picture_get_timestamp(qPrintable(fileName));
|
||||||
time_first.setTime_t(timestamp + m_amount);
|
time_first.setTime_t(timestamp + m_amount);
|
||||||
if (timestamp == 0)
|
if (timestamp == 0)
|
||||||
ui.invalidFilesText->append(fileName + " - " + tr("No Exif date/time found"));
|
ui.invalidFilesText->append(fileName + " - " + tr("No Exif date/time found"));
|
||||||
|
|
|
@ -335,7 +335,7 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton *button)
|
||||||
bool d_eq_f = (qDialogUid == qFileUid);
|
bool d_eq_f = (qDialogUid == qFileUid);
|
||||||
if (!d_eq_f || s_eq_d)
|
if (!d_eq_f || s_eq_d)
|
||||||
s.setValue("subsurface_webservice_uid", qDialogUid);
|
s.setValue("subsurface_webservice_uid", qDialogUid);
|
||||||
set_userid(qDialogUid.toLocal8Bit().data());
|
set_userid(qPrintable(qDialogUid));
|
||||||
}
|
}
|
||||||
s.sync();
|
s.sync();
|
||||||
hide();
|
hide();
|
||||||
|
|
|
@ -1082,7 +1082,7 @@ void MainTab::on_buddy_textChanged()
|
||||||
if (editMode == IGNORE || acceptingEdit == true)
|
if (editMode == IGNORE || acceptingEdit == true)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (same_string(displayed_dive.buddy, ui.buddy->toPlainText().toUtf8().data()))
|
if (same_string(displayed_dive.buddy, qPrintable(ui.buddy->toPlainText())))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QStringList text_list = ui.buddy->toPlainText().split(",", QString::SkipEmptyParts);
|
QStringList text_list = ui.buddy->toPlainText().split(",", QString::SkipEmptyParts);
|
||||||
|
@ -1090,7 +1090,7 @@ void MainTab::on_buddy_textChanged()
|
||||||
text_list[i] = text_list[i].trimmed();
|
text_list[i] = text_list[i].trimmed();
|
||||||
QString text = text_list.join(", ");
|
QString text = text_list.join(", ");
|
||||||
free(displayed_dive.buddy);
|
free(displayed_dive.buddy);
|
||||||
displayed_dive.buddy = strdup(text.toUtf8().data());
|
displayed_dive.buddy = strdup(qPrintable(text));
|
||||||
markChangedWidget(ui.buddy);
|
markChangedWidget(ui.buddy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1099,7 +1099,7 @@ void MainTab::on_divemaster_textChanged()
|
||||||
if (editMode == IGNORE || acceptingEdit == true)
|
if (editMode == IGNORE || acceptingEdit == true)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (same_string(displayed_dive.divemaster, ui.divemaster->toPlainText().toUtf8().data()))
|
if (same_string(displayed_dive.divemaster, qPrintable(ui.divemaster->toPlainText())))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QStringList text_list = ui.divemaster->toPlainText().split(",", QString::SkipEmptyParts);
|
QStringList text_list = ui.divemaster->toPlainText().split(",", QString::SkipEmptyParts);
|
||||||
|
@ -1107,7 +1107,7 @@ void MainTab::on_divemaster_textChanged()
|
||||||
text_list[i] = text_list[i].trimmed();
|
text_list[i] = text_list[i].trimmed();
|
||||||
QString text = text_list.join(", ");
|
QString text = text_list.join(", ");
|
||||||
free(displayed_dive.divemaster);
|
free(displayed_dive.divemaster);
|
||||||
displayed_dive.divemaster = strdup(text.toUtf8().data());
|
displayed_dive.divemaster = strdup(qPrintable(text));
|
||||||
markChangedWidget(ui.divemaster);
|
markChangedWidget(ui.divemaster);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1241,7 +1241,7 @@ void MainTab::saveTags()
|
||||||
taglist_free(displayed_dive.tag_list);
|
taglist_free(displayed_dive.tag_list);
|
||||||
displayed_dive.tag_list = NULL;
|
displayed_dive.tag_list = NULL;
|
||||||
Q_FOREACH (const QString& tag, ui.tagWidget->getBlockStringList())
|
Q_FOREACH (const QString& tag, ui.tagWidget->getBlockStringList())
|
||||||
taglist_add_tag(&displayed_dive.tag_list, tag.toUtf8().data());
|
taglist_add_tag(&displayed_dive.tag_list, qPrintable(tag));
|
||||||
taglist_cleanup(&displayed_dive.tag_list);
|
taglist_cleanup(&displayed_dive.tag_list);
|
||||||
|
|
||||||
// figure out which tags were added and which tags were removed
|
// figure out which tags were added and which tags were removed
|
||||||
|
@ -1352,7 +1352,7 @@ void MainTab::on_tagWidget_textChanged()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
taglist_get_tagstring(displayed_dive.tag_list, buf, 1024);
|
taglist_get_tagstring(displayed_dive.tag_list, buf, 1024);
|
||||||
if (same_string(buf, ui.tagWidget->toPlainText().toUtf8().data()))
|
if (same_string(buf, qPrintable(ui.tagWidget->toPlainText())))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
markChangedWidget(ui.tagWidget);
|
markChangedWidget(ui.tagWidget);
|
||||||
|
@ -1407,7 +1407,7 @@ void MainTab::on_suit_textChanged(const QString &text)
|
||||||
if (editMode == IGNORE || acceptingEdit == true)
|
if (editMode == IGNORE || acceptingEdit == true)
|
||||||
return;
|
return;
|
||||||
free(displayed_dive.suit);
|
free(displayed_dive.suit);
|
||||||
displayed_dive.suit = strdup(text.toUtf8().data());
|
displayed_dive.suit = strdup(qPrintable(text));
|
||||||
markChangedWidget(ui.suit);
|
markChangedWidget(ui.suit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1416,18 +1416,18 @@ void MainTab::on_notes_textChanged()
|
||||||
if (editMode == IGNORE || acceptingEdit == true)
|
if (editMode == IGNORE || acceptingEdit == true)
|
||||||
return;
|
return;
|
||||||
if (currentTrip) {
|
if (currentTrip) {
|
||||||
if (same_string(displayedTrip.notes, ui.notes->toPlainText().toUtf8().data()))
|
if (same_string(displayedTrip.notes, qPrintable(ui.notes->toPlainText())))
|
||||||
return;
|
return;
|
||||||
free(displayedTrip.notes);
|
free(displayedTrip.notes);
|
||||||
displayedTrip.notes = strdup(ui.notes->toPlainText().toUtf8().data());
|
displayedTrip.notes = strdup(qPrintable(ui.notes->toPlainText()));
|
||||||
} else {
|
} else {
|
||||||
if (same_string(displayed_dive.notes, ui.notes->toPlainText().toUtf8().data()))
|
if (same_string(displayed_dive.notes, qPrintable(ui.notes->toPlainText())))
|
||||||
return;
|
return;
|
||||||
free(displayed_dive.notes);
|
free(displayed_dive.notes);
|
||||||
if (ui.notes->toHtml().indexOf("<table") != -1)
|
if (ui.notes->toHtml().indexOf("<table") != -1)
|
||||||
displayed_dive.notes = strdup(ui.notes->toHtml().toUtf8().data());
|
displayed_dive.notes = strdup(qPrintable(ui.notes->toHtml()));
|
||||||
else
|
else
|
||||||
displayed_dive.notes = strdup(ui.notes->toPlainText().toUtf8().data());
|
displayed_dive.notes = strdup(qPrintable(ui.notes->toPlainText()));
|
||||||
}
|
}
|
||||||
markChangedWidget(ui.notes);
|
markChangedWidget(ui.notes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,7 +250,7 @@ void TemplateLayout::writeTemplate(QString template_name, QString grantlee_templ
|
||||||
{
|
{
|
||||||
QFile qfile(getPrintingTemplatePathUser() + QDir::separator() + template_name);
|
QFile qfile(getPrintingTemplatePathUser() + QDir::separator() + template_name);
|
||||||
if (qfile.open(QFile::ReadWrite | QFile::Text)) {
|
if (qfile.open(QFile::ReadWrite | QFile::Text)) {
|
||||||
qfile.write(grantlee_template.toUtf8().data());
|
qfile.write(qPrintable(grantlee_template));
|
||||||
qfile.resize(qfile.pos());
|
qfile.resize(qfile.pos());
|
||||||
qfile.close();
|
qfile.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,7 +144,7 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false),
|
||||||
connect(qobject_cast<QApplication *>(QApplication::instance()), &QApplication::applicationStateChanged, this, &QMLManager::applicationStateChanged);
|
connect(qobject_cast<QApplication *>(QApplication::instance()), &QApplication::applicationStateChanged, this, &QMLManager::applicationStateChanged);
|
||||||
|
|
||||||
QString libdcLogFileName = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation).first() + "/libdivecomputer.log";
|
QString libdcLogFileName = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation).first() + "/libdivecomputer.log";
|
||||||
logfile_name = strdup(libdcLogFileName.toUtf8().data());
|
logfile_name = strdup(qPrintable(libdcLogFileName));
|
||||||
#if defined(Q_OS_ANDROID)
|
#if defined(Q_OS_ANDROID)
|
||||||
appLogFileName = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation).first() + "/subsurface.log";
|
appLogFileName = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation).first() + "/subsurface.log";
|
||||||
appLogFile.setFileName(appLogFileName);
|
appLogFile.setFileName(appLogFileName);
|
||||||
|
@ -1640,7 +1640,7 @@ void writeToAppLogFile(QString logText)
|
||||||
void QMLManager::writeToAppLogFile(QString logText)
|
void QMLManager::writeToAppLogFile(QString logText)
|
||||||
{
|
{
|
||||||
if (appLogFileOpen) {
|
if (appLogFileOpen) {
|
||||||
appLogFile.write(logText.toUtf8().data());
|
appLogFile.write(qPrintable(logText));
|
||||||
appLogFile.flush();
|
appLogFile.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,9 +179,9 @@ void DiveEventItem::setupToolTipString(struct gasmix *lastgasmix)
|
||||||
bool icd = isobaric_counterdiffusion(lastgasmix, mix, &icd_data);
|
bool icd = isobaric_counterdiffusion(lastgasmix, mix, &icd_data);
|
||||||
if (icd_data.dHe < 0) {
|
if (icd_data.dHe < 0) {
|
||||||
put_format(&mb, "\n%s %s:%+.3g%% %s:%+.3g%%%s%+.3g%%",
|
put_format(&mb, "\n%s %s:%+.3g%% %s:%+.3g%%%s%+.3g%%",
|
||||||
tr("ICD").toUtf8().constData(),
|
qPrintable(tr("ICD")),
|
||||||
tr("ΔHe").toUtf8().constData(), icd_data.dHe / 10.0,
|
qPrintable(tr("ΔHe")), icd_data.dHe / 10.0,
|
||||||
tr("ΔN₂").toUtf8().constData(), icd_data.dN2 / 10.0,
|
qPrintable(tr("ΔN₂")), icd_data.dN2 / 10.0,
|
||||||
icd ? ">" : "<", lrint(-icd_data.dHe / 5.0) / 10.0);
|
icd ? ">" : "<", lrint(-icd_data.dHe / 5.0) / 10.0);
|
||||||
name += QString::fromUtf8(mb.buffer, mb.len);
|
name += QString::fromUtf8(mb.buffer, mb.len);
|
||||||
free_buffer(&mb);
|
free_buffer(&mb);
|
||||||
|
|
|
@ -1582,7 +1582,7 @@ void ProfileWidget2::changeGas()
|
||||||
gasChangeEvent = gasChangeEvent->next;
|
gasChangeEvent = gasChangeEvent->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
validate_gas(gas.toUtf8().constData(), &gasmix);
|
validate_gas(qPrintable(gas), &gasmix);
|
||||||
QRegExp rx("\\(\\D*(\\d+)");
|
QRegExp rx("\\(\\D*(\\d+)");
|
||||||
int tank;
|
int tank;
|
||||||
if (rx.indexIn(action->text()) > -1) {
|
if (rx.indexIn(action->text()) > -1) {
|
||||||
|
@ -1667,8 +1667,8 @@ void ProfileWidget2::editName()
|
||||||
// order is important! first update the current dive (by matching the unchanged event),
|
// order is important! first update the current dive (by matching the unchanged event),
|
||||||
// then update the displayed dive (as event is part of the events on displayed dive
|
// then update the displayed dive (as event is part of the events on displayed dive
|
||||||
// and will be freed as part of changing the name!
|
// and will be freed as part of changing the name!
|
||||||
update_event_name(current_dive, event, newName.toUtf8().data());
|
update_event_name(current_dive, event, qPrintable(newName));
|
||||||
update_event_name(&displayed_dive, event, newName.toUtf8().data());
|
update_event_name(&displayed_dive, event, qPrintable(newName));
|
||||||
invalidate_dive_cache(current_dive);
|
invalidate_dive_cache(current_dive);
|
||||||
mark_divelist_changed(true);
|
mark_divelist_changed(true);
|
||||||
replot();
|
replot();
|
||||||
|
|
|
@ -320,7 +320,7 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
|
||||||
TankInfoModel *tanks = TankInfoModel::instance();
|
TankInfoModel *tanks = TankInfoModel::instance();
|
||||||
QModelIndexList matches = tanks->match(tanks->index(0, 0), Qt::DisplayRole, cyl->type.description);
|
QModelIndexList matches = tanks->match(tanks->index(0, 0), Qt::DisplayRole, cyl->type.description);
|
||||||
|
|
||||||
cyl->type.size = string_to_volume(vString.toUtf8().data(), cyl->type.workingpressure);
|
cyl->type.size = string_to_volume(qPrintable(vString), cyl->type.workingpressure);
|
||||||
mark_divelist_changed(true);
|
mark_divelist_changed(true);
|
||||||
if (!matches.isEmpty())
|
if (!matches.isEmpty())
|
||||||
tanks->setData(tanks->index(matches.first().row(), TankInfoModel::ML), cyl->type.size.mliter);
|
tanks->setData(tanks->index(matches.first().row(), TankInfoModel::ML), cyl->type.size.mliter);
|
||||||
|
@ -331,7 +331,7 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
|
||||||
if (CHANGED()) {
|
if (CHANGED()) {
|
||||||
TankInfoModel *tanks = TankInfoModel::instance();
|
TankInfoModel *tanks = TankInfoModel::instance();
|
||||||
QModelIndexList matches = tanks->match(tanks->index(0, 0), Qt::DisplayRole, cyl->type.description);
|
QModelIndexList matches = tanks->match(tanks->index(0, 0), Qt::DisplayRole, cyl->type.description);
|
||||||
cyl->type.workingpressure = string_to_pressure(vString.toUtf8().data());
|
cyl->type.workingpressure = string_to_pressure(qPrintable(vString));
|
||||||
if (!matches.isEmpty())
|
if (!matches.isEmpty())
|
||||||
tanks->setData(tanks->index(matches.first().row(), TankInfoModel::BAR), cyl->type.workingpressure.mbar / 1000.0);
|
tanks->setData(tanks->index(matches.first().row(), TankInfoModel::BAR), cyl->type.workingpressure.mbar / 1000.0);
|
||||||
changed = true;
|
changed = true;
|
||||||
|
@ -339,20 +339,20 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
|
||||||
break;
|
break;
|
||||||
case START:
|
case START:
|
||||||
if (CHANGED()) {
|
if (CHANGED()) {
|
||||||
cyl->start = string_to_pressure(vString.toUtf8().data());
|
cyl->start = string_to_pressure(qPrintable(vString));
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case END:
|
case END:
|
||||||
if (CHANGED()) {
|
if (CHANGED()) {
|
||||||
//&& (!cyl->start.mbar || string_to_pressure(vString.toUtf8().data()).mbar <= cyl->start.mbar)) {
|
//&& (!cyl->start.mbar || string_to_pressure(qPrintable(vString)).mbar <= cyl->start.mbar)) {
|
||||||
cyl->end = string_to_pressure(vString.toUtf8().data());
|
cyl->end = string_to_pressure(qPrintable(vString));
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case O2:
|
case O2:
|
||||||
if (CHANGED()) {
|
if (CHANGED()) {
|
||||||
cyl->gasmix.o2 = string_to_fraction(vString.toUtf8().data());
|
cyl->gasmix.o2 = string_to_fraction(qPrintable(vString));
|
||||||
// fO2 + fHe must not be greater than 1
|
// fO2 + fHe must not be greater than 1
|
||||||
if (get_o2(&cyl->gasmix) + get_he(&cyl->gasmix) > 1000)
|
if (get_o2(&cyl->gasmix) + get_he(&cyl->gasmix) > 1000)
|
||||||
cyl->gasmix.he.permille = 1000 - get_o2(&cyl->gasmix);
|
cyl->gasmix.he.permille = 1000 - get_o2(&cyl->gasmix);
|
||||||
|
@ -369,7 +369,7 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
|
||||||
break;
|
break;
|
||||||
case HE:
|
case HE:
|
||||||
if (CHANGED()) {
|
if (CHANGED()) {
|
||||||
cyl->gasmix.he = string_to_fraction(vString.toUtf8().data());
|
cyl->gasmix.he = string_to_fraction(qPrintable(vString));
|
||||||
// fO2 + fHe must not be greater than 1
|
// fO2 + fHe must not be greater than 1
|
||||||
if (get_o2(&cyl->gasmix) + get_he(&cyl->gasmix) > 1000)
|
if (get_o2(&cyl->gasmix) + get_he(&cyl->gasmix) > 1000)
|
||||||
cyl->gasmix.o2.permille = 1000 - get_he(&cyl->gasmix);
|
cyl->gasmix.o2.permille = 1000 - get_he(&cyl->gasmix);
|
||||||
|
@ -379,20 +379,20 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
|
||||||
break;
|
break;
|
||||||
case DEPTH:
|
case DEPTH:
|
||||||
if (CHANGED()) {
|
if (CHANGED()) {
|
||||||
cyl->depth = string_to_depth(vString.toUtf8().data());
|
cyl->depth = string_to_depth(qPrintable(vString));
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MOD:
|
case MOD:
|
||||||
if (CHANGED()) {
|
if (CHANGED()) {
|
||||||
if (QString::compare(vString.toUtf8().data(), "*") == 0) {
|
if (QString::compare(qPrintable(vString), "*") == 0) {
|
||||||
cyl->bestmix_o2 = true;
|
cyl->bestmix_o2 = true;
|
||||||
// Calculate fO2 for max. depth
|
// Calculate fO2 for max. depth
|
||||||
cyl->gasmix.o2 = best_o2(displayed_dive.maxdepth, &displayed_dive);
|
cyl->gasmix.o2 = best_o2(displayed_dive.maxdepth, &displayed_dive);
|
||||||
} else {
|
} else {
|
||||||
cyl->bestmix_o2 = false;
|
cyl->bestmix_o2 = false;
|
||||||
// Calculate fO2 for input depth
|
// Calculate fO2 for input depth
|
||||||
cyl->gasmix.o2 = best_o2(string_to_depth(vString.toUtf8().data()), &displayed_dive);
|
cyl->gasmix.o2 = best_o2(string_to_depth(qPrintable(vString)), &displayed_dive);
|
||||||
}
|
}
|
||||||
pressure_t modpO2;
|
pressure_t modpO2;
|
||||||
modpO2.mbar = prefs.decopo2;
|
modpO2.mbar = prefs.decopo2;
|
||||||
|
@ -402,14 +402,14 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
|
||||||
break;
|
break;
|
||||||
case MND:
|
case MND:
|
||||||
if (CHANGED()) {
|
if (CHANGED()) {
|
||||||
if (QString::compare(vString.toUtf8().data(), "*") == 0) {
|
if (QString::compare(qPrintable(vString), "*") == 0) {
|
||||||
cyl->bestmix_he = true;
|
cyl->bestmix_he = true;
|
||||||
// Calculate fO2 for max. depth
|
// Calculate fO2 for max. depth
|
||||||
cyl->gasmix.he = best_he(displayed_dive.maxdepth, &displayed_dive);
|
cyl->gasmix.he = best_he(displayed_dive.maxdepth, &displayed_dive);
|
||||||
} else {
|
} else {
|
||||||
cyl->bestmix_he = false;
|
cyl->bestmix_he = false;
|
||||||
// Calculate fHe for input depth
|
// Calculate fHe for input depth
|
||||||
cyl->gasmix.he = best_he(string_to_depth(vString.toUtf8().data()), &displayed_dive);
|
cyl->gasmix.he = best_he(string_to_depth(qPrintable(vString)), &displayed_dive);
|
||||||
}
|
}
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,7 +161,7 @@ void DivePictureModel::removePicture(const QString &fileUrl, bool last)
|
||||||
int i;
|
int i;
|
||||||
struct dive *dive;
|
struct dive *dive;
|
||||||
for_each_dive (i, dive) {
|
for_each_dive (i, dive) {
|
||||||
if (dive->selected && dive_remove_picture(dive, fileUrl.toUtf8().data()))
|
if (dive->selected && dive_remove_picture(dive, qPrintable(fileUrl)))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (last) {
|
if (last) {
|
||||||
|
|
|
@ -160,7 +160,7 @@ void DivePlannerPointsModel::setupCylinders()
|
||||||
}
|
}
|
||||||
if (cylinder_none(&displayed_dive.cylinder[0])) {
|
if (cylinder_none(&displayed_dive.cylinder[0])) {
|
||||||
// roughly an AL80
|
// roughly an AL80
|
||||||
displayed_dive.cylinder[0].type.description = strdup(tr("unknown").toUtf8().constData());
|
displayed_dive.cylinder[0].type.description = strdup(qPrintable(tr("unknown")));
|
||||||
displayed_dive.cylinder[0].type.size.mliter = 11100;
|
displayed_dive.cylinder[0].type.size.mliter = 11100;
|
||||||
displayed_dive.cylinder[0].type.workingpressure.mbar = 207000;
|
displayed_dive.cylinder[0].type.workingpressure.mbar = 207000;
|
||||||
}
|
}
|
||||||
|
@ -1063,9 +1063,9 @@ void DivePlannerPointsModel::computeVariations(struct diveplan *original_plan, s
|
||||||
restore_deco_state(save, &ds, false);
|
restore_deco_state(save, &ds, false);
|
||||||
|
|
||||||
char buf[200];
|
char buf[200];
|
||||||
sprintf(buf, ", %s: + %d:%02d /%s + %d:%02d /min", tr("Stop times").toUtf8().data(),
|
sprintf(buf, ", %s: + %d:%02d /%s + %d:%02d /min", qPrintable(tr("Stop times")),
|
||||||
FRACTION(analyzeVariations(shallower, original, deeper, depth_units.toUtf8().data()), 60), depth_units.toUtf8().data(),
|
FRACTION(analyzeVariations(shallower, original, deeper, qPrintable(depth_units)), 60), qPrintable(depth_units),
|
||||||
FRACTION(analyzeVariations(shorter, original, longer, time_units.toUtf8().data()), 60));
|
FRACTION(analyzeVariations(shorter, original, longer, qPrintable(time_units)), 60));
|
||||||
|
|
||||||
emit variationsComputed(QString(buf));
|
emit variationsComputed(QString(buf));
|
||||||
#ifdef DEBUG_STOPVAR
|
#ifdef DEBUG_STOPVAR
|
||||||
|
@ -1123,7 +1123,7 @@ void DivePlannerPointsModel::createPlan(bool replanCopy)
|
||||||
// Deal with line breaks
|
// Deal with line breaks
|
||||||
oldnotes.replace("\n", "<br>");
|
oldnotes.replace("\n", "<br>");
|
||||||
oldnotes.append(displayed_dive.notes);
|
oldnotes.append(displayed_dive.notes);
|
||||||
displayed_dive.notes = strdup(oldnotes.toUtf8().data());
|
displayed_dive.notes = strdup(qPrintable(oldnotes));
|
||||||
// If we save as new create a copy of the dive here
|
// If we save as new create a copy of the dive here
|
||||||
if (replanCopy) {
|
if (replanCopy) {
|
||||||
struct dive *copy = alloc_dive();
|
struct dive *copy = alloc_dive();
|
||||||
|
|
|
@ -88,7 +88,7 @@ QVariant FilterModelBase::data(const QModelIndex &index, int role) const
|
||||||
return checkState[index.row()] ? Qt::Checked : Qt::Unchecked;
|
return checkState[index.row()] ? Qt::Checked : Qt::Unchecked;
|
||||||
} else if (role == Qt::DisplayRole) {
|
} else if (role == Qt::DisplayRole) {
|
||||||
QString value = stringList()[index.row()];
|
QString value = stringList()[index.row()];
|
||||||
int count = countDives((index.row() == rowCount() - 1) ? "" : value.toUtf8().data());
|
int count = countDives((index.row() == rowCount() - 1) ? "" : qPrintable(value));
|
||||||
return value + QString(" (%1)").arg(count);
|
return value + QString(" (%1)").arg(count);
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
|
@ -42,7 +42,7 @@ void MessageHandlerModel::addLog(QtMsgType type, const QString& message)
|
||||||
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
||||||
m_data.append({message, type});
|
m_data.append({message, type});
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
INFO("%s", message.toUtf8().constData());
|
INFO("%s", qPrintable(message));
|
||||||
#if defined (Q_OS_ANDROID)
|
#if defined (Q_OS_ANDROID)
|
||||||
writeToAppLogFile(message);
|
writeToAppLogFile(message);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -114,14 +114,14 @@ bool WeightModel::setData(const QModelIndex &index, const QVariant &value, int r
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ws_info[i].name == NULL) // didn't find a match
|
if (ws_info[i].name == NULL) // didn't find a match
|
||||||
ws->description = strdup(vString.toUtf8().constData());
|
ws->description = strdup(qPrintable(vString));
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WEIGHT:
|
case WEIGHT:
|
||||||
if (CHANGED()) {
|
if (CHANGED()) {
|
||||||
ws->weight = string_to_weight(vString.toUtf8().data());
|
ws->weight = string_to_weight(qPrintable(vString));
|
||||||
// now update the ws_info
|
// now update the ws_info
|
||||||
changed = true;
|
changed = true;
|
||||||
WSInfoModel *wsim = WSInfoModel::instance();
|
WSInfoModel *wsim = WSInfoModel::instance();
|
||||||
|
|
|
@ -92,7 +92,7 @@ void Smrtk2ssrfcWindow::on_importButton_clicked()
|
||||||
ui->plainTextEdit->appendPlainText(error_buf);
|
ui->plainTextEdit->appendPlainText(error_buf);
|
||||||
}
|
}
|
||||||
ui->progressBar->setValue(inputFiles.size());
|
ui->progressBar->setValue(inputFiles.size());
|
||||||
save_dives_logic(outputFile.toUtf8().data(), false);
|
save_dives_logic(qPrintable(outputFile), false);
|
||||||
ui->progressBar->setDisabled(true);
|
ui->progressBar->setDisabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ int main(int argc, char **argv)
|
||||||
if (a.isEmpty())
|
if (a.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
if (a.at(0) == '-') {
|
if (a.at(0) == '-') {
|
||||||
parse_argument(a.toLocal8Bit().data());
|
parse_argument(qPrintable(a));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (imported) {
|
if (imported) {
|
||||||
|
@ -142,7 +142,7 @@ void validateGL()
|
||||||
if (!quickBackend.isEmpty()) {
|
if (!quickBackend.isEmpty()) {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
qDebug() << QStringLiteral(VALIDATE_GL_PREFIX "'QT_QUICK_BACKEND' is set to '%1'. "
|
qDebug() << QStringLiteral(VALIDATE_GL_PREFIX "'QT_QUICK_BACKEND' is set to '%1'. "
|
||||||
"Skipping validation.").arg(quickBackend).toUtf8().data();
|
"Skipping validation.").arg(quickBackend);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ void validateGL()
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
if (verbose)
|
if (verbose)
|
||||||
qDebug() << QStringLiteral(VALIDATE_GL_PREFIX "created OpenGLContext.").toUtf8().data();
|
qDebug() << QStringLiteral(VALIDATE_GL_PREFIX "created OpenGLContext.");
|
||||||
ctx.makeCurrent(&surface);
|
ctx.makeCurrent(&surface);
|
||||||
func = ctx.functions();
|
func = ctx.functions();
|
||||||
if (!func) {
|
if (!func) {
|
||||||
|
@ -168,7 +168,7 @@ void validateGL()
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
if (verbose)
|
if (verbose)
|
||||||
qDebug() << QStringLiteral(VALIDATE_GL_PREFIX "obtained QOpenGLFunctions.").toUtf8().data();
|
qDebug() << QStringLiteral(VALIDATE_GL_PREFIX "obtained QOpenGLFunctions.");
|
||||||
// detect version for legacy profiles
|
// detect version for legacy profiles
|
||||||
verChar = (const char *)func->glGetString(GL_VERSION);
|
verChar = (const char *)func->glGetString(GL_VERSION);
|
||||||
if (verChar) {
|
if (verChar) {
|
||||||
|
@ -178,7 +178,7 @@ void validateGL()
|
||||||
"Attempting to run with the available profile!\n"
|
"Attempting to run with the available profile!\n"
|
||||||
"If this fails try manually setting the environment variable\n"
|
"If this fails try manually setting the environment variable\n"
|
||||||
"'QT_QUICK_BACKEND' with the value of 'software'\n"
|
"'QT_QUICK_BACKEND' with the value of 'software'\n"
|
||||||
"before running Subsurface!\n").toUtf8().data();
|
"before running Subsurface!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int min, maj;
|
int min, maj;
|
||||||
|
@ -197,7 +197,7 @@ void validateGL()
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
if (verbose)
|
if (verbose)
|
||||||
qDebug() << QStringLiteral(VALIDATE_GL_PREFIX "detected OpenGL version %1.%2.").arg(verMajor).arg(verMinor).toUtf8().data();
|
qDebug() << QStringLiteral(VALIDATE_GL_PREFIX "detected OpenGL version %1.%2.").arg(verMajor).arg(verMinor);
|
||||||
if (verMajor * 10 + verMinor < 21) { // set 2.1 as the minimal version
|
if (verMajor * 10 + verMinor < 21) { // set 2.1 as the minimal version
|
||||||
glError = "OpenGL 2.1 or later is required";
|
glError = "OpenGL 2.1 or later is required";
|
||||||
goto exit;
|
goto exit;
|
||||||
|
@ -211,10 +211,10 @@ exit:
|
||||||
qWarning() << QStringLiteral(VALIDATE_GL_PREFIX "ERROR: %1.\n"
|
qWarning() << QStringLiteral(VALIDATE_GL_PREFIX "ERROR: %1.\n"
|
||||||
"Cannot automatically fallback to a software renderer!\n"
|
"Cannot automatically fallback to a software renderer!\n"
|
||||||
"Set the environment variable 'QT_QUICK_BACKEND' with the value of 'software'\n"
|
"Set the environment variable 'QT_QUICK_BACKEND' with the value of 'software'\n"
|
||||||
"before running Subsurface!\n").arg(glError).toUtf8().data();
|
"before running Subsurface!\n").arg(glError);
|
||||||
exit(0);
|
exit(0);
|
||||||
#else
|
#else
|
||||||
qWarning() << QStringLiteral(VALIDATE_GL_PREFIX "WARNING: %1. Using a software renderer!").arg(glError).toUtf8().data();
|
qWarning() << QStringLiteral(VALIDATE_GL_PREFIX "WARNING: %1. Using a software renderer!").arg(glError);
|
||||||
QQuickWindow::setSceneGraphBackend(QSGRendererInterface::Software);
|
QQuickWindow::setSceneGraphBackend(QSGRendererInterface::Software);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ int main(int argc, char **argv)
|
||||||
for (i = 1; i < arguments.length(); i++) {
|
for (i = 1; i < arguments.length(); i++) {
|
||||||
QString a = arguments.at(i);
|
QString a = arguments.at(i);
|
||||||
if (!a.isEmpty() && a.at(0) == '-') {
|
if (!a.isEmpty() && a.at(0) == '-') {
|
||||||
parse_argument(a.toLocal8Bit().data());
|
parse_argument(qPrintable(a));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QNetworkProxy>
|
#include <QNetworkProxy>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QTextCodec>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
// this is a local helper function in git-access.c
|
// this is a local helper function in git-access.c
|
||||||
|
@ -19,6 +20,9 @@ extern "C" char *get_local_dir(const char *remote, const char *branch);
|
||||||
|
|
||||||
void TestGitStorage::initTestCase()
|
void TestGitStorage::initTestCase()
|
||||||
{
|
{
|
||||||
|
// Set UTF8 text codec as in real applications
|
||||||
|
QTextCodec::setCodecForLocale(QTextCodec::codecForMib(106));
|
||||||
|
|
||||||
// first, setup the preferences an proxy information
|
// first, setup the preferences an proxy information
|
||||||
copy_prefs(&default_prefs, &prefs);
|
copy_prefs(&default_prefs, &prefs);
|
||||||
QCoreApplication::setOrganizationName("Subsurface");
|
QCoreApplication::setOrganizationName("Subsurface");
|
||||||
|
@ -39,7 +43,7 @@ void TestGitStorage::initTestCase()
|
||||||
QString gitUrl(prefs.cloud_base_url);
|
QString gitUrl(prefs.cloud_base_url);
|
||||||
if (gitUrl.right(1) != "/")
|
if (gitUrl.right(1) != "/")
|
||||||
gitUrl += "/";
|
gitUrl += "/";
|
||||||
prefs.cloud_git_url = strdup(qUtf8Printable(gitUrl + "git"));
|
prefs.cloud_git_url = strdup(qPrintable(gitUrl + "git"));
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
prefs.cloud_storage_email_encoded = strdup("ssrftest@hohndel.org");
|
prefs.cloud_storage_email_encoded = strdup("ssrftest@hohndel.org");
|
||||||
prefs.cloud_storage_password = strdup("geheim");
|
prefs.cloud_storage_password = strdup("geheim");
|
||||||
|
@ -93,11 +97,11 @@ void TestGitStorage::testGitStorageLocal()
|
||||||
QCOMPARE(QDir().mkdir(testDirName), true);
|
QCOMPARE(QDir().mkdir(testDirName), true);
|
||||||
QString repoNameRead = prefixRead + testDirName;
|
QString repoNameRead = prefixRead + testDirName;
|
||||||
QString repoNameWrite = prefixWrite + testDirName;
|
QString repoNameWrite = prefixWrite + testDirName;
|
||||||
QCOMPARE(git_repository_init(&repo, qUtf8Printable(testDirName), false), 0);
|
QCOMPARE(git_repository_init(&repo, qPrintable(testDirName), false), 0);
|
||||||
QCOMPARE(save_dives(qUtf8Printable(repoNameWrite + "[test]")), 0);
|
QCOMPARE(save_dives(qPrintable(repoNameWrite + "[test]")), 0);
|
||||||
QCOMPARE(save_dives("./SampleDivesV3.ssrf"), 0);
|
QCOMPARE(save_dives("./SampleDivesV3.ssrf"), 0);
|
||||||
clear_dive_file_data();
|
clear_dive_file_data();
|
||||||
QCOMPARE(parse_file(qUtf8Printable(repoNameRead + "[test]")), 0);
|
QCOMPARE(parse_file(qPrintable(repoNameRead + "[test]")), 0);
|
||||||
QCOMPARE(save_dives("./SampleDivesV3viagit.ssrf"), 0);
|
QCOMPARE(save_dives("./SampleDivesV3viagit.ssrf"), 0);
|
||||||
QFile org("./SampleDivesV3.ssrf");
|
QFile org("./SampleDivesV3.ssrf");
|
||||||
org.open(QFile::ReadOnly);
|
org.open(QFile::ReadOnly);
|
||||||
|
@ -117,9 +121,9 @@ void TestGitStorage::testGitStorageCloud()
|
||||||
// and repeat the same test as before with the local git storage
|
// and repeat the same test as before with the local git storage
|
||||||
QString cloudTestRepo("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org[ssrftest@hohndel.org]");
|
QString cloudTestRepo("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org[ssrftest@hohndel.org]");
|
||||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/SampleDivesV2.ssrf"), 0);
|
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/SampleDivesV2.ssrf"), 0);
|
||||||
QCOMPARE(save_dives(qUtf8Printable(cloudTestRepo)), 0);
|
QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0);
|
||||||
clear_dive_file_data();
|
clear_dive_file_data();
|
||||||
QCOMPARE(parse_file(qUtf8Printable(cloudTestRepo)), 0);
|
QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0);
|
||||||
QCOMPARE(save_dives("./SampleDivesV3viacloud.ssrf"), 0);
|
QCOMPARE(save_dives("./SampleDivesV3viacloud.ssrf"), 0);
|
||||||
QFile org("./SampleDivesV3.ssrf");
|
QFile org("./SampleDivesV3.ssrf");
|
||||||
org.open(QFile::ReadOnly);
|
org.open(QFile::ReadOnly);
|
||||||
|
@ -140,17 +144,17 @@ void TestGitStorage::testGitStorageCloudOfflineSync()
|
||||||
QString localCacheDir(get_local_dir("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org", "ssrftest@hohndel.org"));
|
QString localCacheDir(get_local_dir("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org", "ssrftest@hohndel.org"));
|
||||||
QString localCacheRepo = localCacheDir + "[ssrftest@hohndel.org]";
|
QString localCacheRepo = localCacheDir + "[ssrftest@hohndel.org]";
|
||||||
// read the local repo from the previous test and add dive 10
|
// read the local repo from the previous test and add dive 10
|
||||||
QCOMPARE(parse_file(qUtf8Printable(localCacheRepo)), 0);
|
QCOMPARE(parse_file(qPrintable(localCacheRepo)), 0);
|
||||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test10.xml"), 0);
|
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test10.xml"), 0);
|
||||||
// calling process_dive() sorts the table, but calling it with
|
// calling process_dive() sorts the table, but calling it with
|
||||||
// is_imported == true causes it to try to update the window title... let's not do that
|
// is_imported == true causes it to try to update the window title... let's not do that
|
||||||
process_dives(false, false);
|
process_dives(false, false);
|
||||||
// now save only to the local cache but not to the remote server
|
// now save only to the local cache but not to the remote server
|
||||||
QCOMPARE(save_dives(qUtf8Printable(localCacheRepo)), 0);
|
QCOMPARE(save_dives(qPrintable(localCacheRepo)), 0);
|
||||||
QCOMPARE(save_dives("./SampleDivesV3plus10local.ssrf"), 0);
|
QCOMPARE(save_dives("./SampleDivesV3plus10local.ssrf"), 0);
|
||||||
clear_dive_file_data();
|
clear_dive_file_data();
|
||||||
// open the cloud storage and compare
|
// open the cloud storage and compare
|
||||||
QCOMPARE(parse_file(qUtf8Printable(cloudTestRepo)), 0);
|
QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0);
|
||||||
QCOMPARE(save_dives("./SampleDivesV3plus10viacloud.ssrf"), 0);
|
QCOMPARE(save_dives("./SampleDivesV3plus10viacloud.ssrf"), 0);
|
||||||
QFile org("./SampleDivesV3plus10local.ssrf");
|
QFile org("./SampleDivesV3plus10local.ssrf");
|
||||||
org.open(QFile::ReadOnly);
|
org.open(QFile::ReadOnly);
|
||||||
|
@ -162,13 +166,13 @@ void TestGitStorage::testGitStorageCloudOfflineSync()
|
||||||
QString written = outS.readAll();
|
QString written = outS.readAll();
|
||||||
QCOMPARE(readin, written);
|
QCOMPARE(readin, written);
|
||||||
// write back out to cloud storage, move away the local cache, open again and compare
|
// write back out to cloud storage, move away the local cache, open again and compare
|
||||||
QCOMPARE(save_dives(qUtf8Printable(cloudTestRepo)), 0);
|
QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0);
|
||||||
clear_dive_file_data();
|
clear_dive_file_data();
|
||||||
QDir localCacheDirectory(localCacheDir);
|
QDir localCacheDirectory(localCacheDir);
|
||||||
QDir localCacheDirectorySave(localCacheDir + "save");
|
QDir localCacheDirectorySave(localCacheDir + "save");
|
||||||
QCOMPARE(localCacheDirectorySave.removeRecursively(), true);
|
QCOMPARE(localCacheDirectorySave.removeRecursively(), true);
|
||||||
QCOMPARE(localCacheDirectory.rename(localCacheDir, localCacheDir + "save"), true);
|
QCOMPARE(localCacheDirectory.rename(localCacheDir, localCacheDir + "save"), true);
|
||||||
QCOMPARE(parse_file(qUtf8Printable(cloudTestRepo)), 0);
|
QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0);
|
||||||
QCOMPARE(save_dives("./SampleDivesV3plus10fromcloud.ssrf"), 0);
|
QCOMPARE(save_dives("./SampleDivesV3plus10fromcloud.ssrf"), 0);
|
||||||
org.close();
|
org.close();
|
||||||
org.open(QFile::ReadOnly);
|
org.open(QFile::ReadOnly);
|
||||||
|
@ -189,17 +193,17 @@ void TestGitStorage::testGitStorageCloudMerge()
|
||||||
QString cloudTestRepo("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org[ssrftest@hohndel.org]");
|
QString cloudTestRepo("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org[ssrftest@hohndel.org]");
|
||||||
QString localCacheDir(get_local_dir("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org", "ssrftest@hohndel.org"));
|
QString localCacheDir(get_local_dir("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org", "ssrftest@hohndel.org"));
|
||||||
QString localCacheRepoSave = localCacheDir + "save[ssrftest@hohndel.org]";
|
QString localCacheRepoSave = localCacheDir + "save[ssrftest@hohndel.org]";
|
||||||
QCOMPARE(parse_file(qUtf8Printable(localCacheRepoSave)), 0);
|
QCOMPARE(parse_file(qPrintable(localCacheRepoSave)), 0);
|
||||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test11.xml"), 0);
|
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test11.xml"), 0);
|
||||||
process_dives(false, false);
|
process_dives(false, false);
|
||||||
QCOMPARE(save_dives(qUtf8Printable(localCacheRepoSave)), 0);
|
QCOMPARE(save_dives(qPrintable(localCacheRepoSave)), 0);
|
||||||
clear_dive_file_data();
|
clear_dive_file_data();
|
||||||
|
|
||||||
// now we open the cloud storage repo and add a different dive to it
|
// now we open the cloud storage repo and add a different dive to it
|
||||||
QCOMPARE(parse_file(qUtf8Printable(cloudTestRepo)), 0);
|
QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0);
|
||||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test12.xml"), 0);
|
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test12.xml"), 0);
|
||||||
process_dives(false, false);
|
process_dives(false, false);
|
||||||
QCOMPARE(save_dives(qUtf8Printable(cloudTestRepo)), 0);
|
QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0);
|
||||||
clear_dive_file_data();
|
clear_dive_file_data();
|
||||||
|
|
||||||
// now we move the saved local cache into place and try to open the cloud repo
|
// now we move the saved local cache into place and try to open the cloud repo
|
||||||
|
@ -208,7 +212,7 @@ void TestGitStorage::testGitStorageCloudMerge()
|
||||||
QCOMPARE(localCacheDirectory.removeRecursively(), true);
|
QCOMPARE(localCacheDirectory.removeRecursively(), true);
|
||||||
QDir localCacheDirectorySave(localCacheDir + "save");
|
QDir localCacheDirectorySave(localCacheDir + "save");
|
||||||
QCOMPARE(localCacheDirectory.rename(localCacheDir + "save", localCacheDir), true);
|
QCOMPARE(localCacheDirectory.rename(localCacheDir + "save", localCacheDir), true);
|
||||||
QCOMPARE(parse_file(qUtf8Printable(cloudTestRepo)), 0);
|
QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0);
|
||||||
QCOMPARE(save_dives("./SampleDivesV3plus10-11-12-merged.ssrf"), 0);
|
QCOMPARE(save_dives("./SampleDivesV3plus10-11-12-merged.ssrf"), 0);
|
||||||
clear_dive_file_data();
|
clear_dive_file_data();
|
||||||
QCOMPARE(parse_file("./SampleDivesV3plus10local.ssrf"), 0);
|
QCOMPARE(parse_file("./SampleDivesV3plus10local.ssrf"), 0);
|
||||||
|
@ -236,12 +240,12 @@ void TestGitStorage::testGitStorageCloudMerge2()
|
||||||
QString cloudTestRepo("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org[ssrftest@hohndel.org]");
|
QString cloudTestRepo("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org[ssrftest@hohndel.org]");
|
||||||
QString localCacheDir(get_local_dir("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org", "ssrftest@hohndel.org"));
|
QString localCacheDir(get_local_dir("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org", "ssrftest@hohndel.org"));
|
||||||
QString localCacheRepo = localCacheDir + "[ssrftest@hohndel.org]";
|
QString localCacheRepo = localCacheDir + "[ssrftest@hohndel.org]";
|
||||||
QCOMPARE(parse_file(qUtf8Printable(localCacheRepo)), 0);
|
QCOMPARE(parse_file(qPrintable(localCacheRepo)), 0);
|
||||||
process_dives(false, false);
|
process_dives(false, false);
|
||||||
struct dive *dive = get_dive(1);
|
struct dive *dive = get_dive(1);
|
||||||
delete_single_dive(1);
|
delete_single_dive(1);
|
||||||
QCOMPARE(save_dives("./SampleDivesMinus1.ssrf"), 0);
|
QCOMPARE(save_dives("./SampleDivesMinus1.ssrf"), 0);
|
||||||
QCOMPARE(save_dives(qUtf8Printable(localCacheRepo)), 0);
|
QCOMPARE(save_dives(qPrintable(localCacheRepo)), 0);
|
||||||
clear_dive_file_data();
|
clear_dive_file_data();
|
||||||
|
|
||||||
// move the local cache away
|
// move the local cache away
|
||||||
|
@ -252,13 +256,13 @@ void TestGitStorage::testGitStorageCloudMerge2()
|
||||||
QCOMPARE(localCacheDirectory.rename(localCacheDir, localCacheDir + "save"), true);
|
QCOMPARE(localCacheDirectory.rename(localCacheDir, localCacheDir + "save"), true);
|
||||||
}
|
}
|
||||||
// now we open the cloud storage repo and modify that first dive
|
// now we open the cloud storage repo and modify that first dive
|
||||||
QCOMPARE(parse_file(qUtf8Printable(cloudTestRepo)), 0);
|
QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0);
|
||||||
process_dives(false, false);
|
process_dives(false, false);
|
||||||
dive = get_dive(1);
|
dive = get_dive(1);
|
||||||
QVERIFY(dive != NULL);
|
QVERIFY(dive != NULL);
|
||||||
free(dive->notes);
|
free(dive->notes);
|
||||||
dive->notes = strdup("These notes have been modified by TestGitStorage");
|
dive->notes = strdup("These notes have been modified by TestGitStorage");
|
||||||
QCOMPARE(save_dives(qUtf8Printable(cloudTestRepo)), 0);
|
QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0);
|
||||||
clear_dive_file_data();
|
clear_dive_file_data();
|
||||||
|
|
||||||
// now we move the saved local cache into place and try to open the cloud repo
|
// now we move the saved local cache into place and try to open the cloud repo
|
||||||
|
@ -268,9 +272,9 @@ void TestGitStorage::testGitStorageCloudMerge2()
|
||||||
QCOMPARE(localCacheDirectory.removeRecursively(), true);
|
QCOMPARE(localCacheDirectory.removeRecursively(), true);
|
||||||
QCOMPARE(localCacheDirectorySave.rename(localCacheDir + "save", localCacheDir), true);
|
QCOMPARE(localCacheDirectorySave.rename(localCacheDir + "save", localCacheDir), true);
|
||||||
|
|
||||||
QCOMPARE(parse_file(qUtf8Printable(cloudTestRepo)), 0);
|
QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0);
|
||||||
QCOMPARE(save_dives("./SampleDivesMinus1-merged.ssrf"), 0);
|
QCOMPARE(save_dives("./SampleDivesMinus1-merged.ssrf"), 0);
|
||||||
QCOMPARE(save_dives(qUtf8Printable(cloudTestRepo)), 0);
|
QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0);
|
||||||
QFile org("./SampleDivesMinus1-merged.ssrf");
|
QFile org("./SampleDivesMinus1-merged.ssrf");
|
||||||
org.open(QFile::ReadOnly);
|
org.open(QFile::ReadOnly);
|
||||||
QFile out("./SampleDivesMinus1.ssrf");
|
QFile out("./SampleDivesMinus1.ssrf");
|
||||||
|
@ -292,7 +296,7 @@ void TestGitStorage::testGitStorageCloudMerge3()
|
||||||
QString cloudTestRepo("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org[ssrftest@hohndel.org]");
|
QString cloudTestRepo("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org[ssrftest@hohndel.org]");
|
||||||
QString localCacheDir(get_local_dir("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org", "ssrftest@hohndel.org"));
|
QString localCacheDir(get_local_dir("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org", "ssrftest@hohndel.org"));
|
||||||
QString localCacheRepo = localCacheDir + "[ssrftest@hohndel.org]";
|
QString localCacheRepo = localCacheDir + "[ssrftest@hohndel.org]";
|
||||||
QCOMPARE(parse_file(qUtf8Printable(cloudTestRepo)), 0);
|
QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0);
|
||||||
process_dives(false, false);
|
process_dives(false, false);
|
||||||
struct dive *dive = get_dive(0);
|
struct dive *dive = get_dive(0);
|
||||||
QVERIFY(dive != 0);
|
QVERIFY(dive != 0);
|
||||||
|
@ -301,10 +305,10 @@ void TestGitStorage::testGitStorageCloudMerge3()
|
||||||
dive->notes = strdup("Create multi line dive notes\nLine 2\nLine 3\nLine 4\nLine 5\nThat should be enough");
|
dive->notes = strdup("Create multi line dive notes\nLine 2\nLine 3\nLine 4\nLine 5\nThat should be enough");
|
||||||
dive = get_dive(2);
|
dive = get_dive(2);
|
||||||
dive->notes = strdup("Create multi line dive notes\nLine 2\nLine 3\nLine 4\nLine 5\nThat should be enough");
|
dive->notes = strdup("Create multi line dive notes\nLine 2\nLine 3\nLine 4\nLine 5\nThat should be enough");
|
||||||
QCOMPARE(save_dives(qUtf8Printable(cloudTestRepo)), 0);
|
QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0);
|
||||||
clear_dive_file_data();
|
clear_dive_file_data();
|
||||||
|
|
||||||
QCOMPARE(parse_file(qUtf8Printable(localCacheRepo)), 0);
|
QCOMPARE(parse_file(qPrintable(localCacheRepo)), 0);
|
||||||
process_dives(false, false);
|
process_dives(false, false);
|
||||||
dive = get_dive(0);
|
dive = get_dive(0);
|
||||||
dive->notes = strdup("Create multi line dive notes\nDifferent line 2 and removed 3-5\n\nThat should be enough");
|
dive->notes = strdup("Create multi line dive notes\nDifferent line 2 and removed 3-5\n\nThat should be enough");
|
||||||
|
@ -312,7 +316,7 @@ void TestGitStorage::testGitStorageCloudMerge3()
|
||||||
dive->notes = strdup("Line 2\nLine 3\nLine 4\nLine 5"); // keep the middle, remove first and last");
|
dive->notes = strdup("Line 2\nLine 3\nLine 4\nLine 5"); // keep the middle, remove first and last");
|
||||||
dive = get_dive(2);
|
dive = get_dive(2);
|
||||||
dive->notes = strdup("single line dive notes");
|
dive->notes = strdup("single line dive notes");
|
||||||
QCOMPARE(save_dives(qUtf8Printable(localCacheRepo)), 0);
|
QCOMPARE(save_dives(qPrintable(localCacheRepo)), 0);
|
||||||
clear_dive_file_data();
|
clear_dive_file_data();
|
||||||
|
|
||||||
// move the local cache away
|
// move the local cache away
|
||||||
|
@ -323,7 +327,7 @@ void TestGitStorage::testGitStorageCloudMerge3()
|
||||||
QCOMPARE(localCacheDirectory.rename(localCacheDir, localCacheDir + "save"), true);
|
QCOMPARE(localCacheDirectory.rename(localCacheDir, localCacheDir + "save"), true);
|
||||||
}
|
}
|
||||||
// now we open the cloud storage repo and modify those first dive notes differently
|
// now we open the cloud storage repo and modify those first dive notes differently
|
||||||
QCOMPARE(parse_file(qUtf8Printable(cloudTestRepo)), 0);
|
QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0);
|
||||||
process_dives(false, false);
|
process_dives(false, false);
|
||||||
dive = get_dive(0);
|
dive = get_dive(0);
|
||||||
dive->notes = strdup("Completely different dive notes\nBut also multi line");
|
dive->notes = strdup("Completely different dive notes\nBut also multi line");
|
||||||
|
@ -331,7 +335,7 @@ void TestGitStorage::testGitStorageCloudMerge3()
|
||||||
dive->notes = strdup("single line dive notes");
|
dive->notes = strdup("single line dive notes");
|
||||||
dive = get_dive(2);
|
dive = get_dive(2);
|
||||||
dive->notes = strdup("Line 2\nLine 3\nLine 4\nLine 5"); // keep the middle, remove first and last");
|
dive->notes = strdup("Line 2\nLine 3\nLine 4\nLine 5"); // keep the middle, remove first and last");
|
||||||
QCOMPARE(save_dives(qUtf8Printable(cloudTestRepo)), 0);
|
QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0);
|
||||||
clear_dive_file_data();
|
clear_dive_file_data();
|
||||||
|
|
||||||
// now we move the saved local cache into place and try to open the cloud repo
|
// now we move the saved local cache into place and try to open the cloud repo
|
||||||
|
@ -341,7 +345,7 @@ void TestGitStorage::testGitStorageCloudMerge3()
|
||||||
QCOMPARE(localCacheDirectory.removeRecursively(), true);
|
QCOMPARE(localCacheDirectory.removeRecursively(), true);
|
||||||
QCOMPARE(localCacheDirectorySave.rename(localCacheDir + "save", localCacheDir), true);
|
QCOMPARE(localCacheDirectorySave.rename(localCacheDir + "save", localCacheDir), true);
|
||||||
|
|
||||||
QCOMPARE(parse_file(qUtf8Printable(cloudTestRepo)), 0);
|
QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0);
|
||||||
QCOMPARE(save_dives("./SampleDivesMerge3.ssrf"), 0);
|
QCOMPARE(save_dives("./SampleDivesMerge3.ssrf"), 0);
|
||||||
// we are not trying to compare this to a pre-determined result... what this test
|
// we are not trying to compare this to a pre-determined result... what this test
|
||||||
// checks is that there are no parsing errors with the merge
|
// checks is that there are no parsing errors with the merge
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue