mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2026-11-27 20:36:49 -08:00
1 parent
e53850627f
commit
bbdfbe64da
7 files changed
+64
No files matched your search
@@ -101,6 +101,28 @@ QVariant EntryAttachmentsModel::data(const QModelIndex& index, int role) const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool EntryAttachmentsModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
{
|
||||
if (!m_readOnly && index.column() == Columns::NameColumn) {
|
||||
const QString key = value.toString().trimmed();
|
||||
if (key.isEmpty() || m_entryAttachments->hasKey(key)) {
|
||||
return false;
|
||||
}
|
||||
m_entryAttachments->rename(keyByIndex(index), key);
|
||||
return true;
|
||||
}
|
||||
return QAbstractListModel::setData(index, value, role);
|
||||
}
|
||||
|
||||
Qt::ItemFlags EntryAttachmentsModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
Qt::ItemFlags flags = QAbstractListModel::flags(index);
|
||||
if (!m_readOnly && index.column() == Columns::NameColumn) {
|
||||
flags = flags | Qt::ItemIsEditable;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
QString EntryAttachmentsModel::keyByIndex(const QModelIndex& index) const
|
||||
{
|
||||
if (!index.isValid()) {
|
||||
@@ -150,3 +172,8 @@ void EntryAttachmentsModel::reset()
|
||||
{
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void EntryAttachmentsModel::setReadOnly(bool readOnly)
|
||||
{
|
||||
m_readOnly = readOnly;
|
||||
}
|
||||
Reference in new issue
Block a user