Complete overhaul of the implementation

This commit is contained in:
Jonathan White
2025-11-02 12:25:28 -05:00
parent bd05bf05fc
commit 27a50d8fa5
7 changed files with 36 additions and 21 deletions

View File

@@ -3720,7 +3720,11 @@ Supported extensions are: %1.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>Share recursively</source> <source>Maintain group structure with shared database</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Keep Group Structure</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>

View File

@@ -213,7 +213,7 @@ namespace KeeShareSettings
} }
} }
} else { } else {
qWarning("Unknown KeeShareSettings element %s", qPrintable(reader.name().toString())); qDebug("Unknown KeeShareSettings element %s", qPrintable(reader.name().toString()));
reader.skipCurrentElement(); reader.skipCurrentElement();
} }
} }
@@ -253,7 +253,7 @@ namespace KeeShareSettings
} else if (reader.name() == "PublicKey") { } else if (reader.name() == "PublicKey") {
own.certificate = Certificate::deserialize(reader); own.certificate = Certificate::deserialize(reader);
} else { } else {
qWarning("Unknown KeeShareSettings element %s", qPrintable(reader.name().toString())); qDebug("Unknown KeeShareSettings element %s", qPrintable(reader.name().toString()));
reader.skipCurrentElement(); reader.skipCurrentElement();
} }
} }
@@ -262,8 +262,7 @@ namespace KeeShareSettings
} }
Reference::Reference() Reference::Reference()
: type(Inactive) : uuid(QUuid::createUuid())
, uuid(QUuid::createUuid())
{ {
} }
@@ -320,15 +319,21 @@ namespace KeeShareSettings
writer.writeStartElement("Password"); writer.writeStartElement("Password");
writer.writeCharacters(reference.password.toUtf8().toBase64()); writer.writeCharacters(reference.password.toUtf8().toBase64());
writer.writeEndElement(); writer.writeEndElement();
writer.writeStartElement("Recurse"); writer.writeStartElement("KeepGroups");
writer.writeCharacters(reference.recurse ? "True" : "False"); writer.writeCharacters(reference.keepGroups ? "True" : "False");
writer.writeEndElement(); writer.writeEndElement();
}); });
} }
Reference Reference::deserialize(const QString& raw) Reference Reference::deserialize(const QString& raw)
{ {
if (raw.isEmpty()) {
return {};
}
Reference reference; Reference reference;
// If KeepGroups is not present, default to false for backward compatibility
reference.keepGroups = false;
xmlDeserialize(raw, [&](QXmlStreamReader& reader) { xmlDeserialize(raw, [&](QXmlStreamReader& reader) {
while (!reader.error() && reader.readNextStartElement()) { while (!reader.error() && reader.readNextStartElement()) {
if (reader.name() == "Type") { if (reader.name() == "Type") {
@@ -349,10 +354,10 @@ namespace KeeShareSettings
reference.path = QString::fromUtf8(QByteArray::fromBase64(reader.readElementText().toLatin1())); reference.path = QString::fromUtf8(QByteArray::fromBase64(reader.readElementText().toLatin1()));
} else if (reader.name() == "Password") { } else if (reader.name() == "Password") {
reference.password = QString::fromUtf8(QByteArray::fromBase64(reader.readElementText().toLatin1())); reference.password = QString::fromUtf8(QByteArray::fromBase64(reader.readElementText().toLatin1()));
} else if (reader.name() == "Recurse") { } else if (reader.name() == "KeepGroups") {
reference.recurse = reader.readElementText().compare("True") == 0; reference.keepGroups = reader.readElementText().compare("True") == 0;
} else { } else {
qWarning("Unknown Reference element %s", qPrintable(reader.name().toString())); qDebug("Unknown Reference element %s", qPrintable(reader.name().toString()));
reader.skipCurrentElement(); reader.skipCurrentElement();
} }
} }

View File

@@ -122,11 +122,11 @@ namespace KeeShareSettings
struct Reference struct Reference
{ {
Type type; Type type = Inactive;
QUuid uuid; QUuid uuid;
QString path; QString path;
QString password; QString password;
bool recurse; bool keepGroups = true;
Reference(); Reference();
bool isNull() const; bool isNull() const;

View File

@@ -110,7 +110,7 @@ namespace
targetRoot->setUpdateTimeinfo(updateTimeinfo); targetRoot->setUpdateTimeinfo(updateTimeinfo);
cloneIcon(targetMetadata, sourceRoot->database(), targetRoot->iconUuid()); cloneIcon(targetMetadata, sourceRoot->database(), targetRoot->iconUuid());
cloneEntries(targetMetadata, sourceRoot, targetRoot); cloneEntries(targetMetadata, sourceRoot, targetRoot);
if (reference.recurse) { if (reference.keepGroups) {
cloneChildren(targetMetadata, sourceRoot, targetRoot); cloneChildren(targetMetadata, sourceRoot, targetRoot);
} }

View File

@@ -43,7 +43,7 @@ EditGroupWidgetKeeShare::EditGroupWidgetKeeShare(QWidget* parent)
connect(m_ui->pathEdit, SIGNAL(editingFinished()), SLOT(selectPath())); connect(m_ui->pathEdit, SIGNAL(editingFinished()), SLOT(selectPath()));
connect(m_ui->pathSelectionButton, SIGNAL(pressed()), SLOT(launchPathSelectionDialog())); connect(m_ui->pathSelectionButton, SIGNAL(pressed()), SLOT(launchPathSelectionDialog()));
connect(m_ui->typeComboBox, SIGNAL(currentIndexChanged(int)), SLOT(selectType())); connect(m_ui->typeComboBox, SIGNAL(currentIndexChanged(int)), SLOT(selectType()));
connect(m_ui->recurseIntoGroupsCheckbox, SIGNAL(toggled(bool)), SLOT(recurseIntoGroupsToggled(bool))); connect(m_ui->keepGroupsCheckbox, SIGNAL(toggled(bool)), SLOT(keepGroupsToggled(bool)));
connect(m_ui->clearButton, SIGNAL(clicked(bool)), SLOT(clearInputs())); connect(m_ui->clearButton, SIGNAL(clicked(bool)), SLOT(clearInputs()));
connect(KeeShare::instance(), SIGNAL(activeChanged()), SLOT(updateSharingState())); connect(KeeShare::instance(), SIGNAL(activeChanged()), SLOT(updateSharingState()));
@@ -98,7 +98,7 @@ void EditGroupWidgetKeeShare::updateSharingState()
m_ui->pathEdit->setEnabled(isEnabled); m_ui->pathEdit->setEnabled(isEnabled);
m_ui->pathSelectionButton->setEnabled(isEnabled); m_ui->pathSelectionButton->setEnabled(isEnabled);
m_ui->passwordEdit->setEnabled(isEnabled); m_ui->passwordEdit->setEnabled(isEnabled);
m_ui->recurseIntoGroupsCheckbox->setEnabled(isEnabled); m_ui->keepGroupsCheckbox->setEnabled(isEnabled);
if (!m_temporaryGroup || !isEnabled) { if (!m_temporaryGroup || !isEnabled) {
m_ui->messageWidget->hideMessage(); m_ui->messageWidget->hideMessage();
@@ -190,7 +190,7 @@ void EditGroupWidgetKeeShare::update()
m_ui->typeComboBox->setCurrentIndex(reference.type); m_ui->typeComboBox->setCurrentIndex(reference.type);
m_ui->passwordEdit->setText(reference.password); m_ui->passwordEdit->setText(reference.password);
m_ui->pathEdit->setText(reference.path); m_ui->pathEdit->setText(reference.path);
m_ui->recurseIntoGroupsCheckbox->setChecked(reference.recurse); m_ui->keepGroupsCheckbox->setChecked(reference.keepGroups);
} }
updateSharingState(); updateSharingState();
@@ -295,12 +295,12 @@ void EditGroupWidgetKeeShare::selectType()
updateSharingState(); updateSharingState();
} }
void EditGroupWidgetKeeShare::recurseIntoGroupsToggled(bool toggled) void EditGroupWidgetKeeShare::keepGroupsToggled(bool toggled)
{ {
if (!m_temporaryGroup) { if (!m_temporaryGroup) {
return; return;
} }
auto reference = KeeShare::referenceOf(m_temporaryGroup); auto reference = KeeShare::referenceOf(m_temporaryGroup);
reference.recurse = toggled; reference.keepGroups = toggled;
KeeShare::setReferenceTo(m_temporaryGroup, reference); KeeShare::setReferenceTo(m_temporaryGroup, reference);
} }

View File

@@ -48,7 +48,7 @@ private slots:
void selectPassword(); void selectPassword();
void launchPathSelectionDialog(); void launchPathSelectionDialog();
void selectPath(); void selectPath();
void recurseIntoGroupsToggled(bool); void keepGroupsToggled(bool);
private: private:
QScopedPointer<Ui::EditGroupWidgetKeeShare> m_ui; QScopedPointer<Ui::EditGroupWidgetKeeShare> m_ui;

View File

@@ -185,9 +185,15 @@
</spacer> </spacer>
</item> </item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QCheckBox" name="recurseIntoGroupsCheckbox"> <widget class="QCheckBox" name="keepGroupsCheckbox">
<property name="toolTip">
<string>Maintain group structure with shared database</string>
</property>
<property name="text"> <property name="text">
<string>Share recursively</string> <string>Keep Group Structure</string>
</property>
<property name="checked">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>