bool TimelineView::match(Twitter::TwitterItem &item, const ForwardingRule &rule){ QRegExp::PatternSyntax pat; Qt::CaseSensitivity cs; if(rule.useRegex) pat = QRegExp::RegExp; else pat = QRegExp::FixedString; if(rule.caseSensitive) cs = Qt::CaseSensitive; else cs = Qt::CaseInsensitive; QRegExp namerx(rule.name, cs, pat); QRegExp contrx(rule.content, cs, pat); QRegExp bothrx(rule.nameOrContent, cs, pat); bool matched = false; if(rule.complex){ if((!rule.name.isEmpty() && namerx.indexIn(item.screenName(),0) != -1) && (!rule.content.isEmpty() && contrx.indexIn(item.status(),0) != -1)){ matched = true; } }else{ if(!rule.nameOrContent.isEmpty() && (bothrx.indexIn(item.screenName(),0) != -1 || bothrx.indexIn(item.status(),0) != -1)){ matched = true; } } if(!matched) return false; if(rule.exUseRegex) pat = QRegExp::RegExp; else pat = QRegExp::FixedString; if(rule.exCaseSensitive) cs = Qt::CaseSensitive; else cs = Qt::CaseInsensitive; QRegExp exnamerx(rule.exName, cs, pat); QRegExp excontrx(rule.exContent, cs, pat); QRegExp exbothrx(rule.exNameOrContent, cs, pat); bool exmatched = false; if(rule.exComplex){ if((!rule.exName.isEmpty() && exnamerx.indexIn(item.screenName(),0) != -1) && (!rule.exContent.isEmpty() && excontrx.indexIn(item.status(),0) != -1)){ exmatched = true; } }else{ if(!rule.exNameOrContent.isEmpty() && (exbothrx.indexIn(item.screenName(),0) != -1 || exbothrx.indexIn(item.status(),0) != -1)){ exmatched = true; } } return !exmatched; }
MakeAtomDialog::MakeAtomDialog(MainWindow *parent) : QDialog(parent) { ui.setupUi(this); mainWindow_ = parent; workingDir_ = mainWindow_->workingDir(); //restrict what can be entered into each of the boxes QRegExp namerx("[A-Z][A-Za-z0-9]{2}"); ui.nameLineEdit->setValidator(new QRegExpValidator(namerx, this)); QRegExp numberrx("^\\d*\\.?\\d*$"); ui.epsilonLineEdit->setValidator(new QRegExpValidator(numberrx, this)); ui.sigmaLineEdit->setValidator(new QRegExpValidator(numberrx, this)); ui.massLineEdit->setValidator(new QRegExpValidator(numberrx, this)); QRegExp chargerx("^-?\\d*\\.?\\d*$"); ui.chargeLineEdit->setValidator(new QRegExpValidator(chargerx, this)); QRegExp symbolrx("[A-Z]{1}[a-z]?"); ui.symbolLineEdit->setValidator(new QRegExpValidator(symbolrx, this)); connect(ui.okButton, SIGNAL(clicked()), this, SLOT(checkFiles())); connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(reject())); }