void PIM_Handler::pageLoadFinished() { WebPage* page = qobject_cast<WebPage*>(sender()); if (!page) { return; } if (!m_loaded) { loadSettings(); } const QWebElement document = page->mainFrame()->documentElement(); const QWebElementCollection elements = document.findAll("input[type=\"text\"]"); foreach (QWebElement element, elements) { const QString name = element.attribute("name"); if (name.isEmpty()) { continue; } PI_Type match = nameMatch(name); if (match != PI_Invalid) { element.setStyleProperty("-webkit-appearance", "none"); element.setStyleProperty("-webkit-box-shadow", "inset 0 0 2px 1px #EEE000"); } } }
bool InterpreterDraft6::isEnabledTransition(const Node<std::string>& transition, const std::string& event) { std::string eventName; if (HAS_ATTR(transition, "event")) { eventName = ATTR(transition, "event"); } else if(HAS_ATTR(transition, "eventexpr")) { if (_dataModel) { eventName = _dataModel.evalAsString(ATTR(transition, "eventexpr")); } else { LOG(ERROR) << "Transition has eventexpr attribute with no datamodel defined"; return false; } } else { return false; } std::list<std::string> eventNames = tokenizeIdRefs(eventName); std::list<std::string>::iterator eventIter = eventNames.begin(); while(eventIter != eventNames.end()) { if(nameMatch(*eventIter, event) && hasConditionMatch(transition)) { return true; } eventIter++; } return false; }
bool PIM_Handler::keyPress(WebView* view, QKeyEvent* event) { if (!view) { return false; } bool isEnter = event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter; bool isControlModifier = event->modifiers() & Qt::ControlModifier; if (!isEnter || !isControlModifier) { return false; } const QWebElement document = view->page()->mainFrame()->documentElement(); const QWebElementCollection elements = document.findAll("input[type=\"text\"]"); foreach (QWebElement element, elements) { const QString name = element.attribute("name"); if (name.isEmpty()) { continue; } PI_Type match = nameMatch(name); if (match != PI_Invalid) { element.evaluateJavaScript(QString("this.value = \"%1\"").arg(m_allInfo[match])); } } return true; }
void fillIntentResult(const DictionaryModel& dictionaryModel, IntentMatcher::IntentResult& intentResult, const EntitiesMatcher::Variables& variables, IntentModel::EntityToNames& entityToVariableNames) { MatchNamer nameMatch(entityToVariableNames); std::transform( variables.begin(), variables.end(), std::back_inserter(intentResult.intent.entityMatches), [&dictionaryModel, &nameMatch](const EntitiesMatcher::Variable& v) { IntentMatcher::EntityMatch match; fillMatchEntity(match, v, dictionaryModel); nameMatch(match); completeMatch(match, v, dictionaryModel); return match; }); }
QTextCodec* QTextCodec::codecForName(const char *name) { if (name == 0 || *name == 0) return 0; setup(); for (std::vector<QTextCodec*>::iterator i = all->begin(); i != all->end(); i++) { QTextCodec *cursor = *i; if (nameMatch(cursor->name(), name)) return cursor; const Aliase* aliases = cursor->aliases(); for (int i = 0; aliases[i]; ++i) if (nameMatch(aliases[i], name)) return cursor; } return 0; }
/*! Searches all installed QTextCodec objects and returns the one which best matches \a name; the match is case-insensitive. Returns 0 if no codec matching the name \a name could be found. */ QTextCodec *QTextCodec::codecForName(const QByteArray &name) { if (name.isEmpty()) return 0; setup(); for (int i = 0; i < all->size(); ++i) { QTextCodec *cursor = all->at(i); if (nameMatch(cursor->name(), name)) return cursor; QList<QByteArray> aliases = cursor->aliases(); for (int i = 0; i < aliases.size(); ++i) if (nameMatch(aliases.at(i), name)) return cursor; } return createForName(name); }
/*! Searches all installed QTextCodec objects and returns the one which best matches \a name; the match is case-insensitive. Returns 0 if no codec matching the name \a name could be found. */ QTextCodec *QTextCodec::codecForName(const QByteArray &name) { if (name.isEmpty()) return 0; QMutexLocker locker(textCodecsMutex()); setup(); if (!validCodecs()) return 0; QTextCodecCache *cache = qTextCodecCache(); QTextCodec *codec; if (cache) { codec = cache->value(name); if (codec) return codec; } for (int i = 0; i < all->size(); ++i) { QTextCodec *cursor = all->at(i); if (nameMatch(cursor->name(), name)) { if (cache) cache->insert(name, cursor); return cursor; } QList<QByteArray> aliases = cursor->aliases(); for (int y = 0; y < aliases.size(); ++y) if (nameMatch(aliases.at(y), name)) { if (cache) cache->insert(name, cursor); return cursor; } } codec = createForName(name); if (codec && cache) cache->insert(name, codec); return codec; }
static QTextCodec *createForName(const QByteArray &name) { #ifndef QT_NO_TEXTCODECPLUGIN QFactoryLoader *l = loader(); QStringList keys = l->keys(); for (int i = 0; i < keys.size(); ++i) { if (nameMatch(name, keys.at(i).toLatin1())) { QString realName = keys.at(i); if (QTextCodecFactoryInterface *factory = qobject_cast<QTextCodecFactoryInterface*>(l->instance(realName))) { return factory->create(realName); } } } #else Q_UNUSED(name); #endif return 0; }
/** * Gets called when the name box is selected. Displays a list of names for the * client to choose in order to filter the graphing. * */ void Summary::on_nameBox_activated(int index) { FieldMatchFilter nameMatch(MEMBER_NAME, ""); vector<grantsAndFundingField> nameFields;; vector<vector<string>> nameResults; vector<Filter*> filters; int earliest = ui->lineEdit->text().toInt(); int latest = ui->lineEdit_2->text().toInt(); if(latest == 0){ time_t t = std::time(0); struct tm * now = localtime(&t); earliest = 1970; latest = now->tm_year + 1900; ui->lineEdit->setText(QString::number(earliest)); ui->lineEdit_2->setText(QString::number(latest)); } DateFilter df(earliest,latest); filters.push_back(&df); filters = chosenName(filters, &nameMatch); if(ui->tabWidget->tabText(ui->tabWidget->currentIndex()).contains("Pub",Qt::CaseInsensitive) == true){ nameFields.push_back(STATUS_DATE); db.getPublications(nameResults,filters,nameFields); } else if(ui->tabWidget->tabText(ui->tabWidget->currentIndex()).contains("Grant",Qt::CaseInsensitive) == true){ nameFields.push_back(START_DATE); db.getGrantsAndFunding(nameResults,filters,nameFields); } else if(ui->tabWidget->tabText(ui->tabWidget->currentIndex()).contains("Pres",Qt::CaseInsensitive) == true){ nameFields.push_back(DATES); db.getPresentations(nameResults,filters,nameFields); } else if(ui->tabWidget->tabText(ui->tabWidget->currentIndex()).contains("Teach",Qt::CaseInsensitive) == true){ nameFields.push_back(START_DATE); db.getTeaching(nameResults,filters,nameFields); } processDate(nameResults); graphs(); graphs(); }
// /// Internal routine used to match a portion of a filename (i.e. name or /// extension) to a wilcard pattern. // static bool nameMatch(LPCTSTR name, LPCTSTR wc) { while (true) { //if (*wc == _T('*') || (!*wc && !*name)) // Greg Bullock suggestion if ((*wc == _T('*') && (wc[1] == _T('\0'))) || (!*wc && !*name)) return true; if (*wc == _T('*')) { // The wildcard string begins with '*' but ends with something else (e.g., "*~") // We'll need to verify that the ending of name matches the wildcard string. wc++; size_t namelen = _tcslen(name); size_t wclen = _tcslen(wc); if (namelen > wclen) name += namelen - wclen; } #if defined(BI_DBCS_SUPPORT) int n = CharSize(name); if (*wc == _T('?') && *name) { wc++; name += n; continue; } else if (n > 1) { // if double byte character if (_tcsncmp(name, wc, n) == 0) { wc += n; name += n; continue; } } else if (_totupper(*name) == _totupper(*wc)) { #else if ((*wc == _T('?') && *name) || (_totupper(*name) == _totupper(*wc))) { #endif wc++; name++; continue; } break; } return false; } // /// Helper function used by 'MatchTemplate'. Returns true if the specified file name /// (path) matches the pattern of the 'filter' parameter. Returns false otherwise. // bool TDocManager::IsAMatch(LPCTSTR path, LPCTSTR fltr) { PRECONDITION(path); PRECONDITION(fltr); // Ensure path has at least a valid file name // TFileName fname(path); if (!fname.HasParts(TFileName::File)) { TRACEX(OwlDocView, 0, _T("IsAMatch: Invoked with invalid path")); return false; } // Retrieve name/extension from path // tstring name = fname.GetParts(TFileName::File); tstring ext = fname.GetParts(TFileName::Ext); // Get pointers to path's name and extension // LPCTSTR ppn = name.c_str(); LPCTSTR ppe = fname.HasParts(TFileName::Ext) ? ext.c_str() : _T(""); if (*ppe == _T('.')) ppe++; // Get pointers to filter's name and extension // TAPointer<tchar> filter(nstrnewdup(fltr)); tchar* pfn = filter; tchar* pfe = _tcsrchr(filter, _T('.')); // Skip past '.' separator of filter // if (pfe) *pfe++ = 0; const tchar* const cpfe = pfe ? pfe : _T(""); // Match the name and extension // return nameMatch(ppn, pfn) && nameMatch(ppe, cpfe); }
/** * Generates a graph once the "Graph" button on the Summary page is clicked * NOTE: Currently generates its own data - not tied to Summary; should be refactored * * @brief Summary::on_pushButton_2_clicked create the graph form. */ void Summary::graphs() { ui->tabWidget->currentIndex(); vector< vector<string> > results; vector<grantsAndFundingField> fields; FieldMatchFilter nameMatch(MEMBER_NAME,""); //Define filter of start dates within 2000 and 2001 vector<Filter*> filters; ui->lineEdit->setValidator(new QIntValidator(1000, 3000, this)); ui->lineEdit_2->setValidator(new QIntValidator(1000, 3000, this)); int earliest = ui->lineEdit->text().toInt(); int latest = ui->lineEdit_2->text().toInt(); if(earliest > latest) //throw error and do not create graph { QMessageBox messageBox; messageBox.critical(0,"Error","Invalid Range"); messageBox.setFixedSize(600,200); } else { //if range left blank set earliest to 1970, and latest to current year if(latest == 0) { time_t t = std::time(0); struct tm * now = localtime(&t); earliest = 1970; latest = now->tm_year + 1900; ui->lineEdit->setText(QString::number(earliest)); ui->lineEdit_2->setText(QString::number(latest)); } //title of the selected tab QString tabSelected = ui->tabWidget->tabText(ui->tabWidget->currentIndex()); //Apply date filters DateFilter df(earliest,latest); filters.push_back(&df); int dateChoice = ui->dateSelector->currentText().toInt(); int dataType = 0; if(tabSelected.contains("Grant",Qt::CaseInsensitive) == true){ filters = chosenName(filters,&nameMatch); fields.push_back(START_DATE); fields.push_back(TOTAL_AMOUNT); fields.push_back(ROLE); db.getGrantsAndFunding(results,filters,fields); dataType = GRANT; } else if(tabSelected.contains("Pub",Qt::CaseInsensitive) == true){ filters = chosenName(filters,&nameMatch); fields.push_back(STATUS_DATE); fields.push_back(TYPE); fields.push_back(ROLE); db.getPublications(results,filters,fields); dataType = PUBLICATION; } else if(tabSelected.contains("Teach",Qt::CaseInsensitive) == true){ filters = chosenName(filters,&nameMatch); fields.push_back(START_DATE); fields.push_back(PROGRAM); fields.push_back(TYPE_OF_COURSE); fields.push_back(HOURS_PER_SESSION_OR_WEEK); fields.push_back(NUMBER_OF_SESSIONS_OR_WEEKS); fields.push_back(TOTAL_HOURS); fields.push_back(MEMBER_NAME); db.getTeaching(results,filters,fields); dataType = TEACHING; } else if(tabSelected.contains("Pres",Qt::CaseInsensitive) == true){ filters = chosenName(filters,&nameMatch); fields.push_back(DATES); fields.push_back(TYPE); db.getPresentations(results,filters,fields); dataType = PRESENTATION; } else{ exit(EXIT_FAILURE); } graph->clearPlottables(); GraphHelper graphHelp(ui->graphSelector->currentIndex(), ui->graphChoice->currentIndex(), dataType,dateChoice,earliest,latest); graphHelp.makeGraph(graph,results); QString titleName = ""; if(QString::compare(ui->nameBox->currentText(),"All Names") != 0) titleName = " for " + ui->nameBox->currentText(); graphHelp.setTitle(graphTitle,ui->graphChoice->currentText() + titleName); graph->replot(); } }