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