Examples/Doc snippets: Fix single-character string literals.
Use character literals where applicable. Change-Id: I79fa5018f05735201ae35ee94ba0d356fcad1056 Reviewed-by: Topi Reiniö <topi.reinio@digia.com>
This commit is contained in:
parent
dab4877a0a
commit
f9bf737d74
@ -112,7 +112,7 @@ protected:
|
||||
|
||||
QString str = QString::number(n);
|
||||
if (str.length() == 1)
|
||||
str.prepend("0");
|
||||
str.prepend('0');
|
||||
|
||||
QFont font;
|
||||
font.setFamily("Helvetica");
|
||||
|
@ -219,8 +219,8 @@ bool FileManager::generateFiles()
|
||||
QString prefix;
|
||||
if (!destinationPath.isEmpty()) {
|
||||
prefix = destinationPath;
|
||||
if (!prefix.endsWith("/"))
|
||||
prefix += "/";
|
||||
if (!prefix.endsWith('/'))
|
||||
prefix += '/';
|
||||
QDir dir;
|
||||
if (!dir.mkpath(prefix)) {
|
||||
errString = tr("Failed to create directory %1").arg(prefix);
|
||||
@ -261,13 +261,13 @@ bool FileManager::generateFiles()
|
||||
|
||||
if (!destinationPath.isEmpty()) {
|
||||
prefix = destinationPath;
|
||||
if (!prefix.endsWith("/"))
|
||||
prefix += "/";
|
||||
if (!prefix.endsWith('/'))
|
||||
prefix += '/';
|
||||
}
|
||||
if (!metaInfo.name().isEmpty()) {
|
||||
prefix += metaInfo.name();
|
||||
if (!prefix.endsWith("/"))
|
||||
prefix += "/";
|
||||
if (!prefix.endsWith('/'))
|
||||
prefix += '/';
|
||||
}
|
||||
if (!dir.mkpath(prefix)) {
|
||||
errString = tr("Failed to create directory %1").arg(prefix);
|
||||
|
@ -96,7 +96,7 @@ bool MetaInfo::parse(const QByteArray &data)
|
||||
QByteArray path;
|
||||
foreach (QVariant p, pathElements) {
|
||||
if (!path.isEmpty())
|
||||
path += "/";
|
||||
path += '/';
|
||||
path += p.toByteArray();
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,7 @@ void Widget::printFormat(const QSurfaceFormat &format)
|
||||
QString opts;
|
||||
for (size_t i = 0; i < sizeof(options) / sizeof(Option); ++i)
|
||||
if (format.testOption(options[i].option))
|
||||
opts += QString::fromLatin1(options[i].str) + QStringLiteral(" ");
|
||||
opts += QString::fromLatin1(options[i].str) + QLatin1Char(' ');
|
||||
m_output->append(tr("Options: %1").arg(opts));
|
||||
|
||||
for (size_t i = 0; i < sizeof(renderables) / sizeof(Renderable); ++i)
|
||||
|
@ -61,10 +61,10 @@ QStringList findFiles(const QString &startDir, QStringList filters)
|
||||
QDir dir(startDir);
|
||||
|
||||
foreach (QString file, dir.entryList(filters, QDir::Files))
|
||||
names += startDir + "/" + file;
|
||||
names += startDir + '/' + file;
|
||||
|
||||
foreach (QString subdir, dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot))
|
||||
names += findFiles(startDir + "/" + subdir, filters);
|
||||
names += findFiles(startDir + '/' + subdir, filters);
|
||||
return names;
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ WordCount singleThreadedWordCount(QStringList files)
|
||||
f.open(QIODevice::ReadOnly);
|
||||
QTextStream textStream(&f);
|
||||
while (textStream.atEnd() == false)
|
||||
foreach(QString word, textStream.readLine().split(" "))
|
||||
foreach (const QString &word, textStream.readLine().split(' '))
|
||||
wordCount[word] += 1;
|
||||
|
||||
}
|
||||
@ -100,7 +100,7 @@ WordCount countWords(const QString &file)
|
||||
WordCount wordCount;
|
||||
|
||||
while (textStream.atEnd() == false)
|
||||
foreach (QString word, textStream.readLine().split(" "))
|
||||
foreach (const QString &word, textStream.readLine().split(' '))
|
||||
wordCount[word] += 1;
|
||||
|
||||
return wordCount;
|
||||
|
@ -153,7 +153,7 @@ void Dialog::addTracks(int albumId, QStringList tracks)
|
||||
for (int i = 0; i < tracks.count(); i++) {
|
||||
QString trackNumber = QString::number(i);
|
||||
if (i < 10)
|
||||
trackNumber.prepend("0");
|
||||
trackNumber.prepend('0');
|
||||
|
||||
QDomText textNode = albumDetails.createTextNode(tracks.at(i));
|
||||
|
||||
|
@ -53,7 +53,7 @@ QVariant CustomSqlModel::data(const QModelIndex &index, int role) const
|
||||
QVariant value = QSqlQueryModel::data(index, role);
|
||||
if (value.isValid() && role == Qt::DisplayRole) {
|
||||
if (index.column() == 0)
|
||||
return value.toString().prepend("#");
|
||||
return value.toString().prepend('#');
|
||||
else if (index.column() == 2)
|
||||
return value.toString().toUpper();
|
||||
}
|
||||
|
@ -79,31 +79,31 @@ void ClassWizard::accept()
|
||||
|
||||
if (field("comment").toBool()) {
|
||||
block += "/*\n";
|
||||
block += " " + header.toLatin1() + "\n";
|
||||
block += " " + header.toLatin1() + '\n';
|
||||
block += "*/\n";
|
||||
block += "\n";
|
||||
block += '\n';
|
||||
}
|
||||
if (field("protect").toBool()) {
|
||||
block += "#ifndef " + macroName + "\n";
|
||||
block += "#define " + macroName + "\n";
|
||||
block += "\n";
|
||||
block += "#ifndef " + macroName + '\n';
|
||||
block += "#define " + macroName + '\n';
|
||||
block += '\n';
|
||||
}
|
||||
if (field("includeBase").toBool()) {
|
||||
block += "#include " + baseInclude + "\n";
|
||||
block += "\n";
|
||||
block += "#include " + baseInclude + '\n';
|
||||
block += '\n';
|
||||
}
|
||||
|
||||
block += "class " + className;
|
||||
if (!baseClass.isEmpty())
|
||||
block += " : public " + baseClass;
|
||||
block += "\n";
|
||||
block += '\n';
|
||||
block += "{\n";
|
||||
|
||||
/* qmake ignore Q_OBJECT */
|
||||
|
||||
if (field("qobjectMacro").toBool()) {
|
||||
block += " Q_OBJECT\n";
|
||||
block += "\n";
|
||||
block += '\n';
|
||||
}
|
||||
block += "public:\n";
|
||||
|
||||
@ -115,7 +115,7 @@ void ClassWizard::accept()
|
||||
block += " " + className + "();\n";
|
||||
if (field("copyCtor").toBool()) {
|
||||
block += " " + className + "(const " + className + " &other);\n";
|
||||
block += "\n";
|
||||
block += '\n';
|
||||
block += " " + className + " &operator=" + "(const " + className
|
||||
+ " &other);\n";
|
||||
}
|
||||
@ -123,11 +123,11 @@ void ClassWizard::accept()
|
||||
block += "};\n";
|
||||
|
||||
if (field("protect").toBool()) {
|
||||
block += "\n";
|
||||
block += '\n';
|
||||
block += "#endif\n";
|
||||
}
|
||||
|
||||
QFile headerFile(outputDir + "/" + header);
|
||||
QFile headerFile(outputDir + '/' + header);
|
||||
if (!headerFile.open(QFile::WriteOnly | QFile::Text)) {
|
||||
QMessageBox::warning(0, QObject::tr("Simple Wizard"),
|
||||
QObject::tr("Cannot write file %1:\n%2")
|
||||
@ -141,12 +141,12 @@ void ClassWizard::accept()
|
||||
|
||||
if (field("comment").toBool()) {
|
||||
block += "/*\n";
|
||||
block += " " + implementation.toLatin1() + "\n";
|
||||
block += " " + implementation.toLatin1() + '\n';
|
||||
block += "*/\n";
|
||||
block += "\n";
|
||||
block += '\n';
|
||||
}
|
||||
block += "#include \"" + header.toLatin1() + "\"\n";
|
||||
block += "\n";
|
||||
block += '\n';
|
||||
|
||||
if (field("qobjectCtor").toBool()) {
|
||||
block += className + "::" + className + "(QObject *parent)\n";
|
||||
@ -171,7 +171,7 @@ void ClassWizard::accept()
|
||||
block += "{\n";
|
||||
block += " *this = other;\n";
|
||||
block += "}\n";
|
||||
block += "\n";
|
||||
block += '\n';
|
||||
block += className + " &" + className + "::operator=(const "
|
||||
+ className + " &other)\n";
|
||||
block += "{\n";
|
||||
@ -183,7 +183,7 @@ void ClassWizard::accept()
|
||||
}
|
||||
}
|
||||
|
||||
QFile implementationFile(outputDir + "/" + implementation);
|
||||
QFile implementationFile(outputDir + '/' + implementation);
|
||||
if (!implementationFile.open(QFile::WriteOnly | QFile::Text)) {
|
||||
QMessageBox::warning(0, QObject::tr("Simple Wizard"),
|
||||
QObject::tr("Cannot write file %1:\n%2")
|
||||
@ -356,9 +356,9 @@ void CodeStylePage::initializePage()
|
||||
if (baseClass.isEmpty()) {
|
||||
baseIncludeLineEdit->clear();
|
||||
} else if (QRegExp("Q[A-Z].*").exactMatch(baseClass)) {
|
||||
baseIncludeLineEdit->setText("<" + baseClass + ">");
|
||||
baseIncludeLineEdit->setText('<' + baseClass + '>');
|
||||
} else {
|
||||
baseIncludeLineEdit->setText("\"" + baseClass.toLower() + ".h\"");
|
||||
baseIncludeLineEdit->setText('"' + baseClass.toLower() + ".h\"");
|
||||
}
|
||||
}
|
||||
//! [16]
|
||||
|
@ -229,7 +229,7 @@ void ImageWidget::goNextImage()
|
||||
prevImage = currentImage;
|
||||
currentImage = nextImage;
|
||||
if (position+1 < files.size())
|
||||
nextImage = loadImage(path+QLatin1String("/")+files.at(position+1));
|
||||
nextImage = loadImage(path + QLatin1Char('/') + files.at(position+1));
|
||||
else
|
||||
nextImage = QImage();
|
||||
}
|
||||
@ -246,7 +246,7 @@ void ImageWidget::goPrevImage()
|
||||
nextImage = currentImage;
|
||||
currentImage = prevImage;
|
||||
if (position > 0)
|
||||
prevImage = loadImage(path+QLatin1String("/")+files.at(position-1));
|
||||
prevImage = loadImage(path + QLatin1Char('/') + files.at(position-1));
|
||||
else
|
||||
prevImage = QImage();
|
||||
}
|
||||
@ -276,12 +276,12 @@ void ImageWidget::goToImage(int index)
|
||||
position = index;
|
||||
|
||||
if (index > 0)
|
||||
prevImage = loadImage(path+QLatin1String("/")+files.at(position-1));
|
||||
prevImage = loadImage(path + QLatin1Char('/') + files.at(position-1));
|
||||
else
|
||||
prevImage = QImage();
|
||||
currentImage = loadImage(path+QLatin1String("/")+files.at(position));
|
||||
currentImage = loadImage(path + QLatin1Char('/') + files.at(position));
|
||||
if (position+1 < files.size())
|
||||
nextImage = loadImage(path+QLatin1String("/")+files.at(position+1));
|
||||
nextImage = loadImage(path + QLatin1Char('/') + files.at(position+1));
|
||||
else
|
||||
nextImage = QImage();
|
||||
update();
|
||||
|
@ -319,9 +319,9 @@ RenderOptionsDialog::RenderOptionsDialog()
|
||||
while (++it != tokens.end()) {
|
||||
m_parameterNames << name;
|
||||
if (!singleElement) {
|
||||
m_parameterNames.back() += "[";
|
||||
m_parameterNames.back() += '[';
|
||||
m_parameterNames.back() += counter + counterPos;
|
||||
m_parameterNames.back() += "]";
|
||||
m_parameterNames.back() += ']';
|
||||
int j = 8; // position of last digit
|
||||
++counter[j];
|
||||
while (j > 0 && counter[j] > '9') {
|
||||
|
@ -124,7 +124,7 @@ void MainWindow::loadFile(const QString &fileName)
|
||||
if (!line.isEmpty()) {
|
||||
model->insertRows(row, 1, QModelIndex());
|
||||
|
||||
QStringList pieces = line.split(",", QString::SkipEmptyParts);
|
||||
QStringList pieces = line.split(',', QString::SkipEmptyParts);
|
||||
model->setData(model->index(row, 0, QModelIndex()),
|
||||
pieces.value(0));
|
||||
model->setData(model->index(row, 1, QModelIndex()),
|
||||
|
@ -246,7 +246,7 @@ void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent)
|
||||
while (number < lines.count()) {
|
||||
int position = 0;
|
||||
while (position < lines[number].length()) {
|
||||
if (lines[number].mid(position, 1) != " ")
|
||||
if (lines[number].at(position) != ' ')
|
||||
break;
|
||||
++position;
|
||||
}
|
||||
|
@ -54,15 +54,15 @@ int main(int argc, char* argv[])
|
||||
QFile file(":/grades.txt");
|
||||
if (file.open(QFile::ReadOnly)) {
|
||||
QString line = file.readLine(200);
|
||||
QStringList list = line.simplified().split(",");
|
||||
QStringList list = line.simplified().split(',');
|
||||
model->setHorizontalHeaderLabels(list);
|
||||
|
||||
int row = 0;
|
||||
QStandardItem *newItem = 0;
|
||||
while (file.canReadLine()) {
|
||||
line = file.readLine(200);
|
||||
if (!line.startsWith("#") && line.contains(",")) {
|
||||
list= line.simplified().split(",");
|
||||
if (!line.startsWith('#') && line.contains(',')) {
|
||||
list = line.simplified().split(',');
|
||||
for (int col = 0; col < list.length(); ++col){
|
||||
newItem = new QStandardItem(list.at(col));
|
||||
model->setItem(row, col, newItem);
|
||||
|
@ -88,7 +88,7 @@ QVariant Model::data(const QModelIndex &index, int role) const
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
if (role == Qt::DisplayRole)
|
||||
return QVariant("Item " + QString::number(index.row()) + ":" + QString::number(index.column()));
|
||||
return QVariant("Item " + QString::number(index.row()) + ':' + QString::number(index.column()));
|
||||
if (role == Qt::DecorationRole) {
|
||||
if (index.column() == 0)
|
||||
return iconProvider.icon(QFileIconProvider::Folder);
|
||||
|
@ -88,7 +88,7 @@ QVariant DomModel::data(const QModelIndex &index, int role) const
|
||||
for (int i = 0; i < attributeMap.count(); ++i) {
|
||||
QDomNode attribute = attributeMap.item(i);
|
||||
attributes << attribute.nodeName() + "=\""
|
||||
+attribute.nodeValue() + "\"";
|
||||
+attribute.nodeValue() + '"';
|
||||
}
|
||||
return attributes.join(' ');
|
||||
case 2:
|
||||
|
@ -180,7 +180,7 @@ void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent)
|
||||
while (number < lines.count()) {
|
||||
int position = 0;
|
||||
while (position < lines[number].length()) {
|
||||
if (lines[number].mid(position, 1) != " ")
|
||||
if (lines[number].at(position) != ' ')
|
||||
break;
|
||||
position++;
|
||||
}
|
||||
|
@ -153,8 +153,8 @@ void RegExpDialog::refresh()
|
||||
QString escaped = pattern;
|
||||
escaped.replace("\\", "\\\\");
|
||||
escaped.replace("\"", "\\\"");
|
||||
escaped.prepend("\"");
|
||||
escaped.append("\"");
|
||||
escaped.prepend('"');
|
||||
escaped.append('"');
|
||||
escapedPatternLineEdit->setText(escaped);
|
||||
|
||||
QRegExp rx(pattern);
|
||||
|
@ -111,8 +111,8 @@ void RegularExpressionDialog::refresh()
|
||||
QString escaped = pattern;
|
||||
escaped.replace(QLatin1String("\\"), QLatin1String("\\\\"));
|
||||
escaped.replace(QLatin1String("\""), QLatin1String("\\\""));
|
||||
escaped.prepend(QLatin1String("\""));
|
||||
escaped.append(QLatin1String("\""));
|
||||
escaped.prepend(QLatin1Char('"'));
|
||||
escaped.append(QLatin1Char('"'));
|
||||
escapedPatternLineEdit->setText(escaped);
|
||||
|
||||
QRegularExpression rx(pattern);
|
||||
|
@ -60,7 +60,7 @@ VariantDelegate::VariantDelegate(QObject *parent)
|
||||
|
||||
dateExp.setPattern("([0-9]{,4})-([0-9]{,2})-([0-9]{,2})");
|
||||
timeExp.setPattern("([0-9]{,2}):([0-9]{,2}):([0-9]{,2})");
|
||||
dateTimeExp.setPattern(dateExp.pattern() + "T" + timeExp.pattern());
|
||||
dateTimeExp.setPattern(dateExp.pattern() + 'T' + timeExp.pattern());
|
||||
}
|
||||
|
||||
void VariantDelegate::paint(QPainter *painter,
|
||||
@ -217,7 +217,7 @@ void VariantDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||
value = QSize(sizeExp.cap(1).toInt(), sizeExp.cap(2).toInt());
|
||||
break;
|
||||
case QVariant::StringList:
|
||||
value = text.split(",");
|
||||
value = text.split(',');
|
||||
break;
|
||||
case QVariant::Time:
|
||||
{
|
||||
|
@ -421,23 +421,23 @@ void AddressBook::exportAsVCard()
|
||||
//! [export function part2]
|
||||
|
||||
//! [export function part3]
|
||||
out << "BEGIN:VCARD" << "\n";
|
||||
out << "VERSION:2.1" << "\n";
|
||||
out << "N:" << lastName << ";" << firstName << "\n";
|
||||
out << "BEGIN:VCARD" << '\n';
|
||||
out << "VERSION:2.1" << '\n';
|
||||
out << "N:" << lastName << ';' << firstName << '\n';
|
||||
|
||||
if (!nameList.isEmpty())
|
||||
out << "FN:" << nameList.join(' ') << "\n";
|
||||
out << "FN:" << nameList.join(' ') << '\n';
|
||||
else
|
||||
out << "FN:" << firstName << "\n";
|
||||
out << "FN:" << firstName << '\n';
|
||||
//! [export function part3]
|
||||
|
||||
//! [export function part4]
|
||||
address.replace(";", "\\;", Qt::CaseInsensitive);
|
||||
address.replace("\n", ";", Qt::CaseInsensitive);
|
||||
address.replace('\n', ";", Qt::CaseInsensitive);
|
||||
address.replace(",", " ", Qt::CaseInsensitive);
|
||||
|
||||
out << "ADR;HOME:;" << address << "\n";
|
||||
out << "END:VCARD" << "\n";
|
||||
out << "ADR;HOME:;" << address << '\n';
|
||||
out << "END:VCARD" << '\n';
|
||||
|
||||
QMessageBox::information(this, tr("Export Successful"),
|
||||
tr("\"%1\" has been exported as a vCard.").arg(name));
|
||||
|
@ -83,7 +83,7 @@ bool MyModel::setData(const QModelIndex & index, const QVariant & value, int rol
|
||||
{
|
||||
for(int col= 0; col < COLS; col++)
|
||||
{
|
||||
result += m_gridData[row][col] + " ";
|
||||
result += m_gridData[row][col] + ' ';
|
||||
}
|
||||
}
|
||||
emit editCompleted( result );
|
||||
|
@ -276,7 +276,7 @@ void Calculator::pointClicked()
|
||||
{
|
||||
if (waitingForOperand)
|
||||
display->setText("0");
|
||||
if (!display->text().contains("."))
|
||||
if (!display->text().contains('.'))
|
||||
display->setText(display->text() + tr("."));
|
||||
waitingForOperand = false;
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ void parseHtmlFile(QTextStream &out, const QString &fileName) {
|
||||
}
|
||||
//! [2]
|
||||
|
||||
out << " Title: \"" << title << "\"" << endl
|
||||
out << " Title: \"" << title << '"' << endl
|
||||
<< " Number of paragraphs: " << paragraphCount << endl
|
||||
<< " Number of links: " << links.size() << endl
|
||||
<< " Showing first few links:" << endl;
|
||||
|
@ -81,8 +81,8 @@ QString XbelGenerator::escapedAttribute(const QString &str)
|
||||
{
|
||||
QString result = escapedText(str);
|
||||
result.replace("\"", """);
|
||||
result.prepend("\"");
|
||||
result.append("\"");
|
||||
result.prepend(QLatin1Char('"'));
|
||||
result.append(QLatin1Char('"'));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ QMap<int, int> map;
|
||||
...
|
||||
QMap<int, int>::const_iterator i;
|
||||
for (i = map.constBegin(); i != map.constEnd(); ++i)
|
||||
qDebug() << i.key() << ":" << i.value();
|
||||
qDebug() << i.key() << ':' << i.value();
|
||||
//! [13]
|
||||
|
||||
|
||||
@ -236,7 +236,7 @@ foreach (const QString &str, list) {
|
||||
QMap<QString, int> map;
|
||||
...
|
||||
foreach (const QString &str, map.keys())
|
||||
qDebug() << str << ":" << map.value(str);
|
||||
qDebug() << str << ':' << map.value(str);
|
||||
//! [19]
|
||||
|
||||
|
||||
@ -245,7 +245,7 @@ QMultiMap<QString, int> map;
|
||||
...
|
||||
foreach (const QString &str, map.uniqueKeys()) {
|
||||
foreach (int i, map.values(str))
|
||||
qDebug() << str << ":" << i;
|
||||
qDebug() << str << ':' << i;
|
||||
}
|
||||
//! [20]
|
||||
|
||||
|
@ -220,7 +220,7 @@ for (i = hash.begin(); i != hash.end(); ++i)
|
||||
//! [19]
|
||||
QHash<QString, int>::iterator i = hash.begin();
|
||||
while (i != hash.end()) {
|
||||
if (i.key().startsWith("_"))
|
||||
if (i.key().startsWith('_'))
|
||||
i = hash.erase(i);
|
||||
else
|
||||
++i;
|
||||
@ -233,7 +233,7 @@ QHash<QString, int>::iterator i = hash.begin();
|
||||
while (i != hash.end()) {
|
||||
QHash<QString, int>::iterator prev = i;
|
||||
++i;
|
||||
if (prev.key().startsWith("_"))
|
||||
if (prev.key().startsWith('_'))
|
||||
hash.erase(prev);
|
||||
}
|
||||
//! [20]
|
||||
@ -242,7 +242,7 @@ while (i != hash.end()) {
|
||||
//! [21]
|
||||
// WRONG
|
||||
while (i != hash.end()) {
|
||||
if (i.key().startsWith("_"))
|
||||
if (i.key().startsWith('_'))
|
||||
hash.erase(i);
|
||||
++i;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ QLinkedList<QString> list;
|
||||
...
|
||||
QLinkedList<QString>::iterator i = list.begin();
|
||||
while (i != list.end()) {
|
||||
if ((*i).startsWith("_"))
|
||||
if ((*i).startsWith('_'))
|
||||
i = list.erase(i);
|
||||
else
|
||||
++i;
|
||||
@ -141,7 +141,7 @@ QLinkedList<QString>::iterator i = list.begin();
|
||||
while (i != list.end()) {
|
||||
QLinkedList<QString>::iterator previous = i;
|
||||
++i;
|
||||
if ((*previous).startsWith("_"))
|
||||
if ((*previous).startsWith('_'))
|
||||
list.erase(previous);
|
||||
}
|
||||
//! [11]
|
||||
@ -150,7 +150,7 @@ while (i != list.end()) {
|
||||
//! [12]
|
||||
// WRONG
|
||||
while (i != list.end()) {
|
||||
if ((*i).startsWith("_"))
|
||||
if ((*i).startsWith('_'))
|
||||
list.erase(i);
|
||||
++i;
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ for (i = map.begin(); i != map.end(); ++i)
|
||||
//! [20]
|
||||
QMap<QString, int>::iterator i = map.begin();
|
||||
while (i != map.end()) {
|
||||
if (i.key().startsWith("_"))
|
||||
if (i.key().startsWith('_'))
|
||||
i = map.erase(i);
|
||||
else
|
||||
++i;
|
||||
@ -247,7 +247,7 @@ QMap<QString, int>::iterator i = map.begin();
|
||||
while (i != map.end()) {
|
||||
QMap<QString, int>::iterator prev = i;
|
||||
++i;
|
||||
if (prev.key().startsWith("_"))
|
||||
if (prev.key().startsWith('_'))
|
||||
map.erase(prev);
|
||||
}
|
||||
//! [21]
|
||||
@ -256,7 +256,7 @@ while (i != map.end()) {
|
||||
//! [22]
|
||||
// WRONG
|
||||
while (i != map.end()) {
|
||||
if (i.key().startsWith("_"))
|
||||
if (i.key().startsWith('_'))
|
||||
map.erase(i);
|
||||
++i;
|
||||
}
|
||||
|
@ -777,10 +777,10 @@ void Widget::splitCaseSensitiveFunction()
|
||||
//! [62]
|
||||
QString str = "a,,b,c";
|
||||
|
||||
QStringList list1 = str.split(",");
|
||||
QStringList list1 = str.split(',');
|
||||
// list1: [ "a", "", "b", "c" ]
|
||||
|
||||
QStringList list2 = str.split(",", QString::SkipEmptyParts);
|
||||
QStringList list2 = str.split(',', QString::SkipEmptyParts);
|
||||
// list2: [ "a", "b", "c" ]
|
||||
//! [62]
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ Widget::Widget(QWidget *parent)
|
||||
//! [5] //! [6]
|
||||
QStringList list;
|
||||
//! [5]
|
||||
list = str.split(",");
|
||||
list = str.split(',');
|
||||
// list: ["Arial", "Helvetica", "Times", "Courier"]
|
||||
//! [6]
|
||||
|
||||
|
@ -60,7 +60,7 @@ int main(int argc, char **argv)
|
||||
|
||||
QString sizes;
|
||||
foreach (int points, database.smoothSizes(family, style))
|
||||
sizes += QString::number(points) + " ";
|
||||
sizes += QString::number(points) + ' ';
|
||||
|
||||
styleItem->setText(1, sizes.trimmed());
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ namespace QTest {
|
||||
{
|
||||
QByteArray ba = "MyPoint(";
|
||||
ba += QByteArray::number(point.x()) + ", " + QByteArray::number(point.y());
|
||||
ba += ")";
|
||||
ba += ')';
|
||||
return qstrdup(ba.data());
|
||||
}
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ bool Handler::characters (const QString &chars)
|
||||
bool Handler::fatalError (const QXmlParseException & exception)
|
||||
{
|
||||
qWarning() << "Fatal error on line" << exception.lineNumber()
|
||||
<< ", column" << exception.columnNumber() << ":"
|
||||
<< ", column" << exception.columnNumber() << ':'
|
||||
<< exception.message();
|
||||
|
||||
return false;
|
||||
|
@ -78,7 +78,7 @@ int main(int argc, char **argv)
|
||||
|
||||
for (int i = 0; i < items; ++i) {
|
||||
for (int j = 0; j < indentations[i]; ++j)
|
||||
std::cout << " ";
|
||||
std::cout << ' ';
|
||||
std::cout << names[i].toLocal8Bit().constData() << std::endl;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user