mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-28 15:27:18 -05:00
Pass database instead of metadata to edit entry widget.
This commit is contained in:
parent
af726d465d
commit
078fe3ccf1
@ -245,7 +245,7 @@ void DatabaseWidget::switchToEntryEdit(Entry* entry)
|
|||||||
void DatabaseWidget::switchToEntryEdit(Entry* entry, bool create)
|
void DatabaseWidget::switchToEntryEdit(Entry* entry, bool create)
|
||||||
{
|
{
|
||||||
m_editEntryWidget->loadEntry(entry, create, m_groupView->currentGroup()->name(),
|
m_editEntryWidget->loadEntry(entry, create, m_groupView->currentGroup()->name(),
|
||||||
m_db->metadata());
|
m_db);
|
||||||
setCurrentIndex(1);
|
setCurrentIndex(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,10 +130,10 @@ const QColor EditEntryWidget::correctSoFarColor = QColor(255, 205, 15);
|
|||||||
const QColor EditEntryWidget::errorColor = QColor(255, 125, 125);
|
const QColor EditEntryWidget::errorColor = QColor(255, 125, 125);
|
||||||
|
|
||||||
void EditEntryWidget::loadEntry(Entry* entry, bool create, const QString& groupName,
|
void EditEntryWidget::loadEntry(Entry* entry, bool create, const QString& groupName,
|
||||||
Metadata* metadata)
|
Database* database)
|
||||||
{
|
{
|
||||||
m_entry = entry;
|
m_entry = entry;
|
||||||
m_metadata = metadata;
|
m_database = database;
|
||||||
m_create = create;
|
m_create = create;
|
||||||
|
|
||||||
if (create) {
|
if (create) {
|
||||||
@ -168,10 +168,10 @@ void EditEntryWidget::loadEntry(Entry* entry, bool create, const QString& groupN
|
|||||||
m_advancedUi->attributesEdit->setEnabled(false);
|
m_advancedUi->attributesEdit->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (metadata) {
|
if (database) {
|
||||||
m_iconsWidget->setEnabled(true);
|
m_iconsWidget->setEnabled(true);
|
||||||
|
|
||||||
m_customIconModel->setIcons(metadata->customIcons());
|
m_customIconModel->setIcons(database->metadata()->customIcons());
|
||||||
|
|
||||||
Uuid iconUuid = entry->iconUuid();
|
Uuid iconUuid = entry->iconUuid();
|
||||||
if (iconUuid.isNull()) {
|
if (iconUuid.isNull()) {
|
||||||
@ -426,7 +426,7 @@ void EditEntryWidget::removeCurrentAttachment()
|
|||||||
|
|
||||||
void EditEntryWidget::addCustomIcon()
|
void EditEntryWidget::addCustomIcon()
|
||||||
{
|
{
|
||||||
if (m_metadata) {
|
if (m_database) {
|
||||||
QString filter = QString("%1 (%2);;%3 (*.*)").arg(tr("Images"),
|
QString filter = QString("%1 (%2);;%3 (*.*)").arg(tr("Images"),
|
||||||
Tools::imageReaderFilter(), tr("All files"));
|
Tools::imageReaderFilter(), tr("All files"));
|
||||||
|
|
||||||
@ -435,8 +435,8 @@ void EditEntryWidget::addCustomIcon()
|
|||||||
if (!filename.isEmpty()) {
|
if (!filename.isEmpty()) {
|
||||||
QImage image(filename);
|
QImage image(filename);
|
||||||
if (!image.isNull()) {
|
if (!image.isNull()) {
|
||||||
m_metadata->addCustomIcon(Uuid::random(), image.scaled(16, 16));
|
m_database->metadata()->addCustomIcon(Uuid::random(), image.scaled(16, 16));
|
||||||
m_customIconModel->setIcons(m_metadata->customIcons());
|
m_customIconModel->setIcons(m_database->metadata()->customIcons());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// TODO: show error
|
// TODO: show error
|
||||||
@ -447,13 +447,13 @@ void EditEntryWidget::addCustomIcon()
|
|||||||
|
|
||||||
void EditEntryWidget::removeCustomIcon()
|
void EditEntryWidget::removeCustomIcon()
|
||||||
{
|
{
|
||||||
if (m_metadata) {
|
if (m_database) {
|
||||||
QModelIndex index = m_iconsUi->customIconsView->currentIndex();
|
QModelIndex index = m_iconsUi->customIconsView->currentIndex();
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
Uuid iconUuid = m_customIconModel->uuidFromIndex(index);
|
Uuid iconUuid = m_customIconModel->uuidFromIndex(index);
|
||||||
int iconUsedCount = 0;
|
int iconUsedCount = 0;
|
||||||
|
|
||||||
QList<Entry*> allEntries = m_metadata->database()->rootGroup()->entriesRecursive(true);
|
QList<Entry*> allEntries = m_database->rootGroup()->entriesRecursive(true);
|
||||||
QListIterator<Entry*> iEntries(allEntries);
|
QListIterator<Entry*> iEntries(allEntries);
|
||||||
while (iEntries.hasNext()) {
|
while (iEntries.hasNext()) {
|
||||||
Entry* entry = iEntries.next();
|
Entry* entry = iEntries.next();
|
||||||
@ -462,7 +462,7 @@ void EditEntryWidget::removeCustomIcon()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<const Group*> allGroups = m_metadata->database()->rootGroup()->groupsRecursive(true);
|
QList<const Group*> allGroups = m_database->rootGroup()->groupsRecursive(true);
|
||||||
QListIterator<const Group*> iGroups(allGroups);
|
QListIterator<const Group*> iGroups(allGroups);
|
||||||
while (iGroups.hasNext()) {
|
while (iGroups.hasNext()) {
|
||||||
const Group* group = iGroups.next();
|
const Group* group = iGroups.next();
|
||||||
@ -472,8 +472,8 @@ void EditEntryWidget::removeCustomIcon()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (iconUsedCount == 0) {
|
if (iconUsedCount == 0) {
|
||||||
m_metadata->removeCustomIcon(iconUuid);
|
m_database->metadata()->removeCustomIcon(iconUuid);
|
||||||
m_customIconModel->setIcons(m_metadata->customIcons());
|
m_customIconModel->setIcons(m_database->metadata()->customIcons());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QMessageBox::information(this, tr("Can't delete icon!"),
|
QMessageBox::information(this, tr("Can't delete icon!"),
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "gui/DialogyWidget.h"
|
#include "gui/DialogyWidget.h"
|
||||||
|
|
||||||
|
class Database;
|
||||||
class Entry;
|
class Entry;
|
||||||
class EntryAttachments;
|
class EntryAttachments;
|
||||||
class EntryAttachmentsModel;
|
class EntryAttachmentsModel;
|
||||||
@ -49,7 +50,7 @@ public:
|
|||||||
explicit EditEntryWidget(QWidget* parent = 0);
|
explicit EditEntryWidget(QWidget* parent = 0);
|
||||||
~EditEntryWidget();
|
~EditEntryWidget();
|
||||||
|
|
||||||
void loadEntry(Entry* entry, bool create, const QString& groupName, Metadata* metadata);
|
void loadEntry(Entry* entry, bool create, const QString& groupName, Database* database);
|
||||||
|
|
||||||
static const QColor normalColor;
|
static const QColor normalColor;
|
||||||
static const QColor correctSoFarColor;
|
static const QColor correctSoFarColor;
|
||||||
@ -81,7 +82,7 @@ private:
|
|||||||
bool passwordsEqual();
|
bool passwordsEqual();
|
||||||
|
|
||||||
Entry* m_entry;
|
Entry* m_entry;
|
||||||
Metadata* m_metadata;
|
Database* m_database;
|
||||||
|
|
||||||
bool m_create;
|
bool m_create;
|
||||||
const QScopedPointer<Ui::EditEntryWidget> m_ui;
|
const QScopedPointer<Ui::EditEntryWidget> m_ui;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user