Skip to content

Commit

Permalink
use QStringLiteral with constant QStrings and QString::arg(*).
Browse files Browse the repository at this point in the history
  • Loading branch information
tsteven4 committed Jul 11, 2022
1 parent 5c93d07 commit ecb9d86
Show file tree
Hide file tree
Showing 23 changed files with 48 additions and 48 deletions.
2 changes: 1 addition & 1 deletion csv_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ csv_stringclean(const QString& source, const QString& to_nuke)
// avoid problematic regular rexpressions, e.g. xmapwpt generated [:\n:],
// or one can imagine [0-9] when we meant the characters, '0', '-', and '9',
// or one can imagine [^a] when we meant the characters '^' and 'a'.
QRegularExpression regex = QRegularExpression(QString("[%1]").arg(QRegularExpression::escape(to_nuke)));
QRegularExpression regex = QRegularExpression(QStringLiteral("[%1]").arg(QRegularExpression::escape(to_nuke)));
assert(regex.isValid());
r.remove(regex);
}
Expand Down
2 changes: 1 addition & 1 deletion dg-100.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ Dg100Format::process_gpsfile(uint8_t data[], route_head** track) const
QDateTime creation_time = bintime2utc(bindate, bintime);
QString datetime = creation_time.toString("yyyy/MM/dd hh:mm:ss");
*track = new route_head;
(*track)->rte_name = QString("%1 tracklog (%2)").arg(model->name, datetime);
(*track)->rte_name = QStringLiteral("%1 tracklog (%2)").arg(model->name, datetime);
(*track)->rte_desc = "GPS tracklog data";
track_add_head(*track);
}
Expand Down
4 changes: 2 additions & 2 deletions garmin_fit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ GarminFitFormat::fit_parse_definition_message(uint8_t header)
// second byte is endianness
def.endian = fit_getuint8();
if (def.endian > 1) {
throw ReaderException(QString("Bad endian field 0x%1 at file position 0x%2.").arg(def.endian, 0, 16).arg(gbftell(fin) - 1, 0, 16).toStdString());
throw ReaderException(QStringLiteral("Bad endian field 0x%1 at file position 0x%2.").arg(def.endian, 0, 16).arg(gbftell(fin) - 1, 0, 16).toStdString());
}
fit_data.endian = def.endian;

Expand Down Expand Up @@ -675,7 +675,7 @@ GarminFitFormat::fit_parse_data(const fit_message_def& def, int time_offset)
auto* lappt = new Waypoint;
lappt->latitude = GPS_Math_Semi_To_Deg(endlat);
lappt->longitude = GPS_Math_Semi_To_Deg(endlon);
lappt->shortname = QString("LAP%1").arg(++lap_ct, 3, 10, QLatin1Char('0'));
lappt->shortname = QStringLiteral("LAP%1").arg(++lap_ct, 3, 10, QLatin1Char('0'));
waypt_add(lappt);
}
break;
Expand Down
6 changes: 3 additions & 3 deletions garmin_gpi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ GarminGPIFormat::read_tag(const char* caller, const int tag, Waypoint* wpt)
speed = MPS_TO_KPH(speed);
}
QString base = wpt->shortname.isEmpty() ? "WPT" : wpt->shortname;
wpt->shortname = base + QString("@%1").arg(speed,0,'f',0);
wpt->shortname = base + QStringLiteral("@%1").arg(speed,0,'f',0);
}
}

Expand Down Expand Up @@ -1230,7 +1230,7 @@ GarminGPIFormat::rd_init(const QString& fname)
read_header();

