Exemplo n.º 1
0
void CFulEditCtrl::CheckUrls(const tstring &line, const int &lineIndex) {
	PME regexp(_T("\\s(https?://\\S+|ftps?://\\S+|mms://\\S+|www\\.\\S+|dchub://\\S+)"), _T("gims"));
	while( regexp.match(line) > 0 ){
		if( regexp.NumBackRefs() == 1){
			CHARRANGE cr;
			cr.cpMin = lineIndex + regexp.GetStartPos(0);
			cr.cpMax = cr.cpMin + regexp.GetLength(0);
			urlRanges.push_back(cr);
		} else {
			for(int j = 1; j < regexp.NumBackRefs(); ++j) {
				CHARRANGE cr;
				cr.cpMin = lineIndex + regexp.GetStartPos(j);
				cr.cpMax = cr.cpMin + regexp.GetLength(j);
				urlRanges.push_back(cr);
			}
		}
	}
}
int CalculatorWidget::calculate(const QString& expression) {
    int result = 0;
    char operation = '+';
    QRegExp regexp("(\\d+)");
    int pos = 0;
    while ((pos = regexp.indexIn(expression, pos)) != -1) {
        int value = regexp.cap(1).toInt();
        switch (operation) {
        case '+': result += value; break;
        case '-': result -= value; break;
        }
        pos += regexp.matchedLength();
        if (pos < expression.length()) {
            operation = expression.at(pos).toLatin1();
        }
    }
    return result;
}
Exemplo n.º 3
0
void TextFindReplacePanel::find (bool backwards)
{
    // Non incremental search!

    if (!mEditor) return;

    QRegExp expr = regexp();
    if (expr.isEmpty()) return;

    QTextDocument::FindFlags opt = flags();
    if (backwards)
        opt |= QTextDocument::FindBackward;

    mEditor->find(expr, opt);

    // This was not incremental search, so reset search position
    mSearchPosition = -1;
}
Exemplo n.º 4
0
bool FilterDialog::validateRegexInput()
{
    if(!regexGroupBox->isChecked())
        return true;
    QString exp(regexLineEdit->text());
    if(exp.isEmpty())
    {
        fireErrorMessageBox(tr("Regular Expression Cannot be Empty!"));
        return false;
    }
    QRegExp regexp(exp);
    if(!regexp.isValid())
    {
        fireErrorMessageBox(tr("WRONG Expression! NOTE: Use Perl standard regex syntax"));
        return false;
    }
    return true;
}
Exemplo n.º 5
0
static void
stuff()
{
    int c, left = '{', paren = 0;
    while (peek() == ' ') {
        get(FALSE);
    }
    for (;;) {
        while (peek() == '*') {
            get(FALSE);
            if (peek() == '/') {
                get(FALSE);
                if (paren > 0) {
                    error("Unbalanced stuff");
                }
                return;
            }
            emit('*');
        }
        c = get(TRUE);
        if (c == EOF) {
            error("Unterminated stuff.");
        } else if (c == '\'' || c == '"' || c == '`') {
            string(c, TRUE);
        } else if (c == '(' || c == '{' || c == '[') {
            paren += 1;
        } else if (c == ')' || c == '}' || c == ']') {
            paren -= 1;
            if (paren < 0) {
                error("Unbalanced stuff");
            }
        } else if (c == '/') {
            if (peek() == '/' || peek() == '*') {
                error("unexpected comment.");
            }
            if (pre_regexp(left)) {
                regexp(TRUE);
            }
        }
        if (c > ' ') {
            left = c;
        }
    }
}
Exemplo n.º 6
0
// ==================================================================
action_result_t TActionRegExp::exec(Tractor *tractor) const
// ==================================================================
{
	T_ASSERT(tractor);
	T_ASSERT(m_data.size());
	T_ASSERT(m_regexp.size());

	QString text(tractor->substituteValues(m_data));
	QStringList assign(m_assignto.split(",", QString::SkipEmptyParts));
	QStringList::const_iterator iter(assign.constBegin());

	QRegExp regexp(m_regexp);
	if (m_case_sensitive)
	{
		regexp.setCaseSensitivity(Qt::CaseSensitive);
	}
	else
	{
		regexp.setCaseSensitivity(Qt::CaseInsensitive);
	}

	if (m_minimal)
	{
		regexp.setMinimal(true);
	}

	int pos(text.indexOf(regexp));

	if (m_strict && pos < 0)
	{
		TERROR(("strict RegExp did not match"));
		return failure(tractor);
	}

	while (pos >= 0 && iter != assign.constEnd())
	{
		tractor->setValue(*iter, regexp.cap(1), m_global);
		pos += regexp.matchedLength();
		pos = text.indexOf(regexp, pos);
		++iter;
	}

	return action_result_normal;
}
Exemplo n.º 7
0
void GameSpyServer::receiveData()
{
    while(m_pUdpSocket->hasPendingDatagrams())
    {
        QByteArray datagram;
        datagram.resize(m_pUdpSocket->pendingDatagramSize());
        QHostAddress sender;
        quint16 senderPort;

        m_pUdpSocket->readDatagram(datagram.data(), datagram.size(),
            &sender, &senderPort);

        QMap<QString, QString> infos;
        QRegExp regexp("\\\\([^\\\\]+)\\\\");
        int pos = 0;
        while((pos = regexp.indexIn(datagram, pos)) != -1)
        {
            QString key = regexp.cap(1);
            pos += regexp.matchedLength() - 1;
            if( (key != "basic" && key != "info")
             && ((pos = regexp.indexIn(datagram, pos)) != -1) )
            {
                infos[key] = regexp.cap(1);
                pos += regexp.matchedLength() - 1;
            }
        }

        bool ok, changed = false;
        unsigned int old_players = m_iNumPlayers;
        changed = confirm_assign(&m_iNumPlayers,
            (unsigned)infos["numplayers"].toInt(&ok, 10)) || changed;
        if(infos["numplayers"] != "0")
            changed = confirm_assign(&m_iMaxPlayers,
                (unsigned)infos["maxplayers"].toInt(&ok, 10)) || changed;
        if(!infos["mapname"].isEmpty())
            changed = confirm_assign(&m_sMap, infos["mapname"]) || changed;
        if(!infos["gametype"].isEmpty())
            changed = confirm_assign(&m_sMode, infos["gametype"]) || changed;
        if(changed)
            emit infosChanged(m_iNumPlayers, m_iMaxPlayers, m_sMap, m_sMode,
                old_players == 0 && m_iNumPlayers > 0);
    }
}
Exemplo n.º 8
0
void AddCourseDialog::loadUi()
{
        saleGroupBox->hide();
	addButton->setIcon( QIcon(":/TransactionRecord/Resources/add.png") );
	delButton->setIcon( QIcon(":/TransactionRecord/Resources/remove.png") );
	upButton->setIcon( QIcon(":/TransactionRecord/Resources/up.png") );
	downButton->setIcon( QIcon(":/TransactionRecord/Resources/down.png") );

	QRegExp regexp("[0-9]{1,100}.[0-9]{0,4}");
	cbLineEdit->setValidator(new QRegExpValidator(regexp, this));

	connect( addButton, SIGNAL( clicked() ), this, SLOT( addSale() ) );
	connect( addButton, SIGNAL( clicked() ), this, SLOT( enableButtons() ) );
	connect( delButton, SIGNAL( clicked() ), this, SLOT( removeSale() ) );
	connect( delButton, SIGNAL( clicked() ), this, SLOT( enableButtons() ) );
	connect( upButton, SIGNAL( clicked() ), this, SLOT( selectItem() ) );
	connect( downButton, SIGNAL( clicked() ), this, SLOT( selectItem() ) );
	connect( okButton, SIGNAL( clicked() ), this, SLOT( okClicked() ) );
}
Exemplo n.º 9
0
bool test_26() {

	OS::get_singleton()->print("\n\nTest 26: RegEx\n");
	RegEx regexp("(.*):(.*)");
	List<String> captures;

	bool match = regexp.match("name:password", &captures);
	printf("\tmatch: %s\n", match?"true":"false");

	printf("\t%i captures:\n", captures.size());
	List<String>::Element *I = captures.front();
	while (I) {

		printf("%ls\n", I->get().c_str());

		I = I->next();
	};
	return captures.size();
};
Exemplo n.º 10
0
void RxCompile::simple()
	{
	if (match("."))
		emit(&any);
	else if (match("\\d"))
		emit(new CharClass(digit));
	else if (match("\\D"))
		emit(new CharClass(notDigit));
	else if (match("\\w"))
		emit(new CharClass(word));
	else if (match("\\W"))
		emit(new CharClass(notWord));
	else if (match("\\s"))
		emit(new CharClass(space));
	else if (match("\\S"))
		emit(new CharClass(notSpace));
	else if (matchBackref())
		{
		int i = src[si - 1] - '0';
		emit(new Backref(i, ignoringCase));
		}
	else if (match("["))
		{
		charClass();
		mustMatch(']');
		}
	else if (match("("))
		{
		int i = ++leftCount;
		emit(new Left(i));
		regexp();					// recurse
		emit(new Right(i));
		mustMatch(')');
		}
	else
		{
		if (si + 1 < sn)
			match("\\");
		emitChars(src + si, 1);
		++si;
		}
	}
