mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Get rid of Database pointer in Metadata.
This commit is contained in:
parent
10e24e7343
commit
cd41727583
@ -42,6 +42,7 @@ Database::Database()
|
||||
m_uuidMap.insert(m_uuid, this);
|
||||
|
||||
connect(m_metadata, SIGNAL(modified()), this, SIGNAL(modified()));
|
||||
connect(m_metadata, SIGNAL(nameTextChanged()), this, SIGNAL(nameTextChanged()));
|
||||
}
|
||||
|
||||
Database::~Database()
|
||||
|
@ -105,6 +105,7 @@ Q_SIGNALS:
|
||||
void groupRemoved();
|
||||
void groupAboutToMove(Group* group, Group* toGroup, int index);
|
||||
void groupMoved();
|
||||
void nameTextChanged();
|
||||
void modified();
|
||||
|
||||
private:
|
||||
|
@ -17,14 +17,12 @@
|
||||
|
||||
#include "Metadata.h"
|
||||
|
||||
#include "core/Database.h"
|
||||
#include "core/Entry.h"
|
||||
#include "core/Group.h"
|
||||
#include "core/Tools.h"
|
||||
|
||||
Metadata::Metadata(Database* parent)
|
||||
Metadata::Metadata(QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_parent(parent)
|
||||
{
|
||||
m_generator = "KeePassX";
|
||||
m_maintenanceHistoryDays = 365;
|
||||
@ -258,7 +256,7 @@ void Metadata::setGenerator(const QString& value)
|
||||
void Metadata::setName(const QString& value)
|
||||
{
|
||||
if (set(m_name, value, m_nameChanged)) {
|
||||
Q_EMIT nameTextChanged(m_parent);
|
||||
Q_EMIT nameTextChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@ -424,8 +422,3 @@ void Metadata::removeCustomField(const QString& key)
|
||||
m_customFields.remove(key);
|
||||
Q_EMIT modified();
|
||||
}
|
||||
|
||||
const Database* Metadata::database() const
|
||||
{
|
||||
return m_parent;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class Metadata : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Metadata(Database* parent);
|
||||
explicit Metadata(QObject* parent = 0);
|
||||
|
||||
QString generator() const;
|
||||
QString name() const;
|
||||
@ -69,7 +69,6 @@ public:
|
||||
int historyMaxItems() const;
|
||||
int historyMaxSize() const;
|
||||
QHash<QString, QString> customFields() const;
|
||||
const Database* database() const;
|
||||
|
||||
static const int defaultHistoryMaxItems;
|
||||
static const int defaultHistoryMaxSize;
|
||||
@ -108,15 +107,13 @@ public:
|
||||
void setUpdateDatetime(bool value);
|
||||
|
||||
Q_SIGNALS:
|
||||
void nameTextChanged(Database* db);
|
||||
void nameTextChanged();
|
||||
void modified();
|
||||
|
||||
private:
|
||||
template <class P, class V> bool set(P& property, const V& value);
|
||||
template <class P, class V> bool set(P& property, const V& value, QDateTime& dateTime);
|
||||
|
||||
Database* const m_parent;
|
||||
|
||||
QString m_generator;
|
||||
QString m_name;
|
||||
QDateTime m_nameChanged;
|
||||
|
@ -390,6 +390,13 @@ void DatabaseTabWidget::updateTabName(Database* db)
|
||||
Q_EMIT tabNameChanged();
|
||||
}
|
||||
|
||||
void DatabaseTabWidget::updateTabNameFromSender()
|
||||
{
|
||||
Q_ASSERT(qobject_cast<Database*>(sender()));
|
||||
|
||||
updateTabName(static_cast<Database*>(sender()));
|
||||
}
|
||||
|
||||
int DatabaseTabWidget::databaseIndex(Database* db)
|
||||
{
|
||||
QWidget* dbWidget = m_dbList.value(db).dbWidget;
|
||||
@ -434,8 +441,7 @@ void DatabaseTabWidget::insertDatabase(Database* db, const DatabaseManagerStruct
|
||||
int index = databaseIndex(db);
|
||||
setCurrentIndex(index);
|
||||
|
||||
connect(db->metadata(), SIGNAL(nameTextChanged(Database*)),
|
||||
SLOT(updateTabName(Database*)));
|
||||
connect(db, SIGNAL(nameTextChanged()), SLOT(updateTabNameFromSender()));
|
||||
connect(dbStruct.dbWidget->entryView(), SIGNAL(entrySelectionChanged()),
|
||||
SLOT(emitEntrySelectionChanged()));
|
||||
connect(dbStruct.dbWidget, SIGNAL(closeRequest()), SLOT(closeDatabaseFromSender()));
|
||||
@ -457,7 +463,8 @@ DatabaseWidget* DatabaseTabWidget::currentDatabaseWidget()
|
||||
|
||||
void DatabaseTabWidget::modified()
|
||||
{
|
||||
Q_ASSERT(sender());
|
||||
Q_ASSERT(qobject_cast<Database*>(sender()));
|
||||
|
||||
Database* db = static_cast<Database*>(sender());
|
||||
DatabaseManagerStruct& dbStruct = m_dbList[db];
|
||||
if (!dbStruct.modified) {
|
||||
|
@ -78,6 +78,7 @@ Q_SIGNALS:
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateTabName(Database* db);
|
||||
void updateTabNameFromSender();
|
||||
void openDatabaseDialog(const QString& pw = QString(), const QString& keyFile = QString());
|
||||
void openDatabaseRead();
|
||||
void openDatabaseCleanup();
|
||||
|
Loading…
Reference in New Issue
Block a user