r24550 by jghali - Code cleanup

scribus-commit scribus-commit at lists.scribus.net
Sat Mar 6 12:39:01 UTC 2021


Author: jghali
Date: Sat Mar  6 12:39:01 2021
New Revision: 24550

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24550
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=24550&path=/trunk/Scribus/scribus/ui/tabruler.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/tabruler.cpp	(original)
+++ trunk/Scribus/scribus/ui/tabruler.cpp	Sat Mar  6 12:39:01 2021
@@ -32,10 +32,10 @@
 #include "units.h"
 #include "util.h"
 
-RulerT::RulerT(QWidget *pa, int ein, const QList<ParagraphStyle::TabRecord>& Tabs, bool ind, double wid) : QWidget(pa),
-	tabValues(Tabs),
+RulerT::RulerT(QWidget *pa, int unit, const QList<ParagraphStyle::TabRecord>& tabs, bool ind, double wid) : QWidget(pa),
+	tabValues(tabs),
 	haveInd(ind),
-	unitIndex(ein)
+	unitIndex(unit)
 {
 	QPalette palette;
 	palette.setColor(backgroundRole(), QColor(255,255,255));
@@ -60,12 +60,12 @@
 	}
 }
 
-void RulerT::setTabs(const QList<ParagraphStyle::TabRecord>& Tabs, int dEin)
-{
-	unitIndex = dEin;
+void RulerT::setTabs(const QList<ParagraphStyle::TabRecord>& tabs, int unit)
+{
+	unitIndex = unit;
 	m_iter  = unitRulerGetIter1FromIndex(unitIndex);
 	m_iter2 = unitRulerGetIter2FromIndex(unitIndex);
-	tabValues = Tabs;
+	tabValues = tabs;
 	actTab    = -1;
 	repaint();
 }
@@ -489,15 +489,9 @@
 	repaint();
 }
 
