r24912 by craig - Clean up use of ParagraphStyle::TabRecord

scribus-commit scribus-commit at lists.scribus.net
Sat Feb 5 15:51:22 UTC 2022


Author: craig
Date: Sat Feb  5 15:51:22 2022
New Revision: 24912

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24912
Log:
Clean up use of ParagraphStyle::TabRecord

Modified:
    trunk/Scribus/scribus/canvasmode_nodeedit.cpp
    trunk/Scribus/scribus/fileloader.cpp
    trunk/Scribus/scribus/gtparagraphstyle.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
    trunk/Scribus/scribus/plugins/gettext/xtgim/xtgscanner.cpp
    trunk/Scribus/scribus/plugins/import/idml_old/importidmlimpl.cpp
    trunk/Scribus/scribus/styles/paragraphstyle.h
    trunk/Scribus/scribus/third_party/rtf-qt/sladocumentrtfoutput.cpp
    trunk/Scribus/scribus/ui/tabruler.cpp

Modified: trunk/Scribus/scribus/canvasmode_nodeedit.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24912&path=/trunk/Scribus/scribus/canvasmode_nodeedit.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_nodeedit.cpp	(original)
+++ trunk/Scribus/scribus/canvasmode_nodeedit.cpp	Sat Feb  5 15:51:22 2022
@@ -355,8 +355,8 @@
 	m->accept();
 	m_view->registerMousePress(m->globalPos());
 	QRect mpo;
-	m_Mxp = m->x();
-	m_Myp = m->y();
+	m_Mxp = m->position().x();
+	m_Myp = m->position().y();
 
 	if (((m->buttons() & Qt::RightButton) && (m->modifiers() & Qt::ControlModifier)) || ((!(m->modifiers() & Qt::ControlModifier)) && (m->buttons() & Qt::MiddleButton)))
 	{

Modified: trunk/Scribus/scribus/fileloader.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24912&path=/trunk/Scribus/scribus/fileloader.cpp
==============================================================================
--- trunk/Scribus/scribus/fileloader.cpp	(original)
+++ trunk/Scribus/scribus/fileloader.cpp	Sat Feb  5 15:51:22 2022
@@ -386,7 +386,6 @@
 			tgv >> xf2;
 			tb.tabPosition = ScCLocale::toDoubleC(xf2);
 			tb.tabType = static_cast<int>(ScCLocale::toDoubleC(xf));
-			tb.tabFillChar =  QChar();
 			tbs.append(tb);
 		}
 		vg.setTabValues(tbs);
@@ -404,10 +403,8 @@
 				ParagraphStyle::TabRecord tb;
 				tb.tabPosition = ScCLocale::toDoubleC(it.attribute("Pos"));
 				tb.tabType = it.attribute("Type").toInt();
-				QString tbCh = it.attribute("Fill", QString());
-				if (tbCh.isEmpty())
-					tb.tabFillChar = QChar();
-				else
+				QString tbCh(it.attribute("Fill", QString()));
+				if (!tbCh.isEmpty())
 					tb.tabFillChar = tbCh[0];
 				tbs.append(tb);
 			}

Modified: trunk/Scribus/scribus/gtparagraphstyle.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24912&path=/trunk/Scribus/scribus/gtparagraphstyle.cpp
==============================================================================
--- trunk/Scribus/scribus/gtparagraphstyle.cpp	(original)
+++ trunk/Scribus/scribus/gtparagraphstyle.cpp	Sat Feb  5 15:51:22 2022
@@ -204,7 +204,6 @@
 	ParagraphStyle::TabRecord tb;
 	tb.tabPosition = newTabValue;
 	tb.tabType = ttype;
-	tb.tabFillChar =  QChar();
 	tabValues.append(tb);
 	flags |= tabValueWasSet;
 }

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24912&path=/trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp	(original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp	Sat Feb  5 15:51:22 2022
@@ -1711,7 +1711,6 @@
 			tgv >> xf2;
 			tb.tabPosition = xf2;
 			tb.tabType = static_cast<int>(xf);
-			tb.tabFillChar = QChar();
 			OB->TabValues.append(tb);
 		}
 		tmp = "";
@@ -2335,11 +2334,8 @@
 				ParagraphStyle::TabRecord tb;
 				tb.tabPosition = ScCLocale::toDoubleC(it.attribute("Pos"));
 				tb.tabType = it.attribute("Type").toInt();
-				QString tbCh = "";
-				tbCh = it.attribute("Fill","");
-				if (tbCh.isEmpty())
-					tb.tabFillChar = QChar();
-				else
+				QString tbCh(it.attribute("Fill",""));
+				if (!tbCh.isEmpty())
 					tb.tabFillChar = tbCh[0];
 				tbs.append(tb);
 			}

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24912&path=/trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp	(original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp	Sat Feb  5 15:51:22 2022
@@ -1474,7 +1474,6 @@
 			tgv >> xf2;
 			tb.tabPosition = xf2;
 			tb.tabType = static_cast<int>(xf);
-			tb.tabFillChar =  QChar();
 			tbs.append(tb);
 		}
 		newStyle.setTabValues(tbs);
