Fix displaying resize widget with small number of sectors.

This commit is contained in:
Andrius Štikonas 2016-07-18 15:08:42 +01:00
parent 254ac012af
commit da0dabc50d
2 changed files with 6 additions and 6 deletions

View File

@ -133,10 +133,10 @@ qint32 PartResizerWidget::handleWidth() const
return style()->pixelMetric(QStyle::PM_SplitterWidth); return style()->pixelMetric(QStyle::PM_SplitterWidth);
} }
qint64 PartResizerWidget::sectorsPerPixel() const long double PartResizerWidget::sectorsPerPixel() const
{ {
//FIXME: Make sure that this function never return 0 //FIXME: Make sure that this function never return 0
return totalSectors() / (width() - 2 * handleWidth()); return totalSectors() / (width() - 2.0L * handleWidth());
} }
int PartResizerWidget::partWidgetStart() const int PartResizerWidget::partWidgetStart() const
@ -286,13 +286,13 @@ void PartResizerWidget::mouseMoveEvent(QMouseEvent* event)
int x = event->pos().x() - m_Hotspot; int x = event->pos().x() - m_Hotspot;
if (draggedWidget() == &leftHandle()) { if (draggedWidget() == &leftHandle()) {
const qint64 newFirstSector = qMax(minimumFirstSector() + x * sectorsPerPixel(), 0LL); const qint64 newFirstSector = qMax(minimumFirstSector() + x * sectorsPerPixel(), 0.0L);
updateFirstSector(newFirstSector); updateFirstSector(newFirstSector);
} else if (draggedWidget() == &rightHandle()) { } else if (draggedWidget() == &rightHandle()) {
const qint64 newLastSector = qMin(minimumFirstSector() + (x - rightHandle().width()) * sectorsPerPixel(), maximumLastSector()); const qint64 newLastSector = qMin(static_cast<qint64>(minimumFirstSector() + (x - rightHandle().width()) * sectorsPerPixel()), maximumLastSector());
updateLastSector(newLastSector); updateLastSector(newLastSector);
} else if (draggedWidget() == &partWidget() && moveAllowed()) { } else if (draggedWidget() == &partWidget() && moveAllowed()) {
const qint64 newFirstSector = qMax(minimumFirstSector() + (x - handleWidth()) * sectorsPerPixel(), 0LL); const qint64 newFirstSector = qMax(minimumFirstSector() + (x - handleWidth()) * sectorsPerPixel(), 0.0L);
movePartition(newFirstSector); movePartition(newFirstSector);
} }
} }

View File

@ -169,7 +169,7 @@ protected:
return m_RightHandle; return m_RightHandle;
} }
qint64 sectorsPerPixel() const; long double sectorsPerPixel() const;
void set(qint64 newCap, qint64 newFreeBefore, qint64 newFreeAfter); void set(qint64 newCap, qint64 newFreeBefore, qint64 newFreeAfter);