Commit 342caa21 authored by hjk's avatar hjk
Browse files

some more whitespace changes

parent 88b7a14a
...@@ -45,7 +45,7 @@ QString CGI::encodeURL(const QString &rawText) ...@@ -45,7 +45,7 @@ QString CGI::encodeURL(const QString &rawText)
enc.reserve(utf.length()); // Make sure we at least have space for a normal US-ASCII URL enc.reserve(utf.length()); // Make sure we at least have space for a normal US-ASCII URL
QByteArray::const_iterator it = utf.constBegin(); QByteArray::const_iterator it = utf.constBegin();
while(it != utf.constEnd()) { while (it != utf.constEnd()) {
char ch = *it; char ch = *it;
if (('A' <= ch && ch <= 'Z') if (('A' <= ch && ch <= 'Z')
|| ('a' <= ch && ch <= 'z') || ('a' <= ch && ch <= 'z')
...@@ -54,7 +54,7 @@ QString CGI::encodeURL(const QString &rawText) ...@@ -54,7 +54,7 @@ QString CGI::encodeURL(const QString &rawText)
else if (ch == ' ') else if (ch == ' ')
enc.append('+'); enc.append('+');
else { else {
switch(ch) { switch (ch) {
case '-': case '_': case '-': case '_':
case '(': case ')': case '(': case ')':
case '.': case '!': case '.': case '!':
...@@ -80,15 +80,15 @@ QString CGI::decodeURL(const QString &urlText) ...@@ -80,15 +80,15 @@ QString CGI::decodeURL(const QString &urlText)
{ {
QByteArray dec; QByteArray dec;
QString::const_iterator it = urlText.constBegin(); QString::const_iterator it = urlText.constBegin();
while(it != urlText.constEnd()) { while (it != urlText.constEnd()) {
ushort ch = (*it).unicode(); ushort ch = (*it).unicode();
switch(ch) { switch (ch) {
case '%': case '%':
{ {
char c1 = char(0x00ff & (*(++it)).unicode()); char c1 = char(0x00ff & (*(++it)).unicode());
char c2 = char(0x00ff & (*(++it)).unicode()); char c2 = char(0x00ff & (*(++it)).unicode());
ushort v = 0; ushort v = 0;
if('A' <= c1 && c1 <= 'Z') if ('A' <= c1 && c1 <= 'Z')
v = c1 - 'A' + 10; v = c1 - 'A' + 10;
else if ('a' <= c1 && c1 <= 'z') else if ('a' <= c1 && c1 <= 'z')
v = c1 - 'a' + 10; v = c1 - 'a' + 10;
...@@ -97,7 +97,7 @@ QString CGI::decodeURL(const QString &urlText) ...@@ -97,7 +97,7 @@ QString CGI::decodeURL(const QString &urlText)
else else
continue; // Malformed URL! continue; // Malformed URL!
v <<= 4; // c1 was MSB half v <<= 4; // c1 was MSB half
if('A' <= c2 && c2 <= 'Z') if ('A' <= c2 && c2 <= 'Z')
v |= c2 - 'A' + 10; v |= c2 - 'A' + 10;
else if ('a' <= c2 && c2 <= 'z') else if ('a' <= c2 && c2 <= 'z')
v |= c2 - 'a' + 10; v |= c2 - 'a' + 10;
...@@ -123,7 +123,7 @@ QString CGI::decodeURL(const QString &urlText) ...@@ -123,7 +123,7 @@ QString CGI::decodeURL(const QString &urlText)
// ------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------
inline const char *unicodeToHTML(ushort unicode_char) inline const char *unicodeToHTML(ushort unicode_char)
{ {
switch(unicode_char) { switch (unicode_char) {
// Latin ------------------------------- // Latin -------------------------------
case 0x0022: return "quot"; // (34 ) quotation mark = APL quote case 0x0022: return "quot"; // (34 ) quotation mark = APL quote
case 0x0026: return "amp"; // (38 ) ampersand case 0x0026: return "amp"; // (38 ) ampersand
......
...@@ -66,10 +66,8 @@ FileDataList splitDiffToFiles(const QByteArray &data) ...@@ -66,10 +66,8 @@ FileDataList splitDiffToFiles(const QByteArray &data)
// The algorithm works like this: // The algorithm works like this:
// On the first match we only get the filename of the first patch part // On the first match we only get the filename of the first patch part
// On the second match (if any) we get the diff content, and the name of the next file patch // On the second match (if any) we get the diff content, and the name of the next file patch
//
while (-1 != (splitIndex = splitExpr.indexIn(strData,splitIndex))) {
while(-1 != (splitIndex = splitExpr.indexIn(strData,splitIndex))) {
if (!filename.isEmpty()) { if (!filename.isEmpty()) {
QString content = strData.mid(previousSplit, splitIndex - previousSplit); QString content = strData.mid(previousSplit, splitIndex - previousSplit);
ret.append(FileData(filename, content.toLatin1())); ret.append(FileData(filename, content.toLatin1()));
......
...@@ -125,7 +125,7 @@ QString View::getComment() ...@@ -125,7 +125,7 @@ QString View::getComment()
QByteArray View::getContent() QByteArray View::getContent()
{ {
QByteArray newContent; QByteArray newContent;
for(int i = 0; i < m_ui.uiPatchList->count(); ++i) { for (int i = 0; i < m_ui.uiPatchList->count(); ++i) {
QListWidgetItem *item = m_ui.uiPatchList->item(i); QListWidgetItem *item = m_ui.uiPatchList->item(i);
if (item->checkState() != Qt::Unchecked) if (item->checkState() != Qt::Unchecked)
newContent += m_parts.at(i).content; newContent += m_parts.at(i).content;
...@@ -159,7 +159,7 @@ int View::show(const QString &user, const QString &description, const QString &c ...@@ -159,7 +159,7 @@ int View::show(const QString &user, const QString &description, const QString &c
QByteArray content; QByteArray content;
m_parts = parts; m_parts = parts;
m_ui.uiPatchList->clear(); m_ui.uiPatchList->clear();
foreach(const FileData part, parts) { foreach (const FileData part, parts) {
QListWidgetItem *itm = new QListWidgetItem(part.filename, m_ui.uiPatchList); QListWidgetItem *itm = new QListWidgetItem(part.filename, m_ui.uiPatchList);
itm->setCheckState(Qt::Checked); itm->setCheckState(Qt::Checked);
itm->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); itm->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
......
...@@ -409,7 +409,7 @@ QVariant HelpViewer::loadResource(int type, const QUrl &name) ...@@ -409,7 +409,7 @@ QVariant HelpViewer::loadResource(int type, const QUrl &name)
void HelpViewer::openLinkInNewTab() void HelpViewer::openLinkInNewTab()
{ {
if(lastAnchor.isEmpty()) if (lastAnchor.isEmpty())
return; return;
parentWidget->setSourceInNewTab(QUrl(lastAnchor)); parentWidget->setSourceInNewTab(QUrl(lastAnchor));
......
...@@ -174,7 +174,7 @@ int main(int argc, char **argv) ...@@ -174,7 +174,7 @@ int main(int argc, char **argv)
return 1; return 1;
} }
foreach(QString fileName, fileNames) foreach (const QString &fileName, fileNames)
if (const int rc = format(fileName)) if (const int rc = format(fileName))
return rc; return rc;
......
...@@ -139,7 +139,7 @@ bool ProEditor::eventFilter(QObject *, QEvent *event) ...@@ -139,7 +139,7 @@ bool ProEditor::eventFilter(QObject *, QEvent *event)
if (event->type() == QEvent::ShortcutOverride) { if (event->type() == QEvent::ShortcutOverride) {
QKeyEvent *k = static_cast<QKeyEvent*>(event); QKeyEvent *k = static_cast<QKeyEvent*>(event);
if (k->modifiers() == Qt::ControlModifier) { if (k->modifiers() == Qt::ControlModifier) {
switch(k->key()) { switch (k->key()) {
case Qt::Key_X: case Qt::Key_X:
cut(); return true; cut(); return true;
case Qt::Key_C: case Qt::Key_C:
...@@ -168,11 +168,8 @@ void ProEditor::updatePasteAction() ...@@ -168,11 +168,8 @@ void ProEditor::updatePasteAction()
bool pasteEnabled = false; bool pasteEnabled = false;
const QMimeData *data = QApplication::clipboard()->mimeData(); const QMimeData *data = QApplication::clipboard()->mimeData();
if (data) { if (data && data->hasFormat(QLatin1String("application/x-problock")))
if (data->hasFormat(QLatin1String("application/x-problock"))) { pasteEnabled = true;
pasteEnabled = true;
}
}
m_pasteAction->setEnabled(pasteEnabled); m_pasteAction->setEnabled(pasteEnabled);
} }
......
...@@ -732,13 +732,10 @@ bool ProEditorModel::insertItem(ProItem *item, int row, const QModelIndex &paren ...@@ -732,13 +732,10 @@ bool ProEditorModel::insertItem(ProItem *item, int row, const QModelIndex &paren
void ProEditorModel::markProFileModified(QModelIndex index) void ProEditorModel::markProFileModified(QModelIndex index)
{ {
while(index.isValid()) while (index.isValid()) {
{ if (proItem(index)->kind() == ProItem::BlockKind) {
if( proItem(index)->kind() == ProItem::BlockKind)
{
ProBlock * block = proBlock(index); ProBlock * block = proBlock(index);
if(block->blockKind() == ProBlock::ProFileKind) if (block->blockKind() == ProBlock::ProFileKind) {
{
ProFile * file = static_cast<ProFile *>(block); ProFile * file = static_cast<ProFile *>(block);
file->setModified(true); file->setModified(true);
return; return;
...@@ -791,9 +788,9 @@ QString ProEditorModel::expressionToString(ProBlock *block, bool display) const ...@@ -791,9 +788,9 @@ QString ProEditorModel::expressionToString(ProBlock *block, bool display) const
{ {
QString result; QString result;
QList<ProItem*> items = block->items(); QList<ProItem*> items = block->items();
for(int i=0; i<items.count(); ++i) { for (int i = 0; i < items.count(); ++i) {
ProItem *item = items.at(i); ProItem *item = items.at(i);
switch(item->kind()) { switch (item->kind()) {
case ProItem::FunctionKind: { case ProItem::FunctionKind: {
ProFunction *v = static_cast<ProFunction*>(item); ProFunction *v = static_cast<ProFunction*>(item);
result += v->text(); result += v->text();
...@@ -808,14 +805,16 @@ QString ProEditorModel::expressionToString(ProBlock *block, bool display) const ...@@ -808,14 +805,16 @@ QString ProEditorModel::expressionToString(ProBlock *block, bool display) const
} else { } else {
result += v->text(); result += v->text();
} }
break; } break;
}
case ProItem::OperatorKind: { case ProItem::OperatorKind: {
ProOperator *v = static_cast<ProOperator*>(item); ProOperator *v = static_cast<ProOperator*>(item);
if (v->operatorKind() == ProOperator::NotOperator) if (v->operatorKind() == ProOperator::NotOperator)
result += QLatin1Char('!'); result += QLatin1Char('!');
else else
result += QLatin1Char('|'); result += QLatin1Char('|');
break; } break;
}
case ProItem::ValueKind: case ProItem::ValueKind:
case ProItem::BlockKind: case ProItem::BlockKind:
break; // ### unhandled break; // ### unhandled
...@@ -847,7 +846,7 @@ QList<ProItem *> ProEditorModel::stringToExpression(const QString &exp) const ...@@ -847,7 +846,7 @@ QList<ProItem *> ProEditorModel::stringToExpression(const QString &exp) const
bool c = false; bool c = false;
QString tmpstr; QString tmpstr;
for (int i=0; i<exp.length(); ++i) { for (int i = 0; i < exp.length(); ++i) {
QChar tmpchar = exp.at(i); QChar tmpchar = exp.at(i);
if (tmpchar == '(') ++p; if (tmpchar == '(') ++p;
else if (tmpchar == ')') --p; else if (tmpchar == ')') --p;
......
...@@ -332,7 +332,7 @@ void ProFileEvaluator::Private::insertOperator(const char op) ...@@ -332,7 +332,7 @@ void ProFileEvaluator::Private::insertOperator(const char op)
updateItem(); updateItem();
ProOperator::OperatorKind opkind; ProOperator::OperatorKind opkind;
switch(op) { switch (op) {
case '!': case '!':
opkind = ProOperator::NotOperator; opkind = ProOperator::NotOperator;
break; break;
...@@ -532,21 +532,21 @@ bool ProFileEvaluator::Private::visitEndProFile(ProFile * pro) ...@@ -532,21 +532,21 @@ bool ProFileEvaluator::Private::visitEndProFile(ProFile * pro)
evaluateFile(mkspecDirectory + "/features/default_post.prf", &ok); evaluateFile(mkspecDirectory + "/features/default_post.prf", &ok);
QStringList processed; QStringList processed;
while(1) { while (1) {
bool finished = true; bool finished = true;
QStringList configs = values("CONFIG"); QStringList configs = values("CONFIG");
for(int i = configs.size()-1; i >= 0; --i) { for (int i = configs.size()-1; i >= 0; --i) {
const QString config = configs[i].toLower(); const QString config = configs[i].toLower();
if(!processed.contains(config)) { if (!processed.contains(config)) {
processed.append(config); processed.append(config);
evaluateFile(mkspecDirectory + "/features/" + config + ".prf", &ok); evaluateFile(mkspecDirectory + "/features/" + config + ".prf", &ok);
if(ok) { if (ok) {
finished = false; finished = false;
break; break;
} }
} }
} }
if(finished) if (finished)
break; break;
} }
} }
......
...@@ -173,41 +173,41 @@ static QStringList split_arg_list(QString params) ...@@ -173,41 +173,41 @@ static QStringList split_arg_list(QString params)
const QChar *params_data = params.data(); const QChar *params_data = params.data();
const int params_len = params.length(); const int params_len = params.length();
int last = 0; int last = 0;
while(last < params_len && ((params_data+last)->unicode() == SPACE while (last < params_len && ((params_data+last)->unicode() == SPACE
/*|| (params_data+last)->unicode() == TAB*/)) /*|| (params_data+last)->unicode() == TAB*/))
++last; ++last;
for(int x = last, parens = 0; x <= params_len; x++) { for (int x = last, parens = 0; x <= params_len; x++) {
unicode = (params_data+x)->unicode(); unicode = (params_data+x)->unicode();
if(x == params_len) { if (x == params_len) {
while(x && (params_data+(x-1))->unicode() == SPACE) while (x && (params_data+(x-1))->unicode() == SPACE)
--x; --x;
QString mid(params_data+last, x-last); QString mid(params_data+last, x-last);
if(quote) { if (quote) {
if(mid[0] == quote && mid[(int)mid.length()-1] == quote) if (mid[0] == quote && mid[(int)mid.length()-1] == quote)
mid = mid.mid(1, mid.length()-2); mid = mid.mid(1, mid.length()-2);
quote = 0; quote = 0;
} }
args << mid; args << mid;
break; break;
} }
if(unicode == LPAREN) { if (unicode == LPAREN) {
--parens; --parens;
} else if(unicode == RPAREN) { } else if (unicode == RPAREN) {
++parens; ++parens;
} else if(quote && unicode == quote) { } else if (quote && unicode == quote) {
quote = 0; quote = 0;
} else if(!quote && (unicode == SINGLEQUOTE || unicode == DOUBLEQUOTE)) { } else if (!quote && (unicode == SINGLEQUOTE || unicode == DOUBLEQUOTE)) {
quote = unicode; quote = unicode;
} else if(!parens && !quote && unicode == COMMA) { } else if (!parens && !quote && unicode == COMMA) {
QString mid = params.mid(last, x - last).trimmed(); QString mid = params.mid(last, x - last).trimmed();
args << mid; args << mid;
last = x+1; last = x+1;
while(last < params_len && ((params_data+last)->unicode() == SPACE while (last < params_len && ((params_data+last)->unicode() == SPACE
/*|| (params_data+last)->unicode() == TAB*/)) /*|| (params_data+last)->unicode() == TAB*/))
++last; ++last;
} }
} }
for(int i = 0; i < args.count(); i++) for (int i = 0; i < args.count(); i++)
unquote(&args[i]); unquote(&args[i]);
return args; return args;
} }
...@@ -227,22 +227,22 @@ static QStringList split_value_list(const QString &vals, bool do_semicolon=false ...@@ -227,22 +227,22 @@ static QStringList split_value_list(const QString &vals, bool do_semicolon=false
const QChar *vals_data = vals.data(); const QChar *vals_data = vals.data();
const int vals_len = vals.length(); const int vals_len = vals.length();
for(int x = 0, parens = 0; x < vals_len; x++) { for (int x = 0, parens = 0; x < vals_len; x++) {
QChar c = vals_data[x]; QChar c = vals_data[x];
if (x != vals_len-1 && c == BACKSLASH && if (x != vals_len-1 && c == BACKSLASH &&
vals_data[x+1].unicode() == '\'' || vals_data[x+1] == DOUBLEQUOTE) { vals_data[x+1].unicode() == '\'' || vals_data[x+1] == DOUBLEQUOTE) {
build += vals_data[x++]; // get that 'escape' build += vals_data[x++]; // get that 'escape'
} else if (!quote.isEmpty() && c == quote.top()) { } else if (!quote.isEmpty() && c == quote.top()) {
quote.pop(); quote.pop();
} else if(c == SINGLEQUOTE || c == DOUBLEQUOTE) { } else if (c == SINGLEQUOTE || c == DOUBLEQUOTE) {
quote.push(c); quote.push(c);
} else if(c == RPAREN) { } else if (c == RPAREN) {
--parens; --parens;
} else if(c == LPAREN) { } else if (c == LPAREN) {
++parens; ++parens;
} }
if(!parens && quote.isEmpty() && ((do_semicolon && c == SEMICOLON) || if (!parens && quote.isEmpty() && ((do_semicolon && c == SEMICOLON) ||
vals_data[x] == Option::field_sep)) { vals_data[x] == Option::field_sep)) {
ret << build; ret << build;
build.clear(); build.clear();
...@@ -250,7 +250,7 @@ static QStringList split_value_list(const QString &vals, bool do_semicolon=false ...@@ -250,7 +250,7 @@ static QStringList split_value_list(const QString &vals, bool do_semicolon=false
build += vals_data[x]; build += vals_data[x];
} }
} }
if(!build.isEmpty()) if (!build.isEmpty())
ret << build; ret << build;
return ret; return ret;
} }
...@@ -262,7 +262,7 @@ static QStringList qmake_mkspec_paths() ...@@ -262,7 +262,7 @@ static QStringList qmake_mkspec_paths()
QByteArray qmakepath = qgetenv("QMAKEPATH"); QByteArray qmakepath = qgetenv("QMAKEPATH");
if (!qmakepath.isEmpty()) { if (!qmakepath.isEmpty()) {
const QStringList lst = splitPathList(QString::fromLocal8Bit(qmakepath)); const QStringList lst = splitPathList(QString::fromLocal8Bit(qmakepath));
for(QStringList::ConstIterator it = lst.begin(); it != lst.end(); ++it) for (QStringList::ConstIterator it = lst.begin(); it != lst.end(); ++it)
ret << ((*it) + concat); ret << ((*it) + concat);
} }
ret << QLibraryInfo::location(QLibraryInfo::DataPath) + concat; ret << QLibraryInfo::location(QLibraryInfo::DataPath) + concat;
......
...@@ -137,7 +137,7 @@ void ProWriter::writeBlock(ProBlock *block, const QString &indent) ...@@ -137,7 +137,7 @@ void ProWriter::writeBlock(ProBlock *block, const QString &indent)
if (block->blockKind() & ProBlock::VariableKind) { if (block->blockKind() & ProBlock::VariableKind) {
ProVariable *v = static_cast<ProVariable*>(block); ProVariable *v = static_cast<ProVariable*>(block);
m_out << v->variable(); m_out << v->variable();
switch(v->variableOperator()) { switch (v->variableOperator()) {
case ProVariable::AddOperator: case ProVariable::AddOperator:
m_out << QLatin1String(" += "); break; m_out << QLatin1String(" += "); break;
case ProVariable::RemoveOperator: case ProVariable::RemoveOperator:
...@@ -165,12 +165,12 @@ void ProWriter::writeBlock(ProBlock *block, const QString &indent) ...@@ -165,12 +165,12 @@ void ProWriter::writeBlock(ProBlock *block, const QString &indent)
} }
QList<ProItem*> items = block->items(); QList<ProItem*> items = block->items();
for (int i=0; i<items.count(); ++i) { for (int i = 0; i < items.count(); ++i) {
m_writeState &= ~LastItem; m_writeState &= ~LastItem;
m_writeState &= ~FirstItem; m_writeState &= ~FirstItem;
if (i == 0) if (i == 0)
m_writeState |= FirstItem; m_writeState |= FirstItem;
if (i == (items.count()-1)) if (i == items.count() - 1)
m_writeState |= LastItem; m_writeState |= LastItem;
writeItem(items.at(i), newindent); writeItem(items.at(i), newindent);
} }
......
...@@ -104,7 +104,7 @@ QDomNode ProXmlParser::createItemNode(QDomDocument doc, ProItem *item) const ...@@ -104,7 +104,7 @@ QDomNode ProXmlParser::createItemNode(QDomDocument doc, ProItem *item) const
tag = doc.createElement(QLatin1String("block")); tag = doc.createElement(QLatin1String("block"));
} }
foreach(ProItem *child, block->items()) { foreach (ProItem *child, block->items()) {
QDomNode childNode = createItemNode(doc, child); QDomNode childNode = createItemNode(doc, child);
if (!childNode.isNull()) if (!childNode.isNull())
tag.appendChild(childNode); tag.appendChild(childNode);
......
...@@ -131,7 +131,7 @@ void ValueEditor::initialize() ...@@ -131,7 +131,7 @@ void ValueEditor::initialize()
connect(m_itemListWidget, SIGNAL(itemChanged(QListWidgetItem *)), connect(m_itemListWidget, SIGNAL(itemChanged(QListWidgetItem *)),
this, SLOT(updateItemChanges(QListWidgetItem *))); this, SLOT(updateItemChanges(QListWidgetItem *)));
foreach(ProVariableInfo *varinfo, m_infomanager->variables()) { foreach (ProVariableInfo *varinfo, m_infomanager->variables()) {
m_varComboBox->addItem(varinfo->name(), varinfo->id()); m_varComboBox->addItem(varinfo->name(), varinfo->id());
} }
......
...@@ -151,7 +151,7 @@ bool ResourceFile::save() ...@@ -151,7 +151,7 @@ bool ResourceFile::save()
const QStringList name_list = prefixList(); const QStringList name_list = prefixList();
foreach (QString name, name_list) { foreach (const QString &name, name_list) {
FileList file_list; FileList file_list;
QString lang; QString lang;
foreach (Prefix *pref, m_prefix_list) { foreach (Prefix *pref, m_prefix_list) {
...@@ -164,7 +164,7 @@ bool ResourceFile::save() ...@@ -164,7 +164,7 @@ bool ResourceFile::save()
QDomElement relt = doc.createElement(QLatin1String("qresource")); QDomElement relt = doc.createElement(QLatin1String("qresource"));
root.appendChild(relt); root.appendChild(relt);
relt.setAttribute(QLatin1String("prefix"), name); relt.setAttribute(QLatin1String("prefix"), name);
if(!lang.isEmpty()) if (!lang.isEmpty())
relt.setAttribute(QLatin1String("lang"), lang); relt.setAttribute(QLatin1String("lang"), lang);