Unverified Commit 78f7a849 authored by Gus Grubba's avatar Gus Grubba Committed by GitHub

Merge pull request #7553 from patrickelectric/qstring_tr

Fix QString, QStringLiteral and tr calls
parents 1fa5d444 72c1c41b
......@@ -205,7 +205,7 @@ Item {
return qsTr("Not Connected")
switch(_authStatus) {
case AirspaceManager.Unknown:
return qsTr("")
return ""
case AirspaceManager.Anonymous:
return qsTr("Anonymous")
case AirspaceManager.Authenticated:
......
......@@ -45,7 +45,7 @@ bool QJsonWebToken::setHeaderJDoc(QJsonDocument jdocHeader)
}
// check if supported algorithm
QString strAlgorithm = jdocHeader.object().value("alg").toString("");
QString strAlgorithm = jdocHeader.object().value("alg").toString();
if (!isAlgorithmSupported(strAlgorithm))
{
return false;
......
......@@ -27,20 +27,20 @@ QString
AirspaceAdvisory::typeStr()
{
switch(type()) {
case Airport: return QString(tr("Airport"));
case Controlled_airspace: return QString(tr("Controlled Airspace"));
case Special_use_airspace: return QString(tr("Special Use Airspace"));
case Tfr: return QString(tr("TFR"));
case Wildfire: return QString(tr("Wild Fire"));
case Park: return QString(tr("Park"));
case Power_plant: return QString(tr("Power Plant"));
case Heliport: return QString(tr("Heliport"));
case Prison: return QString(tr("Prison"));
case School: return QString(tr("School"));
case Hospital: return QString(tr("Hospital"));
case Fire: return QString(tr("Fire"));
case Emergency: return QString(tr("Emergency"));
case Invalid: return QString(tr("Custom"));
default: return QString(tr("Unknown"));
case Airport: return tr("Airport");
case Controlled_airspace: return tr("Controlled Airspace");
case Special_use_airspace: return tr("Special Use Airspace");
case Tfr: return tr("TFR");
case Wildfire: return tr("Wild Fire");
case Park: return tr("Park");
case Power_plant: return tr("Power Plant");
case Heliport: return tr("Heliport");
case Prison: return tr("Prison");
case School: return tr("School");
case Hospital: return tr("Hospital");
case Fire: return tr("Fire");
case Emergency: return tr("Emergency");
case Invalid: return tr("Custom");
default: return tr("Unknown");
}
}
......@@ -135,9 +135,6 @@ void GeoTagController::_setErrorMessage(const QString& error)
GeoTagWorker::GeoTagWorker()
: _cancel(false)
, _logFile("")
, _imageDirectory("")
, _saveDirectory("")
{
}
......
......@@ -177,7 +177,7 @@ LogDownloadController::_logEntry(UASInterface* uas, uint32_t time_utc, uint32_t
entry->setSize(size);
entry->setTime(QDateTime::fromTime_t(time_utc));
entry->setReceived(true);
entry->setStatus(QString(tr("Available")));
entry->setStatus(tr("Available"));
} else {
qWarning() << "Received log entry for out-of-bound index:" << id;
}
......@@ -224,7 +224,7 @@ LogDownloadController::_resetSelection(bool canceled)
if(entry) {
if(entry->selected()) {
if(canceled) {
entry->setStatus(QString(tr("Canceled")));
entry->setStatus(tr("Canceled"));
}
entry->setSelected(false);
}
......@@ -271,7 +271,7 @@ LogDownloadController::_findMissingEntries()
for(int i = 0; i < num_logs; i++) {
QGCLogEntry* entry = _logEntriesModel[i];
if(entry && !entry->received()) {
entry->setStatus(QString(tr("Error")));
entry->setStatus(tr("Error"));
}
}
//-- Give up
......@@ -357,7 +357,7 @@ LogDownloadController::_logData(UASInterface* uas, uint32_t ofs, uint16_t id, ui
_timer.start(timeout_time);
//-- Do we have it all?
if(_logComplete()) {
_downloadData->entry->setStatus(QString(tr("Downloaded")));
_downloadData->entry->setStatus(tr("Downloaded"));
//-- Check for more
_receivedAllData();
} else if (_chunkComplete()) {
......@@ -376,7 +376,7 @@ LogDownloadController::_logData(UASInterface* uas, uint32_t ofs, uint16_t id, ui
qWarning() << "Received log offset greater than expected";
}
if(!result) {
_downloadData->entry->setStatus(QString(tr("Error")));
_downloadData->entry->setStatus(tr("Error"));
}
}
......@@ -423,7 +423,7 @@ LogDownloadController::_findMissingData()
}
if(_retries++ > 2) {
_downloadData->entry->setStatus(QString(tr("Timed Out")));
_downloadData->entry->setStatus(tr("Timed Out"));
//-- Give up
qWarning() << "Too many errors retreiving log data. Giving up.";
_receivedAllData();
......@@ -541,7 +541,7 @@ void LogDownloadController::downloadToDirectory(const QString& dir)
QGCLogEntry* entry = _logEntriesModel[i];
if(entry) {
if(entry->selected()) {
entry->setStatus(QString(tr("Waiting")));
entry->setStatus(tr("Waiting"));
}
}
}
......@@ -632,7 +632,7 @@ LogDownloadController::_prepareLogDownload()
if (_downloadData->file.exists()) {
_downloadData->file.remove();
}
_downloadData->entry->setStatus(QString(tr("Error")));
_downloadData->entry->setStatus(tr("Error"));
delete _downloadData;
_downloadData = NULL;
}
......@@ -686,7 +686,7 @@ LogDownloadController::cancel(void)
_receivedAllEntries();
}
if(_downloadData) {
_downloadData->entry->setStatus(QString(tr("Canceled")));
_downloadData->entry->setStatus(tr("Canceled"));
if (_downloadData->file.exists()) {
_downloadData->file.remove();
}
......
......@@ -409,7 +409,7 @@ MAVLinkInspectorController::_vehicleAdded(Vehicle* vehicle)
} else {
v = new QGCMAVLinkVehicle(this, static_cast<uint8_t>(vehicle->id()));
_vehicles.append(v);
_vehicleNames.append(QString(tr("Vehicle %1")).arg(vehicle->id()));
_vehicleNames.append(tr("Vehicle %1").arg(vehicle->id()));
}
emit vehiclesChanged();
}
......@@ -422,7 +422,7 @@ MAVLinkInspectorController::_vehicleRemoved(Vehicle* vehicle)
if(v) {
v->deleteLater();
_vehicles.removeOne(v);
QString vs = QString(tr("Vehicle %1")).arg(vehicle->id());
QString vs = tr("Vehicle %1").arg(vehicle->id());
_vehicleNames.removeOne(vs);
emit vehiclesChanged();
}
......@@ -438,7 +438,7 @@ MAVLinkInspectorController::_receiveMessage(LinkInterface* link, mavlink_message
if(!v) {
v = new QGCMAVLinkVehicle(this, message.sysid);
_vehicles.append(v);
_vehicleNames.append(QString(tr("Vehicle %1")).arg(message.sysid));
_vehicleNames.append(tr("Vehicle %1").arg(message.sysid));
emit vehiclesChanged();
if(!_activeVehicle) {
_activeVehicle = v;
......
......@@ -25,7 +25,7 @@ MavlinkConsoleController::MavlinkConsoleController()
MavlinkConsoleController::~MavlinkConsoleController()
{
if (_vehicle) {
QByteArray msg("");
QByteArray msg;
_sendSerialData(msg, true);
}
}
......
......@@ -625,7 +625,7 @@ void QGCApplication::saveTelemetryLogOnMainThread(QString tempLogfile)
int tryIndex = 1;
QString saveFileName = nameFormat.arg(
QDateTime::currentDateTime().toString(dtFormat)).arg("").arg(toolbox()->settingsManager()->appSettings()->telemetryFileExtension);
QDateTime::currentDateTime().toString(dtFormat)).arg(QStringLiteral("")).arg(toolbox()->settingsManager()->appSettings()->telemetryFileExtension);
while (saveDir.exists(saveFileName)) {
saveFileName = nameFormat.arg(
QDateTime::currentDateTime().toString(dtFormat)).arg(QStringLiteral(".%1").arg(tryIndex++)).arg(toolbox()->settingsManager()->appSettings()->telemetryFileExtension);
......
......@@ -498,7 +498,7 @@ TaisyncManager::_updateSettings(QByteArray jSonData)
//-- Link Status?
if(jSonData.contains("\"flight\":")) {
_reqMask &= ~static_cast<uint32_t>(REQ_LINK_STATUS);
bool tlinkConnected = jObj["flight"].toString("") == "online";
bool tlinkConnected = jObj["flight"].toString() == "online";
if(tlinkConnected != _linkConnected) {
_linkConnected = tlinkConnected;
emit linkConnectedChanged();
......
......@@ -197,14 +197,14 @@ Rectangle {
Layout.minimumWidth: _labelWidth
}
QGCLabel {
text: QGroundControl.taisyncManager.connected ? QGroundControl.taisyncManager.serialNumber : qsTr("")
text: QGroundControl.taisyncManager.connected ? QGroundControl.taisyncManager.serialNumber : ""
Layout.minimumWidth: _valueWidth
}
QGCLabel {
text: qsTr("Firmware Version:")
}
QGCLabel {
text: QGroundControl.taisyncManager.connected ? QGroundControl.taisyncManager.fwVersion : qsTr("")
text: QGroundControl.taisyncManager.connected ? QGroundControl.taisyncManager.fwVersion : ""
}
}
}
......
......@@ -1539,7 +1539,7 @@ void Vehicle::_handleSysStatus(mavlink_message_t& message)
if (sysStatus.battery_remaining > 0) {
if (sysStatus.battery_remaining < _settingsManager->appSettings()->batteryPercentRemainingAnnounce()->rawValue().toInt() &&
sysStatus.battery_remaining < _lastAnnouncedLowBatteryPercent) {
_say(QString(tr("%1 low battery: %2 percent remaining")).arg(_vehicleIdSpeech()).arg(sysStatus.battery_remaining));
_say(tr("%1 low battery: %2 percent remaining").arg(_vehicleIdSpeech()).arg(sysStatus.battery_remaining));
}
_lastAnnouncedLowBatteryPercent = sysStatus.battery_remaining;
}
......@@ -2934,7 +2934,7 @@ QString Vehicle::vehicleTypeName() const {
QString Vehicle::_vehicleIdSpeech(void)
{
if (_toolbox->multiVehicleManager()->vehicles()->count() > 1) {
return QString(tr("vehicle %1")).arg(id());
return tr("vehicle %1").arg(id());
} else {
return QString();
}
......@@ -2942,13 +2942,13 @@ QString Vehicle::_vehicleIdSpeech(void)
void Vehicle::_handleFlightModeChanged(const QString& flightMode)
{
_say(QString(tr("%1 %2 flight mode")).arg(_vehicleIdSpeech()).arg(flightMode));
_say(tr("%1 %2 flight mode").arg(_vehicleIdSpeech()).arg(flightMode));
emit guidedModeChanged(_firmwarePlugin->isGuidedMode(this));
}
void Vehicle::_announceArmedChanged(bool armed)
{
_say(QString("%1 %2").arg(_vehicleIdSpeech()).arg(armed ? QString(tr("armed")) : QString(tr("disarmed"))));
_say(QString("%1 %2").arg(_vehicleIdSpeech()).arg(armed ? tr("armed") : tr("disarmed")));
}
void Vehicle::_setFlying(bool flying)
......
......@@ -345,7 +345,7 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
**/
QString MAVLinkProtocol::getName()
{
return QString(tr("MAVLink protocol"));
return tr("MAVLink protocol");
}
/** @return System id of this application */
......
......@@ -149,42 +149,41 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString
}
// And determine the text for the severitie
QString severityText("");
QString severityText;
switch (severity)
{
case MAV_SEVERITY_EMERGENCY:
severityText = QString(tr(" EMERGENCY:"));
severityText = tr(" EMERGENCY:");
break;
case MAV_SEVERITY_ALERT:
severityText = QString(tr(" ALERT:"));
severityText = tr(" ALERT:");
break;
case MAV_SEVERITY_CRITICAL:
severityText = QString(tr(" Critical:"));
severityText = tr(" Critical:");
break;
case MAV_SEVERITY_ERROR:
severityText = QString(tr(" Error:"));
severityText = tr(" Error:");
break;
case MAV_SEVERITY_WARNING:
severityText = QString(tr(" Warning:"));
severityText = tr(" Warning:");
break;
case MAV_SEVERITY_NOTICE:
severityText = QString(tr(" Notice:"));
severityText = tr(" Notice:");
break;
case MAV_SEVERITY_INFO:
severityText = QString(tr(" Info:"));
severityText = tr(" Info:");
break;
case MAV_SEVERITY_DEBUG:
severityText = QString(tr(" Debug:"));
severityText = tr(" Debug:");
break;
default:
severityText = QString(tr(""));
break;
}
// Finally preppend the properly-styled text with a timestamp.
QString dateString = QDateTime::currentDateTime().toString("hh:mm:ss.zzz");
UASMessage* message = new UASMessage(compId, severity, text);
QString compString("");
QString compString;
if (_multiComp) {
compString = QString(" COMP:%1").arg(compId);
}
......
......@@ -227,7 +227,7 @@ void MAVLinkDecoder::emitFieldValue(mavlink_message_t* msg, int fieldid, quint64
QString fieldType;
uint8_t* m = (uint8_t*)(msgDict[msgid].payload64);
QString name("%1.%2");
QString unit("");
QString unit;
// Debug vector messages
if (msgid == MAVLINK_MSG_ID_DEBUG_VECT)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment