Merge pull request #219 from keepassxreboot/feature/search-clone-entry

Clone an entry when in search mode
This commit is contained in:
Janek Bevendorff 2017-01-26 04:21:52 +02:00 committed by GitHub
commit e826309d59
5 changed files with 9 additions and 5 deletions

View File

@ -508,7 +508,8 @@ Entry* Entry::clone(CloneFlags flags) const
entry->m_data.timeInfo.setLocationChanged(now);
}
if (flags & CloneRenameTitle)
entry->setTitle(entry->title() + tr(" - Clone"));
return entry;
}

View File

@ -115,7 +115,8 @@ public:
CloneNoFlags = 0,
CloneNewUuid = 1, // generate a random uuid for the clone
CloneResetTimeInfo = 2, // set all TimeInfo attributes to the current time
CloneIncludeHistory = 4 // clone the history items
CloneIncludeHistory = 4, // clone the history items
CloneRenameTitle = 8 // add "-Clone" after the original title
};
Q_DECLARE_FLAGS(CloneFlags, CloneFlag)

View File

@ -312,8 +312,10 @@ void DatabaseWidget::cloneEntry()
return;
}
Entry* entry = currentEntry->clone(Entry::CloneNewUuid | Entry::CloneResetTimeInfo);
Entry* entry = currentEntry->clone(Entry::CloneNewUuid | Entry::CloneResetTimeInfo | Entry::CloneRenameTitle);
entry->setGroup(currentEntry->group());
if (isInSearchMode())
search(m_lastSearchText);
m_entryView->setFocus();
m_entryView->setCurrentEntry(entry);
}

View File

@ -364,7 +364,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
bool groupSelected = dbWidget->isGroupSelected();
m_ui->actionEntryNew->setEnabled(!inSearch);
m_ui->actionEntryClone->setEnabled(singleEntrySelected && !inSearch);
m_ui->actionEntryClone->setEnabled(singleEntrySelected);
m_ui->actionEntryEdit->setEnabled(singleEntrySelected);
m_ui->actionEntryDelete->setEnabled(entriesSelected);
m_ui->actionEntryCopyTitle->setEnabled(singleEntrySelected && dbWidget->currentEntryHasTitle());

View File

@ -566,7 +566,7 @@ void TestGui::testCloneEntry()
QCOMPARE(entryView->model()->rowCount(), 2);
Entry* entryClone = entryView->entryFromIndex(entryView->model()->index(1, 1));
QVERIFY(entryOrg->uuid() != entryClone->uuid());
QCOMPARE(entryClone->title(), entryOrg->title());
QCOMPARE(entryClone->title(), entryOrg->title() + QString(" - Clone"));
}
void TestGui::testDragAndDropEntry()