r24752 by jghali - Code cleanup

scribus-commit scribus-commit at lists.scribus.net
Mon Oct 25 19:43:18 UTC 2021


Author: jghali
Date: Mon Oct 25 19:43:18 2021
New Revision: 24752

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

Modified:
    trunk/Scribus/scribus/rawimage.cpp
    trunk/Scribus/scribus/rawimage.h
    trunk/Scribus/scribus/scimagestructs.cpp
    trunk/Scribus/scribus/scimagestructs.h
    trunk/Scribus/scribus/scraction.cpp
    trunk/Scribus/scribus/scraction.h
    trunk/Scribus/scribus/scribusdoc.h

Modified: trunk/Scribus/scribus/rawimage.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24752&path=/trunk/Scribus/scribus/rawimage.cpp
==============================================================================
--- trunk/Scribus/scribus/rawimage.cpp	(original)
+++ trunk/Scribus/scribus/rawimage.cpp	Mon Oct 25 19:43:18 2021
@@ -5,10 +5,6 @@
 for which a new license (GPL+exception) is in place.
 */
 #include "rawimage.h"
-
-RawImage::RawImage()
-{
-}
 
 RawImage::RawImage( int width, int height, int channels )
 {
@@ -25,9 +21,9 @@
 	m_width = width;
 	m_height = height;
 	m_channels = channels;
-	int finalSize=width * height * channels;
+	int finalSize = width * height * channels;
 	resize(finalSize);
-	return (size()==finalSize);
+	return (size() == finalSize);
 }
 
 uchar *RawImage::scanLine(int row)
@@ -60,52 +56,52 @@
 	{
 		for (int i = 0; i < height(); i++)
 		{
-			ptr = (QRgb *)img.scanLine(i);
+			ptr = (QRgb *) img.scanLine(i);
 			src = scanLine(i);
 			for (int j = 0; j < width(); j++)
 			{
-				*ptr++ = qRgba(src[0],src[1],src[2],src[3]);
+				*ptr++ = qRgba(src[0], src[1], src[2], src[3]);
 				src += chans;
 			}
 		}
+		return img;
 	}
-	else
+
+	for (int i = 0; i < height(); i++)
 	{
-		for (int i = 0; i < height(); i++)
+		ptr = (QRgb *) img.scanLine(i);
+		src = scanLine(i);
+		for (int j = 0; j < width(); j++)
 		{
-			ptr = (QRgb *)img.scanLine(i);
-			src = scanLine(i);
-			for (int j = 0; j < width(); j++)
+			if (chans > 1)
 			{
-				if (chans > 1)
+				if (cmyk)
 				{
-					if (cmyk)
+					ck = src[3];
+					cr = 255 - qMin(255, src[0] + ck);
+					cg = 255 - qMin(255, src[1] + ck);
+					cb = 255 - qMin(255, src[2] + ck);
+					if (chans > 4)
 					{
-						ck = src[3];
-						cr = 255 - qMin(255, src[0] + ck);
-						cg = 255 - qMin(255, src[1] + ck);
-						cb = 255 - qMin(255, src[2] + ck);
-						if (chans > 4)
-						{
-							ca = src[4];
-							*ptr++ = qRgba(cr,cg,cb,ca);
-						}
-						else
-							*ptr++ = qRgba(cr,cg,cb,255);
+						ca = src[4];
+						*ptr++ = qRgba(cr, cg, cb, ca);
 					}
 					else
-					{
-						if (chans > 3)
-							*ptr++ = qRgba(src[0],src[1],src[2],src[3]);
-						else
-							*ptr++ = qRgba(src[0],src[1],src[2],255);
-					}
+						*ptr++ = qRgba(cr, cg, cb, 255);
 				}
 				else
-					*ptr++ = qRgba(src[0],src[0],src[0],255);
-				src += chans;
+				{
+					if (chans > 3)
+						*ptr++ = qRgba(src[0], src[1], src[2], src[3]);
+					else
+						*ptr++ = qRgba(src[0], src[1], src[2], 255);
+				}
 			}
+			else
+				*ptr++ = qRgba(src[0], src[0], src[0], 255);
+			src += chans;
 		}
 	}
+
 	return img;
 }

