mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2026-11-27 12:27:04 -08:00
Support editing attribute values in a separate text edit.
This commit is contained in:
1 parent
3ab81ea776
commit
1d39368f8d
8 files changed
+210
-15
No files matched your search
@@ -23,6 +23,7 @@
|
||||
EntryAttributesModel::EntryAttributesModel(QObject* parent)
|
||||
: QAbstractListModel(parent)
|
||||
, m_entryAttributes(0)
|
||||
, m_nextRenameDataChange(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -43,6 +44,9 @@ void EntryAttributesModel::setEntryAttributes(EntryAttributes* entryAttributes)
|
||||
connect(m_entryAttributes, SIGNAL(added(QString)), SLOT(attributeAdd()));
|
||||
connect(m_entryAttributes, SIGNAL(aboutToBeRemoved(QString)), SLOT(attributeAboutToRemove(QString)));
|
||||
connect(m_entryAttributes, SIGNAL(removed(QString)), SLOT(attributeRemove()));
|
||||
connect(m_entryAttributes, SIGNAL(aboutToRename(QString,QString)),
|
||||
SLOT(attributeAboutToRename(QString,QString)));
|
||||
connect(m_entryAttributes, SIGNAL(renamed(QString,QString)), SLOT(attributeRename(QString,QString)));
|
||||
connect(m_entryAttributes, SIGNAL(aboutToBeReset()), SLOT(aboutToReset()));
|
||||
connect(m_entryAttributes, SIGNAL(reset()), SLOT(reset()));
|
||||
}
|
||||
@@ -171,6 +175,46 @@ void EntryAttributesModel::attributeRemove()
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
void EntryAttributesModel::attributeAboutToRename(QString oldKey, QString newKey)
|
||||
{
|
||||
int oldRow = m_attributes.indexOf(oldKey);
|
||||
|
||||
QList<QString> rows = m_attributes;
|
||||
rows.removeOne(oldKey);
|
||||
rows.append(newKey);
|
||||
qSort(rows);
|
||||
int newRow = rows.indexOf(newKey);
|
||||
if (newRow > oldRow) {
|
||||
newRow++;
|
||||
}
|
||||
|
||||
if (oldRow != newRow) {
|
||||
bool result = beginMoveRows(QModelIndex(), oldRow, oldRow, QModelIndex(), newRow);
|
||||
Q_UNUSED(result);
|
||||
Q_ASSERT(result);
|
||||
}
|
||||
else {
|
||||
m_nextRenameDataChange = true;
|
||||
}
|
||||
}
|
||||
|
||||
void EntryAttributesModel::attributeRename(QString oldKey, QString newKey)
|
||||
{
|
||||
Q_UNUSED(oldKey);
|
||||
|
||||
updateAttributes();
|
||||
|
||||
if (!m_nextRenameDataChange) {
|
||||
endMoveRows();
|
||||
}
|
||||
else {
|
||||
m_nextRenameDataChange = false;
|
||||
|
||||
QModelIndex keyIndex = index(m_attributes.indexOf(newKey), 0);
|
||||
Q_EMIT dataChanged(keyIndex, keyIndex);
|
||||
}
|
||||
}
|
||||
|
||||
void EntryAttributesModel::aboutToReset()
|
||||
{
|
||||
beginResetModel();
|
||||
|
||||
Reference in new issue
Block a user