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 b08455db authored by Kevin Funk's avatar Kevin Funk

Modernize: Use nullptr where possible

parent bde09969
......@@ -42,7 +42,7 @@ kpEffectClearCommand::kpEffectClearCommand (bool actOnSelection,
: kpCommand (environ),
m_actOnSelection (actOnSelection),
m_newColor (newColor),
m_oldImagePtr (0)
m_oldImagePtr (nullptr)
{
}
......@@ -107,6 +107,6 @@ void kpEffectClearCommand::unexecute ()
delete m_oldImagePtr;
m_oldImagePtr = 0;
m_oldImagePtr = nullptr;
}
......@@ -64,7 +64,7 @@ kpTransformResizeScaleCommand::kpTransformResizeScaleCommand (bool actOnSelectio
m_actOnSelection (actOnSelection),
m_type (type),
m_backgroundColor (environ->backgroundColor ()),
m_oldSelectionPtr (0)
m_oldSelectionPtr (nullptr)
{
kpDocument *doc = document ();
Q_ASSERT (doc);
......
......@@ -56,7 +56,7 @@ kpTransformRotateCommand::kpTransformRotateCommand (bool actOnSelection,
m_angle (angle),
m_backgroundColor (environ->backgroundColor (actOnSelection)),
m_losslessRotation (kpPixmapFX::isLosslessRotation (angle)),
m_oldSelectionPtr (0)
m_oldSelectionPtr (nullptr)
{
}
......@@ -212,7 +212,7 @@ void kpTransformRotateCommand::unexecute ()
{
m_oldSelectionPtr->setBaseImage (oldImage);
doc->setSelection (*m_oldSelectionPtr);
delete m_oldSelectionPtr; m_oldSelectionPtr = 0;
delete m_oldSelectionPtr; m_oldSelectionPtr = nullptr;
environ ()->somethingBelowTheCursorChanged ();
}
......
......@@ -59,7 +59,7 @@ kpTransformSkewCommand::kpTransformSkewCommand (bool actOnSelection,
m_actOnSelection (actOnSelection),
m_hangle (hangle), m_vangle (vangle),
m_backgroundColor (environ->backgroundColor (actOnSelection)),
m_oldSelectionPtr (0)
m_oldSelectionPtr (nullptr)
{
}
......@@ -188,7 +188,7 @@ void kpTransformSkewCommand::unexecute ()
else
{
doc->setSelection (*m_oldSelectionPtr);
delete m_oldSelectionPtr; m_oldSelectionPtr = 0;
delete m_oldSelectionPtr; m_oldSelectionPtr = nullptr;
environ ()->somethingBelowTheCursorChanged ();
}
......
......@@ -700,7 +700,7 @@ void kpCommandHistoryBase::updateActions ()
kpCommand *kpCommandHistoryBase::nextUndoCommand () const
{
if (m_undoCommandList.isEmpty ())
return 0;
return nullptr;
return m_undoCommandList.first ();
}
......@@ -709,7 +709,7 @@ kpCommand *kpCommandHistoryBase::nextUndoCommand () const
kpCommand *kpCommandHistoryBase::nextRedoCommand () const
{
if (m_redoCommandList.isEmpty ())
return 0;
return nullptr;
return m_redoCommandList.first ();
}
......
......@@ -60,7 +60,7 @@ kpToolSelectionCreateCommand::kpToolSelectionCreateCommand (const QString &name,
const kpAbstractSelection &fromSelection,
kpCommandEnvironment *environ)
: kpNamedCommand (name, environ),
m_fromSelection (0),
m_fromSelection (nullptr),
m_textRow (0), m_textCol (0)
{
setFromSelection (fromSelection);
......
......@@ -46,7 +46,7 @@ kpToolSelectionDestroyCommand::kpToolSelectionDestroyCommand (const QString &nam
kpCommandEnvironment *environ)
: kpNamedCommand (name, environ),
m_pushOntoDocument (pushOntoDocument),
m_oldSelectionPtr (0),
m_oldSelectionPtr (nullptr),
m_textRow(0), m_textCol(0)
{
}
......@@ -166,6 +166,6 @@ void kpToolSelectionDestroyCommand::unexecute ()
environ ()->somethingBelowTheCursorChanged ();
delete m_oldSelectionPtr;
m_oldSelectionPtr = 0;
m_oldSelectionPtr = nullptr;
}
......@@ -166,7 +166,7 @@ void kpToolSelectionResizeScaleCommand::resizeScaleAndMove (bool delayed)
killSmoothScaleTimer ();
kpAbstractSelection *newSelPtr = 0;
kpAbstractSelection *newSelPtr = nullptr;
if (textSelection ())
{
......
......@@ -33,7 +33,7 @@
#include <qcursor.h>
static const QCursor *TheLightCursor = 0;
static const QCursor *TheLightCursor = nullptr;
// public static
......
......@@ -74,10 +74,10 @@ kpEffectsDialog::kpEffectsDialog (bool actOnSelection,
_env,
parent),
m_delayedUpdateTimer (new QTimer (this)),
m_effectsComboBox (0),
m_settingsGroupBox (0),
m_settingsLayout (0),
m_effectWidget (0)
m_effectsComboBox (nullptr),
m_settingsGroupBox (nullptr),
m_settingsLayout (nullptr),
m_effectWidget (nullptr)
{
#if DEBUG_KP_EFFECTS_DIALOG
qCDebug(kpLogDialogs) << "kpEffectsDialog::kpEffectsDialog()";
......@@ -170,7 +170,7 @@ bool kpEffectsDialog::isNoOp () const
kpEffectCommandBase *kpEffectsDialog::createCommand () const
{
if (!m_effectWidget)
return 0;
return nullptr;
return m_effectWidget->createCommand (m_environ->commandEnvironment ());
}
......@@ -226,7 +226,7 @@ void kpEffectsDialog::selectEffect (int which)
delete m_effectWidget;
m_effectWidget = 0;
m_effectWidget = nullptr;
m_settingsGroupBox->setWindowTitle(QString());
......
......@@ -462,7 +462,7 @@ kpDocumentMetaInfo kpDocumentMetaInfoDialog::metaInfo (
.subs (value).subs (r + 1/*count from 1*/).toString ();
// Print only 1 error message per method invocation.
errorMessage = 0;
errorMessage = nullptr;
}
// Ignore.
......@@ -492,7 +492,7 @@ kpDocumentMetaInfo kpDocumentMetaInfoDialog::metaInfo (
.toString ();
// Print only 1 error message per method invocation.
errorMessage = 0;
errorMessage = nullptr;
}
// Ignore this duplicate - keep the first value of the key.
......
......@@ -79,7 +79,7 @@ public:
//
// This is a slow method as it recalculates the meta information each
// time it's called.
kpDocumentMetaInfo metaInfo (QString *errorMessage = 0) const;
kpDocumentMetaInfo metaInfo (QString *errorMessage = nullptr) const;
private:
void editCell (int r, int c);
......
......@@ -62,11 +62,11 @@ kpTransformPreviewDialog::kpTransformPreviewDialog (Features features,
: QDialog (parent),
m_afterActionText (afterActionText),
m_actOnSelection (actOnSelection),
m_dimensionsGroupBox (0),
m_afterTransformDimensionsLabel (0),
m_previewGroupBox (0),
m_previewPixmapLabel (0),
m_gridLayout (0),
m_dimensionsGroupBox (nullptr),
m_afterTransformDimensionsLabel (nullptr),
m_previewGroupBox (nullptr),
m_previewPixmapLabel (nullptr),
m_gridLayout (nullptr),
m_environ (_env)
{
setWindowTitle (caption);
......
......@@ -55,7 +55,7 @@ const QSize kpDocumentSaveOptionsPreviewDialog::s_pixmapLabelMinimumSize (25, 25
kpDocumentSaveOptionsPreviewDialog::kpDocumentSaveOptionsPreviewDialog (
QWidget *parent )
: kpSubWindow (parent),
m_filePixmap (0),
m_filePixmap (nullptr),
m_fileSize (0)
{
setWindowTitle (i18nc ("@title:window", "Save Preview"));
......
......@@ -76,7 +76,7 @@ kpDocument::kpDocument (int w, int h,
m_saveOptions (new kpDocumentSaveOptions ()),
m_metaInfo (new kpDocumentMetaInfo ()),
m_modified (false),
m_selection (0),
m_selection (nullptr),
m_oldWidth (-1), m_oldHeight (-1),
d (new kpDocumentPrivate ())
{
......
......@@ -83,8 +83,8 @@ public:
static QImage getPixmapFromFile (const QUrl &url, bool suppressDoesntExistDialog,
QWidget *parent,
kpDocumentSaveOptions *saveOptions = 0,
kpDocumentMetaInfo *metaInfo = 0);
kpDocumentSaveOptions *saveOptions = nullptr,
kpDocumentMetaInfo *metaInfo = nullptr);
// REFACTOR: fix: open*() should only be called once.
// Create a new kpDocument() if you want to open again.
void openNew (const QUrl &url);
......@@ -107,7 +107,7 @@ public:
const kpDocumentMetaInfo &metaInfo,
bool lossyPrompt,
QWidget *parent,
bool *userCancelled = 0);
bool *userCancelled = nullptr);
static bool savePixmapToFile (const QImage &pixmap,
const QUrl &url,
const kpDocumentSaveOptions &saveOptions,
......
......@@ -36,7 +36,7 @@ class kpDocumentEnvironment;
struct kpDocumentPrivate
{
kpDocumentPrivate ()
: environ(0)
: environ(nullptr)
{
}
......
......@@ -134,7 +134,7 @@ void kpDocument::setSelection (const kpAbstractSelection &selection)
emit contentsChanged (oldSelection->boundingRect ());
delete oldSelection;
oldSelection = 0;
oldSelection = nullptr;
}
if (m_selection->hasContent ())
......@@ -253,7 +253,7 @@ void kpDocument::selectionDelete ()
const bool selectionHadContent = m_selection->hasContent ();
delete m_selection;
m_selection = 0;
m_selection = nullptr;
// HACK to prevent document from being modified when
......
......@@ -108,7 +108,7 @@ void kpDocumentEnvironment::switchToCompatibleTool (const kpAbstractSelection &s
#endif
*isTextChanged = (mainWindow ()->toolIsTextTool () !=
(dynamic_cast <const kpTextSelection *> (&selection) != 0));
(dynamic_cast <const kpTextSelection *> (&selection) != nullptr));
// We don't change the Selection Tool if the new selection's
// shape is merely different to the current tool's (e.g. rectangular
......
......@@ -100,7 +100,7 @@ kpEffectToneEnhanceApplier::kpEffectToneEnhanceApplier ()
m_nComputedWid = 0;
m_nComputedHgt = 0;
m_pHistogram = new unsigned int[TONE_MAP_SIZE];
m_pToneMaps = 0;
m_pToneMaps = nullptr;
}
//---------------------------------------------------------------------
......@@ -120,7 +120,7 @@ void kpEffectToneEnhanceApplier::DeleteToneMaps()
for(int i = 0; i < nToneMaps; i++)
delete[] m_pToneMaps[i];
delete[] m_pToneMaps;
m_pToneMaps = 0;
m_pToneMaps = nullptr;
m_nToneMapGranularity = 0;
}
......
......@@ -86,7 +86,7 @@ public:
//
private:
kpColor pixelColor (int x, int y, bool *beenHere = 0) const;
kpColor pixelColor (int x, int y, bool *beenHere = nullptr) const;
bool shouldGoTo (int x, int y) const;
// Finds the minimum x value at a certain line to be filled.
......
......@@ -73,7 +73,7 @@ public:
// WARNING: Only call the <ctor> with imagePtr = 0 if you are going to use
// operator= to fill it in with a valid imagePtr immediately
// afterwards.
kpTransformAutoCropBorder (const kpImage *imagePtr = 0, int processedColorSimilarity = 0);
kpTransformAutoCropBorder (const kpImage *imagePtr = nullptr, int processedColorSimilarity = 0);
kpCommandSize::SizeType size () const;
......@@ -351,10 +351,10 @@ kpTransformAutoCropCommand::kpTransformAutoCropCommand (bool actOnSelection,
d->rightBorder = rightBorder;
d->topBorder = topBorder;
d->botBorder = botBorder;
d->leftImage = 0;
d->rightImage = 0;
d->topImage = 0;
d->botImage = 0;
d->leftImage = nullptr;
d->rightImage = nullptr;
d->topImage = nullptr;
d->botImage = nullptr;
kpDocument *doc = document ();
Q_ASSERT (doc);
......@@ -362,7 +362,7 @@ kpTransformAutoCropCommand::kpTransformAutoCropCommand (bool actOnSelection,
d->oldWidth = doc->width (d->actOnSelection);
d->oldHeight = doc->height (d->actOnSelection);
d->oldSelectionPtr = 0;
d->oldSelectionPtr = nullptr;
}
//---------------------------------------------------------------------
......@@ -461,10 +461,10 @@ void kpTransformAutoCropCommand::deleteUndoImages ()
qCDebug(kpLogImagelib) << "kpTransformAutoCropCommand::deleteUndoImages()";
#endif
delete d->leftImage; d->leftImage = 0;
delete d->rightImage; d->rightImage = 0;
delete d->topImage; d->topImage = 0;
delete d->botImage; d->botImage = 0;
delete d->leftImage; d->leftImage = nullptr;
delete d->rightImage; d->rightImage = nullptr;
delete d->topImage; d->topImage = nullptr;
delete d->botImage; d->botImage = nullptr;
}
......@@ -532,14 +532,14 @@ void kpTransformAutoCropCommand::unexecute ()
{
&d->leftBorder, &d->rightBorder,
&d->topBorder, &d->botBorder,
0
nullptr
};
const kpImage *images [] =
{
d->leftImage, d->rightImage,
d->topImage, d->botImage,
0
nullptr
};
const kpImage **p = images;
......@@ -582,7 +582,7 @@ void kpTransformAutoCropCommand::unexecute ()
d->oldSelectionPtr->setBaseImage (image);
doc->setSelection (*d->oldSelectionPtr);
delete d->oldSelectionPtr; d->oldSelectionPtr = 0;
delete d->oldSelectionPtr; d->oldSelectionPtr = nullptr;
environ ()->somethingBelowTheCursorChanged ();
}
......
......@@ -58,7 +58,7 @@ kpThumbnail::kpThumbnail (kpMainWindow *parent)
Q_ASSERT (parent);
d->mainWindow = parent;
d->view = 0;
d->view = nullptr;
d->lay = new QHBoxLayout (this);
......@@ -134,7 +134,7 @@ void kpThumbnail::slotViewDestroyed ()
qCDebug(kpLogMisc) << "kpThumbnail::slotViewDestroyed()";
#endif
d->view = 0;
d->view = nullptr;
updateCaption ();
}
......
......@@ -373,8 +373,8 @@ void kpGrip::leaveEvent (QEvent * /*e*/)
// TODO: Are we checking for m_view == 0 often enough? Also an issue in KDE 3.
kpViewScrollableContainer::kpViewScrollableContainer(QWidget *parent)
: QScrollArea(parent),
m_view(0), m_overlay(new kpOverlay(viewport(), this)),
m_docResizingGrip (0),
m_view(nullptr), m_overlay(new kpOverlay(viewport(), this)),
m_docResizingGrip (nullptr),
m_dragScrollTimer (new QTimer (this)),
m_zoomLevel (100),
m_scrollTimerRunOnce (false),
......@@ -504,7 +504,7 @@ void kpViewScrollableContainer::calculateDocResizingGrip ()
else if (m_rightGrip->isDrawing ())
m_docResizingGrip = m_rightGrip;
else
m_docResizingGrip = 0;
m_docResizingGrip = nullptr;
}
//---------------------------------------------------------------------
......@@ -963,9 +963,9 @@ void kpViewScrollableContainer::updateGrips ()
m_bottomRightGrip->move(m_view->width(), m_view->height());
}
m_bottomGrip->setHidden (m_view == 0);
m_rightGrip->setHidden (m_view == 0);
m_bottomRightGrip->setHidden (m_view == 0);
m_bottomGrip->setHidden (m_view == nullptr);
m_rightGrip->setHidden (m_view == nullptr);
m_bottomRightGrip->setHidden (m_view == nullptr);
recalculateStatusMessage ();
}
......@@ -975,7 +975,7 @@ void kpViewScrollableContainer::updateGrips ()
// protected slot
void kpViewScrollableContainer::slotViewDestroyed ()
{
m_view = 0;
m_view = nullptr;
updateGrips ();
}
......@@ -1027,7 +1027,7 @@ bool kpViewScrollableContainer::beginDragScroll(int zoomLevel, bool *didSomethin
bool kpViewScrollableContainer::beginDragScroll(int zoomLevel)
{
return beginDragScroll(zoomLevel,
0/*don't want scrolled notification*/);
nullptr/*don't want scrolled notification*/);
}
//---------------------------------------------------------------------
......@@ -1140,7 +1140,7 @@ bool kpViewScrollableContainer::slotDragScroll (bool *didSomething)
// protected slot
bool kpViewScrollableContainer::slotDragScroll ()
{
return slotDragScroll (0/*don't want scrolled notification*/);
return slotDragScroll (nullptr/*don't want scrolled notification*/);
}
//---------------------------------------------------------------------
......
......@@ -159,7 +159,7 @@ kpAbstractImageSelection *kpSelectionDrag::decode(const QMimeData *mimeData)
qCDebug(kpLogLayers) << "kpSelectionDrag::decode(kpAbstractSelection) mimeSource had no sel "
"and could not decode to image" << endl;
#endif
return 0;
return nullptr;
}
}
......
......@@ -59,7 +59,7 @@ kpAbstractImageSelection *kpSelectionFactory::FromStream (QDataStream &stream)
// Text selections are only ever seen in the clipboard as ordinary text,
// not selections, since copying text formatting over the clipboard doesn't
// seem compelling.
kpAbstractImageSelection *imageSel = 0;
kpAbstractImageSelection *imageSel = nullptr;
switch (serialID)
{
case kpRectangularImageSelection::SerialID:
......@@ -76,15 +76,15 @@ kpAbstractImageSelection *kpSelectionFactory::FromStream (QDataStream &stream)
}
// Unknown selection type?
if (imageSel == 0)
if (imageSel == nullptr)
{
return 0;
return nullptr;
}
if (!imageSel->readFromStream (stream))
{
delete imageSel;
return 0;
return nullptr;
}
return imageSel;
......
......@@ -42,8 +42,8 @@ kpTempImage::kpTempImage (bool isBrush, RenderMode renderMode,
m_topLeft (topLeft),
m_image (image),
m_width (image.width ()), m_height (image.height ()),
m_userFunction (0),
m_userData (0)
m_userFunction (nullptr),
m_userData (nullptr)
{
// Use below constructor for that.
Q_ASSERT (renderMode != UserFunction);
......
......@@ -45,7 +45,7 @@ class kpColorCellsBase::kpColorCellsBasePrivate
public:
kpColorCellsBasePrivate(kpColorCellsBase *q): q(q)
{
colors = 0;
colors = nullptr;
inMouse = false;
selected = -1;
shade = false;
......@@ -251,7 +251,7 @@ void kpColorCellsBase::setColor( int column, const QColor &colorIn )
if (color.isValid ())
{
if ( tableItem == 0 ) {
if ( tableItem == nullptr ) {
tableItem = new QTableWidgetItem();
setItem(tableRow,tableColumn,tableItem);
}
......
......@@ -62,7 +62,7 @@
//---------------------------------------------------------------------
kpMainWindow::kpMainWindow ()
: KXmlGuiWindow (0/*parent*/)
: KXmlGuiWindow (nullptr/*parent*/)
{
init ();
open (QUrl (), true/*create an empty doc*/);
......@@ -73,7 +73,7 @@ kpMainWindow::kpMainWindow ()
//---------------------------------------------------------------------
kpMainWindow::kpMainWindow (const QUrl &url)
: KXmlGuiWindow (0/*parent*/)
: KXmlGuiWindow (nullptr/*parent*/)
{
init ();
open (url, true/*create an empty doc with the same url if url !exist*/);
......@@ -84,7 +84,7 @@ kpMainWindow::kpMainWindow (const QUrl &url)
//---------------------------------------------------------------------
kpMainWindow::kpMainWindow (kpDocument *newDoc)
: KXmlGuiWindow (0/*parent*/)
: KXmlGuiWindow (nullptr/*parent*/)
{
init ();
setDocument (newDoc);
......@@ -295,7 +295,7 @@ void kpMainWindow::readProperties (const KConfigGroup &configGroup)
#if DEBUG_KP_MAIN_WINDOW
qCDebug(kpLogMainWindow) << "\tno url - no document";
#endif
setDocument (0);
setDocument (nullptr);
}
// Have a document.
else
......@@ -464,12 +464,12 @@ kpMainWindow::~kpMainWindow ()
// Delete document & views.
// Note: This will disconnects signals from the current kpTool, so kpTool
// must not be destructed yet.
setDocument (0);
setDocument (nullptr);
delete d->commandHistory; d->commandHistory = 0;
delete d->scrollView; d->scrollView = 0;
delete d->commandHistory; d->commandHistory = nullptr;
delete d->scrollView; d->scrollView = nullptr;
delete d; d = 0;
delete d; d = nullptr;
}
//---------------------------------------------------------------------
......@@ -513,7 +513,7 @@ kpColorToolBar *kpMainWindow::colorToolBar () const
// public
kpColorCells *kpMainWindow::colorCells () const
{
return d->colorToolBar ? d->colorToolBar->colorCells () : 0;
return d->colorToolBar ? d->colorToolBar->colorCells () : nullptr;
}
//---------------------------------------------------------------------
......@@ -611,7 +611,7 @@ void kpMainWindow::setDocument (kpDocument *newDoc)
enableDocumentActions (false);
}
delete d->mainView; d->mainView = 0;
delete d->mainView; d->mainView = nullptr;
slotDestroyThumbnail ();
// viewManager will die and so will the selection
......@@ -621,7 +621,7 @@ void kpMainWindow::setDocument (kpDocument *newDoc)
d->actionDeselect->setEnabled (false);
d->actionCopyToFile->setEnabled (false);
delete d->viewManager; d->viewManager = 0;
delete d->viewManager; d->viewManager = nullptr;
#if DEBUG_KP_MAIN_WINDOW
qCDebug(kpLogMainWindow) << "\tdestroying document";
......@@ -662,7 +662,7 @@ void kpMainWindow::setDocument (kpDocument *newDoc)
d->viewManager = new kpViewManager (this);
d->mainView = new kpZoomedView (d->document, d->toolToolBar, d->viewManager,
0/*buddyView*/,
nullptr/*buddyView*/,
d->scrollView,
d->scrollView->viewport ());
d->mainView->setObjectName ( QLatin1String("mainView" ));
......@@ -848,7 +848,7 @@ void kpMainWindow::dropEvent (QDropEvent *e)
qCDebug(kpLogMainWindow) << "\tpos toGlobal=" << globalPos;
#endif
kpView *view = 0;
kpView *view = nullptr;
if (d->viewManager)
{
......
......@@ -56,15 +56,15 @@ struct kpMainWindowPrivate
{
kpMainWindowPrivate ()
: isFullyConstructed(false),
scrollView(0),
mainView(0),
thumbnail(0),
thumbnailView(0),
document(0),
viewManager(0),
colorToolBar(0),
toolToolBar(0),
commandHistory(0),
scrollView(nullptr),
mainView(nullptr),
thumbnail(nullptr),
thumbnailView(nullptr),
document(nullptr),
viewManager(nullptr),
colorToolBar(nullptr),
toolToolBar(nullptr),
commandHistory(nullptr),
configFirstTime(false),
configShowGrid(false),
......@@ -72,40 +72,40 @@ struct kpMainWindowPrivate
configThumbnailShown(false),
configZoomedThumbnail(false),
documentEnvironment(0),
commandEnvironment(0),
documentEnvironment(nullptr),
commandEnvironment(nullptr),
// Tools
toolSelectionEnvironment(0),
toolsActionGroup(0),
toolSpraycan(0),
toolBrush(0),
toolColorEraser(0),