Call m_group->database() instead of keeping a reference to Database in Entries.

Previously we didn't update m_db when the database of the group changed.
This commit is contained in:
Felix Geyer 2012-04-18 13:57:57 +02:00
parent 123e3766fe
commit a5ac1f2e80
2 changed files with 16 additions and 7 deletions

View File

@ -25,7 +25,6 @@
Entry::Entry()
{
m_group = 0;
m_db = 0;
m_updateTimeinfo = true;
m_iconNumber = 0;
@ -79,8 +78,8 @@ QImage Entry::icon() const
return databaseIcons()->icon(m_iconNumber);
}
else {
// TODO check if m_db is 0
return m_db->metadata()->customIcon(m_customIcon);
// TODO check if database() is 0
return database()->metadata()->customIcon(m_customIcon);
}
}
@ -92,8 +91,8 @@ QPixmap Entry::iconPixmap() const
else {
QPixmap pixmap;
if (!QPixmapCache::find(m_pixmapCacheKey, &pixmap)) {
// TODO check if m_db is 0
pixmap = QPixmap::fromImage(m_db->metadata()->customIcon(m_customIcon));
// TODO check if database() is 0
pixmap = QPixmap::fromImage(database()->metadata()->customIcon(m_customIcon));
*const_cast<QPixmapCache::Key*>(&m_pixmapCacheKey) = QPixmapCache::insert(pixmap);
}
@ -336,7 +335,6 @@ void Entry::setGroup(Group* group)
}
group->addEntry(this);
m_group = group;
m_db = group->database();
QObject::setParent(group);
}
@ -344,3 +342,13 @@ void Entry::emitDataChanged()
{
Q_EMIT dataChanged(this);
}
const Database* Entry::database() const
{
if (m_group) {
return m_group->database();
}
else {
return 0;
}
}

View File

@ -111,6 +111,8 @@ private Q_SLOTS:
void emitDataChanged();
private:
const Database* database() const;
Uuid m_uuid;
int m_iconNumber;
Uuid m_customIcon;
@ -128,7 +130,6 @@ private:
QList<Entry*> m_history;
QPointer<Group> m_group;
const Database* m_db;
QPixmapCache::Key m_pixmapCacheKey;
bool m_updateTimeinfo;