-Tabruler::Tabruler( QWidget* parent, bool haveFirst, int dEin, const QList<ParagraphStyle::TabRecord>& Tabs, double wid ) : QWidget( parent ),
-	firstLineLabel(nullptr),
-	leftIndentLabel(nullptr),
-	rightIndentLabel(nullptr),
-	firstLineData(nullptr),
-	leftIndentData(nullptr),
-	rightIndentData(nullptr)
-{
-	m_docUnitRatio = unitGetRatioFromIndex(dEin);
+Tabruler::Tabruler( QWidget* parent, bool haveFirst, int unit, const QList<ParagraphStyle::TabRecord>& tabs, double wid ): QWidget( parent )
+{
+	m_docUnitRatio = unitGetRatioFromIndex(unit);
 	double ww = (wid < 0) ? 4000 : wid;
 	tabrulerLayout = new QVBoxLayout( this );
 	tabrulerLayout->setContentsMargins(0, 0, 0, 0);
@@ -510,7 +504,7 @@
 	rulerScrollL->setArrowType(Qt::LeftArrow);
 	rulerScrollL->setAutoRepeat( true );
 	layout2->addWidget( rulerScrollL );
-	ruler = new RulerT( this, dEin, Tabs, haveFirst, wid );
+	ruler = new RulerT( this, unit, tabs, haveFirst, wid );
 	ruler->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
 	layout2->addWidget( ruler );
 	rulerScrollR = new QToolButton(this);
@@ -531,7 +525,7 @@
 	typeCombo->addItem( tr( "Comma" ) );
 	typeCombo->addItem( tr( "Center" ) );
 	layout1->addWidget( typeCombo );
-	tabData = new ScrSpinBox( 0, ww / m_docUnitRatio, this, dEin );
+	tabData = new ScrSpinBox( 0, ww / m_docUnitRatio, this, unit );
 	tabData->setValue(0);
 	positionLabel = new QLabel( tr("&Position:"), this );
 	positionLabel->setBuddy(tabData);
@@ -567,14 +561,14 @@
 	indentLayout->setSpacing(6);
 	if (haveFirst)
 	{
-		firstLineData = new ScrSpinBox( -3000, ww / m_docUnitRatio, this, dEin);
+		firstLineData = new ScrSpinBox( -3000, ww / m_docUnitRatio, this, unit);
 		firstLineData->setValue(0);
 		firstLineLabel = new QLabel(this);
 		firstLineLabel->setText("");
 		firstLineLabel->setPixmap(IconManager::instance().loadPixmap("firstline.png"));
 		indentLayout->addWidget( firstLineLabel );
 		indentLayout->addWidget( firstLineData );
-		leftIndentData = new ScrSpinBox( 0, ww / m_docUnitRatio, this, dEin );
+		leftIndentData = new ScrSpinBox( 0, ww / m_docUnitRatio, this, unit);
 		leftIndentData->setValue(0);
 		leftIndentLabel = new QLabel(this);
 		leftIndentLabel->setText("");
@@ -584,7 +578,7 @@
 		rightIndentLabel = new QLabel(this);
 		rightIndentLabel->setText("");
 		rightIndentLabel->setPixmap(IconManager::instance().loadPixmap("rightindent.png"));
-		rightIndentData = new ScrSpinBox(0, ww / m_docUnitRatio, this, dEin);
+		rightIndentData = new ScrSpinBox(0, ww / m_docUnitRatio, this, unit);
 		rightIndentData->setValue(0);
 		indentLayout->addWidget(rightIndentLabel);
 		indentLayout->addWidget(rightIndentData);
@@ -604,7 +598,7 @@
 	tabData->setEnabled(false);
 	tabFillCombo->setEnabled(false);
 	typeCombo->setEnabled(false);
-	if (Tabs.count() == 0)
+	if (tabs.count() == 0)
 		clearButton->setEnabled(false);
 	clearOneButton->setEnabled(false);
 	resize( minimumSizeHint() );
@@ -649,8 +643,7 @@
 	clearButton->setToolTip( tr( "Delete all Tabulators" ) );
 	clearOneButton->setToolTip( tr("Delete selected Tabulator"));
 
-	QString ein = unitGetSuffixFromIndex(dEin);
-	if (dEin == 2)
+	if (unit == SC_INCHES)
 	{
 		if (haveFirst)
 		{
@@ -660,13 +653,6 @@
 		}
 		tabData->setDecimals(4);
 	}
-	if (haveFirst)
-	{
-		firstLineData->setSuffix(ein);
-		leftIndentData->setSuffix(ein);
-		rightIndentData->setSuffix(ein);
-	}
-	tabData->setSuffix(ein);
 	m_haveFirst = haveFirst;
 
 	connect(ScQApp, SIGNAL(iconSetChanged()), this, SLOT(iconSetChange()));
@@ -756,18 +742,18 @@
 	tabData->setSuffix(unitSuffix);
 }
 
-void Tabruler::setTabs(const QList<ParagraphStyle::TabRecord>& Tabs, int dEin)
-{
-	m_docUnitRatio = unitGetRatioFromIndex(dEin);
-	tabData->setNewUnit(dEin);
+void Tabruler::setTabs(const QList<ParagraphStyle::TabRecord>& tabs, int unit)
+{
+	m_docUnitRatio = unitGetRatioFromIndex(unit);
+	tabData->setNewUnit(unit);
 	if (m_haveFirst)
 	{
-		firstLineData->setNewUnit(dEin);
-		leftIndentData->setNewUnit(dEin);
-		rightIndentData->setNewUnit(dEin);
-	}
-	ruler->setTabs(Tabs, dEin);
-	if (Tabs.count() == 0)
+		firstLineData->setNewUnit(unit);
+		leftIndentData->setNewUnit(unit);
+		rightIndentData->setNewUnit(unit);
+	}
+	ruler->setTabs(tabs, unit);
+	if (tabs.count() == 0)
 		clearButton->setEnabled(false);
 	clearOneButton->setEnabled(false);
 	tabData->setEnabled(false);

Modified: trunk/Scribus/scribus/ui/tabruler.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24550&path=/trunk/Scribus/scribus/ui/tabruler.h
==============================================================================
--- trunk/Scribus/scribus/ui/tabruler.h	(original)
+++ trunk/Scribus/scribus/ui/tabruler.h	Sat Mar  6 12:39:01 2021
@@ -7,33 +7,33 @@
 #ifndef TABRULER_H
 #define TABRULER_H
 
-#include <QVariant>
-#include <QWidget>
+#include <QEvent>
+#include <QGridLayout>
 #include <QHBoxLayout>
-#include <QPaintEvent>
-#include <QGridLayout>
 #include <QLabel>
 #include <QMouseEvent>
-#include <QEvent>
+#include <QPaintEvent>
+#include <QVariant>
 #include <QVBoxLayout>
+#include <QWidget>
 
 #include "scribusapi.h"
 #include "sctextstruct.h"
 
 class QComboBox;
 class QPushButton;
+class QToolButton;
 class ScrSpinBox;
-class QToolButton;
 
 class SCRIBUS_API RulerT : public QWidget
 {
 	Q_OBJECT
 
 public:
-	RulerT(QWidget* parent, int ein, const QList<ParagraphStyle::TabRecord>& Tabs, bool ind, double wid);
+	RulerT(QWidget* parent, int unit, const QList<ParagraphStyle::TabRecord>& tabs, bool ind, double wid);
 	~RulerT() {};
 
-	void setTabs(const QList<ParagraphStyle::TabRecord>& Tabs, int dEin);
+	void setTabs(const QList<ParagraphStyle::TabRecord>& tabs, int unit);
 	void updateTabList();
 
 	bool mousePressed { false };
@@ -90,12 +90,12 @@
 public:
 	Tabruler(QWidget* parent,
 			 bool haveFirst = true,
-			 int dEin = 1,
-			 const QList<ParagraphStyle::TabRecord>& Tabs = QList<ParagraphStyle::TabRecord>(),
+			 int unit = 1,
+			 const QList<ParagraphStyle::TabRecord>& tabs = QList<ParagraphStyle::TabRecord>(),
 			 double wid = -1);
 	~Tabruler() {};
 
-	virtual void setTabs(const QList<ParagraphStyle::TabRecord>& Tabs, int dEin);
+	virtual void setTabs(const QList<ParagraphStyle::TabRecord>& tabs, int unit);
 
 	QList<ParagraphStyle::TabRecord> getTabVals();
 	double getFirstLine();




More information about the scribus-commit mailing list