if ((codepage >= 1250) && (codepage <= 1257)) {
QString qCodecName = QString("windows-%1").arg(codepage);
QString qCodecName = QStringLiteral("windows-%1").arg(codepage);
cet_convert_init(CSTR(qCodecName), 1);
} else if (codepage == 65001) {
cet_convert_init("utf8", 1);
Expand Down Expand Up @@ -1273,7 +1273,7 @@ GarminGPIFormat::wr_init(const QString& fname)
codepage = 0;

for (int i = 1250; i <= 1257; i++) {
if (QString("windows-%1").arg(i).compare(QString(opt_writecodec), Qt::CaseInsensitive) == 0) {
if (QStringLiteral("windows-%1").arg(i).compare(QString(opt_writecodec), Qt::CaseInsensitive) == 0) {
codepage = i;
break;
}
Expand Down
4 changes: 2 additions & 2 deletions garmin_tables.cc
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,11 @@ QString
gt_find_desc_from_icon_number(const int icon, garmin_formats_e garmin_format)
{
if ((garmin_format == GDB) && (icon >= 500) && (icon <= 563)) {
return QString("Custom %1").arg(icon - 500);
return QStringLiteral("Custom %1").arg(icon - 500);
}

if ((garmin_format == PCX) && (icon >= 7680) && (icon <= 8191)) {
return QString("Custom %1").arg(icon - 7680);
return QStringLiteral("Custom %1").arg(icon - 7680);
}

for (const icon_mapping_t* i = garmin_icon_table; i->icon; i++) {
Expand Down
10 changes: 5 additions & 5 deletions gdb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,22 +284,22 @@ QString GdbFormat::gdb_to_ISO8601_duration(unsigned int seconds)
unsigned int days = seconds / 86400u;
QString out = "P";
if (days != 0) {
out.append(QString("D%1").arg(days));
out.append(QStringLiteral("D%1").arg(days));
seconds -= 86400u * days;
}
out.append(QString("T"));
unsigned int hours = seconds / 3600u;
if (hours != 0) {
out.append(QString("%1H").arg(hours));
out.append(QStringLiteral("%1H").arg(hours));
seconds -= 3600u * hours;
}
unsigned int minutes = seconds / 60u;
if (minutes != 0) {
out.append(QString("%1M").arg(minutes));
out.append(QStringLiteral("%1M").arg(minutes));
seconds -= 60u * minutes;
}
if (seconds != 0) {
out.append(QString("%1S").arg(seconds));
out.append(QStringLiteral("%1S").arg(seconds));
}
return out;
}
Expand Down Expand Up @@ -578,7 +578,7 @@ GdbFormat::read_waypoint(gt_waypt_classes_e* waypt_class_out)
res->description = FREAD_CSTR_AS_QSTR; /* instruction */
if (wpt_class == gt_waypt_class_map_intersection || wpt_class == gt_waypt_class_map_line) {
garmin_fs_t::set_duration(gmsd, duration);
res->notes = QString("[%1]").arg(gdb_to_ISO8601_duration(duration));
res->notes = QStringLiteral("[%1]").arg(gdb_to_ISO8601_duration(duration));
#if GDB_DEBUG
DBG(GDB_DBG_WPTe, 1)
printf(MYNAME "-wpt \"%s\" (%d): duration = %u\n",
Expand Down
2 changes: 1 addition & 1 deletion gpssim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ gpssim_trk_hdr(const route_head* rh)
fatal(MYNAME ": output file already open.\n");
}

QString ofname = QString("%1%2%3.gpssim").arg(fnamestr, doing_tracks ? "-track" : "-route").arg(trk_count++, 4, 10, QChar('0'));
QString ofname = QStringLiteral("%1%2%3.gpssim").arg(fnamestr, doing_tracks ? "-track" : "-route").arg(trk_count++, 4, 10, QChar('0'));
fout = gbfopen(ofname, "wb", MYNAME);
}
(void) track_recompute(rh);
Expand Down
2 changes: 1 addition & 1 deletion gtrnctr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ GtrnctrFormat::gtc_crs_hdr(const route_head* rte)

if (!rte->rte_name.isEmpty()) {
QString name = rte->rte_name.left(kGtcMaxNameLen);
gtc_write_xml(0, QString("<Name>%1</Name>\n").arg(name));
gtc_write_xml(0, QStringLiteral("<Name>%1</Name>\n").arg(name));
} else {
gtc_write_xml(0, "<Name>New Course</Name>\n");
}
Expand Down
14 changes: 7 additions & 7 deletions kml.cc
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ void KmlFormat::wr_init(const QString& fname)
void KmlFormat::wr_position_init(const QString& fname)
{
posnfilename = fname;
posnfilenametmp = QString("%1-").arg(fname);
posnfilenametmp = QStringLiteral("%1-").arg(fname);
realtime_positioning = 1;
max_position_points = atoi(opt_max_position_points);
}
Expand Down Expand Up @@ -842,9 +842,9 @@ void KmlFormat::kml_output_point(const Waypoint* waypointp, kml_point_type pt_ty
if (trackdirection && (pt_type == kmlpt_track)) {
QString value;
if (waypointp->speed < 1) {
value = QString("%1-none").arg(style);
value = QStringLiteral("%1-none").arg(style);
} else {
value = QString("%1-%2").arg(style)
value = QStringLiteral("%1-%2").arg(style)
.arg((int)(waypointp->course / 22.5 + .5) % 16);
}
writer->writeTextElement(QStringLiteral("styleUrl"), value);
Expand Down Expand Up @@ -1141,7 +1141,7 @@ QString KmlFormat::kml_lookup_gc_icon(const Waypoint* waypointp)
break;
}

return QString("https://www.geocaching.com/images/kml/%1").arg(icon);
return QStringLiteral("https://www.geocaching.com/images/kml/%1").arg(icon);
}

const char* KmlFormat::kml_lookup_gc_container(const Waypoint* waypointp)
Expand Down Expand Up @@ -1184,9 +1184,9 @@ QString KmlFormat::kml_gc_mkstar(int rating)
}

if (0 == rating % 10) {
star_content = QString("stars%1").arg(rating / 10);
star_content = QStringLiteral("stars%1").arg(rating / 10);
} else {
star_content = QString("stars%1_%2").arg(rating / 10).arg(rating % 10);
star_content = QStringLiteral("stars%1_%2").arg(rating / 10).arg(rating % 10);
}

return star_content;
Expand Down Expand Up @@ -1770,7 +1770,7 @@ void KmlFormat::write()
if (trackdirection) {
kml_write_bitmap_style(kmlpt_other, ICON_TRK, "track-none");
for (int i = 0; i < 16; ++i) {
kml_write_bitmap_style(kmlpt_other, QString(ICON_DIR).arg(i), QString("track-%1").arg(i));
kml_write_bitmap_style(kmlpt_other, QStringLiteral(ICON_DIR).arg(i), QStringLiteral("track-%1").arg(i));
}
} else {
kml_write_bitmap_style(kmlpt_track, ICON_TRK, nullptr);
Expand Down
2 changes: 1 addition & 1 deletion lowranceusr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,7 @@ LowranceusrFormat::lowranceusr_trail_hdr(const route_head* trk)
} else if (!trk->rte_desc.isEmpty()) {
name = trk->rte_desc;
} else {
name = name + QString("Babel %1").arg(trail_count);
name = name + QStringLiteral("Babel %1").arg(trail_count);
}

int text_len = name.length();
Expand Down
2 changes: 1 addition & 1 deletion lowranceusr.h
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ class LowranceusrFormat : public Format
}

// Didn't find it in table, default to leave it as the number found
return QString("icon-%1").arg(icon);
return QStringLiteral("icon-%1").arg(icon);
}

template <typename T>
Expand Down
4 changes: 2 additions & 2 deletions mtk_logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ static int add_trackpoint(int idx, unsigned long bmask, struct data_item* itm)
if (global_opts.masked_objective& TRKDATAMASK && (trk_head == nullptr || (mtk_info.track_event & MTK_EVT_START))) {
char spds[50];
trk_head = new route_head;
trk_head->rte_name = QString("track-%1").arg(1 + track_count());
trk_head->rte_name = QStringLiteral("track-%1").arg(1 + track_count());

spds[0] = '\0';
if (mtk_info.speed > 0) {
Expand Down Expand Up @@ -896,7 +896,7 @@ static int add_trackpoint(int idx, unsigned long bmask, struct data_item* itm)
/* Button press -- create waypoint, start count at 1 */
auto* w = new Waypoint(*trk);

w->shortname = QString("WP%1").arg(waypt_count() + 1, 6, 10, QLatin1Char('0'));
w->shortname = QStringLiteral("WP%1").arg(waypt_count() + 1, 6, 10, QLatin1Char('0'));
waypt_add(w);
}
// In theory we would not add the waypoint to the list of
Expand Down
4 changes: 2 additions & 2 deletions nmea.cc
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ QTime NmeaFormat::nmea_parse_hms(const QString& str)
if (retval.isValid() && parts.size() == 2) {
bool ok;
// prepend "0.". prepending "." won't work if there are no trailing digits.
long msec = lround(1000.0 * QString("0.%1").arg(parts.at(1)).toDouble(&ok));
long msec = lround(1000.0 * QStringLiteral("0.%1").arg(parts.at(1)).toDouble(&ok));
if (ok) {
retval = retval.addMSecs(msec);
} else {
Expand Down Expand Up @@ -631,7 +631,7 @@ NmeaFormat::gpzda_parse(const QString& ibuf)
const QStringList fields = ibuf.split(',');
if (fields.size() > 4) {
QTime time = nmea_parse_hms(fields[1]);
QString datestr = QString("%1%2%3").arg(fields[2], fields[3], fields[4]);
QString datestr = QStringLiteral("%1%2%3").arg(fields[2], fields[3], fields[4]);
QDate date = QDate::fromString(datestr, "ddMMyyyy");

// The prev_datetime data member might be used by
Expand Down
2 changes: 1 addition & 1 deletion osm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ OsmFormat::osm_feature_symbol(const int ikey, const char* value) const
if (values.contains(key)) {
result = values.value(key)->icon;
} else {
result = QString("%1:%2").arg(osm_features[ikey], value);
result = QStringLiteral("%1:%2").arg(osm_features[ikey], value);
}
return result;
}
Expand Down
6 changes: 3 additions & 3 deletions ozi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ ozi_get_time_str(const Waypoint* waypointp)
{
if (waypointp->creation_time.isValid()) {
double time = (waypt_time(waypointp) / SECONDS_PER_DAY) + DAYS_SINCE_1990;
return QString("%1").arg(time, 0, 'f', 7);
return QStringLiteral("%1").arg(time, 0, 'f', 7);
}
return QString("");
}
Expand Down Expand Up @@ -243,7 +243,7 @@ ozi_openfile(const QString& fname)

QString buff;
if ((track_out_count) && (ozi_objective == trkdata)) {
buff = QString("-%1").arg(track_out_count);
buff = QStringLiteral("-%1").arg(track_out_count);
} else {
buff = QString("");
}
Expand All @@ -256,7 +256,7 @@ ozi_openfile(const QString& fname)
sname.chop(suffix_len + 1);
}

QString tmpname = QString("%1%2.%3").arg(sname, buff, ozi_extensions[ozi_objective]);
QString tmpname = QStringLiteral("%1%2.%3").arg(sname, buff, ozi_extensions[ozi_objective]);

/* re-open file_out with the new filename */
if (stream != nullptr) {
Expand Down
2 changes: 1 addition & 1 deletion qstarz_bl_1000.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ QstarzBL1000Format::qstarz_bl_1000_read_record(QDataStream& stream, route_head*

if (qstarz_bl_1000_is_waypoint_type(type)) {
if (global_opts.synthesize_shortnames) {
waypoint->shortname = QString("WP%2").arg(waypt_count() + 1, 3, 10, QChar('0'));
waypoint->shortname = QStringLiteral("WP%2").arg(waypt_count() + 1, 3, 10, QChar('0'));
waypoint->wpt_flags.shortname_is_synthetic = 1;
}
waypt_add(waypoint);
Expand Down
2 changes: 1 addition & 1 deletion route.cc
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ computed_trkdata track_recompute(const route_head* trk)
}

if (thisw->shortname.isEmpty()) {
thisw->shortname = QString("%1-%2").arg(trk->rte_name).arg(tkpt);
thisw->shortname = QStringLiteral("%1-%2").arg(trk->rte_name).arg(tkpt);
}
tkpt++;
prev = thisw;
Expand Down
2 changes: 1 addition & 1 deletion skytraq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ SkytraqBase::make_trackpoint(struct read_state* st, double lat, double lon, doub
{
auto* wpt = new Waypoint;

wpt->shortname = QString("TP%1").arg(++st->tpn, 4, 10, QLatin1Char('0'));
wpt->shortname = QStringLiteral("TP%1").arg(++st->tpn, 4, 10, QLatin1Char('0'));

wpt->latitude = lat;
wpt->longitude = lon;
Expand Down
10 changes: 5 additions & 5 deletions tpo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ static void tpo_read_2_x()
track_add_head(track_temp);

/* generate a generic track name */
track_temp->rte_name = QString("Track %1").arg(i+1);
track_temp->rte_name = QStringLiteral("Track %1").arg(i+1);

/* zoom level 1-5 visibility flags */
gbfread(&buff[0], 1, 10, tpo_file_in);
Expand Down Expand Up @@ -566,7 +566,7 @@ static void tpo_process_tracks()
if (tmp) {
styles[ii].name = gbfreadbuf(tmp, tpo_file_in);
} else { // Assign a generic style name
styles[ii].name = QString("STYLE %1").arg(ii);
styles[ii].name = QStringLiteral("STYLE %1").arg(ii);
}
#ifdef Tracks2012
//TBD: Should this be TRACKNAMELENGTH?
Expand Down Expand Up @@ -1219,7 +1219,7 @@ static void tpo_process_map_notes()
Waypoint* waypoint_temp = tpo_convert_ll(lat, lon);

// Assign a generic waypoint name
waypoint_temp->shortname = QString("NOTE %1").arg(ii + 1);
waypoint_temp->shortname = QStringLiteral("NOTE %1").arg(ii + 1);

//UNKNOWN DATA LENGTH
(void)tpo_read_int();
Expand Down Expand Up @@ -1320,7 +1320,7 @@ static void tpo_process_symbols()
Waypoint* waypoint_temp = tpo_convert_ll(lat, lon);

// Assign a generic waypoint name
waypoint_temp->shortname = QString("SYM %1").arg(ii + 1);
waypoint_temp->shortname = QStringLiteral("SYM %1").arg(ii + 1);

// Add the waypoint to the chain of waypoints
waypt_add(waypoint_temp);
Expand Down Expand Up @@ -1363,7 +1363,7 @@ static void tpo_process_text_labels()
Waypoint* waypoint_temp = tpo_convert_ll(lat, lon);

// Assign a generic waypoint name
waypoint_temp->shortname = QString("TXT %1").arg(ii + 1);
waypoint_temp->shortname = QStringLiteral("TXT %1").arg(ii + 1);

for (int jj = 0; jj < 16; jj++) {
//UNKNOWN DATA LENGTH
Expand Down
6 changes: 3 additions & 3 deletions trackfilter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ void TrackFilter::trackfilter_split_init_rte_name(route_head* track, const gpsba
strftime(buff, sizeof(buff), opt_title, &tm);
track->rte_name = buff;
} else {
track->rte_name = QString("%1-%2").arg(opt_title, datetimestring);
track->rte_name = QStringLiteral("%1-%2").arg(opt_title, datetimestring);
}
} else if (!track->rte_name.isEmpty()) {
track->rte_name = QString("%1-%2").arg(track->rte_name, datetimestring);
track->rte_name = QStringLiteral("%1-%2").arg(track->rte_name, datetimestring);
} else {
track->rte_name = datetimestring;
}
Expand Down Expand Up @@ -759,7 +759,7 @@ void TrackFilter::trackfilter_seg2trk()
dest->rte_num = src->rte_num;
/* name in the form TRACKNAME #n */
if (!src->rte_name.isEmpty()) {
dest->rte_name = QString("%1 #%2").arg(src->rte_name).arg(++trk_seg_num);
dest->rte_name = QStringLiteral("%1 #%2").arg(src->rte_name).arg(++trk_seg_num);
}

/* Insert after original track or after last newly
Expand Down
2 changes: 1 addition & 1 deletion transform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void TransformFilter::transform_rte_disp_hdr_cb(const route_head* rte)
current_trk = new route_head;
track_add_head(current_trk);
if (!rte->rte_name.isEmpty()) {
current_trk->rte_desc = QString("Generated from route %1").arg(rte->rte_name);
current_trk->rte_desc = QStringLiteral("Generated from route %1").arg(rte->rte_name);
current_trk->rte_name = rte->rte_name; /* name the new trk */
}
}
Expand Down
2 changes: 1 addition & 1 deletion unicsv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,7 @@ UnicsvFormat::unicsv_waypt_disp_cb(const Waypoint* wpt)
&east, &north, &zone, &zonec, unicsv_datum_idx)) {
unicsv_fatal_outside(wpt);
}
*fout << QString("%1").arg(zone, 2, 10, QLatin1Char('0')) << unicsv_fieldsep
*fout << QStringLiteral("%1").arg(zone, 2, 10, QLatin1Char('0')) << unicsv_fieldsep
<< zonec << unicsv_fieldsep
<< qSetRealNumberPrecision(0) << east << unicsv_fieldsep
<< north;
Expand Down
Loading

0 comments on commit ecb9d86

Please sign in to comment.