/** * @return Pointer to the pattern with the given name or * \p NULL if no such pattern was found. The pattern will be loaded into * memory if it's not already. */ RS_Pattern* RS_PatternList::requestPattern(const QString& name) { RS_DEBUG->print("RS_PatternList::requestPattern %s", name.toLatin1().data()); QString name2 = name.toLower(); RS_Pattern* foundPattern = NULL; RS_DEBUG->print("name2: %s", name2.toLatin1().data()); // Search our list of available patterns: for (int i = 0; i < patterns.size(); ++i) { RS_Pattern* p = patterns.at(i); if (p->getFileName()==name2) { // Make sure this pattern is loaded into memory: p->loadPattern(); foundPattern = p; break; } } //if (foundPattern==NULL && name!="standard") { // foundPattern = requestPattern("standard"); //} return foundPattern; }
bool RS_PatternList::contains(const QString& name) { QString name2 = name.toLower(); // Search our list of available patterns: for (int i = 0; i < patterns.size(); ++i) { RS_Pattern* p = patterns.at(i); if (p->getFileName()==name2) { return true; } } return false; }
/** * Initializes the pattern list by creating empty RS_Pattern * objects, one for each pattern that could be found. */ void RS_PatternList::init() { RS_DEBUG->print("RS_PatternList::initPatterns"); QStringList list = RS_SYSTEM->getPatternList(); RS_Pattern* pattern; patterns.clear(); for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) { RS_DEBUG->print("pattern: %s:", (*it).toLatin1().data()); QFileInfo fi(*it); pattern = new RS_Pattern(fi.baseName().toLower()); patterns.append(pattern); RS_DEBUG->print("base: %s", pattern->getFileName().toLatin1().data()); } }