diff --git a/src/core/partitiontable.cpp b/src/core/partitiontable.cpp index 23c62e7..f871d07 100644 --- a/src/core/partitiontable.cpp +++ b/src/core/partitiontable.cpp @@ -89,6 +89,17 @@ qint64 PartitionTable::freeSectorsAfter(const Partition& p) const return 0; } +qint64 PartitionTable::freeSectors() const +{ + qint64 sectors = 0; + foreach(const Partition * p, children()) + if (p->roles().has(PartitionRole::Unallocated)) { + sectors += p->length(); + } + + return sectors; +} + /** @return true if the PartitionTable has an extended Partition */ bool PartitionTable::hasExtended() const { diff --git a/src/core/partitiontable.h b/src/core/partitiontable.h index aebc15b..eb83c5c 100644 --- a/src/core/partitiontable.h +++ b/src/core/partitiontable.h @@ -126,6 +126,7 @@ public: qint64 freeSectorsBefore(const Partition& p) const; qint64 freeSectorsAfter(const Partition& p) const; + qint64 freeSectors() const; bool hasExtended() const; Partition* extended() const; diff --git a/src/gui/partresizerwidget.cpp b/src/gui/partresizerwidget.cpp index e7efc60..564f93d 100644 --- a/src/gui/partresizerwidget.cpp +++ b/src/gui/partresizerwidget.cpp @@ -135,6 +135,7 @@ qint32 PartResizerWidget::handleWidth() const qint64 PartResizerWidget::sectorsPerPixel() const { + //FIXME: Make sure that this function never return 0 return totalSectors() / (width() - 2 * handleWidth()); }