r24261 by jghali - Code style fixes and cleanups

scribus-commit scribus-commit at lists.scribus.net
Tue Nov 17 13:12:58 UTC 2020


Author: jghali
Date: Tue Nov 17 13:12:58 2020
New Revision: 24261

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24261
Log:
Code style fixes and cleanups

Modified:
    trunk/Scribus/scribus/fileloader.cpp
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/text/storytext.cpp

Modified: trunk/Scribus/scribus/fileloader.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24261&path=/trunk/Scribus/scribus/fileloader.cpp
==============================================================================
--- trunk/Scribus/scribus/fileloader.cpp	(original)
+++ trunk/Scribus/scribus/fileloader.cpp	Tue Nov 17 13:12:58 2020
@@ -82,12 +82,12 @@
 	QStringList fmts = LoadSavePlugin::fileDialogLoadFilter();
 	QString fmtString = QObject::tr("All Supported Formats")+" (";
 	int ind = -1;
-	for (int i = 0; i < fmts.count()-1; i++)
+	for (int i = 0; i < fmts.count() - 1; ++i)
 	{
 		QString fmt(fmts[i]);
 		int s = fmt.indexOf("(");
 		int e = fmt.lastIndexOf(")");
-		QString f(fmt.mid(s+1, e-s-1));
+		QString f(fmt.mid(s + 1, e - s - 1));
 #ifndef HAVE_POPPLER
 		if (f.contains("pdf"))	// for removing PDF from the list
 		{
@@ -350,8 +350,8 @@
 	vg.charStyle().setFont((*currDoc->AllFonts)[tmpf]);
 	vg.charStyle().setFontSize(qRound(ScCLocale::toDoubleC(pg.attribute("FONTSIZE"), 12.0) * 10.0));
 	vg.setHasDropCap(static_cast<bool>(pg.attribute("DROP", "0").toInt()));
-	vg.setPeCharStyleName(pg.attribute("DROPCHSTYLE", ""));
-	vg.setPeCharStyleName(pg.attribute("PECHSTYLE", ""));
+	vg.setPeCharStyleName(pg.attribute("DROPCHSTYLE", QString()));
+	vg.setPeCharStyleName(pg.attribute("PECHSTYLE", QString()));
 	vg.setDropCapLines(pg.attribute("DROPLIN", "2").toInt());
 	vg.setParEffectOffset(ScCLocale::toDoubleC(pg.attribute("DROPDIST"), 0.0));
 	vg.setParEffectOffset(ScCLocale::toDoubleC(pg.attribute("PEDIST"), 0.0));
@@ -390,29 +390,28 @@
 			tbs.append(tb);
 		}
 		vg.setTabValues(tbs);
-		tmp = "";
+		tmp.clear();
 	}
 	else
 	{
 		QList<ParagraphStyle::TabRecord> tbs;
-		QDomNode IT = pg.firstChild();
-		while (!IT.isNull())
-		{
-			QDomElement it = IT.toElement();
-			if (it.tagName()=="Tabs")
+		QDomNode domNode = pg.firstChild();
+		while (!domNode.isNull())
+		{
+			QDomElement it = domNode.toElement();
+			if (it.tagName() == "Tabs")
 			{
 				ParagraphStyle::TabRecord tb;
 				tb.tabPosition = ScCLocale::toDoubleC(it.attribute("Pos"));
 				tb.tabType = it.attribute("Type").toInt();
-				QString tbCh = "";
-				tbCh = it.attribute("Fill","");
+				QString tbCh = it.attribute("Fill", QString());
 				if (tbCh.isEmpty())
 					tb.tabFillChar = QChar();
 				else
 					tb.tabFillChar = tbCh[0];
 				tbs.append(tb);
 			}
-			IT=IT.nextSibling();
+			domNode = domNode.nextSibling();
 		}
 		vg.setTabValues(tbs);
 	}
@@ -456,25 +455,24 @@
 
 void FileLoader::informReplacementFonts()
 {
-	if (m_ReplacedFonts.count() != 0)
-	{
-		qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
-		QString mess = tr("Some fonts used by this document have been substituted:")+"\n\n";
-		QMap<QString, QString>::Iterator it;
-		for (it = m_ReplacedFonts.begin(); it != m_ReplacedFonts.end(); ++it)
-		{
-			mess += it.key() + tr(" was replaced by: ")+ it.value() +"\n";
-		}
-		ScMessageBox::warning(ScCore->primaryMainWindow(), CommonStrings::trWarning, mess);
-	}
+	if (m_ReplacedFonts.count() == 0)
+		return;
+
+	qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
+	QString mess = tr("Some fonts used by this document have been substituted:") + "\n\n";
+	for (auto it = m_ReplacedFonts.begin(); it != m_ReplacedFonts.end(); ++it)
+	{
+		mess += it.key() + tr(" was replaced by: ") + it.value() +"\n";
+	}
+	ScMessageBox::warning(ScCore->primaryMainWindow(), CommonStrings::trWarning, mess);
 }
 
 bool FileLoader::findFormat(uint formatId, QList<FileFormat>::const_iterator &it)
 {
 	QList<FileFormat> fileFormats(LoadSavePlugin::supportedFormats());
-	it=fileFormats.constBegin();
+	it = fileFormats.constBegin();
 	QList<FileFormat>::const_iterator itEnd(fileFormats.constEnd());
-	for ( ; it != itEnd ; ++it )
+	for ( ; it != itEnd ; ++it)
 	{
 		if (formatId == it->formatId)
 			return true;

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24261&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp	(original)
+++ trunk/Scribus/scribus/scribus.cpp	Tue Nov 17 13:12:58 2020
@@ -4594,10 +4594,10 @@
 			if (currItem->isNoteFrame())
 			{
 				story->setDoc(doc);
-				for (int pos=story->length() -1; pos >= 0; --pos)
+				for (int pos = story->length() - 1; pos >= 0; --pos)
 				{
 					if (story->hasMark(pos) && (story->mark(pos)->isNoteType()))
-						story->removeChars(pos,1);
+						story->removeChars(pos, 1);
 				}
 			}
 			if (UndoManager::undoEnabled())

Modified: trunk/Scribus/scribus/text/storytext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24261&path=/trunk/Scribus/scribus/text/storytext.cpp
==============================================================================
--- trunk/Scribus/scribus/text/storytext.cpp	(original)
+++ trunk/Scribus/scribus/text/storytext.cpp	Tue Nov 17 13:12:58 2020
@@ -2210,7 +2210,7 @@
 	paragraphStyle(0).saxx(handler);
 	handler.begin("span", empty);
 	lastStyle.saxx(handler);
-	for (int i=0; i < length(); ++i)
+	for (int i = 0; i < length(); ++i)
 	{
 		const QChar curr(text(i));
 		const CharStyle& style(charStyle(i));
@@ -2259,7 +2259,7 @@
 				continue; //do not insert notes marks into text frames nad vice versa
 			Xml_attr mark_attr;
 			mark_attr.insert("label", mrk->label);
-			mark_attr.insert("typ", QString::number((int )mrk->getType()));
+			mark_attr.insert("typ", QString::number((int) mrk->getType()));
 //			if (!mrk->isType(MARKBullNumType))
 //			{
 //				mark_attr.insert("strtxt", mrk->getString());
@@ -2347,11 +2347,11 @@
 		}
 		else
 			continue;
-		lastPos = i+1;
+		lastPos = i + 1;
 	}
 	
 	if  (length() - lastPos > 0)
-		handler.chars(textWithSoftHyphens(lastPos, length()-lastPos));
+		handler.chars(textWithSoftHyphens(lastPos, length() - lastPos));
 	handler.end("span");
 	handler.end("p");
 	
@@ -2359,7 +2359,6 @@
 //		paragraphStyle(length()-1).saxx(handler);
 	
 	handler.end(elemtag);
-
 }
 
 
@@ -2381,14 +2380,14 @@
 					obj->insertChars(obj->length(), txt.mid(lastPos, toInsert));
 				len = obj->length();
 				// qreal SHY means user provided SHY, single SHY is automatic one
-				if (obj->hasFlag(len-1, ScLayout_HyphenationPossible))
+				if (obj->hasFlag(len - 1, ScLayout_HyphenationPossible))
 				{
-					obj->clearFlag(len-1, ScLayout_HyphenationPossible);
+					obj->clearFlag(len - 1, ScLayout_HyphenationPossible);
 					obj->insertChars(len, QString(chr));
 				}
 				else
 				{
-					obj->setFlag(len-1, ScLayout_HyphenationPossible);
+					obj->setFlag(len - 1, ScLayout_HyphenationPossible);
 				}
 				lastPos = i + 1;
 			} 




More information about the scribus-commit mailing list