diff --git a/src/core/Entry.cpp b/src/core/Entry.cpp index b2b06e7c8..ecc275a28 100644 --- a/src/core/Entry.cpp +++ b/src/core/Entry.cpp @@ -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; } diff --git a/src/core/Entry.h b/src/core/Entry.h index 66b9362a6..ae60b596c 100644 --- a/src/core/Entry.h +++ b/src/core/Entry.h @@ -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) diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index f08b432fe..6e3398c2d 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -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); } diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index cc94ca9a9..819bda5dc 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -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()); diff --git a/tests/gui/TestGui.cpp b/tests/gui/TestGui.cpp index 7d6677601..0c776e021 100644 --- a/tests/gui/TestGui.cpp +++ b/tests/gui/TestGui.cpp @@ -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()