r21953 by craig - Clazy part 11: Mostly pass QStrings by reference

scribus-commit scribus-commit at lists.scribus.net
Fri Apr 21 15:48:04 UTC 2017


Author: craig
Date: Fri Apr 21 15:48:04 2017
New Revision: 21953

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21953
Log:
Clazy part 11: Mostly pass QStrings by reference

Modified:
    trunk/Scribus/scribus/notesstyles.h
    trunk/Scribus/scribus/pageitem.cpp
    trunk/Scribus/scribus/pageitem.h
    trunk/Scribus/scribus/plugins/import/pct/importpct.cpp
    trunk/Scribus/scribus/plugins/import/uniconvertor/uniconvplugin.cpp
    trunk/Scribus/scribus/scribusdoc.h
    trunk/Scribus/scribus/scribusstructs.h

Modified: trunk/Scribus/scribus/notesstyles.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21953&path=/trunk/Scribus/scribus/notesstyles.h
==============================================================================
--- trunk/Scribus/scribus/notesstyles.h	(original)
+++ trunk/Scribus/scribus/notesstyles.h	Fri Apr 21 15:48:04 2017
@@ -28,22 +28,22 @@
 class SCRIBUS_API NotesStyle
 {
 public:
-	NotesStyle() : m_nameStr ("Default"), m_startNum(1), m_endNotesStyle(false), m_numeration(), m_numRange(NSRdocument), m_prefixStr(""), m_suffixStr(")"),
+	NotesStyle() : m_nameStr ("Default"), m_startNum(1), m_endNotesStyle(false), m_numeration(), m_numRange(NSRdocument), m_suffixStr(")"),
 		m_autoNotesHeight(true), m_autoNotesWidth(true), m_autoRemoveEmptyNotesFrames(true), m_autoWeldNotesFrames(true),
-		m_superscriptInNote(true), m_superscriptInMaster(true), m_marksCharStyle(""), m_notesParaStyle("") {}
+		m_superscriptInNote(true), m_superscriptInMaster(true) {}
 	~NotesStyle() {}
 	bool operator!=(const NotesStyle& n2);
 
 	QString name() const { return m_nameStr; }
-	void setName(const QString s) { m_nameStr = s; }
+	void setName(const QString& s) { m_nameStr = s; }
 	int start() const { return m_startNum; }
 	void setStart(const int i) { m_startNum = i; }
 	void setRange(NumerationRange ns) { m_numRange = ns; }
 	const NumerationRange& range() const { return m_numRange; }
 	QString prefix() const { return m_prefixStr; }
-	void setPrefix (const QString str) { m_prefixStr = str; }
+	void setPrefix (const QString& str) { m_prefixStr = str; }
 	QString suffix() const { return m_suffixStr; }
-	void setSuffix (const QString str) { m_suffixStr = str; }
+	void setSuffix (const QString& str) { m_suffixStr = str; }
 
 	QString numString(const int num) const { return m_numeration.numString(num); }
 	void setType(const NumFormat type) { m_numeration.numFormat = type; }
@@ -63,9 +63,9 @@
 	bool isSuperscriptInMaster() const { return m_superscriptInMaster; }
 	void setSuperscriptInMaster(bool set) { m_superscriptInMaster = set; }
 	const QString marksChStyle() const { return m_marksCharStyle; }
-	void setMarksCharStyle(const QString styleName) { m_marksCharStyle = styleName; }
+	void setMarksCharStyle(const QString& styleName) { m_marksCharStyle = styleName; }
 	const QString notesParStyle() const { return m_notesParaStyle; }
-	void setNotesParStyle(const QString styleName) { m_notesParaStyle = styleName; }
+	void setNotesParStyle(const QString& styleName) { m_notesParaStyle = styleName; }
 
 	void setEndNotes(bool);
 
@@ -95,12 +95,12 @@
 
 private:
 	//only ScribusDoc can create and delete notes
-	TextNote(NotesStyle *nStyle) : textLen(0), m_notesStyle(nStyle), m_noteSaxedText(""), m_noteMasterMark(NULL), m_noteFrameMark(NULL), m_number(0) { }
+	TextNote(NotesStyle *nStyle) : textLen(0), m_notesStyle(nStyle), m_noteMasterMark(NULL), m_noteFrameMark(NULL), m_number(0) { }
 	~TextNote() {}
 public:
 	void setNotesStyle (NotesStyle* ns) { m_notesStyle = ns; }
 	NotesStyle* notesStyle() { return m_notesStyle; }
-	const int num() { return  m_number; }
+	int num() { return  m_number; }
 	void setNum(const int i) { m_number = i; }
 	const QString numString();
 	Mark* masterMark() { return m_noteMasterMark; }
@@ -108,7 +108,7 @@
 	Mark* noteMark() { return m_noteFrameMark; }
 	void setNoteMark(Mark* m) { m_noteFrameMark = m; }
 	const QString saxedText() { return m_noteSaxedText; }
-	void setSaxedText(const QString string) { m_noteSaxedText = string; }
+	void setSaxedText(const QString& string) { m_noteSaxedText = string; }
 	bool isEndNote() { return m_notesStyle->isEndNotes(); }
 	int textLen;
 

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21953&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp	(original)
+++ trunk/Scribus/scribus/pageitem.cpp	Fri Apr 21 15:48:04 2017
@@ -9642,7 +9642,7 @@
 	}
 }
 
