mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-28 00:42:19 -07:00
check if new value was inserted
This commit is contained in:
parent
9716f7f2c3
commit
56ebaed8a4
3 changed files with 14 additions and 3 deletions
|
|
@ -25,7 +25,11 @@ const QHash<QString, QString> &CardInfo::getPropertiesHash() const
|
|||
|
||||
void CardInfo::setProperty(const QString &_name, const QString &_value)
|
||||
{
|
||||
properties.insert(_name, _value);
|
||||
bool changed = properties.insert(_name, _value);
|
||||
if (!changed) {
|
||||
return;
|
||||
}
|
||||
|
||||
emit cardInfoChanged(smartThis);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,10 +76,16 @@ QString LazyPropertiesHash::value(const QString &key) const
|
|||
return properties.value(key);
|
||||
}
|
||||
|
||||
void LazyPropertiesHash::insert(const QString &key, const QString &value)
|
||||
bool LazyPropertiesHash::insert(const QString &key, const QString &value)
|
||||
{
|
||||
ensureMaterialized();
|
||||
|
||||
if (value == properties.value(key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
properties.insert(key, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
const QHash<QString, QString> &LazyPropertiesHash::getProperties() const
|
||||
|
|
|
|||
|
|
@ -60,8 +60,9 @@ public:
|
|||
* @brief Inserts a value into the materialized properties hash
|
||||
* @param key The key
|
||||
* @param value The value to insert
|
||||
* @return True if a new value was inserted; false if the new value is the same as the existing value
|
||||
*/
|
||||
void insert(const QString &key, const QString &value);
|
||||
bool insert(const QString &key, const QString &value);
|
||||
|
||||
/**
|
||||
* @brief Gets a view of the materialized properties hash.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue