QIcon DesignerIconCache::icon(const PropertySheetIconValue &value) const { typedef PropertySheetIconValue::ModeStateToPixmapMap::const_iterator ModeStateToPixmapMapConstIt; QMap<PropertySheetIconValue, QIcon>::const_iterator it = m_cache.constFind(value); if (it != m_cache.constEnd()) return it.value(); // Match on the theme first if it is available. if (!value.theme().isEmpty()) { const QString theme = value.theme(); if (QIcon::hasThemeIcon(theme)) { const QIcon themeIcon = QIcon::fromTheme(theme); m_cache.insert(value, themeIcon); return themeIcon; } } QIcon icon; const PropertySheetIconValue::ModeStateToPixmapMap &paths = value.paths(); const ModeStateToPixmapMapConstIt cend = paths.constEnd(); for (ModeStateToPixmapMapConstIt it = paths.constBegin(); it != cend; ++it) { const QPair<QIcon::Mode, QIcon::State> pair = it.key(); icon.addFile(it.value().path(), QSize(), pair.first, pair.second); } m_cache.insert(value, icon); return icon; }
void PropertySheetIconValue::assign(const PropertySheetIconValue &other, uint mask) { for (int i = 0; i < 8; i++) { uint flag = 1 << i; if (mask & flag) { const ModeStateKey state = subPropertyFlagToIconModeState(flag); setPixmap(state.first, state.second, other.pixmap(state.first, state.second)); } } if (mask & ThemeIconMask) setTheme(other.theme()); }
uint PropertySheetIconValue::compare(const PropertySheetIconValue &other) const { uint diffMask = mask() | other.mask(); for (int i = 0; i < 8; i++) { uint flag = 1 << i; if (diffMask & flag) { // if state is set in both icons, compare the values const ModeStateKey state = stateMap()->state(flag); if (pixmap(state.first, state.second) == other.pixmap(state.first, state.second)) diffMask &= ~flag; } } return diffMask; }
QDESIGNER_SHARED_EXPORT QDebug operator<<(QDebug d, const PropertySheetIconValue &p) { typedef PropertySheetIconValue::ModeStateToPixmapMap::const_iterator ModeStateToPixmapMapConstIt; QDebug nospace = d.nospace(); nospace << "PropertySheetIconValue theme='" << p.theme() << "' "; const PropertySheetIconValue::ModeStateToPixmapMap &paths = p.paths(); const ModeStateToPixmapMapConstIt cend = paths.constEnd(); for (ModeStateToPixmapMapConstIt it = paths.constBegin(); it != cend; ++it) nospace << " mode=" << it.key().first << ",state=" << it.key().second << ",'" << it.value().path() << '\''; nospace << " mask=0x" << QString::number(p.mask(), 16); return d; }
uint PropertySheetIconValue::compare(const PropertySheetIconValue &other) const { uint diffMask = mask() | other.mask(); for (int i = 0; i < 8; i++) { const uint flag = 1 << i; if (diffMask & flag) { // if state is set in both icons, compare the values const QPair<QIcon::Mode, QIcon::State> state = subPropertyFlagToIconModeState(flag); if (pixmap(state.first, state.second) == other.pixmap(state.first, state.second)) diffMask &= ~flag; } } if ((diffMask & ThemeIconMask) && theme() == other.theme()) diffMask &= ~ThemeIconMask; return diffMask; }
void PropertySheetIconValue::assign(const PropertySheetIconValue &other, uint mask) { for (int i = 0; i < 8; i++) { uint flag = 1 << i; if (mask & flag) { const ModeStateKey state = stateMap()->state(flag); setPixmap(state.first, state.second, other.pixmap(state.first, state.second)); } } }
QIcon DesignerIconCache::icon(const PropertySheetIconValue &value) const { QMap<PropertySheetIconValue, QIcon>::const_iterator it = m_cache.constFind(value); if (it != m_cache.constEnd()) return it.value(); QIcon icon; QMap<QPair<QIcon::Mode, QIcon::State>, PropertySheetPixmapValue> paths = value.paths(); QMapIterator<QPair<QIcon::Mode, QIcon::State>, PropertySheetPixmapValue> itPath(paths); while (itPath.hasNext()) { QPair<QIcon::Mode, QIcon::State> pair = itPath.next().key(); icon.addFile(itPath.value().path(), QSize(), pair.first, pair.second); } m_cache.insert(value, icon); return icon; }