1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

style: change postfix increment to prefix increment

This commit is contained in:
Zetok Zalbavar 2016-10-29 23:48:03 +01:00
parent 6ee3b95b6f
commit 64bbc6cfbb
No known key found for this signature in database
GPG Key ID: C953D3880212068A
28 changed files with 53 additions and 53 deletions

View File

@ -308,7 +308,7 @@ void Audio::subscribeInput()
return; return;
} }
inSubscriptions++; ++inSubscriptions;
qDebug() << "Subscribed to audio input device [" << inSubscriptions << "subscriptions ]"; qDebug() << "Subscribed to audio input device [" << inSubscriptions << "subscriptions ]";
} }

View File

@ -865,7 +865,7 @@ void ChatLog::retranslateUi()
bool ChatLog::isActiveFileTransfer(ChatLine::Ptr l) bool ChatLog::isActiveFileTransfer(ChatLine::Ptr l)
{ {
int count = l->getColumnCount(); int count = l->getColumnCount();
for (int i = 0; i < count; i++) for (int i = 0; i < count; ++i)
{ {
ChatLineContent *content = l->getContent(i); ChatLineContent *content = l->getContent(i);
ChatLineContentProxy *proxy = qobject_cast<ChatLineContentProxy*>(content); ChatLineContentProxy *proxy = qobject_cast<ChatLineContentProxy*>(content);

View File

@ -121,7 +121,7 @@ void FileTransferWidget::autoAcceptTransfer(const QString &path)
do do
{ {
filepath = QString("%1/%2%3.%4").arg(path, base, number > 0 ? QString(" (%1)").arg(QString::number(number)) : QString(), suffix); filepath = QString("%1/%2%3.%4").arg(path, base, number > 0 ? QString(" (%1)").arg(QString::number(number)) : QString(), suffix);
number++; ++number;
} }
while (QFileInfo(filepath).exists()); while (QFileInfo(filepath).exists());

View File

@ -340,7 +340,7 @@ QString Text::extractSanitizedText(int from, int to) const
if (pos >= from && pos < to) if (pos >= from && pos < to)
{ {
txt += rune; txt += rune;
pos++; ++pos;
} }
} }
else else
@ -350,7 +350,7 @@ QString Text::extractSanitizedText(int from, int to) const
if (pos >= from && pos < to) if (pos >= from && pos < to)
txt += c; txt += c;
pos++; ++pos;
} }
} }
} }

View File

@ -397,7 +397,7 @@ bool Core::checkConnection()
emit disconnected(); emit disconnected();
isConnected = false; isConnected = false;
//count++; //count++;
} //else if (!toxConnected) count++; } //else if (!toxConnected) ++count;
return isConnected; return isConnected;
} }
@ -436,8 +436,8 @@ void Core::bootstrapDht()
qDebug() << "Error adding TCP relay from "+dhtServer.name; qDebug() << "Error adding TCP relay from "+dhtServer.name;
} }
j++; ++j;
i++; ++i;
} }
} }
@ -1047,7 +1047,7 @@ QList<QString> Core::getGroupPeerNames(int groupId) const
qWarning() << "getGroupPeerNames: Unexpected tox_group_get_names result"; qWarning() << "getGroupPeerNames: Unexpected tox_group_get_names result";
return names; return names;
} }
for (uint16_t i=0; i<nPeers; i++) for (uint16_t i=0; i<nPeers; ++i)
names.push_back(CString::toString(namesArray[i], lengths[i])); names.push_back(CString::toString(namesArray[i], lengths[i]));
return names; return names;

View File

