Exemplo n.º 1
0
    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;
    }
Exemplo n.º 2
0
 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());
 }
Exemplo n.º 3
0
    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;
    }
Exemplo n.º 4
0
 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;
 }