Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit decc2d76 authored by André Agenor's avatar André Agenor

Modernizes and remove Clang-Tyde warnings

Summary: Signed-off-by: André Agenor <andreagenor@icloud.com>

Reviewers: tcanabrava

Reviewed By: tcanabrava

Differential Revision: https://phabricator.kde.org/D19164
parent d66a0839
......@@ -43,9 +43,7 @@ kpEffectBalanceCommand::kpEffectBalanceCommand (int channels,
{
}
kpEffectBalanceCommand::~kpEffectBalanceCommand ()
{
}
kpEffectBalanceCommand::~kpEffectBalanceCommand () = default;
// protected virtual [base kpEffectCommandBase]
......
......@@ -46,20 +46,17 @@ kpEffectBlurSharpenCommand::kpEffectBlurSharpenCommand (kpEffectBlurSharpen::Typ
{
}
kpEffectBlurSharpenCommand::~kpEffectBlurSharpenCommand ()
{
}
kpEffectBlurSharpenCommand::~kpEffectBlurSharpenCommand () = default;
// public static
QString kpEffectBlurSharpenCommand::nameForType (kpEffectBlurSharpen::Type type)
{
if (type == kpEffectBlurSharpen::Blur)
return i18n ("Soften");
else if (type == kpEffectBlurSharpen::Sharpen)
return i18n ("Sharpen");
else
return QString();
switch (type) {
case kpEffectBlurSharpen::Blur: return i18n ("Soften");
case kpEffectBlurSharpen::Sharpen: return i18n ("Sharpen");
default: return QString();
}
}
......
......@@ -57,10 +57,7 @@ QString kpEffectClearCommand::name () const
{
QString opName = i18n ("Clear");
if (m_actOnSelection)
return i18n ("Selection: %1", opName);
else
return opName;
return (m_actOnSelection) ? i18n ("Selection: %1", opName) : opName;
}
......@@ -92,8 +89,9 @@ void kpEffectClearCommand::execute ()
Q_ASSERT (sel);
sel->fill (m_newColor);
}
else
else {
doc->fill (m_newColor);
}
}
// public virtual [base kpCommand]
......
......@@ -39,7 +39,7 @@
struct kpEffectCommandBasePrivate
{
QString name;
bool actOnSelection;
bool actOnSelection{false};
kpImage oldImage;
};
......@@ -63,10 +63,7 @@ kpEffectCommandBase::~kpEffectCommandBase ()
// public virtual [base kpCommand]
QString kpEffectCommandBase::name () const
{
if (d->actOnSelection)
return i18n ("Selection: %1", d->name);
else
return d->name;
return (d->actOnSelection) ? i18n ("Selection: %1", d->name) : d->name;
}
......
......@@ -44,9 +44,7 @@ kpEffectEmbossCommand::kpEffectEmbossCommand (int strength,
{
}
kpEffectEmbossCommand::~kpEffectEmbossCommand ()
{
}
kpEffectEmbossCommand::~kpEffectEmbossCommand () = default;
// protected virtual [base kpEffectCommandBase]
......
......@@ -45,9 +45,7 @@ kpEffectFlattenCommand::kpEffectFlattenCommand (const QColor &color1,
{
}
kpEffectFlattenCommand::~kpEffectFlattenCommand ()
{
}
kpEffectFlattenCommand::~kpEffectFlattenCommand () = default;
//
......
......@@ -44,9 +44,7 @@ kpEffectGrayscaleCommand::kpEffectGrayscaleCommand (
{
}
kpEffectGrayscaleCommand::~kpEffectGrayscaleCommand ()
{
}
kpEffectGrayscaleCommand::~kpEffectGrayscaleCommand () = default;
//
......
......@@ -51,9 +51,7 @@ kpEffectInvertCommand::kpEffectInvertCommand (bool actOnSelection,
{
}
kpEffectInvertCommand::~kpEffectInvertCommand ()
{
}
kpEffectInvertCommand::~kpEffectInvertCommand () = default;
//
......
......@@ -49,23 +49,19 @@ kpEffectReduceColorsCommand::kpEffectReduceColorsCommand (int depth, bool dither
// public
QString kpEffectReduceColorsCommand::commandName (int depth, int dither) const
{
if (depth == 1)
{
if (dither)
switch (depth) {
case 1: if (dither) {
return i18n ("Reduce to Monochrome (Dithered)");
else
return i18n ("Reduce to Monochrome");
}
else if (depth == 8)
{
if (dither)
}
return i18n ("Reduce to Monochrome");
case 8:
if (dither) {
return i18n ("Reduce to 256 Color (Dithered)");
else
return i18n ("Reduce to 256 Color");
}
else
{
return QString();
}
return i18n ("Reduce to 256 Color");
default: return QString();
}
}
......
......@@ -43,9 +43,7 @@ kpEffectToneEnhanceCommand::kpEffectToneEnhanceCommand (double granularity, doub
{
}
kpEffectToneEnhanceCommand::~kpEffectToneEnhanceCommand ()
{
}
kpEffectToneEnhanceCommand::~kpEffectToneEnhanceCommand () = default;
// protected virtual [base kpEffectCommandBase]
......
......@@ -52,9 +52,7 @@ kpTransformFlipCommand::kpTransformFlipCommand (bool actOnSelection,
//---------------------------------------------------------------------
kpTransformFlipCommand::~kpTransformFlipCommand ()
{
}
kpTransformFlipCommand::~kpTransformFlipCommand () = default;
//---------------------------------------------------------------------
// public virtual [base kpCommand]
......@@ -75,16 +73,17 @@ QString kpTransformFlipCommand::name () const
opName = i18n ("Flip vertically");
else
{
qCCritical(kpLogCommands) << "kpTransformFlipCommand::name() not asked to flip" << endl;
qCCritical(kpLogCommands) << "kpTransformFlipCommand::name() not asked to flip";
return QString();
}
#endif
if (m_actOnSelection)
if (m_actOnSelection) {
return i18n ("Selection: %1", opName);
else
return opName;
}
return opName;
}
//---------------------------------------------------------------------
......
......@@ -97,15 +97,19 @@ QString kpTransformResizeScaleCommand::name () const
{
if (m_actOnTextSelection)
{
if (m_type == Resize)
if (m_type == Resize) {
return i18n ("Text: Resize Box");
}
}
else
{
if (m_type == Scale)
if (m_type == Scale) {
return i18n ("Selection: Scale");
else if (m_type == SmoothScale)
}
if (m_type == SmoothScale) {
return i18n ("Selection: Smooth Scale");
}
}
}
else
......@@ -163,7 +167,7 @@ void kpTransformResizeScaleCommand::setNewHeight (int height)
// public
QSize kpTransformResizeScaleCommand::newSize () const
{
return QSize (newWidth (), newHeight ());
return {newWidth (), newHeight ()};
}
// public virtual
......@@ -189,8 +193,7 @@ bool kpTransformResizeScaleCommand::scaleSelectionWithImage () const
void kpTransformResizeScaleCommand::scaleSelectionRegionWithDocument ()
{
#if DEBUG_KP_TOOL_RESIZE_SCALE_COMMAND
qCDebug(kpLogCommands) << "kpTransformResizeScaleCommand::scaleSelectionRegionWithDocument"
<< endl;
qCDebug(kpLogCommands) << "kpTransformResizeScaleCommand::scaleSelectionRegionWithDocument";
#endif
Q_ASSERT (m_oldSelectionPtr);
......@@ -218,10 +221,9 @@ void kpTransformResizeScaleCommand::scaleSelectionRegionWithDocument ()
-currentPoints.boundingRect ().x () + newX,
-currentPoints.boundingRect ().y () + newY);
kpAbstractImageSelection *imageSel =
dynamic_cast <kpAbstractImageSelection *> (m_oldSelectionPtr);
kpTextSelection *textSel =
dynamic_cast <kpTextSelection *> (m_oldSelectionPtr);
auto *imageSel = dynamic_cast <kpAbstractImageSelection *> (m_oldSelectionPtr);
auto *textSel = dynamic_cast <kpTextSelection *> (m_oldSelectionPtr);
if (imageSel)
{
document ()->setSelection (
......@@ -235,8 +237,9 @@ void kpTransformResizeScaleCommand::scaleSelectionRegionWithDocument ()
textSel->textLines (),
textSel->textStyle ()));
}
else
else {
Q_ASSERT (!"Unknown selection type");
}
environ ()->somethingBelowTheCursorChanged ();
......@@ -251,8 +254,7 @@ void kpTransformResizeScaleCommand::execute ()
<< " oldWidth=" << m_oldWidth
<< " oldHeight=" << m_oldHeight
<< " newWidth=" << m_newWidth
<< " newHeight=" << m_newHeight
<< endl;
<< " newHeight=" << m_newHeight;
if (m_oldWidth == m_newWidth && m_oldHeight == m_newHeight)
return;
......@@ -261,8 +263,9 @@ void kpTransformResizeScaleCommand::execute ()
{
if (m_actOnSelection)
{
if (!m_actOnTextSelection)
if (!m_actOnTextSelection) {
Q_ASSERT (!"kpTransformResizeScaleCommand::execute() resizing sel doesn't make sense");
}
QApplication::setOverrideCursor (Qt::WaitCursor);
......@@ -310,8 +313,9 @@ void kpTransformResizeScaleCommand::execute ()
kpImage oldImage = document ()->image (m_actOnSelection);
if (!m_isLosslessScale)
if (!m_isLosslessScale) {
m_oldImage = oldImage;
}
kpImage newImage = kpPixmapFX::scale (oldImage, m_newWidth, m_newHeight,
m_type == SmoothScale);
......@@ -326,12 +330,14 @@ void kpTransformResizeScaleCommand::execute ()
if (m_actOnSelection)
{
if (m_actOnTextSelection)
if (m_actOnTextSelection) {
Q_ASSERT (!"kpTransformResizeScaleCommand::execute() scaling text sel doesn't make sense");
}
Q_ASSERT (m_oldSelectionPtr);
if ( !m_oldSelectionPtr ) // make coverity happy
return;
if ( !m_oldSelectionPtr ) { // make coverity happy
return;
}
QRect newRect = QRect (m_oldSelectionPtr->x (), m_oldSelectionPtr->y (),
newImage.width (), newImage.height ());
......@@ -341,7 +347,7 @@ void kpTransformResizeScaleCommand::execute ()
Q_ASSERT (dynamic_cast <kpAbstractImageSelection *> (m_oldSelectionPtr));
document ()->setSelection (
kpRectangularImageSelection (newRect, newImage,
static_cast <kpAbstractImageSelection *> (m_oldSelectionPtr)
dynamic_cast <kpAbstractImageSelection *> (m_oldSelectionPtr)
->transparency ()));
environ ()->somethingBelowTheCursorChanged ();
......@@ -365,10 +371,11 @@ void kpTransformResizeScaleCommand::execute ()
void kpTransformResizeScaleCommand::unexecute ()
{
qCDebug(kpLogCommands) << "kpTransformResizeScaleCommand::unexecute() type="
<< m_type << endl;
<< m_type;
if (m_oldWidth == m_newWidth && m_oldHeight == m_newHeight)
if (m_oldWidth == m_newWidth && m_oldHeight == m_newHeight) {
return;
}
kpDocument *doc = document ();
Q_ASSERT (doc);
......@@ -377,8 +384,9 @@ void kpTransformResizeScaleCommand::unexecute ()
{
if (m_actOnSelection)
{
if (!m_actOnTextSelection)
if (!m_actOnTextSelection) {
Q_ASSERT (!"kpTransformResizeScaleCommand::unexecute() resizing sel doesn't make sense");
}
QApplication::setOverrideCursor (Qt::WaitCursor);
......@@ -431,21 +439,22 @@ void kpTransformResizeScaleCommand::unexecute ()
kpImage oldImage;
if (!m_isLosslessScale)
if (!m_isLosslessScale) {
oldImage = m_oldImage;
else
} else {
oldImage = kpPixmapFX::scale (doc->image (m_actOnSelection),
m_oldWidth, m_oldHeight);
}
if (m_actOnSelection)
{
if (m_actOnTextSelection)
if (m_actOnTextSelection) {
Q_ASSERT (!"kpTransformResizeScaleCommand::unexecute() scaling text sel doesn't make sense");
}
Q_ASSERT (dynamic_cast <kpAbstractImageSelection *> (m_oldSelectionPtr));
kpAbstractImageSelection *oldImageSel =
static_cast <kpAbstractImageSelection *> (m_oldSelectionPtr);
auto *oldImageSel = dynamic_cast <kpAbstractImageSelection *> (m_oldSelectionPtr);
kpAbstractImageSelection *oldSelection = oldImageSel->clone ();
oldSelection->setBaseImage (oldImage);
......
......@@ -71,10 +71,7 @@ QString kpTransformRotateCommand::name () const
{
QString opName = i18n ("Rotate");
if (m_actOnSelection)
return i18n ("Selection: %1", opName);
else
return opName;
return (m_actOnSelection) ? i18n ("Selection: %1", opName) : opName;
}
......@@ -96,18 +93,19 @@ void kpTransformRotateCommand::execute ()
QApplication::setOverrideCursor (Qt::WaitCursor);
if (!m_losslessRotation)
if (!m_losslessRotation) {
m_oldImage = doc->image (m_actOnSelection);
}
kpImage newImage = kpPixmapFX::rotate (doc->image (m_actOnSelection),
m_angle,
m_backgroundColor);
if (!m_actOnSelection)
if (!m_actOnSelection) {
doc->setImage (newImage);
else
{
}
else {
kpAbstractImageSelection *sel = doc->imageSelection ();
Q_ASSERT (sel);
......@@ -163,8 +161,7 @@ void kpTransformRotateCommand::execute ()
<< currentPoints.boundingRect ()
<< " newPixmap: w=" << newImage.width ()
<< " h=" << newImage.height ()
<< " (victim of rounding error and/or rotated-a-(rectangular)-pixmap-that-was-transparent-in-the-corners-making-sel-uselessly-bigger-than-needs-be)"
<< endl;
<< " (victim of rounding error and/or rotated-a-(rectangular)-pixmap-that-was-transparent-in-the-corners-making-sel-uselessly-bigger-than-needs-be)";
#endif
doc->setSelection (
kpRectangularImageSelection (
......@@ -206,10 +203,10 @@ void kpTransformRotateCommand::unexecute ()
}
if (!m_actOnSelection)
if (!m_actOnSelection) {
doc->setImage (oldImage);
else
{
}
else {
m_oldSelectionPtr->setBaseImage (oldImage);
doc->setSelection (*m_oldSelectionPtr);
delete m_oldSelectionPtr; m_oldSelectionPtr = nullptr;
......
......@@ -74,10 +74,7 @@ QString kpTransformSkewCommand::name () const
{
QString opName = i18n ("Skew");
if (m_actOnSelection)
return i18n ("Selection: %1", opName);
else
return opName;
return (m_actOnSelection) ? i18n ("Selection: %1", opName) : opName;
}
......@@ -150,8 +147,7 @@ void kpTransformSkewCommand::execute ()
<< currentPoints.boundingRect ()
<< " newPixmap: w=" << newImage.width ()
<< " h=" << newImage.height ()
<< " (victim of rounding error and/or skewed-a-(rectangular)-pixmap-that-was-transparent-in-the-corners-making-sel-uselessly-bigger-than-needs-be))"
<< endl;
<< " (victim of rounding error and/or skewed-a-(rectangular)-pixmap-that-was-transparent-in-the-corners-making-sel-uselessly-bigger-than-needs-be))";
#endif
doc->setSelection (
kpRectangularImageSelection (
......
......@@ -40,9 +40,7 @@ kpCommand::kpCommand (kpCommandEnvironment *environ)
Q_ASSERT (environ);
}
kpCommand::~kpCommand ()
{
}
kpCommand::~kpCommand () = default;
kpCommandEnvironment *kpCommand::environ () const
......
......@@ -44,9 +44,7 @@ kpCommandHistory::kpCommandHistory (bool doReadConfig, kpMainWindow *mainWindow)
{
}
kpCommandHistory::~kpCommandHistory ()
{
}
kpCommandHistory::~kpCommandHistory () = default;
static bool NextUndoCommandIsCreateBorder (kpCommandHistory *commandHistory)
......@@ -54,12 +52,14 @@ static bool NextUndoCommandIsCreateBorder (kpCommandHistory *commandHistory)
Q_ASSERT (commandHistory);
kpCommand *cmd = commandHistory->nextUndoCommand ();
if (!cmd)
if (!cmd) {
return false;
}
kpToolSelectionCreateCommand *c = dynamic_cast <kpToolSelectionCreateCommand *> (cmd);
if (!c)
auto *c = dynamic_cast <kpToolSelectionCreateCommand *> (cmd);
if (!c) {
return false;
}
const kpAbstractSelection *sel = c->fromSelection ();
Q_ASSERT (sel);
......@@ -80,11 +80,13 @@ void kpCommandHistory::addCreateSelectionCommand (kpToolSelectionCreateCommand *
if (::NextUndoCommandIsCreateBorder (this))
{
setNextUndoCommand (cmd);
if (execute)
if (execute) {
cmd->execute ();
}
}
else
else {
addCommand (cmd, execute);
}
}
//---------------------------------------------------------------------
......@@ -98,8 +100,9 @@ void kpCommandHistory::undo ()
qCDebug(kpLogCommands) << "\thas begun shape - cancel draw";
m_mainWindow->tool ()->cancelShapeInternal ();
}
else
else {
kpCommandHistoryBase::undo ();
}
}
//---------------------------------------------------------------------
......@@ -117,8 +120,9 @@ void kpCommandHistory::redo ()
// down).
m_mainWindow->tool ()->cancelShapeInternal ();
}
else
else {
kpCommandHistoryBase::redo ();
}
}
This diff is collapsed.
......@@ -62,8 +62,7 @@ kpCommandSize::SizeType kpCommandSize::PixmapSize (int width, int height, int de
<< " h=" << height
<< " d=" << depth
<< " roundedDepth=" << roundedDepth
<< " ret=" << ret
<< endl;
<< " ret=" << ret;
return ret;
}
......@@ -92,8 +91,7 @@ kpCommandSize::SizeType kpCommandSize::QImageSize (int width, int height, int de
<< " h=" << height
<< " d=" << depth
<< " roundedDepth=" << roundedDepth
<< " ret=" << ret
<< endl;
<< " ret=" << ret;
return ret;
}
......@@ -130,8 +128,7 @@ kpCommandSize::SizeType kpCommandSize::StringSize (const QString &string)
{
qCDebug(kpLogCommands) << "kpCommandSize::StringSize(" << string << ")"
<< " len=" << string.length ()
<< " sizeof(QChar)=" << sizeof (QChar)
<< endl;
<< " sizeof(QChar)=" << sizeof (QChar);
return static_cast<SizeType> (static_cast<unsigned int> (string.length ()) * sizeof (QChar));
}
......@@ -141,8 +138,7 @@ kpCommandSize::SizeType kpCommandSize::PolygonSize (const QPolygon &points)
{
qCDebug(kpLogCommands) << "kpCommandSize::PolygonSize() points.size="
<< points.size ()
<< " sizeof(QPoint)=" << sizeof (QPoint)
<< endl;
<< " sizeof(QPoint)=" << sizeof (QPoint);
return static_cast<SizeType> (static_cast<unsigned int> (points.size ()) * sizeof (QPoint));
}
......
......@@ -67,11 +67,10 @@ kpCommandSize::SizeType kpMacroCommand::size () const
SizeType s = 0;
qCDebug(kpLogCommands) << "\tcalculating:";
foreach (kpCommand *cmd, m_commandList)
for (auto *cmd : m_commandList)
{
qCDebug(kpLogCommands) << "\t\tcurrentSize=" << s << " + "
<< cmd->name () << ".size=" << cmd->size ()
<< endl;
<< cmd->name () << ".size=" << cmd->size ();
s += cmd->size ();
}
......
......@@ -106,8 +106,7 @@ void kpToolFlowCommand::updateBoundingRect (const QRect &rect)