@@ -1496,8 +1495,9 @@
 				ScXmlStreamAttributes attrs2 = reader.scAttributes();
 				tb.tabPosition = attrs2.valueAsDouble("Pos");
 				tb.tabType     = attrs2.valueAsInt("Type");
-				QString tbCh   = attrs2.valueAsString("Fill","");
-				tb.tabFillChar = tbCh.isEmpty() ? QChar() : tbCh[0];
+				QString tbCh(attrs2.valueAsString("Fill",""));
+				if (!tbCh.isEmpty())
+					tb.tabFillChar = tbCh[0];
 				tbs.append(tb);
 			}
 		}
@@ -2108,8 +2108,9 @@
 			ParagraphStyle::TabRecord tb;
 			tb.tabPosition = tAtt.valueAsDouble("Pos");
 			tb.tabType     = tAtt.valueAsInt("Type");
-			QString tbCh   = tAtt.valueAsString("Fill", "");
-			tb.tabFillChar = tbCh.isEmpty() ? QChar() : tbCh[0];
+			QString tbCh(tAtt.valueAsString("Fill", ""));
+			if (!tbCh.isEmpty())
+				tb.tabFillChar = tbCh[0];
 			tabValues.append(tb);
 		}
 		if (tName == QLatin1String("LATEX"))
@@ -2989,7 +2990,6 @@
 			tgv >> xf2;
 			tb.tabPosition = xf2;
 			tb.tabType = static_cast<int>(xf);
-			tb.tabFillChar = QChar();
 			tbs.append(tb);
 		}
 		tmp = "";

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24912&path=/trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp	(original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp	Sat Feb  5 15:51:22 2022
@@ -1463,11 +1463,8 @@
 				ParagraphStyle::TabRecord tb;
 				tb.tabPosition = ScCLocale::toDoubleC(it.attribute("Pos"));
 				tb.tabType = it.attribute("Type").toInt();
-				QString tbCh = "";
-				tbCh = it.attribute("Fill","");
-				if (tbCh.isEmpty())
-					tb.tabFillChar = QChar();
-				else
+				QString tbCh(it.attribute("Fill",""));
+				if (!tbCh.isEmpty())
 					tb.tabFillChar = tbCh[0];
 				tbs.append(tb);
 			}
@@ -1721,7 +1718,6 @@
 			tgv >> xf2;
 			tb.tabPosition = xf2;
 			tb.tabType = static_cast<int>(xf);
-			tb.tabFillChar = QChar();
 			tbValues.append(tb);
 		}
 		tmp = "";
@@ -1737,11 +1733,8 @@
 				ParagraphStyle::TabRecord tb;
 				tb.tabPosition = ScCLocale::toDoubleC(it.attribute("Pos"));
 				tb.tabType = it.attribute("Type").toInt();
-				QString tbCh = "";
-				tbCh = it.attribute("Fill","");
-				if (tbCh.isEmpty())
-					tb.tabFillChar = QChar();
-				else
+				QString tbCh(it.attribute("Fill",""));
+				if (!tbCh.isEmpty())
 					tb.tabFillChar = tbCh[0];
 				tbValues.append(tb);
 			}

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24912&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp	(original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp	Sat Feb  5 15:51:22 2022
@@ -3220,8 +3220,9 @@
 			ScXmlStreamAttributes attrs2 = reader.scAttributes();
 			tb.tabPosition = attrs2.valueAsDouble("Pos");
 			tb.tabType     = attrs2.valueAsInt("Type");
-			QString tbCh   = attrs2.valueAsString("Fill","");
-			tb.tabFillChar = tbCh.isEmpty() ? QChar() : tbCh[0];
+			QString tbCh(attrs2.valueAsString("Fill",""));
+			if (!tbCh.isEmpty())
+				tb.tabFillChar = tbCh[0];
 			tbs.append(tb);
 		}
 	}
@@ -4460,8 +4461,9 @@
 			ParagraphStyle::TabRecord tb;
 			tb.tabPosition = tAtt.valueAsDouble("Pos");
 			tb.tabType     = tAtt.valueAsInt("Type");
-			QString tbCh   = tAtt.valueAsString("Fill", "");
-			tb.tabFillChar = tbCh.isEmpty() ? QChar() : tbCh[0];
+			QString tbCh(tAtt.valueAsString("Fill", ""));
+			if (!tbCh.isEmpty())
+				tb.tabFillChar = tbCh[0];
 			tabValues.append(tb);
 		}
 		if (tName == QLatin1String("LATEX"))