-void PageItem::setFileIconPressed(QString val)
+void PageItem::setFileIconPressed(const QString& val)
 {
 	Pfile2 = val;
 	if (!Pfile2.isEmpty())
@@ -9653,7 +9653,7 @@
 	}
 }
 
-void PageItem::setFileIconRollover(QString val)
+void PageItem::setFileIconRollover(const QString& val)
 {
 	Pfile3 = val;
 	if (!Pfile3.isEmpty())
@@ -10324,7 +10324,7 @@
 	}
 }
 
-void PageItem::setInlineData(QString data)
+void PageItem::setInlineData(const QString& data)
 {
 	QByteArray inlineImageData;
 	inlineImageData.append(data);
@@ -10365,7 +10365,7 @@
 	delete tempFile;
 }
 
-void PageItem::makeImageExternal(QString path)
+void PageItem::makeImageExternal(const QString& path)
 {
 	if ((isTempFile) && (isInlineImage) && (!path.isEmpty()))
 	{

Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21953&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h	(original)
+++ trunk/Scribus/scribus/pageitem.h	Fri Apr 21 15:48:04 2017
@@ -419,9 +419,9 @@
 	void SetQColor(QColor *tmp, QString farbe, double shad);
 	void DrawPolyL(QPainter *p, QPolygon pts);
 	const FPointArray shape() const { return PoLine; }
-	void setShape(FPointArray val) { PoLine = val; }
+	void setShape(const FPointArray& val) { PoLine = val; }
 	const FPointArray contour() const { return ContourLine; }
-	void setContour(FPointArray val) { ContourLine = val; }
+	void setContour(const FPointArray& val) { ContourLine = val; }
 	bool flipPathText() const { return textPathFlipped; }
 	void setFlipPathText(bool val) { textPathFlipped = val; }
 	int pathTextType() const { return textPathType; }
@@ -434,7 +434,7 @@
 	bool useEmbeddedImageProfile() const { return UseEmbedded; }
 	void setUseEmbeddedImageProfile(bool val) { UseEmbedded = val; }
 	QString embeddedImageProfile() const { return EmProfile; }
-	void setEmbeddedImageProfile(QString val) { EmProfile = val; }
+	void setEmbeddedImageProfile(const QString& val) { EmProfile = val; }
 	bool drawFrame() { return ((m_ItemType == TextFrame && !m_sampleItem) || (m_ItemType == ImageFrame) || (m_ItemType == PathText)); }
 	QString externalFile() const { return Pfile; }
 	void setExternalFile(QString val);
@@ -443,13 +443,13 @@
 
 	//FIXME: maybe these should go into annotation?
 	QString fileIconPressed() const { return Pfile2; }
-	void setFileIconPressed(QString val);
+	void setFileIconPressed(const QString& val);
 	QString fileIconRollover() const { return Pfile3; }
-	void setFileIconRollover(QString val);
+	void setFileIconRollover(const QString& val);
 	int  cmsRenderingIntent() const { return IRender; }
 	void setCmsRenderingIntent(eRenderIntent val) { IRender = val; }
 	QString cmsProfile() const { return IProfile; }
-	void setCmsProfile(QString val) { IProfile = val; }
+	void setCmsProfile(const QString& val) { IProfile = val; }
 	void setOverrideCompressionMethod(bool val) { OverrideCompressionMethod = val; }
 	void setCompressionMethodIndex(int val) { CompressionMethodIndex = val; }
 	void setOverrideCompressionQuality(bool val) { OverrideCompressionQuality = val; }
@@ -724,10 +724,10 @@
 	void setFitImageToFrame(bool val) { ScaleType = !val; }
 	bool isImageInline() const { return isInlineImage; }
 	void setImageInline(bool val) { isInlineImage = val; }
-	void setInlineExt(QString val) { inlineExt = val; }
-	void setInlineData(QString data);
+	void setInlineExt(const QString& val) { inlineExt = val; }
+	void setInlineData(const QString& data);
 	void makeImageInline();
-	void makeImageExternal(QString path);
+	void makeImageExternal(const QString& path);
 
 	//Text Data - Move to PageItem_TextFrame at some point? --- no, to FrameStyle, av
 	double textToFrameDistLeft() const { return m_textDistanceMargins.left(); }

Modified: trunk/Scribus/scribus/plugins/import/pct/importpct.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21953&path=/trunk/Scribus/scribus/plugins/import/pct/importpct.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pct/importpct.cpp	(original)
+++ trunk/Scribus/scribus/plugins/import/pct/importpct.cpp	Fri Apr 21 15:48:04 2017
@@ -1544,17 +1544,12 @@
 		if (!codec)
 			return;
 	}
-	QString string = codec->toUnicode(textString);
+	QString string(codec->toUnicode(textString));
 	QFont textFont;
 	if (!fontMap.contains(currentFontID))
 		textFont = QFont();
 	else
-	{
-		QString fontName = fontMap[currentFontID];
-		textFont = QFont(fontName, currentTextSize);
-		QFontInfo inf(textFont);
-//		qDebug() << "Using Font" << inf.family() << "for" << fontName;
-	}
+		textFont = QFont(fontMap[currentFontID], currentTextSize);
 	textFont.setPixelSize(currentTextSize);
 	if (currentFontStyle & 1)
 		textFont.setBold(true);

Modified: trunk/Scribus/scribus/plugins/import/uniconvertor/uniconvplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21953&path=/trunk/Scribus/scribus/plugins/import/uniconvertor/uniconvplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/uniconvertor/uniconvplugin.cpp	(original)
+++ trunk/Scribus/scribus/plugins/import/uniconvertor/uniconvplugin.cpp	Fri Apr 21 15:48:04 2017
@@ -165,16 +165,14 @@
 	if (!uniconv.waitForFinished(120000)) {
 		qDebug() << "Uniconv exit code:" << uniconv.exitCode();
 		ScMessageBox::warning(mw, CommonStrings::trWarning,
-			tr("Uniconvertor did not exit correctly: %1").arg(
-			uniconv.errorString()).arg(QString(uniconv.readAll())));
+			tr("Uniconvertor did not exit correctly: %1").arg(uniconv.errorString(), QString(uniconv.readAll())));
 		delete tempFile;
 		return false;
 	}
 	if (uniconv.exitCode()) {
 		qDebug() << "Uniconv exit code:" << uniconv.exitCode();
 		ScMessageBox::warning(mw, CommonStrings::trWarning,
-			tr("Uniconvertor failed to convert the file: %1").arg(
-				QString(uniconv.readAll())));
+			tr("Uniconvertor failed to convert the file: %1").arg(QString(uniconv.readAll())));
 		delete tempFile;
 		return false;
 	}

Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21953&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h	(original)
+++ trunk/Scribus/scribus/scribusdoc.h	Fri Apr 21 15:48:04 2017
@@ -520,7 +520,7 @@
 	 */
 	void enableCMS(bool enable);
 	
