Simplify QTableGenerator::printComposeTable()
Instead of filling a QString with lots of temporaries in-between, simply stream everything into QDebug directly. Requires the use of #ifndef QT_NO_DEBUG_STREAM because of the explicit mentioning of QDebug. Further simplified it by removing the complicated trailing-comma handling. The struct-like output can tolerate a trailing comma which has been allowed in C/C++ since its inception. Change-Id: I0393a37cd21a50e902c8cb9f8b752ebb946d1669 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
parent
fc8323fec6
commit
1c0f247671
@ -442,28 +442,22 @@ void TableGenerator::parseKeySequence(char *line)
|
|||||||
void TableGenerator::printComposeTable() const
|
void TableGenerator::printComposeTable() const
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_GENERATOR
|
#ifdef DEBUG_GENERATOR
|
||||||
|
# ifndef QT_NO_DEBUG_STREAM
|
||||||
if (m_composeTable.isEmpty())
|
if (m_composeTable.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QString output;
|
QDebug ds = qDebug() << "output:\n";
|
||||||
QComposeTableElement elem;
|
ds.nospace();
|
||||||
QString comma = QStringLiteral(",");
|
const int tableSize = m_composeTable.size();
|
||||||
int tableSize = m_composeTable.size();
|
|
||||||
for (int i = 0; i < tableSize; ++i) {
|
for (int i = 0; i < tableSize; ++i) {
|
||||||
elem = m_composeTable.at(i);
|
const QComposeTableElement &elem = m_composeTable.at(i);
|
||||||
output.append(QLatin1String("{ {"));
|
ds << "{ {";
|
||||||
for (int j = 0; j < QT_KEYSEQUENCE_MAX_LEN; j++) {
|
for (int j = 0; j < QT_KEYSEQUENCE_MAX_LEN; j++) {
|
||||||
output.append(QString(QLatin1String("0x%1, ")).arg(QString::number(elem.keys[j],16)));
|
ds << hex << showbase << elem.keys[j] << ", ";
|
||||||
}
|
}
|
||||||
// take care of the trailing comma
|
ds << "}, " << hex << showbase << elem.value << ", \"\" }, // " << elem.comment << " \n";
|
||||||
if (i == tableSize - 1)
|
|
||||||
comma = QStringLiteral("");
|
|
||||||
output.append(QString(QLatin1String("}, 0x%1, \"\" }%2 // %3 \n"))
|
|
||||||
.arg(QString::number(elem.value,16))
|
|
||||||
.arg(comma)
|
|
||||||
.arg(elem.comment));
|
|
||||||
}
|
}
|
||||||
qDebug() << "output: \n" << output;
|
# endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user