From 6e20a6ae0b48dd69a110f65536d704490e7aab2d Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Wed, 1 Sep 2021 08:34:18 +0200 Subject: [PATCH] Make sure that quota value was defined --- src/folder/foldertreewidgetproxymodel.cpp | 30 ++++++++++++----------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/folder/foldertreewidgetproxymodel.cpp b/src/folder/foldertreewidgetproxymodel.cpp index 4db0589..b6a6123 100644 --- a/src/folder/foldertreewidgetproxymodel.cpp +++ b/src/folder/foldertreewidgetproxymodel.cpp @@ -35,19 +35,21 @@ public: bool checkQuotaExcedded(const QModelIndex &index, qreal &percentage) { - if (index.model()->hasChildren(index)) { - const int rowCount = index.model()->rowCount(index); - for (int row = 0; row < rowCount; row++) { - const QModelIndex firstIndex = q->mapToSource(index.model()->index(row, 0, index)); - - const auto collectionFirst = q->sourceModel()->data(firstIndex, Akonadi::EntityTreeModel::CollectionRole).value(); - if (collectionFirst.isValid() && collectionFirst.hasAttribute()) { - const auto *quota = collectionFirst.attribute(); - - if (quota->currentValue() > -1 && quota->maximumValue() > 0) { - percentage = (100.0 * quota->currentValue()) / quota->maximumValue(); - if (percentage >= threshold) { - return true; + if (threshold >= 0.0) { + if (index.model()->hasChildren(index)) { + const int rowCount = index.model()->rowCount(index); + for (int row = 0; row < rowCount; row++) { + const QModelIndex firstIndex = q->mapToSource(index.model()->index(row, 0, index)); + + const auto collectionFirst = q->sourceModel()->data(firstIndex, Akonadi::EntityTreeModel::CollectionRole).value(); + if (collectionFirst.isValid() && collectionFirst.hasAttribute()) { + const auto *quota = collectionFirst.attribute(); + + if (quota->currentValue() > -1 && quota->maximumValue() > 0) { + percentage = (100.0 * quota->currentValue()) / quota->maximumValue(); + if (percentage >= threshold) { + return true; + } } } } @@ -60,7 +62,7 @@ public: Akonadi::MimeTypeChecker checker; QColor brokenAccountColor; - qreal threshold = 0.0; + qreal threshold = -1.0; FolderTreeWidgetProxyModel *const q; bool enableCheck = false; bool hideVirtualFolder = false;