void QPixmapIconEngine::addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state) { if (!pixmap.isNull()) { QPixmapIconEngineEntry *pe = tryMatch(pixmap.size(), mode, state); if(pe && pe->size == pixmap.size()) { pe->pixmap = pixmap; pe->fileName.clear(); } else { pixmaps += QPixmapIconEngineEntry(pixmap, mode, state); } } }
bool tryMatch(const char *s, const char *p) { if (*s == 0 && *p == 0) return true; if (*s == 0 || *p == 0) return false; if (*(p + 1) == '*') { if (*p == *s || *p == '.') return tryMatch(s + 1, p) || tryMatch(s + 1, p + 2) || tryMatch(s, p + 2); else return tryMatch(s, p + 2); } else if (*p == *s || *p == '.') { return tryMatch(s + 1, p + 1); } else { return false; } }
QPixmapIconEngineEntry *QPixmapIconEngine::bestMatch(const QSize &size, QIcon::Mode mode, QIcon::State state, bool sizeOnly) { QPixmapIconEngineEntry *pe = tryMatch(size, mode, state); while (!pe){ QIcon::State oppositeState = (state == QIcon::On) ? QIcon::Off : QIcon::On; if (mode == QIcon::Disabled || mode == QIcon::Selected) { QIcon::Mode oppositeMode = (mode == QIcon::Disabled) ? QIcon::Selected : QIcon::Disabled; if ((pe = tryMatch(size, QIcon::Normal, state))) break; if ((pe = tryMatch(size, QIcon::Active, state))) break; if ((pe = tryMatch(size, mode, oppositeState))) break; if ((pe = tryMatch(size, QIcon::Normal, oppositeState))) break; if ((pe = tryMatch(size, QIcon::Active, oppositeState))) break; if ((pe = tryMatch(size, oppositeMode, state))) break; if ((pe = tryMatch(size, oppositeMode, oppositeState))) break; } else { QIcon::Mode oppositeMode = (mode == QIcon::Normal) ? QIcon::Active : QIcon::Normal; if ((pe = tryMatch(size, oppositeMode, state))) break; if ((pe = tryMatch(size, mode, oppositeState))) break; if ((pe = tryMatch(size, oppositeMode, oppositeState))) break; if ((pe = tryMatch(size, QIcon::Disabled, state))) break; if ((pe = tryMatch(size, QIcon::Selected, state))) break; if ((pe = tryMatch(size, QIcon::Disabled, oppositeState))) break; if ((pe = tryMatch(size, QIcon::Selected, oppositeState))) break; } if (!pe) return pe; } if (sizeOnly ? (pe->size.isNull() || !pe->size.isValid()) : pe->pixmap.isNull()) { pe->pixmap = QPixmap(pe->fileName); if (!pe->pixmap.isNull()) pe->size = pe->pixmap.size(); } return pe; }
bool Task::matchKeyword(string keyword){ return tryMatch(description, keyword); }
bool isMatch(const char *s, const char *p) { if (s == NULL || p == NULL) return false; return tryMatch(s, p); };