mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-02-25 08:51:21 -05:00
Fix failing entry model test for attachment name and size
This commit is contained in:
parent
0c200d360b
commit
ed0bda98a6
@ -86,17 +86,20 @@ QVariant EntryAttachmentsModel::data(const QModelIndex& index, int role) const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole || role == Qt::EditRole) {
|
||||||
QString key = keyByIndex(index);
|
const QString key = keyByIndex(index);
|
||||||
switch (index.column()) {
|
const int column = index.column();
|
||||||
case Columns::NameColumn:
|
if (column == Columns::NameColumn) {
|
||||||
return key;
|
return key;
|
||||||
case Columns::SizeColumn:
|
} else if (column == SizeColumn) {
|
||||||
return Tools::humanReadableFileSize(m_entryAttachments->value(key).size());
|
const int attachmentSize = m_entryAttachments->value(key).size();
|
||||||
default:
|
if (role == Qt::DisplayRole) {
|
||||||
break;
|
return Tools::humanReadableFileSize(attachmentSize);
|
||||||
|
}
|
||||||
|
return attachmentSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,9 +122,11 @@ void TestEntryModel::testAttachmentsModel()
|
|||||||
entryAttachments->set("first", QByteArray("123"));
|
entryAttachments->set("first", QByteArray("123"));
|
||||||
|
|
||||||
entryAttachments->set("2nd", QByteArray("456"));
|
entryAttachments->set("2nd", QByteArray("456"));
|
||||||
entryAttachments->set("2nd", QByteArray("789"));
|
entryAttachments->set("2nd", QByteArray("7890"));
|
||||||
|
|
||||||
QCOMPARE(model->data(model->index(0, 0)).toString().left(4), QString("2nd "));
|
const int firstRow = 0;
|
||||||
|
QCOMPARE(model->data(model->index(firstRow, EntryAttachmentsModel::NameColumn)).toString(), QString("2nd"));
|
||||||
|
QCOMPARE(model->data(model->index(firstRow, EntryAttachmentsModel::SizeColumn), Qt::EditRole).toInt(), 4);
|
||||||
|
|
||||||
entryAttachments->remove("first");
|
entryAttachments->remove("first");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user