Process correctly the return value of the confirm dialog.

Update the backup usage label after deleting an entry.
Update the parent metadata size after deleting a node.
This commit is contained in:
codestation
2013-08-29 12:28:40 -04:30
parent b34b2f63f4
commit e44c3bca28
5 changed files with 17 additions and 9 deletions

View File

@@ -61,12 +61,7 @@ void BackupManagerForm::removeEntry(BackupItem *item)
msgBox.setMessageText(tr("Are you sure to remove the backup of the following entry?"), item->title);
msgBox.setMessagePixmap(*item->getIconPixmap(), item->getIconWidth());
switch(msgBox.exec()) {
case QDialogButtonBox::Ok:
break;
case QDialogButtonBox::Cancel:
return;
default:
if(msgBox.exec() == 0) {
return;
}
@@ -78,6 +73,15 @@ void BackupManagerForm::removeEntry(BackupItem *item)
db->remove(obj);
}
ui->tableWidget->removeRow(item->row);
obj = db->ohfiToObject(obj->metadata.ohfiParent);
if(obj) {
setBackupUsage(obj->metadata.size);
}
}
void BackupManagerForm::setBackupUsage(quint64 size)
{
ui->usageLabel->setText(tr("Backup disk usage: %1").arg(readable_size(size, true)));
}
void BackupManagerForm::loadBackupListing(int index)
@@ -138,7 +142,7 @@ void BackupManagerForm::loadBackupListing(int index)
horiz_header->setResizeMode(QHeaderView::Stretch);
CMAObject *obj = db->ohfiToObject(ohfi);
ui->usageLabel->setText(tr("Backup disk usage: %1").arg(readable_size(obj->metadata.size, true)));
setBackupUsage(obj->metadata.size);
QList<BackupItem *> item_list;

View File

@@ -41,6 +41,7 @@ public:
private:
void setupForm();
void setBackupUsage(quint64 size);
Ui::BackupManagerForm *ui;

View File

@@ -184,11 +184,12 @@ bool CMAObject::removeReferencedObject()
}
}
void CMAObject::updateObjectSize(unsigned long size)
void CMAObject::updateObjectSize(qint64 size)
{
if(parent) {
parent->updateObjectSize(size);
}
//FIXME: size should be quint64
metadata.size += size;
}

View File

@@ -37,7 +37,7 @@ public:
void rename(const QString &name);
bool removeReferencedObject();
void initObject(const QFileInfo &file);
void updateObjectSize(unsigned long size);
void updateObjectSize(qint64 size);
bool hasParent(const CMAObject *obj);
bool operator==(const CMAObject &obj);

View File

@@ -181,6 +181,8 @@ bool Database::removeInternal(root_list &list, const CMAObject *obj)
while(it != list.end()) {
if(!found && (*it) == obj) {
// update the size of the parent objects
(*it)->updateObjectSize(-(*it)->metadata.size);
it = list.erase(it);
found = true;
} else if(found && (*it)->metadata.ohfiParent == obj->metadata.ohfi) {