r24549 by jghali - Code cleanup

scribus-commit scribus-commit at lists.scribus.net
Sat Mar 6 12:23:13 UTC 2021


Author: jghali
Date: Sat Mar  6 12:23:13 2021
New Revision: 24549

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

Modified:
    trunk/Scribus/scribus/ui/tabruler.cpp
    trunk/Scribus/scribus/ui/tabruler.h

Modified: trunk/Scribus/scribus/ui/tabruler.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24549&path=/trunk/Scribus/scribus/ui/tabruler.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/tabruler.cpp	(original)
+++ trunk/Scribus/scribus/ui/tabruler.cpp	Sat Mar  6 12:23:13 2021
@@ -33,37 +33,28 @@
 #include "util.h"
 
 RulerT::RulerT(QWidget *pa, int ein, const QList<ParagraphStyle::TabRecord>& Tabs, bool ind, double wid) : QWidget(pa),
-	mousePressed(false),
 	tabValues(Tabs),
 	haveInd(ind),
-	unitIndex(ein),
-	offset(0),
-	actTab(-1),
-	leftIndent(0),
-	firstLine(0),
-	Width(0.0),
-	rulerCode(0),
-	mouseX(0),
-	offsetIncrement(5)
+	unitIndex(ein)
 {
 	QPalette palette;
 	palette.setColor(backgroundRole(), QColor(255,255,255));
 	setPalette(palette);
-	iter = unitRulerGetIter1FromIndex(unitIndex);
-	iter2 = unitRulerGetIter2FromIndex(unitIndex);
+	m_iter = unitRulerGetIter1FromIndex(unitIndex);
+	m_iter2 = unitRulerGetIter2FromIndex(unitIndex);
 
 	setMouseTracking(true);
 	if (wid < 0)
 	{
 		setMinimumSize(QSize(400,25));
 		setMaximumSize(QSize(4000,25));
-		Width = 4000;
+		m_rulerWidth = 4000;
 		resize(400, 25);
 	}
 	else
 	{
-		Width = wid;
-		setMinimumSize(QSize(qMin(static_cast<int>(Width), 400), 25));
+		m_rulerWidth = wid;
+		setMinimumSize(QSize(qMin(static_cast<int>(m_rulerWidth), 400), 25));
 		setMaximumSize(QSize(4000, 25));
 		resize(qMin(static_cast<int>(wid), 400), 25);
 	}
@@ -72,8 +63,8 @@
 void RulerT::setTabs(const QList<ParagraphStyle::TabRecord>& Tabs, int dEin)
 {
 	unitIndex = dEin;
-	iter  = unitRulerGetIter1FromIndex(unitIndex);
-	iter2 = unitRulerGetIter2FromIndex(unitIndex);
+	m_iter  = unitRulerGetIter1FromIndex(unitIndex);
+	m_iter2 = unitRulerGetIter2FromIndex(unitIndex);
 	tabValues = Tabs;
 	actTab    = -1;
 	repaint();
@@ -93,14 +84,14 @@
 	p.setBrush(textColor);
 	p.setFont(font());
 	p.setPen(QPen(textColor, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
-	for (xl = 0; xl < width() + offset; xl += iter)
+	for (xl = 0; xl < width() + offset; xl += m_iter)
 	{
 		if (xl < offset)
 			continue;
 		p.drawLine(qRound(xl), 18, qRound(xl), 24);
 	}
 
-	for (xl = 0; xl < width() + (iter2 / 2) + offset; xl += iter2)
+	for (xl = 0; xl < width() + (m_iter2 / 2) + offset; xl += m_iter2)
 	{
 		if (xl < offset)
 			continue;
@@ -110,10 +101,10 @@
 			case 2:
 			{
 				QString tx;
-				int num1 = static_cast<int>(xl / iter2);
+				int num1 = static_cast<int>(xl / m_iter2);
 				if (num1 != 0)
 					tx = QString::number(num1);
-				double frac = (xl / iter2) - num1;
+				double frac = (xl / m_iter2) - num1;
 				if ((frac > 0.24) && (frac < 0.26))
 					tx += QChar(0xBC);
 				if ((frac > 0.49) && (frac < 0.51))
@@ -124,10 +115,10 @@
 				break;
 			}
 			case 3:
-				p.drawText(qRound(xl + 2), 17, QString::number(xl / iter));
+				p.drawText(qRound(xl + 2), 17, QString::number(xl / m_iter));
 				break;
 			default:
-				p.drawText(qRound(xl + 2), 17, QString::number(xl / iter * 10));
+				p.drawText(qRound(xl + 2), 17, QString::number(xl / m_iter * 10));
 				break;
 		}
 	}
@@ -289,10 +280,10 @@
 		{
 			case 1:
 				firstLine -= mouseX - m->x();
-				if (firstLine+leftIndent+offset < offset)
+				if (firstLine + leftIndent + offset < offset)
 					firstLine += mouseX - m->x();
-				if (firstLine+leftIndent > Width)
-					firstLine  = Width - leftIndent;
+				if (firstLine + leftIndent > m_rulerWidth)
+					firstLine  = m_rulerWidth - leftIndent;
 				emit firstLineMoved(firstLine);
 				repaint();
 				break;
@@ -301,8 +292,8 @@
 				leftIndent -= mouseX - m->x();
 				if (leftIndent < 0)
 					leftIndent = 0;
-				if (leftIndent > Width-1)
-					leftIndent  = Width-1;
+				if (leftIndent > m_rulerWidth - 1)
+					leftIndent  = m_rulerWidth - 1;
 				firstLine = oldInd - leftIndent;
 				emit leftIndentMoved(leftIndent);
 				emit firstLineMoved(firstLine);
@@ -312,8 +303,8 @@
 				tabValues[actTab].tabPosition -= mouseX - m->x();
 				if (tabValues[actTab].tabPosition < 0)
 					tabValues[actTab].tabPosition = 0;
-				if (tabValues[actTab].tabPosition > Width-1)
-					tabValues[actTab].tabPosition = Width-1;
+				if (tabValues[actTab].tabPosition > m_rulerWidth - 1)
+					tabValues[actTab].tabPosition = m_rulerWidth - 1;
 				updateTabList();
 				emit tabMoved(tabValues[actTab].tabPosition);
 				repaint();
@@ -409,7 +400,7 @@
 	offsetIncrement++;
 	if (offsetIncrement > 30)
 		offsetIncrement = 30;
-	if (offset + width() > static_cast<int>(Width))
+	if (offset + width() > static_cast<int>(m_rulerWidth))
 		offset -= 5;
 	repaint();
 }
@@ -476,9 +467,9 @@
 		firstLine = 0-leftIndent;
 		emit firstLineMoved(firstLine);
 	}
-	if (firstLine+leftIndent > Width)
-	{
-		firstLine = Width-leftIndent;
+	if (firstLine+leftIndent > m_rulerWidth)
+	{
+		firstLine = m_rulerWidth - leftIndent;
 		emit firstLineMoved(firstLine);
 	}
 	repaint();
@@ -488,9 +479,9 @@
 {
 	double oldInd = leftIndent + firstLine;
 	leftIndent = t;
-	if (leftIndent > Width-1)
-	{
-		leftIndent  = Width - 1;
+	if (leftIndent > m_rulerWidth - 1)
+	{
+		leftIndent  = m_rulerWidth - 1;
 		emit leftIndentMoved(leftIndent);
 	}
 	firstLine = oldInd - leftIndent;
@@ -506,7 +497,7 @@
 	leftIndentData(nullptr),
 	rightIndentData(nullptr)
 {
-	m_docUnitRatio=unitGetRatioFromIndex(dEin);
+	m_docUnitRatio = unitGetRatioFromIndex(dEin);
 	double ww = (wid < 0) ? 4000 : wid;
 	tabrulerLayout = new QVBoxLayout( this );
 	tabrulerLayout->setContentsMargins(0, 0, 0, 0);

Modified: trunk/Scribus/scribus/ui/tabruler.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24549&path=/trunk/Scribus/scribus/ui/tabruler.h
==============================================================================
--- trunk/Scribus/scribus/ui/tabruler.h	(original)
+++ trunk/Scribus/scribus/ui/tabruler.h	Sat Mar  6 12:23:13 2021
@@ -36,18 +36,17 @@
 	void setTabs(const QList<ParagraphStyle::TabRecord>& Tabs, int dEin);
 	void updateTabList();
 
-	bool mousePressed;
+	bool mousePressed { false };
 	QList<ParagraphStyle::TabRecord> tabValues;
-	bool haveInd;
-	int unitIndex;
-	int offset;
-	int actTab;
-	double leftIndent;
-	double firstLine;
-	double Width;
-	int rulerCode;
-	int mouseX;
-	int offsetIncrement;
+	bool haveInd { false };
+	int unitIndex { 0 };
+	int offset { 0 };
+	int actTab { -1 };
+	double leftIndent { 0.0 };
+	double firstLine { 0.0 };
+	int rulerCode { 0 };
+	int mouseX { 0 };
+	int offsetIncrement { 5 };
 
 public slots:
 	void resetOffsetInc();
@@ -79,7 +78,9 @@
 	virtual void leaveEvent(QEvent*);
 	
 private:
-	double iter, iter2;
+	double m_iter { 10.0 }; // Result of unitRulerGetIter1FromIndex() for point unit
+	double m_iter2 { 100.0 }; // Result of unitRulerGetIter2FromIndex() for point unit
+	double m_rulerWidth { 0.0 };
 };
 
 class SCRIBUS_API Tabruler : public QWidget




More information about the scribus-commit mailing list