From 0ab8227d943801dc4b6cbbc11f6c82a67439b57e Mon Sep 17 00:00:00 2001 From: Chantara Tith Date: Wed, 29 Jun 2016 17:37:21 +0700 Subject: [PATCH] Add freeSetors for partitionTable --- src/core/partitiontable.cpp | 11 +++++++++++ src/core/partitiontable.h | 1 + src/gui/partresizerwidget.cpp | 1 + 3 files changed, 13 insertions(+) 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()); }