r24725 by craig - Replace usage of QString.midRef with QStringView.mid

scribus-commit scribus-commit at lists.scribus.net
Sun Oct 3 12:34:58 UTC 2021


Author: craig
Date: Sun Oct  3 12:34:58 2021
New Revision: 24725

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24725
Log:
Replace usage of QString.midRef with QStringView.mid

Modified:
    trunk/Scribus/scribus/imagedataloaders/scimgdataloader_ps.cpp
    trunk/Scribus/scribus/plugins/import/ai/importai.cpp
    trunk/Scribus/scribus/sccolor.cpp
    trunk/Scribus/scribus/ui/annot.cpp
    trunk/Scribus/scribus/ui/pagepalette_widgets.cpp

Modified: trunk/Scribus/scribus/imagedataloaders/scimgdataloader_ps.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24725&path=/trunk/Scribus/scribus/imagedataloaders/scimgdataloader_ps.cpp
==============================================================================
--- trunk/Scribus/scribus/imagedataloaders/scimgdataloader_ps.cpp	(original)
+++ trunk/Scribus/scribus/imagedataloaders/scimgdataloader_ps.cpp	Sun Oct  3 12:34:58 2021
@@ -10,6 +10,7 @@
 #include <QFile>
 #include <QFileInfo>
 #include <QRegExp>
+#include <QStringView>
 
 #include "cmsettings.h"
 #include "colormgmt/sccolormgmtengine.h"
@@ -100,7 +101,7 @@
 				for (int a = 2; a < tmp.length(); a += 2)
 				{
 					bool ok;
-					ushort data = tmp.midRef(a, 2).toUShort(&ok, 16);
+					ushort data = QStringView{tmp}.mid(a, 2).toUShort(&ok, 16);
 					psdata.resize(psdata.size()+1);
 					psdata[psdata.size()-1] = data;
 				}
@@ -425,7 +426,7 @@
 							for (int a = 2; a < tmp.length(); a += 2)
 							{
 								bool ok;
-								ushort data = tmp.midRef(a, 2).toUShort(&ok, 16);
+								ushort data = QStringView{tmp}.mid(a, 2).toUShort(&ok, 16);
 								psdata.resize(psdata.size()+1);
 								psdata[psdata.size()-1] = data;
 							}
@@ -442,7 +443,7 @@
 							for (int a = 2; a < tmp.length(); a += 2)
 							{
 								bool ok;
-								ushort data = tmp.midRef(a, 2).toUShort(&ok, 16);
+								ushort data = QStringView{tmp}.mid(a, 2).toUShort(&ok, 16);
 								psdata.resize(psdata.size()+1);
 								psdata[psdata.size()-1] = data;
 							}
@@ -1244,7 +1245,7 @@
 						for (int a = 0; a < tmp.length(); a += 2)
 						{
 							bool ok;
-							ushort data = tmp.midRef(a, 2).toUShort(&ok, 16);
+							ushort data = QStringView{tmp}.mid(a, 2).toUShort(&ok, 16);
 							psdata.resize(psdata.size()+1);
 							psdata[psdata.size()-1] = data;
 						}
@@ -1377,7 +1378,7 @@
 							for (int a = 0; a < tmp.length(); a += 2)
 							{
 								bool ok;
-								ushort data = tmp.midRef(a, 2).toUShort(&ok, 16);
+								ushort data = QStringView{tmp}.mid(a, 2).toUShort(&ok, 16);
 								psdata.resize(psdata.size()+1);
 								psdata[psdata.size()-1] = data;
 							}

Modified: trunk/Scribus/scribus/plugins/import/ai/importai.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24725&path=/trunk/Scribus/scribus/plugins/import/ai/importai.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/ai/importai.cpp	(original)
+++ trunk/Scribus/scribus/plugins/import/ai/importai.cpp	Sun Oct  3 12:34:58 2021
@@ -1353,14 +1353,14 @@
 	double x, y, x1, y1, x2, y2;
 	int z, tmpInt;
 	PageItem *ite;
-	QString command = "";
-	QString Cdata = "";
+	QString command;
+	QString Cdata;
 	QStringList da;
 	if (dataMode && fObjectMode)
 	{
 		if (data.contains("~>"))
 		{
-			dataString += data.midRef(1);
+			dataString += QStringView{data}.mid(1);
 			dataMode = false;
 			QByteArray fData;
 			decodeA85(fData, dataString);
@@ -1420,7 +1420,7 @@
 		}
 		else
 		{
-			dataString += data.midRef(1);
+			dataString += QStringView{data}.mid(1);
 		}
 		return;
 	}
