Commit 1057f224 authored by Toni Asensi Esteve's avatar Toni Asensi Esteve

Avoid 'conversion may change value' cases in code related to graphs

Revision: !24
parent 031fa025
......@@ -136,7 +136,7 @@ void KrFSDisplay::paintEvent(QPaintEvent *)
// top of the pie
paint.drawPie(margins.left() + LEFT, margins.top() + BOTTOM - Z_HEIGHT, WIDTH, HEIGHT, STARTANGLE, DEG(360));
// the "used space" slice
float i = ((float)(totalSpace - freeSpace) / (totalSpace)) * 360.0;
long double i = (static_cast<long double>(totalSpace - freeSpace) / totalSpace) * 360.0;
paint.setBrush(Qt::gray);
paint.drawPie(margins.left() + LEFT, margins.top() + BOTTOM - Z_HEIGHT, WIDTH, HEIGHT, STARTANGLE, (int) DEG(i));
// if we need to draw a 3d stripe ...
......@@ -166,12 +166,12 @@ void KrPie::paintEvent(QPaintEvent *)
{
QPainter paint(this);
// now create the slices
float sAngle = STARTANGLE;
long double sAngle = STARTANGLE;
for (int ndx = 0; ndx != slices.count(); ndx++) {
paint.setBrush(slices[ndx].getColor());
paint.setPen(slices[ndx].getColor());
// angles are negative to create a clock-wise drawing of slices
float angle = -(slices[ndx].getPerct() / 100 * 360) * 16;
long double angle = -(slices[ndx].getPerct() / 100 * 360) * 16;
for (int i = 1; i < Z_HEIGHT; ++i)
paint.drawPie(LEFT, BOTTOM + i, WIDTH, HEIGHT, (int) sAngle, (int) angle);
sAngle += angle;
......@@ -185,7 +185,7 @@ void KrPie::paintEvent(QPaintEvent *)
paint.setBrush(slices[ndx].getColor());
paint.setPen(slices[ndx].getColor());
// angles are negative to create a clock-wise drawing of slices
float angle = -(slices[ndx].getPerct() / 100 * 360) * 16;
long double angle = -(slices[ndx].getPerct() / 100 * 360) * 16;
paint.drawPie(LEFT, BOTTOM, WIDTH, HEIGHT, (int) sAngle, (int) angle);
sAngle += angle;
}
......
......@@ -100,12 +100,12 @@ private:
class KrPieSlice
{
public:
KrPieSlice(float _perct, QColor _color, QString _label) :
KrPieSlice(long double _perct, QColor _color, QString _label) :
perct(_perct), color(std::move(_color)), label(std::move(_label)) {}
inline QColor getColor() {
return color;
}
inline float getPerct() {
inline long double getPerct() {
return perct;
}
inline QString getLabel() {
......@@ -119,7 +119,7 @@ public:
}
private:
float perct;
long double perct;
QColor color;
QString label;
};
......
......@@ -34,7 +34,7 @@
RadialMap::Builder::Builder(RadialMap::Map *m, const Directory* const d, bool fast)
: m_map(m)
, m_root(d)
, m_minSize(static_cast<FileSize>((d->size() * 3) / (PI * m->height() - m->MAP_2MARGIN)))
, m_minSize(static_cast<FileSize>(static_cast<long double>(d->size() * 3) / (PI * m->height() - m->MAP_2MARGIN)))
, m_depth(&m->m_visibleDepth)
{
m_signature = new Chain<Segment> [*m_depth + 1];
......@@ -84,13 +84,13 @@ RadialMap::Builder::findVisibleDepth(const Directory* const dir, const unsigned
void
RadialMap::Builder::setLimits(const uint &b) //b = breadth?
{
double size3 = m_root->size() * 3;
double pi2B = PI * 2 * b;
long double size3 = m_root->size() * 3;
long double pi2B = PI * 2 * b;
m_limits = new FileSize [*m_depth + 1]; //FIXME delete!
for (unsigned int d = 0; d <= *m_depth; ++d)
m_limits[d] = (FileSize)(size3 / (double)(pi2B * (d + 1))); //min is angle that gives 3px outer diameter for that depth
m_limits[d] = static_cast<FileSize>(size3 / (pi2B * (d + 1))); //min is angle that gives 3px outer diameter for that depth
}
......
......@@ -65,7 +65,7 @@ RadialMap::Map::invalidate(const bool desaturateTheImage)
if (desaturateTheImage) {
QImage img = this->toImage();
KIconEffect::deSaturate(img, 0.7);
KIconEffect::deSaturate(img, 0.7f);
KIconEffect::toGray(img, true);
this->QPixmap::operator=(fromImage(img, Qt::AutoColor));
......
......@@ -115,7 +115,7 @@ SegmentTip::updateTip(const File* const file, const Directory* const root)
QString s2 = file->humanReadableSize();
QLocale loc;
const uint MARGIN = 3;
const uint pc = 100 * file->size() / root->size();
const FileSize pc = 100 * file->size() / root->size();
uint maxw = 0;
uint h = fontMetrics().height() * 2 + 2 * MARGIN;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment