Commit 66044df3 authored by Kurt Hindenburg's avatar Kurt Hindenburg

fix a lot of issues of readability-implicit-bool-cast

parent 2b586e6f
......@@ -244,19 +244,19 @@ ColorEntry ColorScheme::colorEntry(int index , uint randomSeed) const
std::mt19937 randomEngine(randomSeed);
int hueDifference = 0;
if (range.hue) {
if (range.hue != 0u) {
std::uniform_int_distribution<int> dist(0, range.hue);
hueDifference = dist(randomEngine);
}
int saturationDifference = 0;
if (range.saturation) {
if (range.saturation != 0u) {
std::uniform_int_distribution<int> dist(0, range.saturation);
saturationDifference = dist(randomEngine) - range.saturation / 2;
}
int valueDifference = 0;
if (range.value) {
if (range.value != 0u) {
std::uniform_int_distribution<int> dist(0, range.value);
valueDifference = dist(randomEngine) - range.value / 2;
}
......
......@@ -161,7 +161,7 @@ void TerminalImageFilterChain::setImage(const Character* const image , int lines
// TODO - Use the "line wrapped" attribute associated with lines in a
// terminal image to avoid adding this imaginary character for wrapped
// lines
if (!(lineProperties.value(i, LINE_DEFAULT) & LINE_WRAPPED))
if ((lineProperties.value(i, LINE_DEFAULT) & LINE_WRAPPED) == 0)
lineStream << QChar('\n');
}
decoder.end();
......
......@@ -446,8 +446,8 @@ bool KeyboardTranslator::Entry::matches(int testKeyCode,
// any or no modifiers. In this context, the 'keypad' modifier does not count.
bool anyModifiersSet = (testKeyboardModifiers != 0)
&& (testKeyboardModifiers != Qt::KeypadModifier);
bool wantAnyModifier = _state & KeyboardTranslator::AnyModifierState;
if (_stateMask & KeyboardTranslator::AnyModifierState) {
bool wantAnyModifier = (_state & KeyboardTranslator::AnyModifierState) != 0;
if ((_stateMask & KeyboardTranslator::AnyModifierState) != 0) {
if (wantAnyModifier != anyModifiersSet)
return false;
}
......@@ -512,9 +512,9 @@ QByteArray KeyboardTranslator::Entry::unescape(const QByteArray& input) const
// with the corresponding character value
char hexDigits[3] = {0};
if ((i < result.count() - 2) && isxdigit(result[i + 2]))
if ((i < result.count() - 2) && (isxdigit(result[i + 2]) != 0))
hexDigits[0] = result[i + 2];
if ((i < result.count() - 3) && isxdigit(result[i + 3]))
if ((i < result.count() - 3) && (isxdigit(result[i + 3]) != 0))
hexDigits[1] = result[i + 3];
unsigned charValue = 0;
......@@ -538,10 +538,10 @@ QByteArray KeyboardTranslator::Entry::unescape(const QByteArray& input) const
void KeyboardTranslator::Entry::insertModifier(QString& item , int modifier) const
{
if (!(modifier & _modifierMask))
if ((modifier & _modifierMask) == 0u)
return;
if (modifier & _modifiers)
if ((modifier & _modifiers) != 0u)
item += '+';
else
item += '-';
......@@ -559,10 +559,10 @@ void KeyboardTranslator::Entry::insertModifier(QString& item , int modifier) con
}
void KeyboardTranslator::Entry::insertState(QString& item, int aState) const
{
if (!(aState & _stateMask))
if ((aState & _stateMask) == 0)
return;
if (aState & _state)
if ((aState & _state) != 0)
item += '+';
else
item += '-';
......
......@@ -248,7 +248,7 @@ void Part::overrideTerminalShortcut(QKeyEvent* event, bool& override)
// Shift+Insert is commonly used as the alternate shortcut for
// pasting in KDE apps(including konsole), so it deserves some
// special treatment.
if ((event->modifiers() & Qt::ShiftModifier) &&
if (((event->modifiers() & Qt::ShiftModifier) != 0u) &&
(event->key() == Qt::Key_Insert)) {
override = false;
return;
......
......@@ -279,7 +279,7 @@ bool ProcessInfo::userNameRequired() const
QString ProcessInfo::currentDir(bool* ok) const
{
if (ok)
*ok = _fields & CURRENT_DIR;
*ok = (_fields & CURRENT_DIR) != 0;
return _currentDir;
}
......
......@@ -127,8 +127,8 @@ bool Pty::flowControlEnabled() const
if (pty()->masterFd() >= 0) {
struct ::termios ttmode;
pty()->tcGetAttr(&ttmode);
return ttmode.c_iflag & IXOFF &&
ttmode.c_iflag & IXON;
return ((ttmode.c_iflag & IXOFF) != 0u) &&
((ttmode.c_iflag & IXON) != 0u);
} else {
qWarning() << "Unable to get flow control status, terminal not connected.";
return _xonXoff;
......
......@@ -373,7 +373,7 @@ void Screen::reverseRendition(Character& p) const
void Screen::updateEffectiveRendition()
{
_effectiveRendition = _currentRendition;
if (_currentRendition & RE_REVERSE) {
if ((_currentRendition & RE_REVERSE) != 0) {
_effectiveForeground = _currentBackground;
_effectiveBackground = _currentForeground;
} else {
......@@ -381,11 +381,11 @@ void Screen::updateEffectiveRendition()
_effectiveBackground = _currentBackground;
}
if (_currentRendition & RE_BOLD) {
if (!(_currentRendition & RE_FAINT))
if ((_currentRendition & RE_BOLD) != 0) {
if ((_currentRendition & RE_FAINT) == 0)
_effectiveForeground.setIntensive();
} else {
if (_currentRendition & RE_FAINT)
if ((_currentRendition & RE_FAINT) != 0)
_effectiveForeground.setFaint();
}
}
......@@ -659,7 +659,7 @@ void Screen::displayCharacter(unsigned short c)
ushort extendedCharLength;
const ushort* oldChars = ExtendedCharTable::instance.lookupExtendedChar(currentChar.character, extendedCharLength);
Q_ASSERT(oldChars);
if (oldChars && extendedCharLength < 3) {
if ((oldChars) && extendedCharLength < 3) {
Q_ASSERT(extendedCharLength > 1);
Q_ASSERT(extendedCharLength < 65535);
auto chars = new ushort[extendedCharLength + 1];
......@@ -703,7 +703,7 @@ void Screen::displayCharacter(unsigned short c)
int i = 0;
const int newCursorX = _cuX + w--;
while (w) {
while (w != 0) {
i++;
if (_screenLines[_cuY].size() < _cuX + i + 1)
......@@ -1244,7 +1244,7 @@ int Screen::copyLineToStream(int line ,
int length = _screenLines[screenLine].count();
// Don't remove end spaces in lines that wrap
if (trimTrailingSpaces && !(_lineProperties[screenLine] & LINE_WRAPPED))
if (trimTrailingSpaces && ((_lineProperties[screenLine] & LINE_WRAPPED) == 0))
{
// ignore trailing white space at the end of the line
for (int i = length-1; i >= 0; i--)
......@@ -1269,7 +1269,7 @@ int Screen::copyLineToStream(int line ,
}
if (appendNewLine && (count + 1 < MAX_CHARS)) {
if (currentLineProperties & LINE_WRAPPED) {
if ((currentLineProperties & LINE_WRAPPED) != 0) {
// do nothing extra when this line is wrapped.
} else {
// When users ask not to preserve the linebreaks, they usually mean:
......@@ -1301,7 +1301,7 @@ void Screen::addHistLine()
const int oldHistLines = _history->getLines();
_history->addCellsVector(_screenLines[0]);
_history->addLine(_lineProperties[0] & LINE_WRAPPED);
_history->addLine((_lineProperties[0] & LINE_WRAPPED) != 0);
const int newHistLines = _history->getLines();
......
......@@ -25,7 +25,7 @@ using namespace Konsole;
void ScrollState::addWheelEvent(const QWheelEvent* wheel)
{
if (wheel->angleDelta().y() && !wheel->pixelDelta().y())
if ((wheel->angleDelta().y() != 0) && (wheel->pixelDelta().y() == 0))
_remainingScrollPixel = 0;
else
_remainingScrollPixel += wheel->pixelDelta().y();
......@@ -42,14 +42,14 @@ int ScrollState::consumeLegacySteps(int stepsize)
{
int steps = _remainingScrollAngle / stepsize;
_remainingScrollAngle -= steps * stepsize;
if (steps)
if (steps != 0)
_remainingScrollPixel = 0;
return steps;
}
int ScrollState::consumeSteps(int pixelStepSize, int angleStepSize)
{
if (_remainingScrollPixel) {
if (_remainingScrollPixel != 0) {
int steps = _remainingScrollPixel / pixelStepSize;
_remainingScrollPixel -= steps * pixelStepSize;
_remainingScrollAngle = 0;
......
......@@ -229,7 +229,7 @@ void SessionController::trackOutput(QKeyEvent* event)
// Only jump to the bottom if the user actually typed something in,
// not if the user e. g. just pressed a modifier.
if (event->text().isEmpty() && event->modifiers()) {
if (event->text().isEmpty() && (event->modifiers() != 0u)) {
return;
}
......@@ -833,7 +833,7 @@ void SessionController::renameSession()
if (!guard)
return;
if (result) {
if (result != 0) {
QString tabTitle = dialog->tabTitleText();
QString remoteTabTitle = dialog->remoteTabTitleText();
......@@ -866,7 +866,7 @@ bool SessionController::confirmClose() const
" Are you sure you want to close it?", title);
int result = KMessageBox::warningYesNo(_view->window(), question, i18n("Confirm Close"));
return (result == KMessageBox::Yes) ? true : false;
return result == KMessageBox::Yes;
}
return true;
}
......@@ -891,7 +891,7 @@ bool SessionController::confirmForceClose() const
" Are you sure you want to kill it by force?", title);
int result = KMessageBox::warningYesNo(_view->window(), question, i18n("Confirm Close"));
return (result == KMessageBox::Yes) ? true : false;
return result == KMessageBox::Yes;
}
return true;
}
......@@ -1386,7 +1386,7 @@ void SessionController::showHistoryOptions()
if (!guard)
return;
if (result) {
if (result != 0) {
scrollBackOptionsChanged(dialog->mode(), dialog->lineCount());
}
}
......@@ -1667,11 +1667,7 @@ void SessionController::zmodemUpload()
bool SessionController::isKonsolePart() const
{
// Check to see if we are being called from Konsole or a KPart
if (qApp->applicationName() == "konsole") {
return false;
} else {
return true;
}
return !(qApp->applicationName() == "konsole");
}
SessionTask::SessionTask(QObject* parent)
......@@ -1809,7 +1805,7 @@ void SaveHistoryTask::jobDataRequested(KIO::Job* job , QByteArray& data)
}
void SaveHistoryTask::jobResult(KJob* job)
{
if (job->error()) {
if (job->error() != 0) {
KMessageBox::sorry(0 , i18n("A problem occurred when saving the output.\n%1", job->errorString()));
}
......
......@@ -108,7 +108,7 @@ void PlainTextDecoder::decodeLine(const Character* const characters, int count,
}
for (int i = 0; i < outputCount;) {
if (characters[i].rendition & RE_EXTENDED_CHAR) {
if ((characters[i].rendition & RE_EXTENDED_CHAR) != 0) {
ushort extendedCharLength = 0;
const ushort* chars = ExtendedCharTable::instance.lookupExtendedChar(characters[i].character, extendedCharLength);
if (chars) {
......@@ -199,11 +199,11 @@ void HTMLDecoder::decodeLine(const Character* const characters, int count, LineP
//colors - a color table must have been defined first
if (_colorTable) {
bool useBold = _lastRendition & RE_BOLD;
bool useBold = (_lastRendition & RE_BOLD) != 0;
if (useBold)
style.append("font-weight:bold;");
if (_lastRendition & RE_UNDERLINE)
if ((_lastRendition & RE_UNDERLINE) != 0)
style.append("font-decoration:underline;");
style.append(QString("color:%1;").arg(_lastForeColor.color(_colorTable).name()));
......@@ -224,7 +224,7 @@ void HTMLDecoder::decodeLine(const Character* const characters, int count, LineP
//output current character
if (spaceCount < 2) {
if (characters[i].rendition & RE_EXTENDED_CHAR) {
if ((characters[i].rendition & RE_EXTENDED_CHAR) != 0) {
ushort extendedCharLength = 0;
const ushort* chars = ExtendedCharTable::instance.lookupExtendedChar(characters[i].character, extendedCharLength);
if (chars) {
......
......@@ -161,7 +161,7 @@ void *TerminalDisplayAccessible::interface_cast(QAccessible::InterfaceType type)
void TerminalDisplayAccessible::setSelection(int selectionIndex, int startOffset, int endOffset)
{
if (selectionIndex)
if (selectionIndex != 0)
return;
addSelection(startOffset, endOffset);
}
......
......@@ -358,8 +358,8 @@ void TabbedViewContainer::closeCurrentTab()
void TabbedViewContainer::updateVisibilityOfQuickButtons()
{
const bool tabBarHidden = _tabBar->isHidden();
_newTabButton->setVisible(!tabBarHidden && (features() & QuickNewView));
_closeTabButton->setVisible(!tabBarHidden && (features() & QuickCloseView));
_newTabButton->setVisible(!tabBarHidden && ((features() & QuickNewView) != 0));
_closeTabButton->setVisible(!tabBarHidden && ((features() & QuickCloseView) != 0));
}
void TabbedViewContainer::setTabBarVisible(bool visible)
......
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