r24736 by jghali - Code cleanup

scribus-commit scribus-commit at lists.scribus.net
Tue Oct 5 21:16:29 UTC 2021


Author: jghali
Date: Tue Oct  5 21:16:29 2021
New Revision: 24736

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24736
Log:
Code cleanup

Modified:
    trunk/Scribus/scribus/pdflib_core.cpp
    trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp
    trunk/Scribus/scribus/plugins/fontpreview/fontpreview.cpp
    trunk/Scribus/scribus/plugins/fontpreview/fontpreview.h
    trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp
    trunk/Scribus/scribus/plugins/import/svg/svgplugin.h
    trunk/Scribus/scribus/scdomelement.cpp
    trunk/Scribus/scribus/scdomelement.h
    trunk/Scribus/scribus/scimagecachefile.cpp
    trunk/Scribus/scribus/scimagecachefile.h
    trunk/Scribus/scribus/sclockedfile.cpp
    trunk/Scribus/scribus/sclockedfile.h
    trunk/Scribus/scribus/ui/colorlistbox.cpp
    trunk/Scribus/scribus/ui/colorlistbox.h
    trunk/Scribus/scribus/ui/colorlistmodel.cpp
    trunk/Scribus/scribus/ui/colorlistmodel.h
    trunk/Scribus/scribus/ui/colorsandfills.cpp
    trunk/Scribus/scribus/ui/colorsandfills.h
    trunk/Scribus/scribus/ui/javadocs.cpp
    trunk/Scribus/scribus/ui/javadocs.h
    trunk/Scribus/scribus/ui/replacecolors.cpp
    trunk/Scribus/scribus/ui/replacecolors.h

Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24736&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp	(original)
+++ trunk/Scribus/scribus/pdflib_core.cpp	Tue Oct  5 21:16:29 2021
@@ -1905,7 +1905,7 @@
 		{
 			uint glyph = 224 * Fc + ww2 - 32;
 			ScFace::FaceEncoding::ConstIterator glIt = gl.find(glyph);
-			if (glIt != gl.cend() && !glIt.value().glyphName.isEmpty())
+			if (glIt != gl.cend() && !glIt->glyphName.isEmpty())
 			{
 				const ScFace::GlyphEncoding& glEncoding = glIt.value();
 				if (startOfSeq)

Modified: trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24736&path=/trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp	(original)
+++ trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp	Tue Oct  5 21:16:29 2021
@@ -1186,7 +1186,7 @@
 
 	void drawGlyphOutline(const GlyphCluster& gc, bool hasFill) override
 	{
-		if (gc.isControlGlyphs() | gc.isEmpty())
+		if (gc.isControlGlyphs() || gc.isEmpty())
 			return;
 
 		double current_x = 0.0;

Modified: trunk/Scribus/scribus/plugins/fontpreview/fontpreview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24736&path=/trunk/Scribus/scribus/plugins/fontpreview/fontpreview.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fontpreview/fontpreview.cpp	(original)
+++ trunk/Scribus/scribus/plugins/fontpreview/fontpreview.cpp	Tue Oct  5 21:16:29 2021
@@ -19,46 +19,50 @@
 
 
 FontPreview::FontPreview(const QString& fontName, QWidget* parent, ScribusDoc* doc)
-	: QDialog(parent, Qt::WindowFlags())
+	: QDialog(parent, Qt::WindowFlags()),
+	  m_Doc(doc)
 {
 	setupUi(this);
 	setModal(true);
 	setWindowIcon(IconManager::instance().loadIcon("AppIcon.png"));
-	m_Doc = doc;
-
-	sampleItem = new SampleItem();
-	sampleItem->setDevicePixelRatio(devicePixelRatioF());
+
+	m_sampleItem = new SampleItem();
+	m_sampleItem->setDevicePixelRatio(devicePixelRatioF());
 
 	languageChange();
 
-	fontModel = new FontListModel(this, m_Doc, false);
-
-	proxyModel = new QSortFilterProxyModel();
-	proxyModel->setDynamicSortFilter(true);
-	proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
-	proxyModel->setSourceModel(fontModel);
-	proxyModel->setFilterKeyColumn(1);
-	proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
-	fontList->setModel(proxyModel);
+	m_fontModel = new FontListModel(this, m_Doc, false);
+
+	m_proxyModel = new QSortFilterProxyModel();
+	m_proxyModel->setDynamicSortFilter(true);
+	m_proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
+	m_proxyModel->setSourceModel(m_fontModel);
+	m_proxyModel->setFilterKeyColumn(1);
+	m_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
+	fontList->setModel(m_proxyModel);
 
 	// scribus config
-	defaultStr = tr("Woven silk pyjamas exchanged for blue quartz", "font preview");
-	prefs = PrefsManager::instance().prefsFile->getPluginContext("fontpreview");
-	uint srt = prefs->getUInt("sortColumn", 0);
-	bool extend = prefs->getBool("extendedView", false);
+	m_defaultStr = tr("Woven silk pyjamas exchanged for blue quartz", "font preview");
+	m_prefs = PrefsManager::instance().prefsFile->getPluginContext("fontpreview");
+	uint srt = m_prefs->getUInt("sortColumn", 0);
+	bool extend = m_prefs->getBool("extendedView", false);
 	extendedCheckBox->setChecked(extend);
-	Qt::SortOrder srtOrder = (Qt::SortOrder) prefs->getUInt("sortColumnOrder", 0);
-
-	proxyModel->sort(srt, srtOrder);
+
+	auto srtOrder = (Qt::SortOrder) m_prefs->getUInt("sortColumnOrder", 0);
+	m_proxyModel->sort(srt, srtOrder);
+
 	fontList->horizontalHeader()->setSortIndicatorShown(true);
 	fontList->horizontalHeader()->setSortIndicator(srt, srtOrder);
-	xsize = prefs->getUInt("xsize", 640);
-	ysize = prefs->getUInt("ysize", 480);
-	sizeSpin->setValue(prefs->getUInt("fontSize", 18));
-	QString ph = prefs->get("phrase", defaultStr);
+
+	m_xsize = m_prefs->getUInt("xsize", 640);
+	m_ysize = m_prefs->getUInt("ysize", 480);
+	sizeSpin->setValue(m_prefs->getUInt("fontSize", 18));
+
+	QString ph = m_prefs->get("phrase", m_defaultStr);
 	displayEdit->setText(ph);
+
 	displayButton_clicked();
-	resize(QSize(xsize, ysize).expandedTo(minimumSizeHint()));
+	resize(QSize(m_xsize, m_ysize).expandedTo(minimumSizeHint()));
 
 	setExtendedView(extend);
 
@@ -73,10 +77,10 @@
 		else
 			searchName = PrefsManager::instance().appPrefs.itemToolPrefs.textFont;
 	}
-	QModelIndexList found = fontModel->match(fontModel->index(0, 0),
-											 Qt::DisplayRole, searchName,
-											 1,
-											 Qt::MatchContains | Qt::MatchWrap);
+	QModelIndexList found = m_fontModel->match(m_fontModel->index(0, 0),
+											   Qt::DisplayRole, searchName,
+											   1,
+											   Qt::MatchContains | Qt::MatchWrap);
 	if (!found.empty())
 	{
 		fontList->scrollTo(found.at(0), QAbstractItemView::PositionAtCenter);
@@ -96,13 +100,13 @@
 
 FontPreview::~FontPreview()
 {
-	prefs->set("sortColumn", fontList->horizontalHeader()->sortIndicatorSection());
-	prefs->set("sortColumnOrder", fontList->horizontalHeader()->sortIndicatorOrder());
-	prefs->set("xsize", width());
-	prefs->set("ysize", height());
-	prefs->set("fontSize", sizeSpin->value());
-	prefs->set("phrase", displayEdit->text());
-	prefs->set("extendedView", extendedCheckBox->isChecked());
+	m_prefs->set("sortColumn", fontList->horizontalHeader()->sortIndicatorSection());
+	m_prefs->set("sortColumnOrder", fontList->horizontalHeader()->sortIndicatorOrder());
+	m_prefs->set("xsize", width());
+	m_prefs->set("ysize", height());
+	m_prefs->set("fontSize", sizeSpin->value());
+	m_prefs->set("phrase", displayEdit->text());
+	m_prefs->set("extendedView", extendedCheckBox->isChecked());
 }
 
 void FontPreview::languageChange()
@@ -126,7 +130,7 @@
 
 bool FontPreview::allowSample()
 {
-	if (fontModel->rowCount() != 0)
+	if (m_fontModel->rowCount() != 0)
 		return true;
 	fontPreview->setText("No font selected");
 	return false;
@@ -141,10 +145,10 @@
 	if (fontName.isNull())
 		return;
 
-	sampleItem->setFontSize(sizeSpin->value() * 10, true);
-	sampleItem->setFont(fontName);
-	QPixmap pixmap = sampleItem->getSample(fontPreview->width(),
-										   fontPreview->height());
+	m_sampleItem->setFontSize(sizeSpin->value() * 10, true);
+	m_sampleItem->setFont(fontName);
+	QPixmap pixmap = m_sampleItem->getSample(fontPreview->width(),
+										     fontPreview->height());
 	fontPreview->clear();
 	if (!pixmap.isNull())
 		fontPreview->setPixmap(pixmap);
@@ -155,7 +159,7 @@
 	fontList->blockSignals(true);
 	QString s(searchEdit->text());
 	if (s.isEmpty())
-		proxyModel->setFilterRegExp(QRegExp("*",
+		m_proxyModel->setFilterRegExp(QRegExp("*",
 											Qt::CaseInsensitive,
 											QRegExp::Wildcard));
 	else
@@ -163,7 +167,7 @@
 		QRegExp regExp(QString("*%1*").arg(s),
 					   Qt::CaseInsensitive,
 					   QRegExp::Wildcard);
-		proxyModel->setFilterRegExp(regExp);
+		m_proxyModel->setFilterRegExp(regExp);
 	}
 	fontList->resizeColumnsToContents();
 	fontList->blockSignals(false);
@@ -174,12 +178,12 @@
 	QModelIndex ix(fontList->currentIndex());
 	if (!ix.isValid())
 		return QString();
-	return fontModel->nameForIndex(proxyModel->mapToSource(fontList->currentIndex()));
+	return m_fontModel->nameForIndex(m_proxyModel->mapToSource(fontList->currentIndex()));
 }
 
 void FontPreview::displayButton_clicked()
 {
-	sampleItem->setText(displayEdit->text());
+	m_sampleItem->setText(displayEdit->text());
 	paintSample();
 }
 
@@ -190,7 +194,7 @@
 
 void FontPreview::resetDisplayButton_clicked()
 {
-	displayEdit->setText(defaultStr);
+	displayEdit->setText(m_defaultStr);
 	displayButton_clicked();
 }
 

Modified: trunk/Scribus/scribus/plugins/fontpreview/fontpreview.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24736&path=/trunk/Scribus/scribus/plugins/fontpreview/fontpreview.h
==============================================================================
--- trunk/Scribus/scribus/plugins/fontpreview/fontpreview.h	(original)
+++ trunk/Scribus/scribus/plugins/fontpreview/fontpreview.h	Tue Oct  5 21:16:29 2021
@@ -44,22 +44,24 @@
 	QPixmap psFont;
 	QPixmap okIcon;
 	//! \brief Default "blue quartz" text
-	QString defaultStr;
+	QString m_defaultStr;
 	/** \brief Configuration structure */
-	PrefsContext* prefs;
+	PrefsContext* m_prefs { nullptr };
 	/*! \brief window size */
-	uint xsize;
-	uint ysize;
+	uint m_xsize { 640 };
+	uint m_ysize { 480 };
+
+	ScribusDoc* m_Doc { nullptr };
 
 	//! \brief Sample text frame to render the preview
-	SampleItem *sampleItem;
+	SampleItem *m_sampleItem { nullptr };
 
 	//! \brief Store fonts in the Qt4 MVC model part.
-	FontListModel * fontModel;
+	FontListModel * m_fontModel { nullptr };
 
 	/*! \brief A model for searching in the font set.
 	see searchEdit_textChanged() for more. */
-	QSortFilterProxyModel * proxyModel;
+	QSortFilterProxyModel * m_proxyModel { nullptr };
 
 	/*! \brief Create a pixmap sample with font preview.
 	With GUI oprions. */
@@ -73,8 +75,6 @@
 	//! \brief Paint sample on the dialog opening.
 	void showEvent(QShowEvent * event);
 	void resizeEvent(QResizeEvent * event);
-
-	ScribusDoc* m_Doc;
 
 protected slots:
 	/*! \brief Sets the strings of the subwidgets using the current

Modified: trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24736&path=/trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp	(original)
+++ trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp	Tue Oct  5 21:16:29 2021
@@ -218,22 +218,22 @@
 }
 
 SVGPlug::SVGPlug(ScribusDoc* doc, int flags)
+	   : m_Doc(doc),
+	     importerFlags(flags)
 {
 	tmpSel = new Selection(this, false);
-	m_Doc = doc;
-	unsupported = false;
-	importFailed = false;
-	importCanceled = true;
-	firstLayer = true;
+
 	importedColors.clear();
 	importedGradients.clear();
 	importedPatterns.clear();
-	docDesc = "";
-	docTitle = "";
-	groupLevel = 0;
-	importerFlags = flags;
+
 	interactive = (flags & LoadSavePlugin::lfInteractive);
 //	m_gc.setAutoDelete(true);
+}
+
+SVGPlug::~SVGPlug()
+{
+	delete tmpSel;
 }
 
 QImage SVGPlug::readThumbnail(const QString& fName)
@@ -284,7 +284,7 @@
 	}
 	QList<PageItem*> Elements = parseGroup(docElem);
 	tmpSel->clear();
-	QImage tmpImage = QImage();
+	QImage tmpImage;
 	if (Elements.count() > 0)
 	{
 		m_Doc->groupObjectsList(Elements);
@@ -337,7 +337,7 @@
 		if ((QChar(bb[0]) == QChar(0x1F)) && (QChar(bb[1]) == QChar(0x8B)))
 			isCompressed = true;
 	}
-	if ((fName.right(2) == "gz") || (isCompressed))
+	if ((fName.right(2) == "gz") || isCompressed)
 	{
 		QFile file(fName);
 		QtIOCompressor compressor(&file);
@@ -384,7 +384,7 @@
 			ret = true;
 		}
 	}
-	if ((ret) || (!interactive))
+	if (ret || !interactive)
 	{
 		if (width > height)
 			m_Doc->setPageOrientation(1);
@@ -923,13 +923,13 @@
 	return item;
 }
 
-bool SVGPlug::isIgnorableNode(const QDomElement &e)
+bool SVGPlug::isIgnorableNode(const QDomElement &e) const
 {
 	QString nodeName(e.tagName());
 	return isIgnorableNodeName(nodeName);
 }
 
-bool SVGPlug::isIgnorableNodeName(const QString &n)
+bool SVGPlug::isIgnorableNodeName(const QString &n) const
 {
 	return n.startsWith("sodipodi") || n.startsWith("inkscape") || n == "metadata";
 }
@@ -1530,7 +1530,7 @@
 	SvgStyle *gc = m_gc.top();
 	int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Ellipse, baseX, baseY, r * 2.0, r * 2.0, gc->LWidth, gc->FillCol, gc->StrokeCol);
 	PageItem* ite = m_Doc->Items->at(z);
-	QTransform mm = QTransform();
+	QTransform mm;
 	mm.translate(x, y);
 	ite->PoLine.map(mm);
 	FPoint wh = getMaxClipF(&ite->PoLine);
@@ -1554,7 +1554,7 @@
 	SvgStyle *gc = m_gc.top();
 	int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Ellipse, baseX, baseY, rx * 2.0, ry * 2.0, gc->LWidth, gc->FillCol, gc->StrokeCol);
 	PageItem* ite = m_Doc->Items->at(z);
-	QTransform mm = QTransform();
+	QTransform mm;
 	mm.translate(x, y);
 	ite->PoLine.map(mm);
 	FPoint wh = getMaxClipF(&ite->PoLine);
@@ -1779,7 +1779,7 @@
 		ite->SetFrameRound();
 		m_Doc->setRedrawBounding(ite);
 	}
-	QTransform mm = QTransform();
+	QTransform mm;
 	mm.translate(x, y);
 	ite->PoLine.map(mm);
 	FPoint wh = getMaxClipF(&ite->PoLine);
@@ -2094,7 +2094,7 @@
 {
 	bool doBreak = false;
 	setupNode(e);
-//	QDomNode c = e.firstChild();
+
 	for (QDomNode n = e.firstChild(); !n.isNull(); n = n.nextSibling())
 	{
 		if (n.isElement() && (parseTagName(n.toElement()) == "tspan"))
@@ -2955,7 +2955,7 @@
 	GElements = parseGroup(b);
 	if (GElements.count() > 0)
 	{
-		ScPattern pat = ScPattern();
+		ScPattern pat;
 		pat.setDoc(m_Doc);
 		PageItem* currItem = GElements.at(0);
 		m_Doc->DoDrawing = true;
@@ -3015,7 +3015,7 @@
 		GElements = parseGroup(b);
 		if (GElements.count() > 0)
 		{
-			ScPattern pat = ScPattern();
+			ScPattern pat;
 			pat.setDoc(m_Doc);
 			PageItem* currItem = GElements.at(0);
 			m_Doc->DoDrawing = true;
@@ -3205,8 +3205,3 @@
 		return tagName.mid(4, -1);
 	return tagName;
 }
-
-SVGPlug::~SVGPlug()
-{
-	delete tmpSel;
-}

Modified: trunk/Scribus/scribus/plugins/import/svg/svgplugin.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24736&path=/trunk/Scribus/scribus/plugins/import/svg/svgplugin.h
==============================================================================
--- trunk/Scribus/scribus/plugins/import/svg/svgplugin.h	(original)
+++ trunk/Scribus/scribus/plugins/import/svg/svgplugin.h	Tue Oct  5 21:16:29 2021
@@ -232,6 +232,7 @@
 	 */
 	SVGPlug(ScribusDoc* doc, int flags);
 	~SVGPlug();
+
 	bool import(const QString& fname, const TransactionSettings& trSettings, int flags);
 	QImage readThumbnail(const QString& fn);
 	bool loadData(const QString& fname);
@@ -240,8 +241,8 @@
 	void setupNode( const QDomElement &e );
 	void setupTransform( const QDomElement &e );
 	PageItem* finishNode( const QDomNode &e, PageItem* item);
-	bool isIgnorableNode( const QDomElement &e );
-	bool isIgnorableNodeName( const QString &n );
+	bool isIgnorableNode( const QDomElement &e ) const;
+	bool isIgnorableNodeName( const QString &n ) const;
 	FPoint parseTextPosition(const QDomElement &e, const FPoint* pos = nullptr);
 	QSizeF  parseWidthHeight(const QDomElement &e);
 	QRectF  parseViewBox(const QDomElement &e);
@@ -284,38 +285,37 @@
 	void parseMarker(const QDomElement &b);
 	void parsePattern(const QDomElement &b);
 	void parseGradient( const QDomElement &e );
-	FPoint GetMaxClipO(FPointArray Clip);
-	FPoint GetMinClipO(FPointArray Clip);
+
 	QDomDocument inpdoc;
 	QString docDesc;
 	QString docTitle;
-	int groupLevel;
+	int groupLevel { 0 };
 	QStack<SvgStyle*>	m_gc;
 	QMap<QString, GradientHelper>	m_gradients;
 	QMap<QString, QDomElement>		m_nodeMap;
 	QMap<QString, FPointArray>		m_clipPaths;
 	QMap<QString, QString>			m_unsupportedFeatures;
-	bool PathClosed;
-	double viewTransformX;
-	double viewTransformY;
-	double viewScaleX;
-	double viewScaleY;
-	bool interactive;
+
+	double viewTransformX { 0.0 };
+	double viewTransformY { 0.0 };
+	double viewScaleX { 1.0 };
+	double viewScaleY { 1.0 };
+	bool interactive { false };
 	//! \brief Indicator if there is any unsupported feature in imported svg.
-	bool unsupported;
-	bool importFailed;
-	bool importCanceled;
-	ScribusDoc* m_Doc;
-	Selection* tmpSel;
+	bool unsupported { false };
+	bool importFailed { false };
+	bool importCanceled { true };
+	ScribusDoc* m_Doc { nullptr };
+	Selection* tmpSel { nullptr };
 	QStringList importedColors;
 	QStringList importedGradients;
 	QMap<QString, QString> importedGradTrans;
 	QStringList importedPatterns;
 	QMap<QString, QString> importedPattTrans;
-	double inGroupXOrigin;
-	double inGroupYOrigin;
-	int importerFlags;
-	bool firstLayer;
+	double inGroupXOrigin { 0 };
+	double inGroupYOrigin { 0 };
+	int importerFlags { 0 };
+	bool firstLayer { true };
 	struct filterSpec
 	{
 		int blendMode;

Modified: trunk/Scribus/scribus/scdomelement.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24736&path=/trunk/Scribus/scribus/scdomelement.cpp
==============================================================================
--- trunk/Scribus/scribus/scdomelement.cpp	(original)
+++ trunk/Scribus/scribus/scdomelement.cpp	Tue Oct  5 21:16:29 2021
@@ -7,11 +7,6 @@
 
 #include "scclocale.h"
 #include "scdomelement.h"
-
-ScDomElement::ScDomElement()
-{
-
-}
 
 ScDomElement::ScDomElement(const QDomElement &elem) : QDomElement(elem)
 {

Modified: trunk/Scribus/scribus/scdomelement.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24736&path=/trunk/Scribus/scribus/scdomelement.h
==============================================================================
--- trunk/Scribus/scribus/scdomelement.h	(original)
+++ trunk/Scribus/scribus/scdomelement.h	Tue Oct  5 21:16:29 2021
@@ -12,7 +12,7 @@
 class ScDomElement : public QDomElement
 {
 public:
-	ScDomElement();
+	ScDomElement() = default;
 	ScDomElement(const QDomElement &elem); 
 
 	int     valueAsInt    (const QString& attrName, int def = 0) const;

Modified: trunk/Scribus/scribus/scimagecachefile.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24736&path=/trunk/Scribus/scribus/scimagecachefile.cpp
==============================================================================
--- trunk/Scribus/scribus/scimagecachefile.cpp	(original)
+++ trunk/Scribus/scribus/scimagecachefile.cpp	Tue Oct  5 21:16:29 2021
@@ -36,10 +36,6 @@
 	QFileInfo info(path());
 	m_modified = info.lastModified();
 	m_size = info.size();
-}
-
-ScImageCacheFile::~ScImageCacheFile()
-{
 }
 
 QString ScImageCacheFile::path(bool relative) const

Modified: trunk/Scribus/scribus/scimagecachefile.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24736&path=/trunk/Scribus/scribus/scimagecachefile.h
==============================================================================
--- trunk/Scribus/scribus/scimagecachefile.h	(original)
+++ trunk/Scribus/scribus/scimagecachefile.h	Tue Oct  5 21:16:29 2021
@@ -40,7 +40,7 @@
 
 public:
 	ScImageCacheFile(const QString & name, ScImageCacheDir* parent = nullptr);
-	~ScImageCacheFile();
+	~ScImageCacheFile() = default;
 
 	QString path(bool relative = false) const;
 	qint64 size() const;
@@ -53,9 +53,9 @@
 
 private:
 	const QString m_name;
-	ScImageCacheDir * const m_parent;
+	ScImageCacheDir * const m_parent { nullptr };
 	QDateTime m_modified;
-	qint64 m_size;
+	qint64 m_size { 0 };
 };
 
 #endif

Modified: trunk/Scribus/scribus/sclockedfile.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24736&path=/trunk/Scribus/scribus/sclockedfile.cpp
==============================================================================
--- trunk/Scribus/scribus/sclockedfile.cpp	(original)
+++ trunk/Scribus/scribus/sclockedfile.cpp	Tue Oct  5 21:16:29 2021
@@ -28,13 +28,8 @@
 
 const QString ScLockedFile::lockSuffix("lock");
 
-ScLockedFile::ScLockedFile()
-	: m_fileName(), m_isOpened(false), m_isLocked(false)
-{
-}
-
 ScLockedFile::ScLockedFile(const QString& name)
-	: m_fileName(name), m_isOpened(false), m_isLocked(false)
+	: m_fileName(name)
 {
 }
 
@@ -106,10 +101,6 @@
 }
 
 
-ScLockedFileRW::ScLockedFileRW()
-{
-}
-
 ScLockedFileRW::ScLockedFileRW(const QString & name)
 	: ScLockedFile(name)
 {

Modified: trunk/Scribus/scribus/sclockedfile.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24736&path=/trunk/Scribus/scribus/sclockedfile.h
==============================================================================
--- trunk/Scribus/scribus/sclockedfile.h	(original)
+++ trunk/Scribus/scribus/sclockedfile.h	Tue Oct  5 21:16:29 2021
@@ -58,14 +58,14 @@
 	static const QString lockSuffix;
 
 protected:
-	ScLockedFile();
-	ScLockedFile(const QString & name);
+	ScLockedFile() = default;
+	explicit ScLockedFile(const QString & name);
 
 	QString m_fileName;
-	bool m_isOpened;
+	bool m_isOpened { false };
 
 private:
-	bool m_isLocked;
+	bool m_isLocked { false };
 
 	QString lockName() const;
 };
@@ -78,12 +78,12 @@
 {
 public:
 	ScLockedFileRO();
-	ScLockedFileRO(const QString & name);
+	explicit ScLockedFileRO(const QString & name);
 
-	virtual bool open();
-	virtual bool commit();
+	bool open() override;
+	bool commit() override;
 
-	virtual QIODevice *io() { return &m_file; }
+	QIODevice *io() override { return &m_file; }
 
 private:
 	QFile m_file;
@@ -96,13 +96,13 @@
 class ScLockedFileRW : public ScLockedFile
 {
 public:
-	ScLockedFileRW();
-	ScLockedFileRW(const QString & name);
+	ScLockedFileRW() = default;
+	explicit ScLockedFileRW(const QString & name);
 
-	virtual bool open();
-	virtual bool commit();
+	bool open() override;
+	bool commit() override;
 
-	virtual QIODevice *io() { return &m_file; }
+	QIODevice *io() override { return &m_file; }
 
 private:
 	QTemporaryFile m_file;

Modified: trunk/Scribus/scribus/ui/colorlistbox.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24736&path=/trunk/Scribus/scribus/ui/colorlistbox.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/colorlistbox.cpp	(original)
+++ trunk/Scribus/scribus/ui/colorlistbox.cpp	Tue Oct  5 21:16:29 2021
@@ -31,7 +31,7 @@
 {
 public:
 	ColorSmallItemDelegate(): ScListBoxPixmap<15, 15>() {};
-	~ColorSmallItemDelegate() {};
+	~ColorSmallItemDelegate() = default;
 	
 	void redraw(const QVariant&) const override;
 	QString text(const QVariant&) const override;
@@ -41,7 +41,7 @@
 {
 public:
 	ColorWideItemDelegate(): ScListBoxPixmap<30, 15>() {};
-	~ColorWideItemDelegate() {};
+	~ColorWideItemDelegate() = default;
 	
 	void redraw(const QVariant&) const override;
 	QString text(const QVariant&) const override;
@@ -51,7 +51,7 @@
 {
 public:
 	ColorFancyItemDelegate();
-	~ColorFancyItemDelegate() {};
+	~ColorFancyItemDelegate() = default;
 	
 	void iconSetChange();
 	void redraw(const QVariant&) const override;
@@ -178,7 +178,6 @@
 ColorListBox::ColorListBox(QWidget * parent)
 	: QListView(parent)
 {
-	cList = nullptr;
 	if (initialized != 12345)
 		sortRule = 0;
 	initialized = 12345;
@@ -486,7 +485,7 @@
 		setCurrentColor(currentSel);
 }
 
-QString ColorListBox::text(int row)
+QString ColorListBox::text(int row) const
 {
 	QVariant varText = data(row, Qt::DisplayRole);
 	return varText.toString();

Modified: trunk/Scribus/scribus/ui/colorlistbox.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24736&path=/trunk/Scribus/scribus/ui/colorlistbox.h
==============================================================================
--- trunk/Scribus/scribus/ui/colorlistbox.h	(original)
+++ trunk/Scribus/scribus/ui/colorlistbox.h	Tue Oct  5 21:16:29 2021
@@ -108,10 +108,10 @@
 		void setShowNoneColor(bool showNone);
 
 		/*! \brief Return text displayed at specified row */
-		QString text(int row);
+		QString text(int row) const;
 				
 		/*! \brief Pointer to the color list displayed by this box */
-		ColorList *cList;
+		ColorList* cList { nullptr };
 
 	public slots:
 		void clear();

Modified: trunk/Scribus/scribus/ui/colorlistmodel.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24736&path=/trunk/Scribus/scribus/ui/colorlistmodel.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/colorlistmodel.cpp	(original)
+++ trunk/Scribus/scribus/ui/colorlistmodel.cpp	Tue Oct  5 21:16:29 2021
@@ -10,11 +10,13 @@
 #include "colorlistbox.h"
 #include "commonstrings.h"
 
-ColorPixmapValue::ColorPixmapValue() : m_name("invalid")
-{}
-
-ColorPixmapValue::ColorPixmapValue(const ColorPixmapValue& other) : m_color(other.m_color), m_doc(other.m_doc), m_name(other.m_name)
-{}
+ColorPixmapValue::ColorPixmapValue(const ColorPixmapValue& other)
+	            : m_color(other.m_color),
+	              m_doc(other.m_doc),
+	              m_name(other.m_name)
+{
+
+}
 
 ColorPixmapValue& ColorPixmapValue::operator= (const ColorPixmapValue& other)
 {
@@ -25,17 +27,16 @@
 }
 
 ColorPixmapValue::ColorPixmapValue(const ScColor& col, ScribusDoc* doc, const QString& colName)
+                : m_color(col),
+	              m_name(colName)
 {
 	m_doc = (doc) ? doc->guardedPtr() : nullptr;
-	m_color = col;
-	m_name = colName;
 }
 
 ColorListModel::ColorListModel(QObject *parent)
 	          : QAbstractItemModel(parent)
 {
-	m_isNoneColorShown = false;
-	m_sortRule = SortByName;
+
 }
 
 void ColorListModel::clear()
@@ -55,7 +56,7 @@
 	if (!index.isValid())
 		return QVariant();
 
-	ColorPixmapValue* pColorValue = static_cast<ColorPixmapValue*>(index.internalPointer());
+	const auto* pColorValue = static_cast<ColorPixmapValue*>(index.internalPointer());
 	if (!pColorValue)
 		return QVariant();
 
@@ -116,7 +117,7 @@
 	if (!hasIndex(row, column, parent))
 		return QModelIndex();
 
-	ColorPixmapValue* pColorValue = static_cast<ColorPixmapValue*>(parent.internalPointer());
+	const auto* pColorValue = static_cast<ColorPixmapValue*>(parent.internalPointer());
 	if (pColorValue)
 		return QModelIndex();
 
@@ -170,7 +171,7 @@
 	if (m_colors.count() == 0)
 		return 0;
 
-	ColorPixmapValue* pColorValue = static_cast<ColorPixmapValue*>(parent.internalPointer());
+	const auto* pColorValue = static_cast<ColorPixmapValue*>(parent.internalPointer());
 	if (pColorValue)
 		return 0;
 
@@ -274,8 +275,8 @@
 	if (v2.m_name == CommonStrings::None || v2.m_name == CommonStrings::tr_None)
 		return false;
 
-	QString sortString1 = QString("%1-%2");
-	QString sortString2 = QString("%1-%2");
+	QString sortString1("%1-%2");
+	QString sortString2("%1-%2");
 
 	if (v1.m_color.isRegistrationColor())
 		sortString1 = sortString1.arg("A", v1.m_name);

Modified: trunk/Scribus/scribus/ui/colorlistmodel.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24736&path=/trunk/Scribus/scribus/ui/colorlistmodel.h
==============================================================================
--- trunk/Scribus/scribus/ui/colorlistmodel.h	(original)
+++ trunk/Scribus/scribus/ui/colorlistmodel.h	Tue Oct  5 21:16:29 2021
@@ -20,9 +20,9 @@
 {
 	ScColor m_color;
 	ScGuardedPtr<ScribusDoc> m_doc;
-	QString m_name;
+	QString m_name { "invalid" };
 
-	ColorPixmapValue();
+	ColorPixmapValue() = default;
 	ColorPixmapValue(const ScColor& col, ScribusDoc* doc, const QString& colName);
 	ColorPixmapValue(const ColorPixmapValue& other);
 	ColorPixmapValue& operator= (const ColorPixmapValue& other);
@@ -95,13 +95,13 @@
 
 protected:
 	//! If None color is shown as first item in the list
-	bool m_isNoneColorShown;
+	bool m_isNoneColorShown { false };
 
 	//! The color list
 	QVector<ColorPixmapValue> m_colors;
 
 	// SortRule m_sortRule
-	SortRule m_sortRule;
+	SortRule m_sortRule { SortByName };
 
 	static bool compareColorNames(const ColorPixmapValue& v1, const ColorPixmapValue& v2);
 	static bool compareColorValues(const ColorPixmapValue& v1, const ColorPixmapValue& v2);

Modified: trunk/Scribus/scribus/ui/colorsandfills.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24736&path=/trunk/Scribus/scribus/ui/colorsandfills.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/colorsandfills.cpp	(original)
+++ trunk/Scribus/scribus/ui/colorsandfills.cpp	Tue Oct  5 21:16:29 2021
@@ -24,6 +24,8 @@
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.             *
 ***************************************************************************/
 
+#include <memory>
+
 #include <QCheckBox>
 #include <QCursor>
 #include <QDir>
@@ -33,6 +35,7 @@
 #include <QImageReader>
 #include <QMenu>
 #include <QMessageBox>
+#include <QScopedPointer>
 
 #include "cmykfw.h"
 #include "colorlistbox.h"
@@ -65,17 +68,16 @@
 #include "util_color.h"
 #include "util_formats.h"
 
-
-ColorsAndFillsDialog::ColorsAndFillsDialog(QWidget* parent, QHash<QString, VGradient> *docGradients, const ColorList& doco, const QString& docColSet, QHash<QString, ScPattern> *docPatterns, ScribusDoc *doc, ScribusMainWindow *scMW) : QDialog(parent)
+ColorsAndFillsDialog::ColorsAndFillsDialog(QWidget* parent, QHash<QString, VGradient> *docGradients, const ColorList& doco, const QString& docColSet, QHash<QString, ScPattern> *docPatterns, ScribusDoc *doc, ScribusMainWindow *scMW)
+	                : QDialog(parent),
+	                  m_doc(doc),
+	                  mainWin(scMW)
 {
 	setupUi(this);
 	setModal(true);
-	paletteLocked = false;
-	modified = false;
-	sortRule = 0;
-	m_doc = doc;
+
 	m_colorList = doco;
-	mainWin = scMW;
+
 	setWindowIcon(IconManager::instance().loadIcon("AppIcon.png"));
 	dataTree->setContextMenuPolicy(Qt::CustomContextMenu);
 	dataTree->setIconSize(QSize(60, 48));
@@ -229,6 +231,7 @@
 		pb.begin(&pixm);
 		pb.fillRect(0, 0, 48, 12, b);
 		pb.end();
+
 		ScPainter *p = new ScPainter(&pixm, 48, 12);
 		p->setPen(Qt::black, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
 		p->setFillMode(ScPainter::Gradient);
@@ -237,8 +240,8 @@
 		p->drawRect(0, 0, 48, 12);
 		p->end();
 		delete p;
-		QPixmap pm;
-		pm = QPixmap::fromImage(pixm);
+
+		QPixmap pm = QPixmap::fromImage(pixm);
 		QTreeWidgetItem *item = new QTreeWidgetItem(gradientItems);
 		item->setText(0, patK[a]);
 		if (patK[a] == addedName)
@@ -252,10 +255,9 @@
 QTreeWidgetItem* ColorsAndFillsDialog::updateColorList(const QString& addedName)
 {
 	QList<QTreeWidgetItem*> lg = colorItems->takeChildren();
-	for (int a = 0; a < lg.count(); a++)
-	{
-		delete lg[a];
-	}
+	for (int i = 0; i < lg.count(); i++)
+		delete lg[i];
+
 	QTreeWidgetItem* ret = nullptr;
 	if (sortRule > 0)
 	{
@@ -329,26 +331,26 @@
 		pmen->addAction( tr("Sort by Color"));
 		pmen->addAction( tr("Sort by Type"));
 		sortRule = pmen->actions().indexOf(pmen->exec(QCursor::pos()));
-		delete pmen;
+		pmen->deleteLater();
 		updateColorList();
 	}
 }
 
 void ColorsAndFillsDialog::selEditColor(QTreeWidgetItem *it)
 {
-	if ((it) && (!paletteLocked))
-	{
-		if ((it->parent() == colorItems) || (it->parent() == gradientItems))
-		{
-			QString curCol = it->text(0);
-			bool enableDel  = (!isMandatoryColor(curCol)) && (m_colorList.count() > 1);
-			bool enableEdit = (!isMandatoryColor(curCol));
-			duplicateButton->setEnabled(curCol != "Registration");
-			deleteButton->setEnabled(enableDel);
-			editButton->setEnabled(enableEdit);
-			if (enableEdit)
-				editColorItem();
-		}
+	if (!it || paletteLocked)
+		return;
+
+	if ((it->parent() == colorItems) || (it->parent() == gradientItems))
+	{
+		QString curCol = it->text(0);
+		bool enableDel  = (!isMandatoryColor(curCol)) && (m_colorList.count() > 1);
+		bool enableEdit = (!isMandatoryColor(curCol));
+		duplicateButton->setEnabled(curCol != "Registration");
+		deleteButton->setEnabled(enableDel);
+		editButton->setEnabled(enableEdit);
+		if (enableEdit)
+			editColorItem();
 	}
 }
 
@@ -365,7 +367,7 @@
 	importButton->setText( tr("&Import"));
 	newButton->setText( tr("Add"));
 	editButton->setText( tr("&Edit"));
-	if ((it) && (!paletteLocked))
+	if (it && !paletteLocked)
 	{
 		if ((it->parent() == colorItems) || (it->parent() == gradientItems))
 		{
@@ -448,43 +450,41 @@
 
 	if ((it->parent() == gradientItems) || (it == gradientItems))
 	{
-		VGradient fill_gradient = VGradient(VGradient::linear);
+		VGradient fill_gradient(VGradient::linear);
 		fill_gradient.clearStops();
 		fill_gradient.addStop(QColor(Qt::black), 0.0, 0.5, 1.0, "Black", 100);
 		fill_gradient.addStop(QColor(Qt::white), 1.0, 0.5, 1.0, "White", 100);
-		gradientEditDialog *dia = new gradientEditDialog(this, tr("New Gradient"), fill_gradient, m_colorList, m_doc, &dialogGradients, true);
-		if (dia->exec())
-		{
-			dialogGradients.insert(dia->name(), dia->gradient());
-			QTreeWidgetItem *lg = updateGradientList(dia->name());
-			if (lg != nullptr)
-			{
-				dataTree->expandItem(lg->parent());
-				dataTree->setCurrentItem(lg, 0, QItemSelectionModel::ClearAndSelect);
-			}
-			itemSelected(dataTree->currentItem());
-			modified = true;
-		}
-		delete dia;
+		QScopedPointer<gradientEditDialog> dia(new gradientEditDialog(this, tr("New Gradient"), fill_gradient, m_colorList, m_doc, &dialogGradients, true));
+		if (!dia->exec())
+			return;
+
+		dialogGradients.insert(dia->name(), dia->gradient());
+		QTreeWidgetItem *lg = updateGradientList(dia->name());
+		if (lg != nullptr)
+		{
+			dataTree->expandItem(lg->parent());
+			dataTree->setCurrentItem(lg, 0, QItemSelectionModel::ClearAndSelect);
+		}
+		itemSelected(dataTree->currentItem());
+		modified = true;
 	}
 	else if ((it->parent() == colorItems) || (it == colorItems))
 	{
-		ScColor tmpColor = ScColor(0, 0, 0, 0);
-		CMYKChoose* dia = new CMYKChoose(this, m_doc, tmpColor, tr("New Color"), &m_colorList, true);
-		if (dia->exec())
-		{
-			dia->Farbe.setSpotColor(dia->isSpotColor());
-			m_colorList.insert(dia->colorName(), dia->Farbe);
-			QTreeWidgetItem *lg = updateColorList(dia->colorName());
-			if (lg != nullptr)
-			{
-				dataTree->expandItem(lg->parent());
-				dataTree->setCurrentItem(lg, 0, QItemSelectionModel::ClearAndSelect);
-			}
-			itemSelected(dataTree->currentItem());
-			modified = true;
-		}
-		delete dia;
+		ScColor tmpColor(0, 0, 0, 0);
+		QScopedPointer<CMYKChoose> dia(new CMYKChoose(this, m_doc, tmpColor, tr("New Color"), &m_colorList, true));
+		if (!dia->exec())
+			return;
+
+		dia->Farbe.setSpotColor(dia->isSpotColor());
+		m_colorList.insert(dia->colorName(), dia->Farbe);
+		QTreeWidgetItem *lg = updateColorList(dia->colorName());
+		if (lg != nullptr)
+		{
+			dataTree->expandItem(lg->parent());
+			dataTree->setCurrentItem(lg, 0, QItemSelectionModel::ClearAndSelect);
+		}
+		itemSelected(dataTree->currentItem());
+		modified = true;
 	}
 	else if ((it->parent() == patternItems) || (it == patternItems))
 	{
@@ -500,7 +500,7 @@
 {
 	if (paletteLocked)
 		return;
-	QTreeWidgetItem* it = dataTree->currentItem();
+	const QTreeWidgetItem* it = dataTree->currentItem();
 	if (!it)
 		return;
 
@@ -508,76 +508,73 @@
 	{
 		QString gradN = it->text(0);
 		QString patternName = origNames[it->text(0)];
-		QString newName;
-		gradientEditDialog *dia = new gradientEditDialog(this, gradN, dialogGradients[gradN], m_colorList, m_doc, &dialogGradients, false);
-		if (dia->exec())
-		{
-			newName = dia->name();
-			if (newName != gradN)
-			{
-				origNames.remove(patternName);
-				origNames.insert(newName, patternName);
-				replaceMap.insert(patternName, newName);
-				dialogGradients.remove(gradN);
-				dialogGradients.insert(newName, dia->gradient());
-			}
-			else
-				dialogGradients[gradN] = dia->gradient();
-			QStringList patterns = dialogPatterns.keys();
-			for (int c = 0; c < dialogPatterns.count(); ++c)
-			{
-				ScPattern pa = dialogPatterns[patterns[c]];
-				for (int o = 0; o < pa.items.count(); o++)
-				{
-					PageItem *ite = pa.items.at(o);
-					if (ite->gradient() == gradN)
-						ite->setGradient(newName);
-					if (ite->strokeGradient() == gradN)
-						ite->setStrokeGradient(newName);
-					if (ite->gradientMask() == gradN)
-						ite->setGradientMask(newName);
-				}
-				PageItem *ite = pa.items.at(0);
-				dialogPatterns[patterns[c]].pattern = ite->DrawObj_toImage(pa.items, 1.0);
-			}
-			QTreeWidgetItem *lg = updateGradientList(dia->name());
-			if (lg != nullptr)
-			{
-				dataTree->expandItem(lg->parent());
-				dataTree->setCurrentItem(lg, 0, QItemSelectionModel::ClearAndSelect);
-			}
-			itemSelected(dataTree->currentItem());
-			modified = true;
-		}
-		delete dia;
+		QScopedPointer<gradientEditDialog> dia(new gradientEditDialog(this, gradN, dialogGradients[gradN], m_colorList, m_doc, &dialogGradients, false));
+		if (!dia->exec())
+			return;
+
+		QString newName = dia->name();
+		if (newName != gradN)
+		{
+			origNames.remove(patternName);
+			origNames.insert(newName, patternName);
+			replaceMap.insert(patternName, newName);
+			dialogGradients.remove(gradN);
+			dialogGradients.insert(newName, dia->gradient());
+		}
+		else
+			dialogGradients[gradN] = dia->gradient();
+		QStringList patterns = dialogPatterns.keys();
+		for (int c = 0; c < dialogPatterns.count(); ++c)
+		{
+			ScPattern pa = dialogPatterns[patterns[c]];
+			for (int o = 0; o < pa.items.count(); o++)
+			{
+				PageItem *ite = pa.items.at(o);
+				if (ite->gradient() == gradN)
+					ite->setGradient(newName);
+				if (ite->strokeGradient() == gradN)
+					ite->setStrokeGradient(newName);
+				if (ite->gradientMask() == gradN)
+					ite->setGradientMask(newName);
+			}
+			PageItem *ite = pa.items.at(0);
+			dialogPatterns[patterns[c]].pattern = ite->DrawObj_toImage(pa.items, 1.0);
+		}
+		QTreeWidgetItem *lg = updateGradientList(dia->name());
+		if (lg != nullptr)
+		{
+			dataTree->expandItem(lg->parent());
+			dataTree->setCurrentItem(lg, 0, QItemSelectionModel::ClearAndSelect);
+		}
+		itemSelected(dataTree->currentItem());
+		modified = true;
 	}
 	else if (it->parent() == colorItems)
 	{
 		ScColor tmpColor = m_colorList[it->text(0)];
-		CMYKChoose* dia = new CMYKChoose(this, m_doc, tmpColor, it->text(0), &m_colorList, false);
-		if (dia->exec())
-		{
-			dia->Farbe.setSpotColor(dia->isSpotColor());
-			dia->Farbe.setRegistrationColor(tmpColor.isRegistrationColor());
-			m_colorList[dia->colorName()] = dia->Farbe;
-			if (it->text(0) != dia->colorName())
-			{
-				replaceColorMap.insert(it->text(0), dia->colorName());
-				m_colorList.remove(it->text(0));
-			}
-			updateGradientColors(dia->colorName(), it->text(0));
-			updateGradientList();
-			updatePatternList();
-			QTreeWidgetItem *lg = updateColorList(dia->colorName());
-			if (lg != nullptr)
-			{
-				dataTree->expandItem(lg->parent());
-				dataTree->setCurrentItem(lg, 0, QItemSelectionModel::ClearAndSelect);
-			}
-			itemSelected(dataTree->currentItem());
-			modified = true;
-		}
-		delete dia;
+		QScopedPointer<CMYKChoose> dia(new CMYKChoose(this, m_doc, tmpColor, it->text(0), &m_colorList, false));
+		if (!dia->exec())
+			return;
+
+		dia->Farbe.setSpotColor(dia->isSpotColor());
+		dia->Farbe.setRegistrationColor(tmpColor.isRegistrationColor());
+		m_colorList[dia->colorName()] = dia->Farbe;
+		if (it->text(0) != dia->colorName())
+		{
+			replaceColorMap.insert(it->text(0), dia->colorName());
+			m_colorList.remove(it->text(0));
+		}
+		updateGradientColors(dia->colorName(), it->text(0));
+		updateGradientList();
+		updatePatternList();
+		QTreeWidgetItem *lg = updateColorList(dia->colorName());
+		if (lg != nullptr)
+		{
+			dataTree->expandItem(lg->parent());
+			dataTree->setCurrentItem(lg, 0, QItemSelectionModel::ClearAndSelect);
+		}
+		itemSelected(dataTree->currentItem());
+		modified = true;
 	}
 	else if (it->parent() == patternItems)
 	{
@@ -586,45 +583,43 @@
 		Query dia(this, "tt", true, tr("&Name:"), tr("Rename Entry"));
 		dia.setEditText(it->text(0), true);
 		dia.setTestList(dialogPatterns.keys());
-		if (dia.exec())
-		{
-			newName = dia.getEditText();
-			ScPattern pat = dialogPatterns.take(it->text(0));
-			dialogPatterns.insert(newName, pat);
-			replaceMapPatterns.insert(patternName, newName);
-			origNamesPatterns.remove(it->text(0));
-			origNamesPatterns.insert(newName, patternName);
-			QStringList patterns = dialogPatterns.keys();
-			for (int c = 0; c < dialogPatterns.count(); ++c)
-			{
-				ScPattern pa = dialogPatterns[patterns[c]];
-				for (int o = 0; o < pa.items.count(); o++)
-				{
-					PageItem *ite = pa.items.at(o);
-					if ((ite->pattern() == patternName) && ((ite->GrType == 8) || (ite->itemType() == PageItem::Symbol)))
-						ite->setPattern(newName);
-					if (!ite->strokePattern().isEmpty())
-					{
-						if (ite->strokePattern() == patternName)
-							ite->setStrokePattern(newName);
-					}
-					if (!ite->patternMask().isEmpty())
-					{
-						if (ite->patternMask() == patternName)
-							ite->setPatternMask(newName);
-					}
-				}
-			}
-			QTreeWidgetItem *lg = updatePatternList(newName);
-			if (lg != nullptr)
-			{
-				dataTree->expandItem(lg->parent());
-				dataTree->setCurrentItem(lg, 0, QItemSelectionModel::ClearAndSelect);
-			}
-			itemSelected(dataTree->currentItem());
-		}
-		else
+		if (!dia.exec())
 			return;
+
+		newName = dia.getEditText();
+		ScPattern pat = dialogPatterns.take(it->text(0));
+		dialogPatterns.insert(newName, pat);
+		replaceMapPatterns.insert(patternName, newName);
+		origNamesPatterns.remove(it->text(0));
+		origNamesPatterns.insert(newName, patternName);
+		QStringList patterns = dialogPatterns.keys();
+		for (int c = 0; c < dialogPatterns.count(); ++c)
+		{
+			ScPattern pa = dialogPatterns[patterns[c]];
+			for (int o = 0; o < pa.items.count(); o++)
+			{
+				PageItem *ite = pa.items.at(o);
+				if ((ite->pattern() == patternName) && ((ite->GrType == 8) || (ite->itemType() == PageItem::Symbol)))
+					ite->setPattern(newName);
+				if (!ite->strokePattern().isEmpty())
+				{
+					if (ite->strokePattern() == patternName)
+						ite->setStrokePattern(newName);
+				}
+				if (!ite->patternMask().isEmpty())
+				{
+					if (ite->patternMask() == patternName)
+						ite->setPatternMask(newName);
+				}
+			}
+		}
+		QTreeWidgetItem *lg = updatePatternList(newName);
+		if (lg != nullptr)
+		{
+			dataTree->expandItem(lg->parent());
+			dataTree->setCurrentItem(lg, 0, QItemSelectionModel::ClearAndSelect);
+		}
+		itemSelected(dataTree->currentItem());
 	}
 }
 
@@ -632,7 +627,7 @@
 {
 	if (paletteLocked)
 		return;
-	QTreeWidgetItem* it = dataTree->currentItem();
+	const QTreeWidgetItem* it = dataTree->currentItem();
 	if (!it)
 		return;
 
@@ -642,69 +637,67 @@
 		dialogGradients.insert(gradN, dialogGradients[it->text(0)]);
 		origNames.insert(gradN, gradN);
 		QString patternName = origNames[gradN];
-		QString newName;
-		gradientEditDialog *dia = new gradientEditDialog(this, gradN, dialogGradients[gradN], m_colorList, m_doc, &dialogGradients, false);
-		if (dia->exec())
-		{
-			newName = dia->name();
-			if (newName != gradN)
-			{
-				origNames.remove(patternName);
-				origNames.insert(newName, patternName);
-				replaceMap.insert(patternName, newName);
-				dialogGradients.remove(gradN);
-				dialogGradients.insert(newName, dia->gradient());
-			}
-			else
-				dialogGradients[gradN] = dia->gradient();
-			updatePatternList();
-			QTreeWidgetItem *lg = updateGradientList(dia->name());
-			if (lg != nullptr)
-			{
-				dataTree->expandItem(lg->parent());
-				dataTree->setCurrentItem(lg, 0, QItemSelectionModel::ClearAndSelect);
-			}
-			itemSelected(dataTree->currentItem());
-			modified = true;
-		}
-		else
+		QScopedPointer<gradientEditDialog> dia(new gradientEditDialog(this, gradN, dialogGradients[gradN], m_colorList, m_doc, &dialogGradients, false));
+		if (!dia->exec())
 		{
 			dialogGradients.remove(gradN);
 			origNames.remove(gradN);
-		}
-		delete dia;
+			return;
+		}
+
+		QString newName = dia->name();
+		if (newName != gradN)
+		{
+			origNames.remove(patternName);
+			origNames.insert(newName, patternName);
+			replaceMap.insert(patternName, newName);
+			dialogGradients.remove(gradN);
+			dialogGradients.insert(newName, dia->gradient());
+		}
+		else
+			dialogGradients[gradN] = dia->gradient();
+		updatePatternList();
+		QTreeWidgetItem *lg = updateGradientList(dia->name());
+		if (lg != nullptr)
+		{
+			dataTree->expandItem(lg->parent());
+			dataTree->setCurrentItem(lg, 0, QItemSelectionModel::ClearAndSelect);
+		}
+		itemSelected(dataTree->currentItem());
+		modified = true;
 	}
 	else if (it->parent() == colorItems)
 	{
 		QString nam = tr("Copy of %1").arg(it->text(0));
 		m_colorList.insert(nam, m_colorList[it->text(0)]);
 		ScColor tmpColor = m_colorList[nam];
-		CMYKChoose* dia = new CMYKChoose(this, m_doc, tmpColor, nam, &m_colorList, false);
-		if (dia->exec())
-		{
-			dia->Farbe.setSpotColor(dia->isSpotColor());
-			dia->Farbe.setRegistrationColor(tmpColor.isRegistrationColor());
-			m_colorList[dia->colorName()] = dia->Farbe;
-			if (nam != dia->colorName())
-			{
-				replaceColorMap.insert(nam, dia->colorName());
-				m_colorList.remove(nam);
-			}
-			updateGradientColors(dia->colorName(), nam);
-			updateGradientList();
-			updatePatternList();
-			QTreeWidgetItem *lg = updateColorList(dia->colorName());
-			if (lg != nullptr)
-			{
-				dataTree->expandItem(lg->parent());
-				dataTree->setCurrentItem(lg, 0, QItemSelectionModel::ClearAndSelect);
-			}
-			itemSelected(dataTree->currentItem());
-			modified = true;
-		}
-		else
+
+		QScopedPointer<CMYKChoose> dia(new CMYKChoose(this, m_doc, tmpColor, nam, &m_colorList, false));
+		if (!dia->exec())
+		{
 			m_colorList.remove(nam);
-		delete dia;
+			return;
+		}
+
+		dia->Farbe.setSpotColor(dia->isSpotColor());
+		dia->Farbe.setRegistrationColor(tmpColor.isRegistrationColor());
+		m_colorList[dia->colorName()] = dia->Farbe;
+		if (nam != dia->colorName())
+		{
+			replaceColorMap.insert(nam, dia->colorName());
+			m_colorList.remove(nam);
+		}
+		updateGradientColors(dia->colorName(), nam);
+		updateGradientList();
+		updatePatternList();
+		QTreeWidgetItem *lg = updateColorList(dia->colorName());
+		if (lg != nullptr)
+		{
+			dataTree->expandItem(lg->parent());
+			dataTree->setCurrentItem(lg, 0, QItemSelectionModel::ClearAndSelect);
+		}
+		itemSelected(dataTree->currentItem());
+		modified = true;
 	}
 }
 
@@ -862,7 +855,7 @@
 				ColorList UsedCG = getGradientColors();
 				if (inDocUsedColors.contains(dColor) || UsedCG.contains(dColor))
 				{
-					DelColor *dia = new DelColor(this, m_colorList, dColor, true);
+					QScopedPointer<DelColor> dia(new DelColor(this, m_colorList, dColor, true));
 					if (dia->exec())
 					{
 						QString replacementColor(dia->getReplacementColor());
@@ -881,7 +874,6 @@
 						m_colorList.remove(dColor);
 						updateGradientColors(replacementColor, dColor);
 					}
-					delete dia;
 				}
 				else
 				{
@@ -937,11 +929,11 @@
 	}
 }
 
-QStringList ColorsAndFillsDialog::getUsedPatternsHelper(const QString& pattern, QStringList &results)
-{
-	ScPattern *pat = &dialogPatterns[pattern];
+QStringList ColorsAndFillsDialog::getUsedPatternsHelper(const QString& pattern, QStringList &results) const
+{
+	const ScPattern *pat = &dialogPatterns[pattern];
 	QStringList pats;
-	pats.clear();
+
 	for (int c = 0; c < pat->items.count(); ++c)
 	{
 		if ((pat->items.at(c)->GrType == Gradient_Pattern) || (pat->items.at(c)->itemType() == PageItem::Symbol))
@@ -1018,13 +1010,12 @@
 
 void ColorsAndFillsDialog::importColorItems()
 {
-	QTreeWidgetItem* it = dataTree->currentItem();
+	const QTreeWidgetItem* it = dataTree->currentItem();
 	if (!it)
 		return;
 
 	if ((it->parent() == gradientItems) || (it == gradientItems))
 	{
-		QString fileName;
 		QString allFormats = tr("All Supported Formats")+" (";
 		allFormats += "*.sgr *.SGR";
 		allFormats += " *.ggr *.GGR";
@@ -1033,13 +1024,15 @@
 		formats += tr("Gimp Gradient Files \"*.ggr\" (*.ggr *.GGR);;");
 		formats += tr("All Files (*)");
 		allFormats += formats;
+
 		PrefsContext* dirs = PrefsManager::instance().prefsFile->getContext("dirs");
 		QString wdir = dirs->get("gradients", ".");
+
 		CustomFDialog dia(this, wdir, tr("Open"), allFormats, fdHidePreviewCheckBox | fdExistingFiles | fdDisableOk);
-		if (dia.exec() == QDialog::Accepted)
-			fileName = dia.selectedFile();
-		else
+		if (dia.exec() != QDialog::Accepted)
 			return;
+		
+		QString fileName = dia.selectedFile();
 		if (!fileName.isEmpty())
 		{
 			PrefsManager::instance().prefsFile->getContext("dirs")->set("gradients", fileName.left(fileName.lastIndexOf("/")));
@@ -1065,7 +1058,7 @@
 		allFormatsV.removeAll("ai");
 		QString extra = allFormatsV.join(" *.");
 		extra.prepend(" *.");
-		QString fileName;
+
 		PrefsContext* dirs = PrefsManager::instance().prefsFile->getContext("dirs");
 		QString wdir = dirs->get("colors", ".");
 		QString docexts("*.sla *.sla.gz *.scd *.scd.gz");
@@ -1073,11 +1066,12 @@
 		QString ooexts(" *.acb *.aco *.ase *.cxf *.gpl *.sbz *.skp *.soc *.xml");
 		ooexts += extra;
 		QString filter = tr("All Supported Formats (%1);;Documents (%2);;Other Files (%3);;All Files (*)").arg(docexts+" "+aiepsext+ooexts, docexts, aiepsext+ooexts);
+		
 		CustomFDialog dia(this, wdir, tr("Import Colors"), filter, fdHidePreviewCheckBox | fdDisableOk);
-		if (dia.exec() == QDialog::Accepted)
-			fileName = dia.selectedFile();
-		else
+		if (dia.exec() != QDialog::Accepted)
 			return;
+
+		QString fileName = dia.selectedFile();
 		if (!fileName.isEmpty())
 			dirs->set("colors", fileName.left(fileName.lastIndexOf("/")));
 		if (!importColorsFromFile(fileName, m_colorList))
@@ -1186,15 +1180,18 @@
 		imgFormats.append("ps");
 		formats.sort();
 		allFormats += formats.join(";;");
+
 		PrefsContext* dirs = PrefsManager::instance().prefsFile->getContext("dirs");
 		QString wdir = dirs->get("patterns", ".");
 		CustomFDialog dia(this, wdir, tr("Open"), allFormats, fdHidePreviewCheckBox | fdExistingFiles | fdDisableOk);
 		if (dia.exec() != QDialog::Accepted)
 			return;
+
 		fileName = dia.selectedFile();
 		if (fileName.isEmpty())
 			return;
-		qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
+
+		QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
 		PrefsManager::instance().prefsFile->getContext("dirs")->set("patterns", fileName.left(fileName.lastIndexOf("/")));
 		QFileInfo fi(fileName);
 		if ((fi.suffix().toLower() == "sce") || (!imgFormats.contains(fi.suffix().toLower())))
@@ -1204,7 +1201,7 @@
 		else
 		{
 			QString patNam = fi.baseName().trimmed().simplified().replace(" ", "_");
-			ScPattern pat = ScPattern();
+			ScPattern pat;
 			pat.setDoc(m_doc);
 			pat.setPattern(fileName);
 			if (!dialogPatterns.contains(patNam))
@@ -1217,7 +1214,7 @@
 		updateGradientList();
 		updatePatternList();
 		itemSelected(nullptr);
-		qApp->restoreOverrideCursor();
+		QGuiApplication::restoreOverrideCursor();
 	}
 }
 
@@ -1258,12 +1255,15 @@
 	mainWin->setStatusBarInfoText( tr("Loading Patterns"));
 	mainWin->mainWindowProgressBar->reset();
 	mainWin->mainWindowProgressBar->setMaximum(d.count() * 2);
-	qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
-	qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
+
+	QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+	QGuiApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
+
 	for (uint dc = 0; dc < d.count(); ++dc)
 	{
 		mainWin->mainWindowProgressBar->setValue(dc);
-		qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
+		QGuiApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
+
 		QFileInfo fi(QDir::cleanPath(QDir::toNativeSeparators(fileName + "/" + d[dc])));
 		QString ext = fi.suffix().toLower();
 		if ((ext == "sce") || (!formats.contains(ext)))
@@ -1272,7 +1272,7 @@
 	for (uint dc = 0; dc < d.count(); ++dc)
 	{
 		mainWin->mainWindowProgressBar->setValue(d.count() + dc);
-		qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
+		QGuiApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
 
 		QFileInfo fi(QDir::cleanPath(QDir::toNativeSeparators(fileName + "/" + d[dc])));
 		QString ext = fi.suffix().toLower();
@@ -1284,7 +1284,7 @@
 		QString patNam = fi.baseName().trimmed().simplified().replace(" ", "_");
 		if (!dialogPatterns.contains(patNam))
 		{
-			ScPattern pat = ScPattern();
+			ScPattern pat;
 			pat.setDoc(m_doc);
 			pat.setPattern(QDir::cleanPath(QDir::toNativeSeparators(fileName + "/" + d[dc])));
 			dialogPatterns.insert(patNam, pat);
@@ -1293,7 +1293,9 @@
 	}
 	d.cdUp();
 	dirs->set("patterndir", d.absolutePath());
-	qApp->restoreOverrideCursor();
+
+	QGuiApplication::restoreOverrideCursor();
+
 	mainWin->setStatusBarInfoText("");
 	mainWin->mainWindowProgressBar->reset();
 }
@@ -1355,7 +1357,7 @@
 			else
 				ite->layout();
 		}
-		ScPattern pat = ScPattern();
+		ScPattern pat;
 		pat.setDoc(m_doc);
 		PageItem* currItem = m_doc->Items->at(ac);
 		double minx =  std::numeric_limits<double>::max();
@@ -1422,7 +1424,7 @@
 	m_doc->view()->setContentsPos(static_cast<int>(storedContentsX * storedViewScale), static_cast<int>(storedContentsY * storedViewScale));
 }
 
-bool ColorsAndFillsDialog::isMandatoryColor(const QString& colorName)
+bool ColorsAndFillsDialog::isMandatoryColor(const QString& colorName) const
 {
 	if (colorName == "Black" || colorName == "White")
 		return true;
@@ -1430,7 +1432,7 @@
 	return color.isRegistrationColor();
 }
 
-QString ColorsAndFillsDialog::getColorTooltip(const ScColor& color)
+QString ColorsAndFillsDialog::getColorTooltip(const ScColor& color) const
 {
 	QString tooltip;
 	if (color.getColorModel() == colorModelRGB)
@@ -1454,11 +1456,10 @@
 	return tooltip;
 }
 
-ColorList ColorsAndFillsDialog::getGradientColors()
+ColorList ColorsAndFillsDialog::getGradientColors() const
 {
 	ColorList colorList;
-	QHash<QString,VGradient>::Iterator itg;
-	for (itg = dialogGradients.begin(); itg != dialogGradients.end(); ++itg)
+	for (auto itg = dialogGradients.begin(); itg != dialogGradients.end(); ++itg)
 	{
 		QList<VColorStop*> cstops = itg.value().colorStops();
 		for (int cst = 0; cst < itg.value().stops(); ++cst)
@@ -1635,7 +1636,7 @@
 		{
 			QString stopName = gradientName+QString("_Stop%1");
 			QString stopNameInUse;
-			VGradient gra = VGradient(VGradient::linear);
+			VGradient gra(VGradient::linear);
 			gra.clearStops();
 			QColor color;
 			tmp = ts.readLine();
@@ -1729,12 +1730,12 @@
 
 void ColorsAndFillsDialog::addGimpColor(QString &colorName, double r, double g, double b)
 {
-	ScColor lf = ScColor();
+	ScColor lf;
 	bool found = false;
-	int Rc, Gc, Bc, hR, hG, hB;
-	Rc = qRound(r * 255);
-	Gc = qRound(g * 255);
-	Bc = qRound(b * 255);
+	int hR, hG, hB;
+	int Rc = qRound(r * 255);
+	int Gc = qRound(g * 255);
+	int Bc = qRound(b * 255);
 	lf.setRgbColor(Rc, Gc, Bc);
 	for (ColorList::Iterator it = m_colorList.begin(); it != m_colorList.end(); ++it)
 	{
@@ -1781,7 +1782,7 @@
 		QDomElement dc = DOC.toElement();
 		if (dc.tagName()=="COLOR")
 		{
-			ScColor lf = ScColor();
+			ScColor lf;
 			if (dc.hasAttribute("SPACE"))
 			{
 				QString space = dc.attribute("SPACE");
@@ -1835,7 +1836,7 @@
 		}
 		if (dc.tagName() == "Gradient")
 		{
-			VGradient gra = VGradient(VGradient::linear);
+			VGradient gra(VGradient::linear);
 			gra.clearStops();
 			QDomNode grad = dc.firstChild();
 			while (!grad.isNull())
@@ -1884,7 +1885,7 @@
 	{
 		m_colorList.insert("White", ScColor(0, 0, 0, 0));
 		m_colorList.insert("Black", ScColor(0, 0, 0, 255));
-		ScColor cc = ScColor(255, 255, 255, 255);
+		ScColor cc(255, 255, 255, 255);
 		cc.setRegistrationColor(true);
 		m_colorList.insert("Registration", cc);
 		m_colorList.insert("Blue", ScColor(255, 255, 0, 0));
@@ -1915,7 +1916,7 @@
 		{
 			m_colorList.insert("White", ScColor(0, 0, 0, 0));
 			m_colorList.insert("Black", ScColor(0, 0, 0, 255));
-			ScColor cc = ScColor(255, 255, 255, 255);
+			ScColor cc(255, 255, 255, 255);
 			cc.setRegistrationColor(true);
 			m_colorList.insert("Registration", cc);
 			m_colorList.insert("Blue", ScColor(255, 255, 0, 0));
@@ -1934,9 +1935,10 @@
 
 void ColorsAndFillsDialog::saveDefaults()
 {
-	QTreeWidgetItem* item = LoadColSet->currentItem();
+	const QTreeWidgetItem* item = LoadColSet->currentItem();
 	QString NameK = item->data(0, Qt::UserRole).toString() + "/" + item->text(0);
 	QString Name = LoadColSet->text();
+
 	Query* dia = new Query(this, "Name", 1, tr("&Name:"), tr("Choose a Name"));
 	if ((customColSet.contains(NameK)) && (!paletteLocked))
 		dia->setEditText(Name, false);
@@ -1944,7 +1946,7 @@
 		dia->setEditText("", false);
 	if (dia->exec())
 		doSaveDefaults(dia->getEditText(), (dia->getEditText() != Name));
-	delete dia;
+	dia->deleteLater();
 }
 
 void ColorsAndFillsDialog::doSaveDefaults(const QString& name, bool changed)
@@ -1956,7 +1958,7 @@
 	const FileFormat *fmt = LoadSavePlugin::getFormatById(FORMATID_SLA150EXPORT);
 	if (fmt)
 	{
-		ScribusDoc *s_doc = new ScribusDoc();
+		std::unique_ptr<ScribusDoc> s_doc(new ScribusDoc());
 		s_doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
 		s_doc->setPage(100, 100, 0, 0, 0, 0, 0, 0, false, false);
 		s_doc->addPage(0);
@@ -1964,9 +1966,8 @@
 		s_doc->PageColors = m_colorList;
 		s_doc->setGradients(dialogGradients);
 		s_doc->setPatterns(dialogPatterns);
-		fmt->setupTargets(s_doc, nullptr, mainWin, nullptr, &(PrefsManager::instance().appPrefs.fontPrefs.AvailFonts));
+		fmt->setupTargets(s_doc.get(), nullptr, mainWin, nullptr, &(PrefsManager::instance().appPrefs.fontPrefs.AvailFonts));
 		fmt->savePalette(filename);
-		delete s_doc;
 	}
 	if (changed)
 	{
@@ -1986,7 +1987,7 @@
 QString ColorsAndFillsDialog::getColorSetName()
 {
 	QString NameK;
-	QTreeWidgetItem* item = LoadColSet->currentItem();
+	const QTreeWidgetItem* item = LoadColSet->currentItem();
 	if (item->text(0) == "Scribus Small")
 		NameK = "Scribus Small";
 	else
@@ -1994,25 +1995,19 @@
 	return NameK;
 }
 
-ScColor ColorsAndFillsDialog::selectedColor()
-{
-	QTreeWidgetItem* it = dataTree->currentItem();
-	if (it)
-	{
-		if (it->parent() == colorItems)
-			return m_colorList[it->text(0)];
-	}
+ScColor ColorsAndFillsDialog::selectedColor() const
+{
+	const QTreeWidgetItem* it = dataTree->currentItem();
+	if (it && (it->parent() == colorItems))
+		return m_colorList[it->text(0)];
 	return ScColor();
 }
 
-QString ColorsAndFillsDialog::selectedColorName()
-{
-	QTreeWidgetItem* it = dataTree->currentItem();
-	if (it)
-	{
-		if (it->parent() == colorItems)
-			return it->text(0);
-	}
+QString ColorsAndFillsDialog::selectedColorName() const
+{
+	const QTreeWidgetItem* it = dataTree->currentItem();
+	if (it && (it->parent() == colorItems))
+		return it->text(0);
 	return CommonStrings::None;
 }
 
@@ -2025,7 +2020,7 @@
 	QList<QTreeWidgetItem *> selItems = dataTree->selectedItems();
 	if (selItems.count() > 0)
 	{
-		QTreeWidgetItem* belowItem = dataTree->itemBelow(selItems.last());
+		const QTreeWidgetItem* belowItem = dataTree->itemBelow(selItems.last());
 		if (belowItem)
 			belowText = belowItem->text(0);
 	}

Modified: trunk/Scribus/scribus/ui/colorsandfills.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24736&path=/trunk/Scribus/scribus/ui/colorsandfills.h
==============================================================================
--- trunk/Scribus/scribus/ui/colorsandfills.h	(original)
+++ trunk/Scribus/scribus/ui/colorsandfills.h	Tue Oct  5 21:16:29 2021
@@ -42,17 +42,18 @@
 	public:
 		ColorsAndFillsDialog(QWidget* parent, QHash<QString, VGradient> *docGradients, const ColorList& doco, const QString& docColSet, QHash<QString, ScPattern> *docPatterns, ScribusDoc *doc, ScribusMainWindow* scMW);
 		~ColorsAndFillsDialog() {}
+
 		/*! \brief Returns the name of the current/selected color set.
 		\retval QString selected name. */
 		QString getColorSetName();
 		/*! \brief Returns currently selected ScColor.
 		It's used e.g. in BarcodeGenerator plugin.
 		*/
-		ScColor selectedColor();
+		ScColor selectedColor() const;
 		/*! \brief Returns name of the currently selected color.
 		It's used e.g. in BarcodeGenerator plugin.
 		*/
-		QString selectedColorName();
+		QString selectedColorName() const;
 
 		void keyPressEvent(QKeyEvent *k);
 
@@ -92,26 +93,27 @@
 		QTreeWidgetItem* updatePatternList(const QString& addedName = "");
 		QTreeWidgetItem* updateGradientList(const QString& addedName = "");
 		QTreeWidgetItem* updateColorList(const QString& addedName = "");
-		ColorList getGradientColors();
-		QString getColorTooltip(const ScColor& color);
-		bool isMandatoryColor(const QString& colorName);
+		ColorList getGradientColors() const;
+		QString getColorTooltip(const ScColor& color) const;
+		bool isMandatoryColor(const QString& colorName) const;
 		void loadPatternDir();
 		void loadVectors(const QString& data);
 		void updateGradientColors(const QString& newName, const QString& oldName);
 		void loadGimpFormat(const QString& fileName);
 		void addGimpColor(QString &colorName, double r, double g, double b);
 		void loadScribusFormat(const QString& fileName);
-		QStringList getUsedPatternsHelper(const QString& pattern, QStringList &results);
+		QStringList getUsedPatternsHelper(const QString& pattern, QStringList &results) const;
 		void doSaveDefaults(const QString& name, bool changed = false);
+
 		ColorSetManager csm;
-		bool paletteLocked;
-		bool modified;
-		int sortRule;
-		QTreeWidgetItem *colorItems;
-		QTreeWidgetItem *gradientItems;
-		QTreeWidgetItem *patternItems;
-		QTreeWidgetItem *systemSwatches;
-		QTreeWidgetItem *userSwatches;
+		bool paletteLocked { false };
+		bool modified { false };
+		int sortRule { 0 };
+		QTreeWidgetItem* colorItems { nullptr };
+		QTreeWidgetItem *gradientItems { nullptr };
+		QTreeWidgetItem *patternItems { nullptr };
+		QTreeWidgetItem *systemSwatches { nullptr };
+		QTreeWidgetItem *userSwatches { nullptr };
 		ColorList inDocUsedColors;
 };
 

Modified: trunk/Scribus/scribus/ui/javadocs.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24736&path=/trunk/Scribus/scribus/ui/javadocs.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/javadocs.cpp	(original)
+++ trunk/Scribus/scribus/ui/javadocs.cpp	Tue Oct  5 21:16:29 2021
@@ -5,6 +5,8 @@
 for which a new license (GPL+exception) is in place.
 */
 #include "javadocs.h"
+
+#include <memory>
 
 #include <QHBoxLayout>
 #include <QVBoxLayout>
@@ -25,13 +27,15 @@
 #include "iconmanager.h"
 
 
-JavaDocs::JavaDocs(QWidget* parent, ScribusDoc *doc, ScribusView* vie) : QDialog( parent )
+JavaDocs::JavaDocs(QWidget* parent, ScribusDoc *doc, ScribusView* vie)
+	    : QDialog( parent ),
+	      m_Doc(doc),
+	      m_View(vie)
 {
 	setModal(true);
 	setWindowTitle( tr( "Edit JavaScripts" ) );
 	setWindowIcon(IconManager::instance().loadIcon("AppIcon.png"));
-	m_Doc = doc;
-	m_View = vie;
+
 	JavaDocsLayout = new QHBoxLayout(this);
 	JavaDocsLayout->setContentsMargins(9, 9, 9, 9);
 	JavaDocsLayout->setSpacing(6);
@@ -55,7 +59,7 @@
 
 	DeleteScript = new QPushButton( tr( "&Delete" ), this);
 	Layout1->addWidget( DeleteScript );
-	QSpacerItem* spacer = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding );
+	auto* spacer = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding );
 	Layout1->addItem( spacer );
 
 	ExitDia = new QPushButton( tr( "&Close" ), this);
@@ -78,40 +82,39 @@
 
 void JavaDocs::slotAdd()
 {
-	QString nam;
 	Query dia(this, "tt", true, tr("&New Script:"), tr("New Script"));
 	dia.setEditText( tr("New Script"), false );
 	dia.setTestList(m_Doc->JavaScripts.keys());
-	if (dia.exec())
-	{
-		nam = dia.getEditText();
-		nam.replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%\\.]"), "_" );
-		Editor* dia2 = new Editor(this, "", m_View);
-		dia2->EditTex->setText("function "+nam+"()\n{\n}");
-		if (dia2->exec())
-		{
-			m_Doc->JavaScripts[nam] = dia2->EditTex->toPlainText();
-			Scripts->addItem(nam);
-			Scripts->setCurrentRow(Scripts->count() - 1);
-			emit docChanged(false);
-		}
-		delete dia2;
-	}
+	if (!dia.exec())
+		return;
+
+	QString nam = dia.getEditText();
+	nam.replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%\\.]"), "_" );
+
+	std::unique_ptr<Editor> dia2(new Editor(this, "", m_View));
+	dia2->EditTex->setText("function "+nam+"()\n{\n}");
+	if (!dia2->exec())
+		return;
+
+	m_Doc->JavaScripts[nam] = dia2->EditTex->toPlainText();
+	Scripts->addItem(nam);
+	Scripts->setCurrentRow(Scripts->count() - 1);
+	emit docChanged(false);
 }
 
 void JavaDocs::slotEdit()
 {
-	QListWidgetItem* currentItem = Scripts->currentItem();
+	const QListWidgetItem* currentItem = Scripts->currentItem();
 	if (!currentItem)
 		return;
+
 	QString name = currentItem->text();
-	Editor* dia2 = new Editor(this, m_Doc->JavaScripts[name], m_View);
-	if (dia2->exec())
-	{
-		m_Doc->JavaScripts[name] = dia2->EditTex->toPlainText();
-		emit docChanged(false);
-	}
-	delete dia2;
+	std::unique_ptr<Editor> dia2(new Editor(this, m_Doc->JavaScripts[name], m_View));
+	if (!dia2->exec())
+		return;
+
+	m_Doc->JavaScripts[name] = dia2->EditTex->toPlainText();
+	emit docChanged(false);
 }
 
 void JavaDocs::slotDelete()

Modified: trunk/Scribus/scribus/ui/javadocs.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24736&path=/trunk/Scribus/scribus/ui/javadocs.h
==============================================================================
--- trunk/Scribus/scribus/ui/javadocs.h	(original)
+++ trunk/Scribus/scribus/ui/javadocs.h	Tue Oct  5 21:16:29 2021
@@ -25,11 +25,11 @@
 	JavaDocs( QWidget* parent, ScribusDoc *doc, ScribusView* vie);
 	~JavaDocs() {};
 
-	QListWidget* Scripts;
-	QPushButton* EditScript;
-	QPushButton* AddScript;
-	QPushButton* DeleteScript;
-	QPushButton* ExitDia;
+	QListWidget* Scripts { nullptr };
+	QPushButton* EditScript { nullptr };
+	QPushButton* AddScript { nullptr };
+	QPushButton* DeleteScript { nullptr };
+	QPushButton* ExitDia { nullptr };
 
 private slots:
 	void slotAdd();
@@ -41,11 +41,11 @@
 	void docChanged(bool);
 
 protected:
-	ScribusDoc  *m_Doc;
-	ScribusView *m_View;
+	ScribusDoc  *m_Doc { nullptr };
+	ScribusView *m_View { nullptr };
 
-	QHBoxLayout* JavaDocsLayout;
-	QVBoxLayout* Layout1;
+	QHBoxLayout* JavaDocsLayout { nullptr };
+	QVBoxLayout* Layout1 { nullptr };
 };
 
 #endif // JAVADOCS_H

Modified: trunk/Scribus/scribus/ui/replacecolors.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24736&path=/trunk/Scribus/scribus/ui/replacecolors.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/replacecolors.cpp	(original)
+++ trunk/Scribus/scribus/ui/replacecolors.cpp	Tue Oct  5 21:16:29 2021
@@ -24,6 +24,8 @@
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.             *
 ***************************************************************************/
 
+#include <memory>
+
 #include "replacecolors.h"
 #include "replaceonecolor.h"
 #include "commonstrings.h"
@@ -39,7 +41,6 @@
 	setWindowIcon(IconManager::instance().loadPixmap("AppIcon.png"));
 	EditColors = colorList;
 	UsedColors = colorListUsed;
-	selectedRow = -1;
 	replaceMap.clear();
 	alertIcon = IconManager::instance().loadPixmap("alert.png", true);
 	cmykIcon = IconManager::instance().loadPixmap("cmyk.png", true);
@@ -66,19 +67,18 @@
 
 void replaceColorsDialog::addColor()
 {
-	replaceColorDialog *dia = new replaceColorDialog(this, EditColors, UsedColors);
-	if (dia->exec())
-	{
-		QString orig = dia->getOriginalColor();
-		if (orig == CommonStrings::tr_NoneColor)
-			orig = CommonStrings::None;
-		QString repl = dia->getReplacementColor();
-		if (repl == CommonStrings::tr_NoneColor)
-			repl = CommonStrings::None;
-		replaceMap.insert(orig, repl);
-		updateReplacementTable();
-	}
-	delete dia;
+	std::unique_ptr<replaceColorDialog> dia(new replaceColorDialog(this, EditColors, UsedColors));
+	if (!dia->exec())
+		return;
+
+	QString orig = dia->getOriginalColor();
+	if (orig == CommonStrings::tr_NoneColor)
+		orig = CommonStrings::None;
+	QString repl = dia->getReplacementColor();
+	if (repl == CommonStrings::tr_NoneColor)
+		repl = CommonStrings::None;
+	replaceMap.insert(orig, repl);
+	updateReplacementTable();
 }
 
 void replaceColorsDialog::selReplacement(int sel)
@@ -102,25 +102,24 @@
 
 void replaceColorsDialog::editReplacement()
 {
-	if (selectedRow > -1)
-	{
-		replaceColorDialog *dia = new replaceColorDialog(this, EditColors, UsedColors);
-		dia->setReplacementColor(replacementTable->item(selectedRow, 1)->text());
-		dia->setOriginalColor(replacementTable->item(selectedRow, 0)->text());
-		if (dia->exec())
-		{
-			replaceMap.remove(replacementTable->item(selectedRow, 0)->text());
-			QString orig = dia->getOriginalColor();
-			if (orig == CommonStrings::tr_NoneColor)
-				orig = CommonStrings::None;
-			QString repl = dia->getReplacementColor();
-			if (repl == CommonStrings::tr_NoneColor)
-				repl = CommonStrings::None;
-			replaceMap.insert(orig, repl);
-			updateReplacementTable();
-		}
-		delete dia;
-	}
+	if (selectedRow < 0)
+		return;
+
+	std::unique_ptr<replaceColorDialog> dia(new replaceColorDialog(this, EditColors, UsedColors));
+	dia->setReplacementColor(replacementTable->item(selectedRow, 1)->text());
+	dia->setOriginalColor(replacementTable->item(selectedRow, 0)->text());
+	if (!dia->exec())
+		return;
+
+	replaceMap.remove(replacementTable->item(selectedRow, 0)->text());
+	QString orig = dia->getOriginalColor();
+	if (orig == CommonStrings::tr_NoneColor)
+		orig = CommonStrings::None;
+	QString repl = dia->getReplacementColor();
+	if (repl == CommonStrings::tr_NoneColor)
+		repl = CommonStrings::None;
+	replaceMap.insert(orig, repl);
+	updateReplacementTable();
 }
 
 void replaceColorsDialog::updateReplacementTable()
@@ -156,7 +155,7 @@
 	}
 }
 
-QPixmap replaceColorsDialog::getColorIcon(const QString& color)
+QPixmap replaceColorsDialog::getColorIcon(const QString& color) const
 {
 	QPixmap smallPix(15, 15);
 	QPixmap pPixmap(60,15);

Modified: trunk/Scribus/scribus/ui/replacecolors.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24736&path=/trunk/Scribus/scribus/ui/replacecolors.h
==============================================================================
--- trunk/Scribus/scribus/ui/replacecolors.h	(original)
+++ trunk/Scribus/scribus/ui/replacecolors.h	Tue Oct  5 21:16:29 2021
@@ -52,8 +52,9 @@
 
 private:
 	void updateReplacementTable();
-	QPixmap getColorIcon(const QString& color);
-	int selectedRow;
+	QPixmap getColorIcon(const QString& color) const;
+
+	int selectedRow { -1 };
 	QPixmap alertIcon;
 	QPixmap cmykIcon;
 	QPixmap rgbIcon;




More information about the scribus-commit mailing list