-	const ParagraphStyle& paragraphStyle(QString name) { return m_docParagraphStyles.get(name); }
+	const ParagraphStyle& paragraphStyle(const QString& name) { return m_docParagraphStyles.get(name); }
 	const StyleSet<ParagraphStyle>& paragraphStyles()   { return m_docParagraphStyles; }
 	bool isDefaultStyle( const ParagraphStyle& p ) const { return m_docParagraphStyles.isDefault(p); }
 	bool isDefaultStyle( const CharStyle& c ) const { return m_docCharStyles.isDefault(c); }
@@ -529,7 +529,7 @@
 	/**
 	 * Returns the table style named @a name.
 	 */
-	const TableStyle& tableStyle(QString name) { return m_docTableStyles.get(name); }
+	const TableStyle& tableStyle(const QString& name) { return m_docTableStyles.get(name); }
 	/**
 	 * Returns the set of table styles in the document.
 	 */
@@ -554,7 +554,7 @@
 	/**
 	 * Returns the table cell style named @a name.
 	 */
-	const CellStyle& cellStyle(QString name) { return m_docCellStyles.get(name); }
+	const CellStyle& cellStyle(const QString& name) { return m_docCellStyles.get(name); }
 	/**
 	 * Returns the set of table cell styles in the document.
 	 */
