r22914 by jghali - More cleanup for ScrSpinBox code

scribus-commit scribus-commit at lists.scribus.net
Tue Mar 26 23:33:33 UTC 2019


Author: jghali
Date: Tue Mar 26 23:33:33 2019
New Revision: 22914

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22914
Log:
More cleanup for ScrSpinBox code

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

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22914&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp	(original)
+++ trunk/Scribus/scribus/scribus.cpp	Tue Mar 26 23:33:33 2019
@@ -1249,7 +1249,6 @@
 	zoomLayout->setSpacing(1);
 
 	zoomSpinBox = new ScrSpinBox( 1, 32000, zoomWidget, 6 );
-	zoomSpinBox->setTabAdvance(false);
 	zoomSpinBox->setFont(fo);
 	zoomSpinBox->setValue( 100 );
 	zoomSpinBox->setSingleStep(10);

Modified: trunk/Scribus/scribus/ui/scrspinbox.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22914&path=/trunk/Scribus/scribus/ui/scrspinbox.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/scrspinbox.cpp	(original)
+++ trunk/Scribus/scribus/ui/scrspinbox.cpp	Tue Mar 26 23:33:33 2019
@@ -39,7 +39,6 @@
 void ScrSpinBox::init(int unitIndex)
 {
 	m_unitIndex = unitIndex;
-	m_tabAdvance = true;
 	setSuffix(unitGetSuffixFromIndex(m_unitIndex));
 	setDecimals(unitGetPrecisionFromIndex(m_unitIndex));
 	setSingleStep(1.0);
@@ -123,7 +122,7 @@
 	setValue(val);
 }
 
-void ScrSpinBox::getValues(double *min, double *max, int *deci, double *val)
+void ScrSpinBox::getValues(double *min, double *max, int *deci, double *val) const
 {
 	*deci = decimals();
 	*min = minimum();
@@ -131,10 +130,10 @@
 	*val = value();
 }
 
-double ScrSpinBox::getValue(int unitIndex)
+double ScrSpinBox::getValue(int unitIndex) const
 {
 	double val=value() / unitGetRatioFromIndex(m_unitIndex);
-	if (unitIndex==0)
+	if (unitIndex == 0)
 		return val;
 	return val * unitGetRatioFromIndex(unitIndex);
 }
@@ -155,9 +154,9 @@
 		ts.replace(CommonStrings::trStrP, CommonStrings::strP);
 	QRegExp rxP;
 	if (m_unitIndex==SC_PICAS)
-		rxP.setPattern("\\b(\\d+)"+CommonStrings::strP+"?(\\d+\\.?\\d*)?\\b");
+		rxP.setPattern("\\b(\\d+)" + CommonStrings::strP + "?(\\d+\\.?\\d*)?\\b");
 	else
-		rxP.setPattern("\\b(\\d+)"+CommonStrings::strP+"(\\d+\\.?\\d*)?\\b");
+		rxP.setPattern("\\b(\\d+)" + CommonStrings::strP + "(\\d+\\.?\\d*)?\\b");
 	int posP = 0;
 	while (posP >= 0)
 	{
@@ -202,10 +201,10 @@
 		pos = ts.lastIndexOf(cSepDecimal, pos);
 		if (pos >= 0) 
 		{
-			if (pos < static_cast<int>(ts.length()))
+			if (pos < ts.length())
 			{
-				if (!ts[pos+1].isDigit())
-					ts.insert(pos+1, "0 ");
+				if (!ts[pos + 1].isDigit())
+					ts.insert(pos + 1, "0 ");
 			}
 			pos--;
 		}
@@ -267,10 +266,10 @@
 
 QString ScrSpinBox::textFromValue(double value) const
 {
-	if (m_unitIndex==SC_PICAS)
+	if (m_unitIndex == SC_PICAS)
 	{
 // 		QString r=QString("%1%2%3").arg((static_cast<int>(value))/12).arg(unitGetStrFromIndex(m_unitIndex)).arg(fabs(fmod(value, 12)));
-		int a = (static_cast<int>(value))/12;
+		int a = (static_cast<int>(value)) / 12;
 		double b = fabs(fmod(value, 12));
 		QString prefix((a==0 && value < 0.0) ? "-" : "");
 		return QString("%1%2%3%4").arg(prefix).arg(a).arg(unitGetStrFromIndex(m_unitIndex)).arg(b);
@@ -291,7 +290,6 @@
 	if (!input.endsWith(FinishTag))
 		input += FinishTag;
 }
-
 
 void ScrSpinBox::textChanged()
 {
@@ -338,8 +336,3 @@
 
 	return QDoubleSpinBox::eventFilter(watched, event);
 }
-
-void ScrSpinBox::setTabAdvance(bool enable)
-{
-	m_tabAdvance = enable;
-}

Modified: trunk/Scribus/scribus/ui/scrspinbox.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22914&path=/trunk/Scribus/scribus/ui/scrspinbox.h
==============================================================================
--- trunk/Scribus/scribus/ui/scrspinbox.h	(original)
+++ trunk/Scribus/scribus/ui/scrspinbox.h	Tue Mar 26 23:33:33 2019
@@ -39,8 +39,7 @@
 		void init(int unitIndex);
 		void setConstants(const QMap<QString, double>* constants);
 		void setNewUnit(int unitIndex);
-		double getValue(int unitIndex=0);
-		void setTabAdvance(bool enable);
+		double getValue(int unitIndex=0) const;
 
 		uint   unitIndex() const { return m_unitIndex; }
 		double unitRatio() const;
@@ -49,16 +48,16 @@
 		void stepBy(int steps) override;
 		
 	public slots:
-		void setValues(double min, double max, int deci, double val);
-		void getValues(double *min, double *max, int *deci, double *val);
+		void getValues(double *min, double *max, int *deci, double *val) const;
 		void setValue(int val);
 		void setValue(double val);
+		void setValues(double min, double max, int deci, double val);
 	
 	protected:
-		void setParameters( int s );
 		uint m_unitIndex;
-		bool m_tabAdvance;
 		const QMap<QString, double>* m_constants;
+
+		void setParameters(int s);
 		bool eventFilter ( QObject * watched, QEvent * event );
 		
 	protected slots:




More information about the scribus-commit mailing list