Replace EntryAttachments and EntryAttributes operator=() with copyDataFrom().

QObjects are not supposed to have assignment operators.
This commit is contained in:
Felix Geyer 2012-07-20 12:13:26 +02:00
parent c7107de2a7
commit a50d2709e7
6 changed files with 24 additions and 28 deletions

View File

@ -494,8 +494,8 @@ Entry* Entry::clone() const
entry->setUpdateTimeinfo(false);
entry->m_uuid = m_uuid;
entry->m_data = m_data;
*entry->m_attributes = *m_attributes;
*entry->m_attachments = *m_attachments;
entry->m_attributes->copyDataFrom(m_attributes);
entry->m_attachments->copyDataFrom(m_attachments);
entry->m_autoTypeAssociations->copyDataFrom(this->m_autoTypeAssociations);
entry->setUpdateTimeinfo(true);
@ -510,8 +510,8 @@ void Entry::beginUpdate()
m_tmpHistoryItem->setUpdateTimeinfo(false);
m_tmpHistoryItem->m_uuid = m_uuid;
m_tmpHistoryItem->m_data = m_data;
*m_tmpHistoryItem->m_attributes = *m_attributes;
*m_tmpHistoryItem->m_attachments = *m_attachments;
m_tmpHistoryItem->m_attributes->copyDataFrom(m_attributes);
m_tmpHistoryItem->m_attachments->copyDataFrom(m_attachments);
m_modifiedSinceBegin = false;
}

View File

@ -92,6 +92,18 @@ void EntryAttachments::clear()
Q_EMIT modified();
}
void EntryAttachments::copyDataFrom(const EntryAttachments* other)
{
if (*this != *other) {
Q_EMIT aboutToBeReset();
m_attachments = other->m_attachments;
Q_EMIT reset();
Q_EMIT modified();
}
}
bool EntryAttachments::operator==(const EntryAttachments& other) const
{
return m_attachments == other.m_attachments;
@ -101,17 +113,3 @@ bool EntryAttachments::operator!=(const EntryAttachments& other) const
{
return m_attachments != other.m_attachments;
}
EntryAttachments& EntryAttachments::operator=(const EntryAttachments& other)
{
if (*this != other) {
Q_EMIT aboutToBeReset();
m_attachments = other.m_attachments;
Q_EMIT reset();
Q_EMIT modified();
}
return *this;
}

View File

@ -35,9 +35,9 @@ public:
void set(const QString& key, const QByteArray& value);
void remove(const QString& key);
void clear();
void copyDataFrom(const EntryAttachments* other);
bool operator==(const EntryAttachments& other) const;
bool operator!=(const EntryAttachments& other) const;
EntryAttachments& operator=(const EntryAttachments& other);
Q_SIGNALS:
void modified();

View File

@ -181,19 +181,17 @@ bool EntryAttributes::areCustomKeysDifferent(const EntryAttributes* other)
return false;
}
EntryAttributes& EntryAttributes::operator=(const EntryAttributes& other)
void EntryAttributes::copyDataFrom(const EntryAttributes* other)
{
if (*this != other) {
if (*this != *other) {
Q_EMIT aboutToBeReset();
m_attributes = other.m_attributes;
m_protectedAttributes = other.m_protectedAttributes;
m_attributes = other->m_attributes;
m_protectedAttributes = other->m_protectedAttributes;
Q_EMIT reset();
Q_EMIT modified();
}
return *this;
}
bool EntryAttributes::operator==(const EntryAttributes& other) const

View File

@ -41,7 +41,7 @@ public:
bool areCustomKeysDifferent(const EntryAttributes* other);
void clear();
int attributesSize();
EntryAttributes& operator=(const EntryAttributes& other);
void copyDataFrom(const EntryAttributes* other);
bool operator==(const EntryAttributes& other) const;
bool operator!=(const EntryAttributes& other) const;

View File

@ -263,7 +263,7 @@ void EditEntryWidget::setForms(const Entry* entry, bool restore)
m_notesUi->notesEdit->setPlainText(entry->notes());
*m_entryAttachments = *entry->attachments();
m_entryAttachments->copyDataFrom(entry->attachments());
m_entryAttributes->copyCustomKeysFrom(entry->attributes());
if (m_attributesModel->rowCount() != 0) {
@ -355,7 +355,7 @@ void EditEntryWidget::saveEntry()
m_entry->setNotes(m_notesUi->notesEdit->toPlainText());
m_entry->attributes()->copyCustomKeysFrom(m_entryAttributes);
*m_entry->attachments() = *m_entryAttachments;
m_entry->attachments()->copyDataFrom(m_entryAttachments);
IconStruct iconStruct = m_iconsWidget->save();