Add group clone action

Close #3796
This commit is contained in:
Stuzer05 2021-02-15 17:10:02 +02:00 committed by Jonathan White
parent bc5d0df19e
commit 304cb44d0d
9 changed files with 43 additions and 0 deletions

View file

@ -826,6 +826,19 @@ void DatabaseWidget::createGroup()
switchToGroupEdit(m_newGroup.data(), true);
}
void DatabaseWidget::cloneGroup()
{
Group* currentGroup = m_groupView->currentGroup();
Q_ASSERT(currentGroup && canCloneCurrentGroup());
if (!currentGroup || !canCloneCurrentGroup()) {
return;
}
m_newGroup.reset(currentGroup->clone(Entry::CloneCopy, Group::CloneDefault | Group::CloneRenameTitle));
m_newParent = currentGroup->parentGroup();
switchToGroupEdit(m_newGroup.data(), true);
}
void DatabaseWidget::deleteGroup()
{
Group* currentGroup = m_groupView->currentGroup();
@ -1375,6 +1388,14 @@ void DatabaseWidget::onEntryChanged(Entry* entry)
emit entrySelectionChanged();
}
bool DatabaseWidget::canCloneCurrentGroup() const
{
bool isRootGroup = m_db->rootGroup() == m_groupView->currentGroup();
// bool isRecycleBin = isRecycleBinSelected();
return !isRootGroup;
}
bool DatabaseWidget::canDeleteCurrentGroup() const
{
bool isRootGroup = m_db->rootGroup() == m_groupView->currentGroup();