@ -323,7 +323,7 @@ bool CoreAV::sendCallAudio(uint32_t callId, const int16_t *pcm, size_t samples,
{ {
if (err == TOXAV_ERR_SEND_FRAME_SYNC) if (err == TOXAV_ERR_SEND_FRAME_SYNC)
{ {
retries++; ++retries;
QThread::usleep(500); QThread::usleep(500);
} }
else else
@ -375,7 +375,7 @@ void CoreAV::sendCallVideo(uint32_t callId, std::shared_ptr<VideoFrame> vframe)
{ {
if (err == TOXAV_ERR_SEND_FRAME_SYNC) if (err == TOXAV_ERR_SEND_FRAME_SYNC)
{ {
retries++; ++retries;
QThread::usleep(500); QThread::usleep(500);
} }
else else

View File

@ -87,7 +87,7 @@ void Group::regeneratePeerList()
peers = Core::getInstance()->getGroupPeerNames(groupId); peers = Core::getInstance()->getGroupPeerNames(groupId);
toxids.clear(); toxids.clear();
nPeers = peers.size(); nPeers = peers.size();
for (int i = 0; i < nPeers; i++) for (int i = 0; i < nPeers; ++i)
{ {
ToxId id = Core::getInstance()->getGroupPeerToxId(groupId, i); ToxId id = Core::getInstance()->getGroupPeerToxId(groupId, i);
if (id.isSelf()) if (id.isSelf())

View File

@ -128,7 +128,7 @@ time_t IPC::postEvent(const QString &name, const QByteArray& data, uint32_t dest
IPCMemory* mem = global(); IPCMemory* mem = global();
time_t result = 0; time_t result = 0;
for (uint32_t i = 0; !evt && i < EVENT_QUEUE_SIZE; i++) for (uint32_t i = 0; !evt && i < EVENT_QUEUE_SIZE; ++i)
{ {
if (mem->events[i].posted == 0) if (mem->events[i].posted == 0)
evt = &mem->events[i]; evt = &mem->events[i];
@ -188,7 +188,7 @@ bool IPC::isEventAccepted(time_t time)
if (difftime(global()->lastProcessed, time) > 0) if (difftime(global()->lastProcessed, time) > 0)
{ {
IPCMemory* mem = global(); IPCMemory* mem = global();
for (uint32_t i = 0; i < EVENT_QUEUE_SIZE; i++) for (uint32_t i = 0; i < EVENT_QUEUE_SIZE; ++i)
{ {
if (mem->events[i].posted == time && mem->events[i].processed) if (mem->events[i].posted == time && mem->events[i].processed)
{ {
@ -225,7 +225,7 @@ bool IPC::waitUntilAccepted(time_t postTime, int32_t timeout/*=-1*/)
IPC::IPCEvent *IPC::fetchEvent() IPC::IPCEvent *IPC::fetchEvent()
{ {
IPCMemory* mem = global(); IPCMemory* mem = global();
for (uint32_t i = 0; i < EVENT_QUEUE_SIZE; i++) for (uint32_t i = 0; i < EVENT_QUEUE_SIZE; ++i)
{ {
IPCEvent* evt = &mem->events[i]; IPCEvent* evt = &mem->events[i];

View File

@ -98,7 +98,7 @@ QByteArray Toxme::getServerPubkey(QString url, QNetworkReply::NetworkError &erro
QByteArray key; QByteArray key;
// I think, exist more easy way to convert key to ByteArray // I think, exist more easy way to convert key to ByteArray
for (int i = 0; i < pubkeySize; i++) { for (int i = 0; i < pubkeySize; ++i) {
QString byte = rawKey.mid(i*2, 2); QString byte = rawKey.mid(i*2, 2);
key[i] = byte.toInt(nullptr, 16); key[i] = byte.toInt(nullptr, 16);
} }

View File

@ -152,7 +152,7 @@ void EncryptedDb::appendToEncrypted(const QString &sql)
} }
buffer = buffer.right(buffer.size() - plainChunkSize); buffer = buffer.right(buffer.size() - plainChunkSize);
chunkPosition++; ++chunkPosition;
} }
encrFile.seek(chunkPosition * encryptedChunkSize); encrFile.seek(chunkPosition * encryptedChunkSize);

View File

@ -616,7 +616,7 @@ QVector<QString> Profile::remove()
isRemoved = true; isRemoved = true;
qDebug() << "Removing profile" << name; qDebug() << "Removing profile" << name;
for (int i=0; i<profiles.size(); i++) for (int i=0; i<profiles.size(); ++i)
{ {
if (profiles[i] == name) if (profiles[i] == name)
{ {

View File

@ -97,7 +97,7 @@ unsigned getVUint32Size(QByteArray data)
char num3; char num3;
do { do {
num3 = data[lensize]; num3 = data[lensize];
lensize++; ++lensize;
} while ((num3 & 0x80) != 0); } while ((num3 & 0x80) != 0);
return lensize; return lensize;
@ -111,7 +111,7 @@ QByteArray vintToData(int num)
while (num >= 0x80) while (num >= 0x80)
{ {
data[i] = static_cast<char>(num | 0x80); data[i] = static_cast<char>(num | 0x80);
i++; ++i;
num = num >> 7; num = num >> 7;
} }
data[i] = static_cast<char>(num); data[i] = static_cast<char>(num);
@ -127,7 +127,7 @@ QByteArray vuintToData(size_t num)
while (num >= 0x80) while (num >= 0x80)
{ {
data[i] = static_cast<char>(num | 0x80); data[i] = static_cast<char>(num | 0x80);
i++; ++i;
num = num >> 7; num = num >> 7;
} }
data[i] = static_cast<char>(num); data[i] = static_cast<char>(num);

View File

@ -719,7 +719,7 @@ void Settings::savePersonal(QString profileName, const QString &password)
ps.setArrayIndex(index); ps.setArrayIndex(index);
ps.setValue("name", circle.name); ps.setValue("name", circle.name);
ps.setValue("expanded", circle.expanded); ps.setValue("expanded", circle.expanded);
index++; ++index;
} }
ps.endArray(); ps.endArray();
} }
@ -2291,7 +2291,7 @@ unsigned int Settings::getUnreadFriendRequests() const
unsigned int unreadFriendRequests = 0; unsigned int unreadFriendRequests = 0;
for (auto request : friendRequests) for (auto request : friendRequests)
if (!request.read) if (!request.read)
unreadFriendRequests++; ++unreadFriendRequests;
return unreadFriendRequests; return unreadFriendRequests;
} }

View File

@ -283,7 +283,7 @@ void SettingsSerializer::save()
QDataStream stream(&data, QIODevice::ReadWrite | QIODevice::Append); QDataStream stream(&data, QIODevice::ReadWrite | QIODevice::Append);
stream.setVersion(QDataStream::Qt_5_0); stream.setVersion(QDataStream::Qt_5_0);
for (int g=-1; g<groups.size(); g++) for (int g=-1; g<groups.size(); ++g)
{ {
// Save the group name, if any // Save the group name, if any
if (g!=-1) if (g!=-1)
@ -534,7 +534,7 @@ void SettingsSerializer::readIni()
else else
{ {
a.group = -1; a.group = -1;
for (int i=0; i<groups.size(); i++) for (int i=0; i<groups.size(); ++i)
if (groups[i] == groups[static_cast<int>(v.group)].left(slashIndex)) if (groups[i] == groups[static_cast<int>(v.group)].left(slashIndex))
a.group = i; a.group = i;
a.name = groups[static_cast<int>(v.group)].mid(slashIndex+1); a.name = groups[static_cast<int>(v.group)].mid(slashIndex+1);
@ -547,7 +547,7 @@ void SettingsSerializer::readIni()
} }
// Associate each array's values with the array // Associate each array's values with the array
for (int ai=0; ai<arrays.size(); ai++) for (int ai=0; ai<arrays.size(); ++ai)
{ {
Array& a = arrays[ai]; Array& a = arrays[ai];
QString arrayPrefix; QString arrayPrefix;
@ -556,7 +556,7 @@ void SettingsSerializer::readIni()
arrayPrefix += a.name+'/'; arrayPrefix += a.name+'/';
// Find groups which represent each array index // Find groups which represent each array index
for (int g=0; g<groups.size(); g++) for (int g=0; g<groups.size(); ++g)
{ {
if (!groups[g].startsWith(arrayPrefix)) if (!groups[g].startsWith(arrayPrefix))
continue; continue;

View File

@ -80,7 +80,7 @@ QVector<QPair<QString,QString>> DirectShow::getDeviceList()
devIdString = wcharToUtf8(olestr); devIdString = wcharToUtf8(olestr);
// replace ':' with '_' since FFmpeg uses : to delimitate sources // replace ':' with '_' since FFmpeg uses : to delimitate sources
for (size_t i = 0; i < strlen(devIdString); i++) for (size_t i = 0; i < strlen(devIdString); ++i)
if (devIdString[i] == ':') if (devIdString[i] == ':')
devIdString[i] = '_'; devIdString[i] = '_';
@ -146,7 +146,7 @@ static IBaseFilter* getDevFilter(QString devName)
devIdString = wcharToUtf8(olestr); devIdString = wcharToUtf8(olestr);
// replace ':' with '_' since FFmpeg uses : to delimitate sources // replace ':' with '_' since FFmpeg uses : to delimitate sources
for (size_t i = 0; i < strlen(devIdString); i++) for (size_t i = 0; i < strlen(devIdString); ++i)
if (devIdString[i] == ':') if (devIdString[i] == ':')
devIdString[i] = '_'; devIdString[i] = '_';

View File

@ -330,7 +330,7 @@ QVector<QPair<QString, QString>> CameraDevice::getRawDeviceListGeneric()
// Convert the list to a QVector // Convert the list to a QVector
devices.resize(devlist->nb_devices); devices.resize(devlist->nb_devices);
for (int i = 0; i < devlist->nb_devices; i++) for (int i = 0; i < devlist->nb_devices; ++i)
{ {
AVDeviceInfo* dev = devlist->devices[i]; AVDeviceInfo* dev = devlist->devices[i];
devices[i].first = dev->device_name; devices[i].first = dev->device_name;

View File

@ -194,7 +194,7 @@ CameraSource::~CameraSource()
if (device) if (device)
{ {
for (int i = 0; i < subscriptions; i++) for (int i = 0; i < subscriptions; ++i)
device->close(); device->close();
device = nullptr; device = nullptr;
@ -286,11 +286,11 @@ bool CameraSource::openDevice()
// We need to open the device as many time as we already have subscribers, // We need to open the device as many time as we already have subscribers,
// otherwise the device could get closed while we still have subscribers // otherwise the device could get closed while we still have subscribers
for (int i = 0; i < subscriptions; i++) for (int i = 0; i < subscriptions; ++i)
device->open(); device->open();
// Find the first video stream // Find the first video stream
for (unsigned i = 0; i < device->context->nb_streams; i++) for (unsigned i = 0; i < device->context->nb_streams; ++i)
{ {
if (device->context->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) if (device->context->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
{ {

View File

@ -84,14 +84,14 @@ void CoreVideoSource::pushFrame(const vpx_image_t* vpxframe)
return; return;
} }
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; ++i)
{ {
int dstStride = avframe->linesize[i]; int dstStride = avframe->linesize[i];
int srcStride = vpxframe->stride[i]; int srcStride = vpxframe->stride[i];
int minStride = std::min(dstStride, srcStride); int minStride = std::min(dstStride, srcStride);
int size = (i == 0) ? height : height / 2; int size = (i == 0) ? height : height / 2;
for (int j = 0; j < size; j++) for (int j = 0; j < size; ++j)
{ {
uint8_t* dst = avframe->data[i] + dstStride * j; uint8_t* dst = avframe->data[i] + dstStride * j;
uint8_t* src = vpxframe->planes[i] + srcStride * j; uint8_t* src = vpxframe->planes[i] + srcStride * j;

View File

@ -369,7 +369,7 @@ void ContentDialog::cycleContacts(bool forward, bool loop)
void ContentDialog::onVideoShow(QSize size) void ContentDialog::onVideoShow(QSize size)
{ {
videoCount++; ++videoCount;
if (videoCount > 1) if (videoCount > 1)
return; return;

View File

@ -62,7 +62,7 @@ EmoticonsWidget::EmoticonsWidget(QWidget *parent) :
// create pages // create pages
buttonLayout->addStretch(); buttonLayout->addStretch();
for (int i = 0; i < pageCount; i++) for (int i = 0; i < pageCount; ++i)
{ {
QGridLayout* pageLayout = new QGridLayout; QGridLayout* pageLayout = new QGridLayout;
pageLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding), maxRows, 0); pageLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding), maxRows, 0);
@ -101,14 +101,14 @@ EmoticonsWidget::EmoticonsWidget(QWidget *parent) :
qobject_cast<QGridLayout*>(stack.widget(currPage)->layout())->addWidget(button, row, col); qobject_cast<QGridLayout*>(stack.widget(currPage)->layout())->addWidget(button, row, col);
col++; ++col;
currItem++; ++currItem;
// next row // next row
if (col >= maxCols) if (col >= maxCols)
{ {
col = 0; col = 0;
row++; ++row;
} }
// next page // next page
@ -116,7 +116,7 @@ EmoticonsWidget::EmoticonsWidget(QWidget *parent) :
{ {
row = 0; row = 0;
currItem = 0; currItem = 0;
currPage++; ++currPage;
} }
} }

View File

@ -226,7 +226,7 @@ void AddFriendForm::setIdFromClipboard()
void AddFriendForm::deleteFriendRequest(const QString& toxId) void AddFriendForm::deleteFriendRequest(const QString& toxId)
{ {
int size = Settings::getInstance().getFriendRequestSize(); int size = Settings::getInstance().getFriendRequestSize();
for (int i = 0; i < size; i++) for (int i = 0; i < size; ++i)
{ {
Settings::Request request = Settings::getInstance().getFriendRequest(i); Settings::Request request = Settings::getInstance().getFriendRequest(i);
if (ToxId(toxId) == ToxId(request.address)) if (ToxId(toxId) == ToxId(request.address))

View File

@ -278,7 +278,7 @@ void AVForm::fillCameraModesComboBox()
bool previouslyBlocked = videoModescomboBox->blockSignals(true); bool previouslyBlocked = videoModescomboBox->blockSignals(true);
videoModescomboBox->clear(); videoModescomboBox->clear();
for(int i = 0; i < videoModes.size(); i++) for(int i = 0; i < videoModes.size(); ++i)
{ {
VideoMode mode = videoModes[i]; VideoMode mode = videoModes[i];
@ -305,7 +305,7 @@ int AVForm::searchPreferredIndex()
QRect prefRes = Settings::getInstance().getCamVideoRes(); QRect prefRes = Settings::getInstance().getCamVideoRes();
quint16 prefFPS = Settings::getInstance().getCamVideoFPS(); quint16 prefFPS = Settings::getInstance().getCamVideoFPS();
for (int i = 0; i < videoModes.size(); i++) for (int i = 0; i < videoModes.size(); ++i)
{ {
VideoMode mode = videoModes[i]; VideoMode mode = videoModes[i];
if (mode.width == prefRes.width() if (mode.width == prefRes.width()
@ -322,7 +322,7 @@ void AVForm::fillScreenModesComboBox()
bool previouslyBlocked = videoModescomboBox->blockSignals(true); bool previouslyBlocked = videoModescomboBox->blockSignals(true);
videoModescomboBox->clear(); videoModescomboBox->clear();
for(int i = 0; i < videoModes.size(); i++) for(int i = 0; i < videoModes.size(); ++i)
{ {
VideoMode mode = videoModes[i]; VideoMode mode = videoModes[i];
QString pixelFormat = CameraDevice::getPixelFormatString(mode.pixel_format); QString pixelFormat = CameraDevice::getPixelFormatString(mode.pixel_format);

View File

@ -121,7 +121,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent)
bodyUI->checkUpdates->setVisible(AUTOUPDATE_ENABLED); bodyUI->checkUpdates->setVisible(AUTOUPDATE_ENABLED);
bodyUI->checkUpdates->setChecked(s.getCheckUpdates()); bodyUI->checkUpdates->setChecked(s.getCheckUpdates());
for (int i = 0; i < langs.size(); i++) for (int i = 0; i < langs.size(); ++i)
bodyUI->transComboBox->insertItem(i, langs[i]); bodyUI->transComboBox->insertItem(i, langs[i]);
bodyUI->transComboBox->setCurrentIndex(locales.indexOf(s.getTranslation())); bodyUI->transComboBox->setCurrentIndex(locales.indexOf(s.getTranslation()));

View File

@ -100,7 +100,7 @@ void PrivacyForm::on_randomNosapamButton_clicked()
qsrand((uint)time.msec()); qsrand((uint)time.msec());
uint32_t newNospam{0}; uint32_t newNospam{0};
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; ++i)
newNospam = (newNospam<<8) + (qrand() % 256); // Generate byte by byte. For some reason. newNospam = (newNospam<<8) + (qrand() % 256); // Generate byte by byte. For some reason.
Core::getInstance()->setNospam(newNospam); Core::getInstance()->setNospam(newNospam);

View File

@ -234,11 +234,11 @@ void UserInterfaceForm::reloadSmileys()
} }
QStringList smileys; QStringList smileys;
for (int i = 0; i < emoticons.size(); i++) for (int i = 0; i < emoticons.size(); ++i)
smileys.push_front(emoticons.at(i).first()); smileys.push_front(emoticons.at(i).first());
const QSize size(18,18); const QSize size(18,18);
for (int i = 0; i < smileLabels.size(); i++) for (int i = 0; i < smileLabels.size(); ++i)
{ {
QIcon icon = SmileyPack::getInstance().getAsIcon(smileys[i]); QIcon icon = SmileyPack::getInstance().getAsIcon(smileys[i]);
smileLabels[i]->setPixmap(icon.pixmap(size)); smileLabels[i]->setPixmap(icon.pixmap(size));

View File

@ -104,6 +104,6 @@ void SettingsWidget::onTabChanged(int index)
void SettingsWidget::retranslateUi() void SettingsWidget::retranslateUi()
{ {
for (size_t i = 0; i < cfgForms.size(); i++) for (size_t i = 0; i < cfgForms.size(); ++i)
settingsWidgets->setTabText(i, cfgForms[i]->getFormName()); settingsWidgets->setTabText(i, cfgForms[i]->getFormName());
} }

View File

@ -93,7 +93,7 @@ void TabCompleter::complete()
auto cur = msgEdit->textCursor(); auto cur = msgEdit->textCursor();
cur.setPosition(cur.selectionEnd()); cur.setPosition(cur.selectionEnd());
msgEdit->setTextCursor(cur); msgEdit->setTextCursor(cur);
for (int i = 0; i < lastCompletionLength; i++) for (int i = 0; i < lastCompletionLength; ++i)
msgEdit->textCursor().deletePreviousChar(); msgEdit->textCursor().deletePreviousChar();
// insert completion // insert completion

View File

@ -96,10 +96,10 @@ void QRWidget::paintImage()
const double aspect = w / h; const double aspect = w / h;
const double scale = ((aspect > 1.0) ? h : w) / s; const double scale = ((aspect > 1.0) ? h : w) / s;
for (int y = 0; y < s; y++) for (int y = 0; y < s; ++y)
{ {
const int yy = y * s; const int yy = y * s;
for (int x = 0; x < s; x++) for (int x = 0; x < s; ++x)
{ {
const int xx = yy + x; const int xx = yy + x;
const unsigned char b = qr->data[xx]; const unsigned char b = qr->data[xx];