Commit cf5346cb authored by Boudewijn Rempt's avatar Boudewijn Rempt

Use Q_FALLTHROUGH everwhere possible

I didn't know it existed...
parent 593dba2b
......@@ -508,6 +508,7 @@ qint32 KisAbrBrushCollection::abr_brush_load(QDataStream & abr, AbrInfo *abr_hdr
qint32 layer_ID = -1;
switch (abr_hdr->version) {
case 1:
Q_FALLTHROUGH();
// fall through, version 1 and 2 are compatible
case 2:
layer_ID = abr_brush_load_v12(abr, abr_hdr, filename, image_ID, id);
......
......@@ -93,7 +93,7 @@ QPixmap KoImageData::pixmap(const QSize &size)
}
case KoImageDataPrivate::StateNotLoaded:
image(); // forces load
// fall through
Q_FALLTHROUGH();
case KoImageDataPrivate::StateImageLoaded:
case KoImageDataPrivate::StateImageOnly:
if (!d->image.isNull()) {
......
......@@ -78,7 +78,7 @@ void KoPathShapeLoaderPrivate::parseSvg(const QString &s, bool process)
switch (command) {
case 'm':
relative = true;
/* Falls through. */
Q_FALLTHROUGH();
case 'M': {
ptr = getCoord(ptr, tox);
ptr = getCoord(ptr, toy);
......@@ -94,7 +94,7 @@ void KoPathShapeLoaderPrivate::parseSvg(const QString &s, bool process)
}
case 'l':
relative = true;
/* Falls through. */
Q_FALLTHROUGH();
case 'L': {
ptr = getCoord(ptr, tox);
ptr = getCoord(ptr, toy);
......@@ -145,7 +145,7 @@ void KoPathShapeLoaderPrivate::parseSvg(const QString &s, bool process)
break;
}
case 'z':
/* Falls through. */
Q_FALLTHROUGH();
case 'Z': {
// reset curx, cury for next path
if (process) {
......@@ -157,7 +157,7 @@ void KoPathShapeLoaderPrivate::parseSvg(const QString &s, bool process)
}
case 'c':
relative = true;
/* Falls through. */
Q_FALLTHROUGH();
case 'C': {
ptr = getCoord(ptr, x1);
ptr = getCoord(ptr, y1);
......@@ -187,7 +187,7 @@ void KoPathShapeLoaderPrivate::parseSvg(const QString &s, bool process)
}
case 's':
relative = true;
/* Falls through. */
Q_FALLTHROUGH();
case 'S': {
ptr = getCoord(ptr, x2);
ptr = getCoord(ptr, y2);
......@@ -219,7 +219,7 @@ void KoPathShapeLoaderPrivate::parseSvg(const QString &s, bool process)
}
case 'q':
relative = true;
/* Falls through. */
Q_FALLTHROUGH();
case 'Q': {
ptr = getCoord(ptr, x1);
ptr = getCoord(ptr, y1);
......@@ -246,7 +246,7 @@ void KoPathShapeLoaderPrivate::parseSvg(const QString &s, bool process)
}
case 't':
relative = true;
/* Falls through. */
Q_FALLTHROUGH();
case 'T': {
ptr = getCoord(ptr, tox);
ptr = getCoord(ptr, toy);
......@@ -279,7 +279,7 @@ void KoPathShapeLoaderPrivate::parseSvg(const QString &s, bool process)
}
case 'a':
relative = true;
/* Falls through. */
Q_FALLTHROUGH();
case 'A': {
bool largeArc, sweep;
qreal angle, rx, ry;
......
......@@ -2246,7 +2246,6 @@ void KoShape::saveOdfCommonChildElements(KoShapeSavingContext &context) const
escapeDirection = "down";
break;
default:
// fall through
break;
}
if(!escapeDirection.isEmpty()) {
......@@ -2282,7 +2281,6 @@ void KoShape::saveOdfCommonChildElements(KoShapeSavingContext &context) const
alignment = "bottom-right";
break;
default:
// fall through
break;
}
if(!alignment.isEmpty()) {
......
......@@ -1396,14 +1396,14 @@ void KisPainter::Private::fillPainterPathImpl(const QPainterPath& path, const QR
switch (fillStyle) {
default:
/* Falls through. */
Q_FALLTHROUGH();
case FillStyleGradient:
// Currently unsupported
/* Falls through. */
Q_FALLTHROUGH();
case FillStyleStrokes:
// Currently unsupported
warnImage << "Unknown or unsupported fill style in fillPolygon\n";
/* Falls through. */
Q_FALLTHROUGH();
case FillStyleForegroundColor:
fillPainter->fillRect(fillRect, q->paintColor(), OPACITY_OPAQUE_U8);
break;
......
......@@ -102,7 +102,7 @@ QVariant DocumentListModel::data(const QModelIndex &index, int role) const
const DocumentInfo &info = d->currentDocumentInfos[row];
switch (role) {
case FileNameRole: // intentional fall through
case FileNameRole: Q_FALLTHROUGH();
case Qt::DisplayRole: return info.fileName;
case FilePathRole: return info.filePath;
case DocTypeRole: return info.docType;
......
......@@ -30,9 +30,12 @@
#include <filter/kis_filter_configuration.h>
#include <kis_paint_device.h>
#include <kis_transaction.h>
#include <commands/kis_change_filter_command.h>
#include <kis_generator_layer.h>
#include <KisViewManager.h>
#include <KisDocument.h>
KisDlgGeneratorLayer::KisDlgGeneratorLayer(const QString & name, KisViewManager *view, QWidget *parent)
KisDlgGeneratorLayer::KisDlgGeneratorLayer(const QString defaultName, KisViewManager *view, QWidget *parent, KisGeneratorLayerSP glayer = 0, const KisFilterConfigurationSP previousConfig = 0)
: KoDialog(parent)
, m_customName(false)
, m_freezeName(false)
......@@ -40,16 +43,57 @@ KisDlgGeneratorLayer::KisDlgGeneratorLayer(const QString & name, KisViewManager
setButtons(Ok | Cancel);
setDefaultButton(Ok);
QWidget * page = new QWidget(this);
isEditing = glayer && previousConfig;
if(isEditing){
setModal(false);
layer = glayer;
configBefore = previousConfig;
}
QWidget *page = new QWidget(this);
m_view = view;
dlgWidget.setupUi(page);
dlgWidget.wdgGenerator->initialize(view);
dlgWidget.wdgGenerator->initialize(m_view);
setMainWidget(page);
dlgWidget.txtLayerName->setText(name);
dlgWidget.txtLayerName->setText( isEditing ? layer->name() : defaultName );
connect(dlgWidget.txtLayerName, SIGNAL(textChanged(QString)),
this, SLOT(slotNameChanged(QString)));
}
KisDlgGeneratorLayer::~KisDlgGeneratorLayer()
{
/*Editing a layer should be using the show function with automatic deletion on close.
*Because of this, the action should be taken care of when the window is closed and
*the user has accepted the changes.*/
if(isEditing && result() == QDialog::Accepted) {
layer->setName(layerName());
KisFilterConfigurationSP configAfter(configuration());
Q_ASSERT(configAfter);
QString xmlBefore = configBefore->toXML();
QString xmlAfter = configAfter->toXML();
if(xmlBefore != xmlAfter) {
KisChangeFilterCmd *cmd
= new KisChangeFilterCmd(layer,
configBefore->name(),
xmlBefore,
configAfter->name(),
xmlAfter,
true);
// FIXME: check whether is needed
cmd->redo();
m_view->undoAdapter()->addCommand(cmd);
m_view->document()->setModified(true);
}
}
}
void KisDlgGeneratorLayer::slotNameChanged(const QString & text)
{
if (m_freezeName)
......
......@@ -43,20 +43,26 @@ public:
* @param name the proposed name for this layer
* @param view the view manager
* @param parent the widget parent of this dialog
* @param glayer optional generator layer for editing
* @param previousConfig optional configuration of layer being edited.
*/
KisDlgGeneratorLayer(const QString & name, KisViewManager *view, QWidget *parent);
KisDlgGeneratorLayer(const QString defaultLayerName, KisViewManager *arg_view, QWidget *parent, KisGeneratorLayerSP glayer, const KisFilterConfigurationSP previousConfig);
~KisDlgGeneratorLayer() override;
void setConfiguration(const KisFilterConfigurationSP config);
KisFilterConfigurationSP configuration() const;
QString layerName() const;
protected Q_SLOTS:
void slotNameChanged(const QString &);
private:
Ui_WdgDlgGeneratorLayer dlgWidget;
KisGeneratorLayerSP layer;
KisFilterConfigurationSP configBefore;
KisViewManager *m_view;
bool isEditing;
bool m_customName;
bool m_freezeName;
};
......
......@@ -292,40 +292,21 @@ void KisLayerManager::layerProperties()
}
}
else if (glayer && !multipleLayersSelected) {
KisDlgGeneratorLayer dlg(glayer->name(), m_view, m_view->mainWindow());
dlg.setCaption(i18n("Fill Layer Properties"));
KisFilterConfigurationSP configBefore(glayer->filter());
Q_ASSERT(configBefore);
QString xmlBefore = configBefore->toXML();
dlg.setConfiguration(configBefore.data());
dlg.resize(dlg.minimumSizeHint());
KisDlgGeneratorLayer *dlg = new KisDlgGeneratorLayer(glayer->name(), m_view, m_view->mainWindow(), glayer, configBefore);
dlg->setCaption(i18n("Fill Layer Properties"));
dlg->setAttribute(Qt::WA_DeleteOnClose);
if (dlg.exec() == QDialog::Accepted) {
dlg->setConfiguration(configBefore.data());
dlg->resize(dlg->minimumSizeHint());
glayer->setName(dlg.layerName());
Qt::WindowFlags flags = dlg->windowFlags();
dlg->setWindowFlags(flags | Qt::WindowStaysOnTopHint | Qt::Dialog);
dlg->show();
KisFilterConfigurationSP configAfter(dlg.configuration());
Q_ASSERT(configAfter);
QString xmlAfter = configAfter->toXML();
if(xmlBefore != xmlAfter) {
KisChangeFilterCmd *cmd
= new KisChangeFilterCmd(glayer,
configBefore->name(),
xmlBefore,
configAfter->name(),
xmlAfter,
true);
// FIXME: check whether is needed
cmd->redo();
m_view->undoAdapter()->addCommand(cmd);
m_view->document()->setModified(true);
}
}
} else if (flayer && !multipleLayersSelected){
QString basePath = QFileInfo(m_view->document()->url().toLocalFile()).absolutePath();
QString fileNameOld = flayer->fileName();
......@@ -674,7 +655,8 @@ KisNodeSP KisLayerManager::addGeneratorLayer(KisNodeSP activeNode)
KisImageWSP image = m_view->image();
QColor currentForeground = m_view->resourceProvider()->fgColor().toQColor();
KisDlgGeneratorLayer dlg(image->nextLayerName(), m_view, m_view->mainWindow());
KisDlgGeneratorLayer dlg(image->nextLayerName(), m_view, m_view->mainWindow(), 0, 0);
KisFilterConfigurationSP defaultConfig = dlg.configuration();
defaultConfig->setProperty("color", currentForeground);
dlg.setConfiguration(defaultConfig);
......
......@@ -166,9 +166,9 @@ Exiv2::Value* kmdValueToExivValue(const KisMetaData::Value& value, Exiv2::TypeId
return new Exiv2::ValueType<Exiv2::URational>(Exiv2::URational(value.asRational().numerator, value.asRational().denominator));
}
case KisMetaData::Value::OrderedArray:
/* Falls through */
Q_FALLTHROUGH();
case KisMetaData::Value::UnorderedArray:
/* Falls through */
Q_FALLTHROUGH();
case KisMetaData::Value::AlternativeArray: {
switch (type) {
case Exiv2::unsignedByte:
......
......@@ -283,15 +283,15 @@ void KisToolPaint::activateAlternateAction(AlternateAction action)
{
switch (action) {
case PickFgNode:
/* Falls through */
Q_FALLTHROUGH();
case PickBgNode:
/* Falls through */
Q_FALLTHROUGH();
case PickFgImage:
/* Falls through */
Q_FALLTHROUGH();
case PickBgImage:
delayedAction = action;
m_colorPickerDelayTimer.start(100);
/* Falls through */
Q_FALLTHROUGH();
default:
pickColorWasOverridden();
KisTool::activateAlternateAction(action);
......
......@@ -129,7 +129,7 @@ bool KCheckAccelerators::eventFilter(QObject *obj, QEvent *e)
if (!static_cast<QChildEvent *>(e)->child()->isWidgetType()) {
break;
}
// fall-through
Q_FALLTHROUGH();
case QEvent::Resize:
case QEvent::LayoutRequest:
case QEvent::WindowActivate:
......
......@@ -288,7 +288,7 @@ void ParagraphBulletsNumbers::styleChanged(int index)
case KoListStyle::AlphaLowerItem:
case KoListStyle::UpperAlphaItem:
showLetterSynchronization = true;
// fall through
Q_FALLTHROUGH();
default:
widget.levels->setEnabled(true);
widget.startValue->setEnabled(true);
......
......@@ -223,7 +223,7 @@ KisImageBuilder_Result CSVLoader::decode(QIODevice *io, const QString &filename)
readLine.rewind();
field = readLine.nextField();
step = 4;
/* Falls through */
Q_FALLTHROUGH();
case 4 : //level header
......@@ -266,7 +266,7 @@ KisImageBuilder_Result CSVLoader::decode(QIODevice *io, const QString &filename)
step = 5;
/* Falls through */
Q_FALLTHROUGH();
case 5 : //frames
......
......@@ -82,20 +82,20 @@ struct TgaHeaderInfo {
switch (tga.image_type) {
case TGA_TYPE_RLE_INDEXED:
rle = true;
/* Falls through */
Q_FALLTHROUGH();
case TGA_TYPE_INDEXED:
pal = true;
break;
case TGA_TYPE_RLE_RGB:
rle = true;
/* Falls through */
Q_FALLTHROUGH();
case TGA_TYPE_RGB:
rgb = true;
break;
case TGA_TYPE_RLE_GREY:
rle = true;
/* Falls through */
Q_FALLTHROUGH();
case TGA_TYPE_GREY:
grey = true;
break;
......
......@@ -352,7 +352,9 @@ void ConvolveMatrixEffect::save(KoXmlWriter &writer)
break;
case Duplicate:
// fall through as it is the default
break;
Q_FALLTHROUGH();
default:
;
}
writer.addAttribute("kernelUnitLength", QString("%1 %2").arg(m_kernelUnitLength.x()).arg(m_kernelUnitLength.y()));
if (m_preserveAlpha) {
......
......@@ -104,7 +104,7 @@ void KisConstrainedRect::moveHandle(HandleType handle, const QPoint &offset, con
break;
case Creation:
baseSizeCoeff = 0;
/* Falls through */
Q_FALLTHROUGH();
case LowerRight:
xSizeCoeff = 1;
ySizeCoeff = 1;
......
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