@@ -2970,7 +2970,7 @@
 			for (int a = 1; a < tmp.length(); a += 2)
 			{
 				bool ok;
-				ushort data = tmp.midRef(a, 2).toUShort(&ok, 16);
+				ushort data = QStringView{tmp}.mid(a, 2).toUShort(&ok, 16);
 				psdata[dataPointer++] = data;
 			}
 		}

Modified: trunk/Scribus/scribus/sccolor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24725&path=/trunk/Scribus/scribus/sccolor.cpp
==============================================================================
--- trunk/Scribus/scribus/sccolor.cpp	(original)
+++ trunk/Scribus/scribus/sccolor.cpp	Sun Oct  3 12:34:58 2021
@@ -367,19 +367,20 @@
 void ScColor::setNamedColor(QString colorName)
 {
 	bool ok;
+	QStringView colorNameView(colorName);
 	if (colorName.length () == 9)
 	{
-		int c = colorName.midRef(1,2).toInt(&ok, 16);
-		int m = colorName.midRef(3,2).toInt(&ok, 16);
-		int y = colorName.midRef(5,2).toInt(&ok, 16);
-		int k = colorName.midRef(7,2).toInt(&ok, 16);
+		int c = colorNameView.mid(1,2).toInt(&ok, 16);
+		int m = colorNameView.mid(3,2).toInt(&ok, 16);
+		int y = colorNameView.mid(5,2).toInt(&ok, 16);
+		int k = colorNameView.mid(7,2).toInt(&ok, 16);
 		setColor(c, m, y, k);
 	}
 	else if (colorName.length () == 7)
 	{
-		int r = colorName.midRef(1,2).toInt(&ok, 16);
-		int g = colorName.midRef(3,2).toInt(&ok, 16);
-		int b = colorName.midRef(5,2).toInt(&ok, 16);
+		int r = colorNameView.mid(1,2).toInt(&ok, 16);
+		int g = colorNameView.mid(3,2).toInt(&ok, 16);
+		int b = colorNameView.mid(5,2).toInt(&ok, 16);
 		setRgbColor(r, g, b);
 	}
 }

Modified: trunk/Scribus/scribus/ui/annot.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24725&path=/trunk/Scribus/scribus/ui/annot.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/annot.cpp	(original)
+++ trunk/Scribus/scribus/ui/annot.cpp	Sun Oct  3 12:34:58 2021
@@ -27,6 +27,7 @@
 #include <QSpacerItem>
 #include <QStackedWidget>
 #include <QStringList>
+#include <QStringView>
 #include <QWidget>
 
 #include "annotation.h"
@@ -773,7 +774,7 @@
 	if (pfol.count() > 1)
 	{
 		tm2 = pfol[0].simplified();
-		tm += tm2.midRef(1, tm2.length()-2);
+		tm += QStringView{tm2}.mid(1, tm2.length()-2);
 		for (int cfx = 1; cfx < pfol.count(); ++cfx)
 		{
 			tm2 = pfol[cfx].simplified();

Modified: trunk/Scribus/scribus/ui/pagepalette_widgets.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24725&path=/trunk/Scribus/scribus/ui/pagepalette_widgets.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/pagepalette_widgets.cpp	(original)
+++ trunk/Scribus/scribus/ui/pagepalette_widgets.cpp	Sun Oct  3 12:34:58 2021
@@ -17,6 +17,7 @@
 #include <QMimeData>
 #include <QMessageBox>
 #include <QPainter>
+#include <QStringView>
 
 #include "commonstrings.h"
 #include "iconmanager.h"
@@ -261,7 +262,7 @@
 			int st = str.indexOf(" ");
 			int en = str.indexOf(" ", st + 1);
 			tmp = str.mid(en+1);
-			int dr = str.midRef(st, en-st).toInt();
+			int dr = QStringView{str}.mid(st, en-st).toInt();
 			int a = rowAt(e->pos().y());
 			int b = columnAt(e->pos().x());
 			if ((a == -1) || (b == -1))




More information about the scribus-commit mailing list