mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-13 16:30:29 -05:00
Add entry clone functionality.
This commit is contained in:
parent
7ebee78c75
commit
eb82df5994
@ -413,6 +413,19 @@ void Entry::truncateHistory() {
|
||||
}
|
||||
}
|
||||
|
||||
Entry* Entry::clone() const
|
||||
{
|
||||
Entry* entry = new Entry();
|
||||
entry->setUpdateTimeinfo(false);
|
||||
entry->m_uuid = m_uuid;
|
||||
entry->m_data = m_data;
|
||||
*entry->m_attributes = *m_attributes;
|
||||
*entry->m_attachments = *m_attachments;
|
||||
entry->setUpdateTimeinfo(true);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
void Entry::beginUpdate()
|
||||
{
|
||||
Q_ASSERT(!m_tmpHistoryItem);
|
||||
|
@ -117,6 +117,7 @@ public:
|
||||
const QList<Entry*>& historyItems() const;
|
||||
void addHistoryItem(Entry* entry);
|
||||
void truncateHistory();
|
||||
Entry* clone() const;
|
||||
|
||||
/**
|
||||
* Call before and after set*() methods to create a history item
|
||||
|
@ -334,6 +334,11 @@ void DatabaseTabWidget::createEntry()
|
||||
currentDatabaseWidget()->createEntry();
|
||||
}
|
||||
|
||||
void DatabaseTabWidget::cloneEntry()
|
||||
{
|
||||
currentDatabaseWidget()->cloneEntry();
|
||||
}
|
||||
|
||||
void DatabaseTabWidget::editEntry()
|
||||
{
|
||||
currentDatabaseWidget()->switchToEntryEdit();
|
||||
|
@ -65,6 +65,7 @@ public Q_SLOTS:
|
||||
void changeMasterKey();
|
||||
void changeDatabaseSettings();
|
||||
void createEntry();
|
||||
void cloneEntry();
|
||||
void editEntry();
|
||||
void deleteEntry();
|
||||
void createGroup();
|
||||
|
@ -156,6 +156,16 @@ void DatabaseWidget::createEntry()
|
||||
switchToEntryEdit(m_newEntry, true);
|
||||
}
|
||||
|
||||
void DatabaseWidget::cloneEntry()
|
||||
{
|
||||
Entry* currentEntry = m_entryView->currentEntry();
|
||||
Entry* entry = currentEntry->clone();
|
||||
entry->setUuid(Uuid::random());
|
||||
entry->setGroup(currentEntry->group());
|
||||
m_entryView->setFocus();
|
||||
m_entryView->setCurrentEntry(entry);
|
||||
}
|
||||
|
||||
void DatabaseWidget::deleteEntry()
|
||||
{
|
||||
bool inRecylceBin = Tools::hasChild(m_db->metadata()->recycleBin(), m_entryView->currentEntry());
|
||||
|
@ -49,8 +49,10 @@ public:
|
||||
GroupView* groupView();
|
||||
EntryView* entryView();
|
||||
bool dbHasKey();
|
||||
void cloneEntry();
|
||||
void deleteEntry();
|
||||
void deleteGroup();
|
||||
|
||||
bool canDeleteCurrentGoup();
|
||||
int addWidget(QWidget* w);
|
||||
void setCurrentIndex(int index);
|
||||
|
@ -71,6 +71,8 @@ MainWindow::MainWindow()
|
||||
|
||||
connect(m_ui->actionEntryNew, SIGNAL(triggered()), m_ui->tabWidget,
|
||||
SLOT(createEntry()));
|
||||
connect(m_ui->actionEntryClone, SIGNAL(triggered()), m_ui->tabWidget,
|
||||
SLOT(cloneEntry()));
|
||||
connect(m_ui->actionEntryEdit, SIGNAL(triggered()), m_ui->tabWidget,
|
||||
SLOT(editEntry()));
|
||||
connect(m_ui->actionEntryDelete, SIGNAL(triggered()), m_ui->tabWidget,
|
||||
@ -114,6 +116,13 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
|
||||
else {
|
||||
m_ui->actionEntryNew->setEnabled(true);
|
||||
}
|
||||
if (dbWidget->entryView()->inSearch() ||
|
||||
!dbWidget->entryView()->currentIndex().isValid()) {
|
||||
m_ui->actionEntryClone->setEnabled(false);
|
||||
}
|
||||
else {
|
||||
m_ui->actionEntryClone->setEnabled(true);
|
||||
}
|
||||
|
||||
if (dbWidget->entryView()->currentIndex().isValid()) {
|
||||
m_ui->actionEntryEdit->setEnabled(true);
|
||||
@ -147,6 +156,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
|
||||
case DatabaseWidget::EditMode:
|
||||
m_ui->actionEntryNew->setEnabled(false);
|
||||
m_ui->actionGroupNew->setEnabled(false);
|
||||
m_ui->actionEntryClone->setEnabled(false);
|
||||
m_ui->actionEntryEdit->setEnabled(false);
|
||||
m_ui->actionGroupEdit->setEnabled(false);
|
||||
m_ui->actionEntryDelete->setEnabled(false);
|
||||
@ -164,6 +174,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
|
||||
else {
|
||||
m_ui->actionEntryNew->setEnabled(false);
|
||||
m_ui->actionGroupNew->setEnabled(false);
|
||||
m_ui->actionEntryClone->setEnabled(false);
|
||||
m_ui->actionEntryEdit->setEnabled(false);
|
||||
m_ui->actionGroupEdit->setEnabled(false);
|
||||
m_ui->actionEntryDelete->setEnabled(false);
|
||||
|
@ -36,7 +36,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>21</height>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
@ -67,6 +67,7 @@
|
||||
<string>Entries</string>
|
||||
</property>
|
||||
<addaction name="actionEntryNew"/>
|
||||
<addaction name="actionEntryClone"/>
|
||||
<addaction name="actionEntryEdit"/>
|
||||
<addaction name="actionEntryDelete"/>
|
||||
</widget>
|
||||
@ -216,6 +217,11 @@
|
||||
<string>Import KeePass 1 database</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEntryClone">
|
||||
<property name="text">
|
||||
<string>Clone entry</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
Loading…
Reference in New Issue
Block a user