Exemplo n.º 11
0
void LoginDialog::OnMainPageFinished() {
    QNetworkReply *reply = qobject_cast<QNetworkReply *>(QObject::sender());
    QString html(reply->readAll());
    QRegExp regexp("/account/view-profile/(.*)\"");
    regexp.setMinimal(true);
    int pos = regexp.indexIn(html);
    if (pos == -1) {
        DisplayError("Failed to find account name.");
        return;
    }
    QString account = regexp.cap(1);
    QLOG_DEBUG() << "Logged in as:" << account;

    std::string league(ui->leagueComboBox->currentText().toStdString());
    app_->InitLogin(std::move(login_manager_), league, account.toStdString());
    mw = new MainWindow(std::move(app_));
    mw->setWindowTitle(QString("Acquisition - %1").arg(league.c_str()));
    mw->show();
    close();
}
Exemplo n.º 12
0
QString UsefulGUIFunctions::generateUniqueDefaultName( const QString& basename,const QStringList& namelist)
{
	int max = INT_MIN;
	QString regexp(basename + "_(\\d)+");
	QStringList items = namelist.filter(QRegExp(regexp));
	for(int ii = 0;ii < items.size();++ii)
	{
		QRegExp reg("(\\d)+");
		items[ii].indexOf(reg);
		int index = reg.cap().toInt();
		if (index > max)
			max = index;
	}
	QString tmpname = basename + "_";
	if (items.size() == 0)
		tmpname += QString::number(namelist.size());
	else
		tmpname += QString::number(max + 1);
	return tmpname;
}
Exemplo n.º 13
0
void WizUpgradeChecker::_check(const QString& strUrl)
{
    QNetworkReply* reply = m_net->get(QNetworkRequest(strUrl));
    WizAutoTimeOutEventLoop loop(reply);
    loop.exec();

    QUrl possibleRedirectedUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
    m_redirectedUrl = redirectUrl(possibleRedirectedUrl, m_redirectedUrl);

    if (!m_redirectedUrl.isEmpty()) {
        // redirect to download server.
        QString strVersion;
        QRegExp regexp("(\\d{4}-\\d{2}-\\d{2})");
        if (regexp.indexIn(m_redirectedUrl.toString()) == -1) {
            Q_EMIT checkFinished(false);
            return;
        }

        strVersion = regexp.cap(0);

        int y = strVersion.split("-").at(0).toInt();
        int m = strVersion.split("-").at(1).toInt();
        int d = strVersion.split("-").at(2).toInt();

        QDate dateUpgrade(y, m, d);

        QFileInfo fi(::WizGetAppFileName());
        QDate dateLocal = fi.created().date();

        if (dateUpgrade > dateLocal) {
            TOLOG(QObject::tr("INFO: Upgrade is avaliable, version time: %1").arg(dateUpgrade.toString()));
            Q_EMIT checkFinished(true);
        } else {
            TOLOG(QObject::tr("INFO: Local version is up to date"));
            Q_EMIT checkFinished(false);
        }
    } else {
        TOLOG(QObject::tr("ERROR: Check upgrade failed"));
        Q_EMIT checkFinished(false);
    }
}
Exemplo n.º 14
0
void MainWindow::on_webView_urlChanged(const QUrl &arg1)
{
    if ("/blank.html" == arg1.path()) {
        QRegExp regexp("access_token=([^,]+)&expires_in=([^,]+)&user_id=([^,]+)");
        QString str=arg1.fragment();
        if( -1 != regexp.indexIn(str) ) {
            m_access_token = regexp.cap(1);
            m_expires_in = regexp.cap(2);
            m_user_id = regexp.cap(3);
            ui->statusBar->clearMessage();
            ui->statusBar->showMessage("Авторизирован. Можно начинать рассылку",10000);
            can_do_message=true;
        }
    }
    else if("/api/login_failure.html" == arg1.path()){
        msg.setText("Errrror. Не получил token");
        msg.exec();
        can_do_message=false;
    }

}
Exemplo n.º 15
0
bool Search::findNextScript()
{
	int sav;
	bool found = false;
	FieldArchive::Sorting sort = sorting();

	if(typeScriptChoice->currentIndex() == 0) {
		found = fieldArchive->searchScriptText(regexp(), fieldID, groupID, methodID, opcodeID, sort);
	}
	else if(typeScriptChoice->currentIndex() == 1) {
		found = fieldArchive->searchScript(1, searchOpcode->currentIndex() | (searchOpcodeValue->value() << 16), fieldID, groupID, methodID, opcodeID, sort);
	}
	else if(typeScriptChoice->currentIndex() == 2) {
		found = fieldArchive->searchScript(2, (popScriptVar->isChecked() << 31) | (selectScriptVar->currentIndex() & 0x7FFFFFFF), fieldID, groupID, methodID, opcodeID, sort);
	}
	else if(typeScriptChoice->currentIndex() == 3) {
		Field *field = fieldArchive->getField(fieldID);
		if(field != NULL && field->hasJsmFile()) {
			found = field->getJsmFile()->search(3, (selectScriptGroup->value() & 0xFFFF) | ((selectScriptLabel->value() & 0xFFFF) << 16), groupID, methodID, opcodeID);
		}
		if(!found) {
			groupID = methodID = opcodeID = 0;
			return false;
		}
	}

	if(found)
	{
		sav = opcodeID;
		emit foundOpcode(fieldID, groupID, methodID, opcodeID);
		// "found" signal may change 'opcodeID' value
		opcodeID = sav + 1;
		return true;
	}

	groupID = methodID = opcodeID = 0;
	fieldID = -1;

	return false;
}
Exemplo n.º 16
0
int E2TaskManager::getMemoryPercentUsed() const
{
    QFile file( "/proc/meminfo" );
    if ( file.open( QIODevice::ReadOnly ) ) {
        QTextStream t( &file );
        QString all = t.readAll();
        int total=0, memfree=0, buffers=0, cached = 0;
        int pos = 0;
        QRegExp regexp("(MemTotal:|MemFree:|Buffers:|\\bCached:)\\s*(\\d+) kB");
        while ( (pos = regexp.indexIn( all, pos )) != -1 ) {
            if ( regexp.cap(1) == "MemTotal:" )
                total = regexp.cap(2).toInt();
            else if ( regexp.cap(1) == "MemFree:" )
                memfree = regexp.cap(2).toInt();
            else if ( regexp.cap(1) == "Buffers:" )
                buffers = regexp.cap(2).toInt();
            else if ( regexp.cap(1) == "Cached:" )
                cached = regexp.cap(2).toInt();
            pos += regexp.matchedLength();
        }

        int realUsed = total - ( buffers + cached + memfree );
        realUsed += buffers;
        memfree += cached;
        /*
        QString unit = tr("kB");
        if (total > 10240) {
            realUsed = realUsed / 1024;
            memfree = memfree / 1024;
            total = total / 1024;
            unit = tr("MB");
        }
        //data->addItem( tr("Used (%1 %2)", "%1 = number, %2 = unit").arg(realUsed).arg(unit), realUsed );
        //data->addItem( tr("Free (%1 %2)", "%1 = number, %2 = unit").arg(memfree).arg(unit), memfree );
        //totalMem->setText( tr( "Total Memory: %1 %2", "%1 = 512 %2 = MB/kB" ).arg( total ).arg( unit ));
        */
        return realUsed * 100 / total;
    }
    return 0;
}
Exemplo n.º 17
0
void MythUIText::SetTextFromMap(QHash<QString, QString> &map)
{
    if (!IsVisible())
        return;

    if (map.contains(objectName()))
    {
        QString newText = GetTemplateText();
        if (newText.isEmpty())
            newText = GetDefaultText();

        QRegExp regexp("%(([^\\|%]+)?\\||\\|(.))?(\\w+)(\\|(.+))?%");
        regexp.setMinimal(true);
        if (!newText.isEmpty() && newText.contains(regexp))
        {
            int pos = 0;
            QString tempString = newText;
            while ((pos = regexp.indexIn(newText, pos)) != -1)
            {
                QString key = regexp.cap(4).toLower().trimmed();
                QString replacement;
                if (!map.value(key).isEmpty())
                {
                    replacement = QString("%1%2%3%4")
                                            .arg(regexp.cap(2))
                                            .arg(regexp.cap(3))
                                            .arg(map.value(key))
                                            .arg(regexp.cap(6));
                }
                tempString.replace(regexp.cap(0), replacement);
                pos += regexp.matchedLength();
            }
            newText = tempString;
        }
        else
            newText = map.value(objectName());

        SetText(newText);
    }
}
Exemplo n.º 18
0
bool Search::findPrevText()
{
	int index, size;
	FieldArchive::Sorting sort = sorting();

	--from;

	if(fieldArchive->searchTextReverse(regexp(), fieldID, textID, from, index, size, sort))
	{
//		qDebug() << "from=" << from << "(Search::findPrevText::from=index)";
		emit foundText(fieldID, textID, index, size);
		return true;
	}

	fieldID = textID = 2147483647;
	from = 0;
//	qDebug() << "FieldID=" << fieldID << "(Search::findPrevText::0)";
//	qDebug() << "textID=" << textID << "(Search::findPrevText::0)";
//	qDebug() << "from=" << from << "(Search::findPrevText::0)";

	return false;
}
Exemplo n.º 19
0
void BuildServer::readFromUdpClient()
{
    QHostAddress aQHost ;
    quint16 port ;
    QByteArray datagram ;
    do
    {
        datagram.resize( udpServer->pendingDatagramSize() ) ;
        udpServer->readDatagram( datagram.data() , datagram.size() , &aQHost , &port ) ;
    }while( udpServer->hasPendingDatagrams() ) ;

    if( datagram[ 0 ] == '1' && datagram[ 1 ] == '2' && datagram[ 2 ] == 's' && datagram[ 3 ] == 's'
            &&  datagram[ 4 ] == 'Y' && datagram[ 5 ] == 'Y' &&  datagram[ 6 ] == 'h' && datagram[ 7 ] == 'h' ) //验证客户端的udp申请
    { 
        QString hostNameStr ;
        QRegExp regexp( "12ssYYhh(.*)" ) ;
        QString( datagram ).indexOf( regexp ) ;
        hostNameStr = regexp.cap( 1 ) ;

        int rowCnt = tableWidget->rowCount() ;
        tableWidget->insertRow( rowCnt ) ;
        tableWidget->setItem( rowCnt , 0 , new QTableWidgetItem( QString::fromUtf8( hostNameStr.toAscii() ) ) ) ;
        tableWidget->setItem( rowCnt , 1 , new QTableWidgetItem( aQHost.toString() ) ) ;
        datagram = ( "12ssYYhh" + QHostInfo::localHostName() ).toUtf8() ;
        udpServer->writeDatagram( datagram.data() , datagram.size() , aQHost , 7758 ) ;
    }
    else if( datagram == "TcpConnectSucess" )
    {
        label->setText( QString::fromUtf8( "已经建立连接" ) ) ;
        QMessageBox::StandardButton reply ;
        reply = QMessageBox::question( this , "" , QString::fromUtf8( "已经建立连接" ) ) ;
        if ( reply == QMessageBox::Ok )
        {
            udpServer->close() ;
            this->close() ;
        }
    }

}
Exemplo n.º 20
0
void EList::setLayerName(QString newName){

    newName = newName.simplified();

    if(!selectedItems().isEmpty() && !newName.isEmpty()){

        //name has to be unique
        for(int i = 0; rowCount() > i; ++i)
            if(item(i, 0)->text() == newName)
                return;

        QRegularExpression regexp("[^0-9a-zA-Z]");
        if(!regexp.match(newName).hasMatch()){

            //if second column use first column
            if(1 == selectedItems().first()->column())
                item(selectedItems().first()->row(), 0)->setText(newName);
            else
                selectedItems().first()->setText(newName);
        }
    }
}
Exemplo n.º 21
0
BOOL CFulEditCtrl::HandleUrl(POINT& pt) {
	tstring tmp;

	tstring::size_type ch = TextUnderCursor(pt, tmp);
	if(ch == tstring::npos) {
		return FALSE;
	}

	int start = tmp.find_last_of(_T(" \t\r"), ch) +1;
	int end = tmp.find_first_of(_T(" \t\r"), start+1);
	if(end == tstring::npos)
		end = tmp.length();
	tstring url = tmp.substr(start, end-start);

	PME regexp(_T("^(https?://|ftps?://|mms://|www\\.|dchub://)"), _T("ims"));
	if(regexp.match(url) > 0) {
		WinUtil::openLink(url);
		return TRUE;
	}

	return FALSE;
}
Exemplo n.º 22
0
QString WebView::promptForFilename(const QNetworkRequest& request,
                                   QNetworkReply* pReply = NULL)
{
   QString defaultFileName = QFileInfo(request.url().path()).fileName();

   // Content-Disposition's filename parameter should be used as the
   // default, if present.
   if (pReply && pReply->hasRawHeader("content-disposition"))
   {
      QString headerValue = QString::fromAscii(pReply->rawHeader("content-disposition"));
      QRegExp regexp(QString::fromAscii("filename=(.+)"), Qt::CaseInsensitive);
      if (regexp.indexIn(headerValue) >= 0)
      {
         defaultFileName = regexp.cap(1);
      }
   }

   QString fileName = QFileDialog::getSaveFileName(this,
                                                   tr("Download File"),
                                                   defaultFileName);
   return fileName;
}
Exemplo n.º 23
0
grep_string(string lines,string exp, string file) {
string *lines_array;
string *matched_arr;
int i, z;
 
    lines_array=explode(lines,"\n");

    matched_arr=regexp(lines_array,exp);

	z = 0;
    
	if (!matched_arr)
        return;

	if(moreflag == 0) {
    	for (i=0;i<sizeof(matched_arr);i++)
        	printf("%s:%s\n", file, matched_arr[i]);
	} else {
    	for (i=0;i<sizeof(matched_arr);i++) {
		   output += ({sprintf("%s:%s\n", file, matched_arr[i])});
		}
	}
Exemplo n.º 24
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    qmlRegisterType<MemoryInitFile>("MemoryInitialization",1,0,"MemoryInitFile");
    qmlRegisterType<MemoryChunk>("MemoryInitialization", 1, 0, "MemoryChunk");
    qmlRegisterType<ChunkData>("MemoryInitialization", 1, 0, "ChunkData");
    QQmlApplicationEngine engine;

    MemoryInitFile  active_file(&app);
    QRegExp   regexp("[0-9abcdef]*");
    QRegExp   regexp2("[0-9]*");
    AddressValidator valid(&active_file,&app);
    ValueValidator   valid2(&active_file, &app);
    valid.setRegExpression(regexp);
    valid2.setRegExpression(regexp2);
    engine.rootContext()->setContextProperty("MemoryFileEngine",&active_file);
    engine.rootContext()->setContextProperty("AddressValidator",&valid);
    engine.rootContext()->setContextProperty("ValueValidator",&valid2);
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));

    return app.exec();
}
Exemplo n.º 25
0
static QColor stringToColor(const QString& s)
{
    QRegExp regexp(QLatin1String("(rgb|rgba)\\s*\\((.+)\\)\\s*"));

    if (regexp.exactMatch(s))
    {
        QStringList colors = regexp.cap(1).split(QLatin1Char(','), QString::SkipEmptyParts);

        if (colors.size() >= 3)
        {
            QColor c(colors.at(0).toInt(), colors.at(1).toInt(), colors.at(2).toInt());

            if (regexp.cap(0) == QLatin1String("rgba") && colors.size() == 4)
            {
                c.setAlpha(colors.at(4).toInt());
            }

            return c;
        }
    }

    return QColor();
}
Exemplo n.º 26
0
QWidget * ExtArgBool::createEditor(QWidget * parent)
{
    bool state = defaultBool();

    boolBox = new QCheckBox(QString().fromUtf8(_argument->display), parent);
    if ( _argument->tooltip != NULL )
        boolBox->setToolTip(QString().fromUtf8(_argument->tooltip));

    if ( _argument->storeval )
    {
        QRegExp regexp(EXTCAP_BOOLEAN_REGEX);

        bool savedstate = ( regexp.indexIn(QString(_argument->storeval[0]), 0) != -1 );
        if ( savedstate != state )
            state = savedstate;
    }

    boolBox->setCheckState(state ? Qt::Checked : Qt::Unchecked );

    connect (boolBox, SIGNAL(stateChanged(int)), SLOT(onIntChanged(int)));

    return boolBox;
}
Exemplo n.º 27
0
bool Search::findNextText()
{
	int size;
	FieldArchive::Sorting sort = sorting();

	++from;

	if(fieldArchive->searchText(regexp(), fieldID, textID, from, size, sort))
	{
//		qDebug() << "from=" << from << "(MsdFile::findNextText::from=index)";
		emit foundText(fieldID, textID, from, size);
		// "found" signal may change 'from' value
//		qDebug() << "from=" << from << "(MsdFile::findNextText::from++)";
		return true;
	}

	textID = from = fieldID = -1;
//	qDebug() << "FieldID=" << fieldID << "(Search::findNextText::0)";
//	qDebug() << "textID=" << textID << "(Search::findNextText::0)";
//	qDebug() << "from=" << from << "(MsdFile::findNextText::0)";

	return false;
}
Exemplo n.º 28
0
void MythUIText::ResetMap(const InfoMap &map)
{
    QString newText = GetTemplateText();

    if (newText.isEmpty())
        newText = GetDefaultText();

    QRegExp regexp("%(([^\\|%]+)?\\||\\|(.))?([\\w#]+)(\\|(.+))?%");
    regexp.setMinimal(true);

    bool replaced = map.contains(objectName());

    if (!replaced && !newText.isEmpty() && newText.contains(regexp))
    {
        int pos = 0;

        QString translatedTemplate = qApp->translate("ThemeUI",
                                                     newText.toUtf8());

        while ((pos = regexp.indexIn(translatedTemplate, pos)) != -1)
        {
            QString key = regexp.cap(4).toLower().trimmed();

            if (map.contains(key))
            {
                replaced = true;
                break;
            }
            pos += regexp.matchedLength();
        }
    }

    if (replaced)
    {
        Reset();
    }
}
Exemplo n.º 29
0
CString CCommands::XApplicationEvents::GetRegexpData( IN CString Data, IN LPCTSTR lpRegexp, IN DWORD dwRegexpType, LPCTSTR sNamedGroup /*= NULL*/ )
{
	CRegexpT <TCHAR> regexp(lpRegexp, dwRegexpType);
	CString strRetData;
	MatchResult result = regexp.Match(Data);
	if (result.IsMatched())
	{
		int iStart, iEnd;
		if (sNamedGroup == NULL)
		{
			iStart = result.GetGroupStart(1); //得到 捕获组\1
			iEnd = result.GetGroupEnd(1);

			if (iStart < 0 || iEnd < 0)
			{
				return "";
			}

			strRetData = Data.Mid(iStart, iEnd - iStart);
		}
		else
		{
			int iIndex;
			iIndex = regexp.GetNamedGroupNumber(sNamedGroup);
			if (iIndex < 0)
			{
				return "";
			}

			iStart = result.GetGroupStart(iIndex);
			iEnd = result.GetGroupEnd(iIndex);

			strRetData = Data.Mid(iStart, iEnd - iStart);
		}
	}
	return strRetData;
}
Exemplo n.º 30
0
AddCurrencyDialog::AddCurrencyDialog(QWidget *parent, Qt::WFlags flags)
	: QDialog(parent, flags)
{
	setupUi(this);
	progressBar->hide();

	QIcon okIcon(style()->standardPixmap(QStyle::SP_DialogApplyButton));
	errorIcon = style()->standardPixmap(QStyle::SP_MessageBoxCritical);
	warningLabel->setPixmap( okIcon.pixmap( QSize(22,22) ) );

	QRegExp regexp("^0{0,1}[0-9]{1,2}$");
	debetLineEdit->setValidator(new QRegExpValidator(regexp, this));
	creditLineEdit->setValidator(new QRegExpValidator(regexp, this));
	unknownLineEdit->setValidator(new QRegExpValidator(regexp, this));
	transitLineEdit->setValidator(new QRegExpValidator(regexp, this));

	QRegExp regexp1("^1{1,1}0{1,1}[0-9]{3,3}$");
	numberLineEdit->setValidator(new QRegExpValidator(regexp1, this));

	connect( cancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
	connect( checkBox, SIGNAL( stateChanged(int) ), this, SLOT( enableNumberLineEdit() ) );
	connect( checkBox, SIGNAL( stateChanged(int) ), this, SLOT( enableOkButton() ) );

	QList<QLineEdit*> list = this->findChildren<QLineEdit *>();
	for(int i = 0; i < list.count(); i++)
		connect( list[i], SIGNAL( textChanged( const QString &) ), this, SLOT( enableOkButton() ) );
	connect( okButton, SIGNAL( clicked() ), this, SLOT( okClicked() ) );

	
	socket.setConnection( host, port, "check_if_major_currency_exists(@result)");
	progressBar->show();

	connect( &socket, SIGNAL( canGetData() ), this, SLOT( checkData() ) );
	connect( &socket, SIGNAL( errorRaised() ), this, SLOT( loadError() ) );
	connect( &qSocket, SIGNAL( canGetData() ), this, SLOT( checkAnswer() ) );
	connect( &qSocket, SIGNAL( errorRaised() ), this, SLOT( loadError() ) );
}