Modified: trunk/Scribus/scribus/rawimage.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24752&path=/trunk/Scribus/scribus/rawimage.h
==============================================================================
--- trunk/Scribus/scribus/rawimage.h	(original)
+++ trunk/Scribus/scribus/rawimage.h	Mon Oct 25 19:43:18 2021
@@ -15,7 +15,7 @@
 class SCRIBUS_API RawImage : public QByteArray
 {
 	public:
-		RawImage();
+		RawImage() = default;
 		RawImage( int width, int height, int channels);
 		~RawImage();
 

Modified: trunk/Scribus/scribus/scimagestructs.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24752&path=/trunk/Scribus/scribus/scimagestructs.cpp
==============================================================================
--- trunk/Scribus/scribus/scimagestructs.cpp	(original)
+++ trunk/Scribus/scribus/scimagestructs.cpp	Mon Oct 25 19:43:18 2021
@@ -17,8 +17,6 @@
 namespace {
 	const QDataStream::Version dsVersion = QDataStream::Qt_4_0;
 }
-
-const qint32 ExifValues::dsVersion = 1;
 
 QDataStream & operator<< (QDataStream& stream, const ExifValues & exif)
 {
@@ -64,8 +62,6 @@
 	dateTime.resize(0);
 	thumbnail = QImage();
 }
-
-const qint32 ImageInfoRecord::iirVersion = 1;
 
 ImageInfoRecord::ImageInfoRecord()
 {

Modified: trunk/Scribus/scribus/scimagestructs.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24752&path=/trunk/Scribus/scribus/scimagestructs.h
==============================================================================
--- trunk/Scribus/scribus/scimagestructs.h	(original)
+++ trunk/Scribus/scribus/scimagestructs.h	Mon Oct 25 19:43:18 2021
@@ -124,14 +124,14 @@
 
 	// Remember to increment this version number and update
 	// the QDataStream operators if this class in changed.
-	static const qint32 dsVersion;
-
-	int width;
-	int height;
-	int   orientation;
-	float ExposureTime;
-	float ApertureFNumber;
-	int   ISOequivalent;
+	static constexpr qint32 dsVersion { 1 };
+
+	int width { 0 };
+	int height { 0 };
+	int   orientation { 1 };
+	float ExposureTime { 0.0f };
+	float ApertureFNumber { 0.0f };
+	int   ISOequivalent { 0 };
 	QString cameraName;
 	QString cameraVendor;
 	QString comment;
@@ -142,7 +142,7 @@
 	QImage thumbnail;
 };
 
-typedef enum
+enum ImageTypeEnum
 {
 	ImageTypeJPG = 0,
 	ImageTypeTIF = 1,
@@ -152,16 +152,16 @@
 	ImageTypeJPG2K = 5,
 	ImageTypeOther = 6,
 	ImageType7 = 7
-} ImageTypeEnum;
-
-typedef enum
+};
+
+enum ColorSpaceEnum
 {
 	ColorSpaceRGB  = 0,
 	ColorSpaceCMYK = 1,
 	ColorSpaceGray = 2,
 	ColorSpaceDuotone = 3,
 	ColorSpaceMonochrome = 4
-} ColorSpaceEnum;
+};
 
 class ImageInfoRecord
 {
@@ -171,27 +171,27 @@
 
 	// Remember to increment this version number and update
 	// the serialization routines if this class in changed.
-	static const int iirVersion;
+	static constexpr int iirVersion { 1 };
 
 	bool canSerialize() const;
 	bool serialize(ScImageCacheProxy & cache) const;
 	bool deserialize(const ScImageCacheProxy & cache);
 
-	ImageTypeEnum type;			/* 0 = jpg, 1 = tiff, 2 = psd, 3 = eps/ps, 4 = pdf, 5 = jpg2000, 6 = other */
-	int  xres;
-	int  yres;
-	int  BBoxX;
-	int  BBoxH;
-	ColorSpaceEnum colorspace; /* 0 = RGB  1 = CMYK  2 = Grayscale 3 = Duotone */
-	bool valid;
-	bool isRequest;
-	bool progressive;
-	bool isEmbedded;
-	bool exifDataValid;
-	int  lowResType; /* 0 = full Resolution, 1 = 72 dpi, 2 = 36 dpi */
-	double lowResScale;
-	int numberOfPages;
-	int actualPageNumber;
+	ImageTypeEnum type { ImageTypeOther };			/* 0 = jpg, 1 = tiff, 2 = psd, 3 = eps/ps, 4 = pdf, 5 = jpg2000, 6 = other */
+	int  xres { 72 };
+	int  yres { 72 };
+	int  BBoxX { 0 };
+	int  BBoxH { 0 };
+	ColorSpaceEnum colorspace { ColorSpaceRGB }; /* 0 = RGB  1 = CMYK  2 = Grayscale 3 = Duotone */
+	bool valid { false };
+	bool isRequest { false };
+	bool progressive { false };
+	bool isEmbedded { false };
+	bool exifDataValid { false };
+	int  lowResType { 1 }; /* 0 = full Resolution, 1 = 72 dpi, 2 = 36 dpi */
+	double lowResScale { 1.0 };
+	int numberOfPages { 1 };
+	int actualPageNumber { 0 };
 	QMap<QString, FPointArray> PDSpathData;
 	QMap<int, ImageLoadRequest> RequestProps;
 	QString clipPath;

Modified: trunk/Scribus/scribus/scraction.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24752&path=/trunk/Scribus/scribus/scraction.cpp
==============================================================================
--- trunk/Scribus/scribus/scraction.cpp	(original)
+++ trunk/Scribus/scribus/scraction.cpp	Mon Oct 25 19:43:18 2021
@@ -111,10 +111,6 @@
 	m_savedKeySequence = QKeySequence("");
 	m_shortcutSaved = false;
 	m_fakeToggle = false;
-}
-
-ScrAction::~ScrAction()
-{
 }
 
 void ScrAction::triggeredToTriggeredData()

Modified: trunk/Scribus/scribus/scraction.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24752&path=/trunk/Scribus/scribus/scraction.h
==============================================================================
--- trunk/Scribus/scribus/scraction.h	(original)
+++ trunk/Scribus/scribus/scraction.h	Mon Oct 25 19:43:18 2021
@@ -94,7 +94,7 @@
 	\param extraQString extra QString value
 	 */
 	ScrAction(QKeySequence accel, QObject *parent, QVariant data = QVariant());
-	~ScrAction();
+	~ScrAction() = default;
 	
 	/*!
 		\author Craig Bradney

Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24752&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h	(original)
+++ trunk/Scribus/scribus/scribusdoc.h	Mon Oct 25 19:43:18 2021
@@ -1454,9 +1454,9 @@
 	int previewVisual {0};
 	struct OpenNodesList
 	{
-		int type;
-		ScPage *page;
-		PageItem *item;
+		int type { -1 };
+		ScPage* page { nullptr };
+		PageItem *item { nullptr };
 	};
 	QList<OpenNodesList> OpenNodes;
 	QTimer *CurTimer {nullptr};




More information about the scribus-commit mailing list