@@ -621,7 +621,7 @@
 	                                          StyleSet<CharStyle> *tempCharStyles,
 											  QHash<QString, multiLine> *tempLineStyles);
 
-	const CharStyle& charStyle(QString name) { return m_docCharStyles.get(name); }
+	const CharStyle& charStyle(const QString& name) { return m_docCharStyles.get(name); }
 	const StyleSet<CharStyle>& charStyles()  { return m_docCharStyles; }
 	void redefineCharStyles(const StyleSet<CharStyle>& newStyles, bool removeUnused=false);
 	/**

Modified: trunk/Scribus/scribus/scribusstructs.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21953&path=/trunk/Scribus/scribus/scribusstructs.h
==============================================================================
--- trunk/Scribus/scribus/scribusstructs.h	(original)
+++ trunk/Scribus/scribus/scribusstructs.h	Fri Apr 21 15:48:04 2017
@@ -155,10 +155,10 @@
 	double firstLineIndent;
 	double tabPosition;
 	CharStyle* style;
-	Bullet() : name(""), charStr(""), indent(0.0), firstLineIndent(0.0), tabPosition(0.0), style(NULL) {}
+	Bullet() : indent(0.0), firstLineIndent(0.0), tabPosition(0.0), style(NULL) {}
 	Bullet(QString n, QString ch) : name(n), charStr(ch), indent(0.0), firstLineIndent(0.0), tabPosition(0.0), style(NULL) {}
 	Bullet(QString n, QString ch, double first, double ind, double tab, CharStyle* chStyle)
-		{ name = n; charStr = ch, firstLineIndent = first; indent = ind; tabPosition = tab; style = chStyle; }
+	    { name = n; charStr = ch, firstLineIndent = first; indent = ind; tabPosition = tab; style = chStyle; }
 };
 
 struct ArrowDesc
@@ -170,7 +170,8 @@
 
 struct PDFPresentationData
 {
-	PDFPresentationData() {
+	PDFPresentationData()
+	{
 		pageEffectDuration = 1;
 		pageViewDuration = 1;
 		effectType = 0;
@@ -342,17 +343,16 @@
 	QString ParaStyle;
 	LastStyles() {
 		StyleStart = 0;
-		ParaStyle = "";
 	}
 };
 
 class AttributeValue
 {
 	public:
-		AttributeValue() : valid(false),  value("")
+		AttributeValue() : valid(false)
 		{
 		}
-		AttributeValue(QString val)
+		AttributeValue(const QString& val)
 		{
 			if (val.isEmpty() || (val == ""))
 			{




More information about the scribus-commit mailing list