r16836 by craig - #10252: When using picas, display them on the status bar location (and also HUD for item creation/resizing)

scribus-commit scribus-commit at lists.scribus.net
Thu Sep 15 21:01:45 UTC 2011


Author: craig
Date: Thu Sep 15 21:01:45 2011
New Revision: 16836

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=16836
Log:
#10252: When using picas, display them on the status bar location (and also HUD for item creation/resizing)

Modified:
    branches/Version135/Scribus/scribus/units.cpp

Modified: branches/Version135/Scribus/scribus/units.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16836&path=/branches/Version135/Scribus/scribus/units.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/units.cpp (original)
+++ branches/Version135/Scribus/scribus/units.cpp Thu Sep 15 21:01:45 2011
@@ -19,6 +19,8 @@
  *                                                                         *
  ***************************************************************************/
 
+#include <cmath>
+#include <QDebug>
 #include <QString>
 #include <QObject>
 #include "units.h"
@@ -364,12 +366,25 @@
 QString value2String(double unitValue, int unitIndex, bool round2Precision, bool appendSuffix)
 {
 	QString s;
-	if (round2Precision)
-		s=QString::number(pts2value(unitValue, unitIndex), 'f', unitGetPrecisionFromIndex(unitIndex));
+	if (unitIndex==SC_PICAS)
+	{
+		int a=(static_cast<int>(unitValue))/12;
+		double b=fabs(fmod(unitValue, 12));
+		QString prefix((a==0 && unitValue < 0.0) ? "-" : "");
+		if (round2Precision)
+			s=QString("%1%2%3%4").arg(prefix).arg(a).arg(unitGetStrFromIndex(unitIndex)).arg(QString::number(b, 'f', unitGetPrecisionFromIndex(unitIndex)));
+		else
+			s=QString("%1%2%3%4").arg(prefix).arg(a).arg(unitGetStrFromIndex(unitIndex)).arg(b);
+	}
 	else
-		s=QString::number(pts2value(unitValue, unitIndex));
-	if (appendSuffix)
-		s += unitGetStrFromIndex(unitIndex);
+	{
+		if (round2Precision)
+			s=QString::number(pts2value(unitValue, unitIndex), 'f', unitGetPrecisionFromIndex(unitIndex));
+		else
+			s=QString::number(pts2value(unitValue, unitIndex));
+		if (appendSuffix)
+			s += " "+unitGetStrFromIndex(unitIndex);
+	}
 	return s;
 }
 




More information about the scribus-commit mailing list