mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-19 03:01:32 -05:00
Support setting a new parent group with an empty db.
This commit is contained in:
parent
fdf4ab9d76
commit
c36481edae
@ -394,13 +394,15 @@ Group* Entry::group()
|
|||||||
|
|
||||||
void Entry::setGroup(Group* group)
|
void Entry::setGroup(Group* group)
|
||||||
{
|
{
|
||||||
|
Q_ASSERT(group);
|
||||||
|
|
||||||
if (m_group == group) {
|
if (m_group == group) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_group) {
|
if (m_group) {
|
||||||
m_group->removeEntry(this);
|
m_group->removeEntry(this);
|
||||||
if (m_group->database() != group->database() && m_group->database()) {
|
if (m_group->database() && m_group->database() != group->database()) {
|
||||||
m_group->database()->addDeletedObject(m_uuid);
|
m_group->database()->addDeletedObject(m_uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
* Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
|
||||||
Copyright (C) <year> <name of author>
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
This program is free software; you can redistribute it and/or modify
|
* it under the terms of the GNU General Public License as published by
|
||||||
it under the terms of the GNU General Public License as published by
|
* the Free Software Foundation, either version 2 or (at your option)
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
* version 3 of the License.
|
||||||
(at your option) any later version.
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
This program is distributed in the hope that it will be useful,
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* GNU General Public License for more details.
|
||||||
GNU General Public License for more details.
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
You should have received a copy of the GNU General Public License along
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
*/
|
||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Group.h"
|
#include "Group.h"
|
||||||
|
|
||||||
@ -277,8 +274,10 @@ void Group::setParent(Group* parent, int index)
|
|||||||
if (!moveWithinDatabase) {
|
if (!moveWithinDatabase) {
|
||||||
cleanupParent();
|
cleanupParent();
|
||||||
m_parent = parent;
|
m_parent = parent;
|
||||||
if (parent->m_db) {
|
if (m_db) {
|
||||||
recCreateDelObjects();
|
recCreateDelObjects();
|
||||||
|
}
|
||||||
|
if (m_db != parent->m_db) {
|
||||||
recSetDatabase(parent->m_db);
|
recSetDatabase(parent->m_db);
|
||||||
}
|
}
|
||||||
QObject::setParent(parent);
|
QObject::setParent(parent);
|
||||||
@ -312,6 +311,7 @@ void Group::setParent(Group* parent, int index)
|
|||||||
void Group::setParent(Database* db)
|
void Group::setParent(Database* db)
|
||||||
{
|
{
|
||||||
Q_ASSERT(db);
|
Q_ASSERT(db);
|
||||||
|
Q_ASSERT(db->rootGroup() == this);
|
||||||
|
|
||||||
cleanupParent();
|
cleanupParent();
|
||||||
|
|
||||||
@ -373,6 +373,7 @@ QList<Entry*> Group::entriesRecursive(bool includeHistoryItems)
|
|||||||
void Group::addEntry(Entry *entry)
|
void Group::addEntry(Entry *entry)
|
||||||
{
|
{
|
||||||
Q_ASSERT(entry);
|
Q_ASSERT(entry);
|
||||||
|
Q_ASSERT(!m_entries.contains(entry));
|
||||||
|
|
||||||
Q_EMIT entryAboutToAdd(entry);
|
Q_EMIT entryAboutToAdd(entry);
|
||||||
|
|
||||||
@ -388,6 +389,8 @@ void Group::addEntry(Entry *entry)
|
|||||||
|
|
||||||
void Group::removeEntry(Entry* entry)
|
void Group::removeEntry(Entry* entry)
|
||||||
{
|
{
|
||||||
|
Q_ASSERT(m_entries.contains(entry));
|
||||||
|
|
||||||
Q_EMIT entryAboutToRemove(entry);
|
Q_EMIT entryAboutToRemove(entry);
|
||||||
|
|
||||||
entry->disconnect(this);
|
entry->disconnect(this);
|
||||||
@ -416,9 +419,12 @@ void Group::recSetDatabase(Database* db)
|
|||||||
if (m_db) {
|
if (m_db) {
|
||||||
entry->disconnect(m_db);
|
entry->disconnect(m_db);
|
||||||
}
|
}
|
||||||
|
if (db) {
|
||||||
connect(entry, SIGNAL(modified()), db, SIGNAL(modified()));
|
connect(entry, SIGNAL(modified()), db, SIGNAL(modified()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (db) {
|
||||||
connect(this, SIGNAL(dataChanged(Group*)), db, SIGNAL(groupDataChanged(Group*)));
|
connect(this, SIGNAL(dataChanged(Group*)), db, SIGNAL(groupDataChanged(Group*)));
|
||||||
connect(this, SIGNAL(aboutToRemove(Group*)), db, SIGNAL(groupAboutToRemove(Group*)));
|
connect(this, SIGNAL(aboutToRemove(Group*)), db, SIGNAL(groupAboutToRemove(Group*)));
|
||||||
connect(this, SIGNAL(removed()), db, SIGNAL(groupRemoved()));
|
connect(this, SIGNAL(removed()), db, SIGNAL(groupRemoved()));
|
||||||
@ -427,6 +433,7 @@ void Group::recSetDatabase(Database* db)
|
|||||||
connect(this, SIGNAL(aboutToMove(Group*,Group*,int)), db, SIGNAL(groupAboutToMove(Group*,Group*,int)));
|
connect(this, SIGNAL(aboutToMove(Group*,Group*,int)), db, SIGNAL(groupAboutToMove(Group*,Group*,int)));
|
||||||
connect(this, SIGNAL(moved()), db, SIGNAL(groupMoved()));
|
connect(this, SIGNAL(moved()), db, SIGNAL(groupMoved()));
|
||||||
connect(this, SIGNAL(modified()), db, SIGNAL(modified()));
|
connect(this, SIGNAL(modified()), db, SIGNAL(modified()));
|
||||||
|
}
|
||||||
|
|
||||||
m_db = db;
|
m_db = db;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user