Commit 6e20a6ae authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Make sure that quota value was defined

parent 17197c84
Pipeline #77661 passed with stage
in 24 minutes and 16 seconds
......@@ -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<Akonadi::Collection>();
if (collectionFirst.isValid() && collectionFirst.hasAttribute<Akonadi::CollectionQuotaAttribute>()) {
const auto *quota = collectionFirst.attribute<Akonadi::CollectionQuotaAttribute>();
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<Akonadi::Collection>();
if (collectionFirst.isValid() && collectionFirst.hasAttribute<Akonadi::CollectionQuotaAttribute>()) {
const auto *quota = collectionFirst.attribute<Akonadi::CollectionQuotaAttribute>();
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;
......
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