Modified: trunk/Scribus/scribus/plugins/gettext/xtgim/xtgscanner.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24912&path=/trunk/Scribus/scribus/plugins/gettext/xtgim/xtgscanner.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/gettext/xtgim/xtgscanner.cpp	(original)
+++ trunk/Scribus/scribus/plugins/gettext/xtgim/xtgscanner.cpp	Sat Feb  5 15:51:22 2022
@@ -670,7 +670,6 @@
 			tb.tabType = 3;
 		tb.tabType = typ;
 		tb.tabPosition = pos;
-		tb.tabFillChar = QChar();
 		tbs.append(tb);
 	}
 	m_currentParagraphStyle.setTabValues(tbs);

Modified: trunk/Scribus/scribus/plugins/import/idml_old/importidmlimpl.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24912&path=/trunk/Scribus/scribus/plugins/import/idml_old/importidmlimpl.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/idml_old/importidmlimpl.cpp	(original)
+++ trunk/Scribus/scribus/plugins/import/idml_old/importidmlimpl.cpp	Sat Feb  5 15:51:22 2022
@@ -416,10 +416,11 @@
 						tb.tabPosition = tabElements.text().toDouble();
 						if(tabElements.tagName()=="AlignmentCharacter")
 						{
-							QString tbCh   = tabElements.text();
+							QString tbCh(tabElements.text());
 							if(tbCh.contains("$ID/",Qt::CaseSensitive))
 								tbCh = tbCh.split("$ID/",QString::SkipEmptyParts,Qt::CaseSensitive).at(1);
-							tb.tabFillChar = tbCh.isEmpty() ? QChar() : tbCh[0];
+							if (!tbCh.isEmpty())
+								tb.tabFillChar = tbCh[0];
 							tbs.append(tb);
 							if (tbs.count() > 0)
 								newStyle.setTabValues(tbs);
@@ -772,13 +773,13 @@
 	l=e.attribute("RightDirection","").split(" ");
 	p.Right.setX(l.at(0).toDouble());
 	p.Right.setY(l.at(1).toDouble());
-	return p;
-}
-/**
-\brief A Function to find width 
-\return width as double if successful, else return -1
-*/
-
+	return p;
+}
+/**
+\brief A Function to find width 
+\return width as double if successful, else return -1
+*/
+
 double ImportIdmlImpl::findWidth(double x1, double y1, double x2, double y2)
 {
 	if(x1==x2)

Modified: trunk/Scribus/scribus/styles/paragraphstyle.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24912&path=/trunk/Scribus/scribus/styles/paragraphstyle.h
==============================================================================
--- trunk/Scribus/scribus/styles/paragraphstyle.h	(original)
+++ trunk/Scribus/scribus/styles/paragraphstyle.h	Sat Feb  5 15:51:22 2022
@@ -69,7 +69,7 @@
 	struct TabRecord
 	{
 		qreal tabPosition;
-		int tabType;
+		int tabType {0};
 		QChar tabFillChar;
 		bool operator==(const TabRecord& other) const;
 		bool operator<(const TabRecord& other)  const { return tabPosition < other.tabPosition; }

Modified: trunk/Scribus/scribus/third_party/rtf-qt/sladocumentrtfoutput.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24912&path=/trunk/Scribus/scribus/third_party/rtf-qt/sladocumentrtfoutput.cpp
==============================================================================
--- trunk/Scribus/scribus/third_party/rtf-qt/sladocumentrtfoutput.cpp	(original)
+++ trunk/Scribus/scribus/third_party/rtf-qt/sladocumentrtfoutput.cpp	Sat Feb  5 15:51:22 2022
@@ -572,7 +572,6 @@
 		ParagraphStyle::TabRecord tb;
 		tb.tabType = type;
 		tb.tabPosition = tabVal;
-		tb.tabFillChar = QChar();
 		QList<ParagraphStyle::TabRecord> tbs = m_textStyle.top().tabValues();
 		if (tbs.count() == 0)
 			tbs.append(tb);

Modified: trunk/Scribus/scribus/ui/tabruler.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24912&path=/trunk/Scribus/scribus/ui/tabruler.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/tabruler.cpp	(original)
+++ trunk/Scribus/scribus/ui/tabruler.cpp	Sat Feb  5 15:51:22 2022
@@ -172,6 +172,8 @@
 {
 	QRect fpo;
 	mousePressed = true;
+	int mPosX = m->position().x();
+	int mPosY = m->position().y();
 	qApp->setOverrideCursor(QCursor(Qt::ArrowCursor));
 	rulerCode = 0;
 	if (haveInd)
@@ -180,14 +182,14 @@
 		if (fpo.contains(m->pos()))
 		{
 			rulerCode = 1;
-			mouseX = m->x();
+			mouseX = mPosX;
 			return;
 		}
 		fpo = QRect(static_cast<int>(leftIndent - offset) - 4, 12, 8, 12);
 		if (fpo.contains(m->pos()))
 		{
 			rulerCode = 2;
-			mouseX = m->x();
+			mouseX = mPosX;
 			return;
 		}
 	}
@@ -200,7 +202,7 @@
 			{
 				rulerCode = 3;
 				actTab = i;
-				mouseX = m->x();
+				mouseX = mPosX;
 				emit tabSelected();
 				emit typeChanged(tabValues[actTab].tabType);
 				emit tabMoved(tabValues[actTab].tabPosition);
@@ -213,9 +215,7 @@
 	if ((rulerCode == 0) && (m->button() == Qt::LeftButton))
 	{
 		ParagraphStyle::TabRecord tb;
-		tb.tabPosition = static_cast<double>(m->x() + offset);
-		tb.tabType = 0;
-		tb.tabFillChar = QChar();
+		tb.tabPosition = static_cast<double>(mPosX + offset);
 		tabValues.prepend(tb);
 		actTab = 0;
 		rulerCode = 3;
@@ -227,14 +227,15 @@
 		emit fillCharChanged(tabValues[actTab].tabFillChar);
 		qApp->changeOverrideCursor(QCursor(Qt::SizeHorCursor));
 	}
-	mouseX = m->x();
+	mouseX = mPosX;
 }
 
 void RulerT::mouseReleaseEvent(QMouseEvent *m)
 {
 	mousePressed = false;
 	qApp->restoreOverrideCursor();
-	if ((m->y() < height()) && (m->y() > 0))
+	int mPosY = m->position().y();
+	if ((mPosY < height()) && (mPosY > 0))
 	{
 		if (rulerCode == 3)
 		{
@@ -273,15 +274,17 @@
 {
 	double oldInd;
 	QRect fpo;
-	if ((mousePressed) && (m->y() < height()) && (m->y() > 0) && (m->x() > 0) && (m->x() < width()))
+	int mPosX = m->position().x();
+	int mPosY = m->position().y();
+	if ((mousePressed) && (mPosY < height()) && (mPosY > 0) && (mPosX > 0) && (mPosX < width()))
 	{
 		qApp->changeOverrideCursor(QCursor(Qt::SizeHorCursor));
 		switch (rulerCode)
 		{
 			case 1:
-				firstLine -= mouseX - m->x();
+				firstLine -= mouseX - mPosX;
 				if (firstLine + leftIndent + offset < offset)
-					firstLine += mouseX - m->x();
+					firstLine += mouseX - mPosX;
 				if (firstLine + leftIndent > m_rulerWidth)
 					firstLine  = m_rulerWidth - leftIndent;
 				emit firstLineMoved(firstLine);
@@ -289,7 +292,7 @@
 				break;
 			case 2:
 				oldInd = leftIndent+firstLine;
-				leftIndent -= mouseX - m->x();
+				leftIndent -= mouseX - mPosX;
 				if (leftIndent < 0)
 					leftIndent = 0;
 				if (leftIndent > m_rulerWidth - 1)
@@ -300,7 +303,7 @@
 				repaint();
 				break;
 			case 3:
-				tabValues[actTab].tabPosition -= mouseX - m->x();
+				tabValues[actTab].tabPosition -= mouseX - mPosX;
 				if (tabValues[actTab].tabPosition < 0)
 					tabValues[actTab].tabPosition = 0;
 				if (tabValues[actTab].tabPosition > m_rulerWidth - 1)
@@ -312,10 +315,10 @@
 			default:
 				break;
 		}
-		mouseX = m->x();
+		mouseX = mPosX;
 		return;
 	}
-	if ((!mousePressed) && (m->y() < height()) && (m->y() > 0) && (m->x() > 0) && (m->x() < width()))
+	if ((!mousePressed) && (mPosY < height()) && (mPosY > 0) && (mPosX > 0) && (mPosX < width()))
 	{
 		setCursor(IconManager::instance().loadCursor("tab.png", 3));
 		if (haveInd)
@@ -346,10 +349,8 @@
 			}
 		}
 	}
-	if ((mousePressed) && ((m->y() > height()) || (m->y() < 0) || (m->x() < 0) || (m->x() > width())))
-	{
+	if ((mousePressed) && ((mPosY > height()) || (mPosY < 0) || (mPosX < 0) || (mPosX > width())))
 		qApp->changeOverrideCursor(IconManager::instance().loadCursor("DelPoint.png", 1, 1));
-	}
 }
 
 void RulerT::leaveEvent(QEvent*)




More information about the scribus-commit mailing list