コード例 #1
0
ファイル: Cinefacts.cpp プロジェクト: BlitzGLEP1326/MediaElch
void Cinefacts::parseImages(QString data, QStringList &posters, QStringList &backgrounds)
{
    QRegExp rx("<header><h3>Poster</h3></header>.*<ul>(.*)</ul>");
    rx.setMinimal(true);
    if (rx.indexIn(data) != -1) {
        QString poster = rx.cap(1);
        QRegExp rx2("<li><a href=\"([^\"]*)\">");
        rx2.setMinimal(true);
        int pos = 0;
        while ((pos = rx2.indexIn(poster, pos)) != -1) {
            posters.append(rx2.cap(1));
            pos += rx2.matchedLength();
        }
    }

    rx.setPattern("<header><h3>Szenenbilder</h3></header>.*<ul>(.*)</ul>");
    rx.setMinimal(true);
    if (rx.indexIn(data) != -1) {
        QString background = rx.cap(1);
        QRegExp rx2("<li><a href=\"([^\"]*)\">");
        rx2.setMinimal(true);
        int pos = 0;
        while ((pos = rx2.indexIn(background, pos)) != -1) {
            backgrounds.append(rx2.cap(1));
            pos += rx2.matchedLength();
        }
    }
}
コード例 #2
0
ファイル: Controller.cpp プロジェクト: ForNeVeR/SeaCraft
bool Controller::parseGameResult(const QString& data)
{
    QRegExp rx("win:");
    if (rx.indexIn(data)!=-1)
        {
            qDebug() << "We win!";
            emit gameResult( GR_WON );
            model->setState(ST_PLACING_SHIPS);
            model->clearMyField();
            model->clearEnemyField();
            return true;
        }

    QRegExp rx2("lose:");
    if (rx2.indexIn(data)!=-1)
        {
            qDebug() << "We lose!";
            emit gameResult( GR_LOST );
            model->setState(ST_PLACING_SHIPS);
            model->clearMyField();
            model->clearEnemyField();
            return true;
        }

    return false;
}
コード例 #3
0
ファイル: TwitPicDialog.cpp プロジェクト: roop/qwit
void TwitPicDialog::uploadFinished() {
	// The xml module is too heavy for this (and a pain to use). Managing with QRegExp for now.
	QString xmlReply = m_reply->readAll();
	xmlReply.replace("\r\n", "");
	xmlReply.replace("\n", "");
	QString errorMsg = "";
	QRegExp rx("<rsp stat=\"(\\S+)\">");
	if (rx.indexIn(xmlReply) >= 0) {
		if (rx.capturedTexts().at(1) == "ok") {
			QRegExp rx2("<mediaurl>(\\S+)<\\/mediaurl>");
			if (rx2.indexIn(xmlReply) >= 0) {
				m_twitPickedUrlString = rx2.capturedTexts().at(1);
			}
		} else {
			QRegExp rx("<err .* msg=\"([^\"]*)\"");
			if (rx.indexIn(xmlReply) >= 0) {
				errorMsg = rx.capturedTexts().at(1);
			}
		}
	}
	if (!m_twitPickedUrlString.isEmpty()) {
		QDialog::accept();
	} else if (!errorMsg.isEmpty()) {
		m_errorMsgLabel->setText("TwitPic said: " + errorMsg);
		m_progressBar->hide();
		m_errorMsgLabel->show();
	}
	m_postButton->setEnabled(true);
}
コード例 #4
0
QStringList TikzCommandInserter::getCommandWords()
{
	QStringList words;
	QString word;

	QRegExp rx1("^([^a-z\\\\<>]*<[^>]*>)*");
	QRegExp rx2("^[^a-z\\\\]*");
	QString allowedLetters = "abcdefghijklmnopqrstuvwxyz\\";
	for (int i = 0; i < m_tikzCommandsList.size(); ++i)
	{
		word = m_tikzCommandsList.at(i).description;
		// remove all special characters and <options> at the beginning of the word
		if (!word.isEmpty() && !allowedLetters.contains(word.at(0))) // minimize the number of uses of QRegExp
		{
			word.remove(rx1);
			word.remove(rx2);
		}
		if (!word.isEmpty())
			words.append(word);
		else
		{
			word = m_tikzCommandsList.at(i).command;
			// remove all special characters and <options> at the beginning of the word
			if (!word.isEmpty() && !allowedLetters.contains(word.at(0))) // minimize the number of uses of QRegExp
			{
				word.remove(rx1);
				word.remove(rx2);
			}
			if (!word.isEmpty())
				words.append(word);
		}
	}

	return words;
}
コード例 #5
0
void QFESPIMB040ScriptedAcquisitionDocSearchThread::run()
{
    for (int i=0; i<files.size(); i++) {
        QFile f(files[i]);
        if (f.open(QIODevice::ReadOnly|QIODevice::Text)) {
            QString contents=f.readAll();
            f.close();
            int pos=0;
            QRegExp rx("<!--\\s*func:([\\w\\.\\_]*)\\s*-->(.*)<!--\\s*/func:\\1\\s*-->");
            while ((pos = rx.indexIn(contents, pos)) != -1) {
                QString name=rx.cap(1).trimmed();
                QString help=rx.cap(2).trimmed();
                QRegExp rx2("<!--\\s*template\\s*-->(.*)<!--\\s*/template\\s*-->");
                QString templ="";
                if (rx2.indexIn(help,0)!=-1) {
                    templ=rx2.cap(1);
                }
                emit foundFunction(name, templ, help);
                pos += rx.matchedLength();
                if (stopped) break;
             }
        }
        if (stopped) break;
    }
}
コード例 #6
0
ファイル: csv.cpp プロジェクト: azdle/Instron-Parser
QStringList CSV::parseLine(QString line){
	QStringList list;
	int pos2 = 0;
    QRegExp rx2("(?:\"([^\"]*)\",?)|(?:([^,]*),?)");
	if(line.size()<1){
        list << "";
	}else while (line.size()>pos2 && (pos2 = rx2.indexIn(line, pos2)) != -1) {
		QString col;
		if(rx2.cap(1).size()>0)
			col = rx2.cap(1);
		else if(rx2.cap(2).size()>0)
			col = rx2.cap(2);
		
		list << col;			

		if(col.size())
			pos2 += rx2.matchedLength();
		else
			pos2++;
	}

    m_line = list;

	return list;
}
コード例 #7
0
ファイル: TSVNPath.cpp プロジェクト: yuexiaoyun/tortoisesvn
bool CTSVNPath::IsValidOnWindows() const
{
    if (m_bIsValidOnWindowsKnown)
        return m_bIsValidOnWindows;

    m_bIsValidOnWindows = true;
    EnsureBackslashPathSet();
    std::wstring checkPath = m_sBackslashPath;
    if (IsUrl())
    {
        CString uipath = CPathUtils::PathUnescape(GetSVNPathString());
        uipath.Replace('/', '\\');
        checkPath = uipath.Mid(uipath.Find('\\', uipath.Find(L":\\\\")+3)+1);
    }
    try
    {
        // now check for illegal filenames
        std::tr1::wregex rx2(L"(\\\\(lpt\\d|com\\d|aux|nul|prn|con)(\\\\|$))|\\*|[^\\\\]\\?|\\||<|>|\\:[^\\\\]", std::tr1::regex_constants::icase | std::tr1::regex_constants::ECMAScript);
        if (std::tr1::regex_search(checkPath, rx2, std::tr1::regex_constants::match_default))
            m_bIsValidOnWindows = false;
    }
    catch (std::exception) {}

    m_bIsValidOnWindowsKnown = true;
    return m_bIsValidOnWindows;
}
コード例 #8
0
ファイル: discname.cpp プロジェクト: AlexRu/rosa-media-player
DiscData DiscName::split(const QString & disc_url, bool * ok)
{
    qDebug("DiscName::split: disc_url: '%s'", disc_url.toUtf8().constData());

    QRegExp rx1("^(dvd|dvdnav|vcd|cdda)://(\\d+)/(.*)");
    QRegExp rx2("^(dvd|dvdnav|vcd|cdda)://(\\d+)");
    QRegExp rx3("^(dvd|dvdnav|vcd|cdda):///(.*)");
    QRegExp rx4("^(dvd|dvdnav|vcd|cdda):(.*)");

    DiscData d;

    bool success = false;

    if (rx1.indexIn(disc_url) != -1)
    {
        d.protocol = rx1.cap(1);
        d.title = rx1.cap(2).toInt();
        d.device = rx1.cap(3);
        success = true;
    }
    else if (rx2.indexIn(disc_url) != -1)
    {
        d.protocol = rx2.cap(1);
        d.title = rx2.cap(2).toInt();
        d.device = "";
        success = true;
    }
    else if (rx3.indexIn(disc_url) != -1)
    {
        d.protocol = rx3.cap(1);
        d.title = 0;
        d.device = rx3.cap(2);
        success = true;
    }
    else if (rx4.indexIn(disc_url) != -1)
    {
        d.protocol = rx4.cap(1);
        d.title = 0;
        d.device ="";
        success = true;
    }

    if (!d.device.isEmpty()) d.device = removeTrailingSlash(d.device);

    if (success)
    {
        qDebug("DiscName::split: protocol: '%s'", d.protocol.toUtf8().constData());
        qDebug("DiscName::split: title: '%d'", d.title);
        qDebug("DiscName::split: device: '%s'", d.device.toUtf8().constData());
    }
    else
    {
        qWarning("DiscName::split: no match in regular expression");
    }

    if (ok != 0) (*ok) = success;

    return d;
}
コード例 #9
0
PropertiesManager::PropertiesManager(RootComponentItem *r) :
    QFormLayout()
{
    root = r;
    QRegExp rx("[A-Za-z_0-9]*");
    validator = new QRegExpValidator(rx, this);
    QRegExp rx2("[A-Za-z 0-9]*");
    componentNameValidator = new QRegExpValidator(rx2, this);
}
コード例 #10
0
ファイル: SvtSoap.cpp プロジェクト: SiteView/genieautorun
bool isSetApi(const QString &module, const QString &method)
{
	Q_UNUSED(module);
    QRegExp rx("^Set");
    QRegExp rx2("^Enable");
    return (method.contains(rx) || method.contains(rx2) || method.contains("UpdateNewFirmware") || method.contains("PressWPSPBC")
         ||method=="Reboot"
         ||method=="UpdateNewFirmware");

}
コード例 #11
0
ファイル: newprojectwizard.cpp プロジェクト: fkfj/dosmall
void NewProjectWizard::accept()
{
	int type = field("projectType").toInt();
	QString projectName = field("projectName").toString();
	QString projectLocation = field("projectLocation").toString();
	QString projectPath = field("projectPath").toString();
	valid = false;
	QString projectType;
	switch (type) {
	case 0:
		projectType = "C";
		break;
	case 1:
		projectType = "C++";
		break;
	default:
		projectType = "C++";
		break;
	}
	
	QRegExp rx1("^\\s*");
	QRegExp rx2("\\s*$");
	QRegExp rx3("/$");
	projectName.remove(rx1);
	projectName.remove(rx2);
	projectLocation.remove(rx1);
	projectLocation.remove(rx2);
	projectLocation.remove(rx3);

	FileTools fileTools;
	if (!fileTools.mkdir(projectPath)) {
		QMessageBox::warning(0, QObject::tr("创建目录失败"),
							 QObject::tr("%1")
							 .arg(fileTools.errorString()));
		return;
	}
	
	if (!QFile::copy(Global::projectConfigTemplate(), projectPath + "/project.small")) {
		QMessageBox::warning(0, QObject::tr("创建项目配置文件失败"),
							 QObject::tr("copy from:%1 \ncopy to:%2")
							 .arg(Global::projectConfigTemplate())
							 .arg(projectPath + "/project.small"));
		return;
	}

	QSettings *settings = new QSettings(projectPath + "/project.small", QSettings::IniFormat);
	settings->setValue("Type", projectType);
	settings->setValue("Name", projectName);
	settings->sync();
	delete settings;
	valid = true;
	path = projectPath;
    QDialog::accept();
}
コード例 #12
0
ファイル: fileviewer.cpp プロジェクト: devjoe/codequery
void fileviewer::updateTextEdit(void)
{
	if (m_iter == m_fileDataList.end()) return;
	QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
	m_textEditSource->clear();

	QFile file(m_iter->filename);
	if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
	{
		QApplication::restoreOverrideCursor();
		return;
	}
	QTextStream in(&file);

	int lang = enHighlightCPP; // default

	QRegExp rx1("\\.py$", Qt::CaseInsensitive);
	int pos = rx1.indexIn(m_iter->filename);
	if (pos != -1) lang = enHighlightPython;

	QRegExp rx2("\\.java$", Qt::CaseInsensitive);
	pos = rx2.indexIn(m_iter->filename);
	if (pos != -1) lang = enHighlightJava;

	QRegExp rx3("\\.rb$", Qt::CaseInsensitive);
	pos = rx3.indexIn(m_iter->filename);
	if (pos != -1) lang = enHighlightRuby;

	QRegExp rx4("\\.js$", Qt::CaseInsensitive);
	pos = rx4.indexIn(m_iter->filename);
	if (pos != -1) lang = enHighlightJavascript;

	m_currentlang = lang;
	setLexer(lang);

	QString alltext;
	while (!in.atEnd())
	{
		alltext = in.readAll();
	}
	m_textEditSource->setText(alltext);
	m_textEditSource->setMarginWidth(0,  QString::number(m_textEditSource->lines() * 10));
	highlightLine(m_iter->linenum.toInt());
	updateFilePathLabel();
	m_pushButtonGoToLine->setEnabled(true);
	m_pushButtonOpenInEditor->setEnabled(true);
	m_pushButtonTextShrink->setEnabled(true);
	m_pushButtonTextEnlarge->setEnabled(true);
	m_listWidgetFunc->clear();
	if (m_iter->fileid < 0)	{emit requestFuncList_filename(m_iter->filename);}
	else {emit requestFuncList_fileid(m_iter->fileid);}
	QApplication::restoreOverrideCursor();
}
コード例 #13
0
// (LFu) this code used be the translateFilter() method in class Subscription
void MetadataFilter::setFilter(const QString& ifmapFilter)
{
    //const char *fnName = "MetadataFilter::setFilter:";

    /* non-predicate expressions joined by "or" need to be translated
       into a parenthesized expression separated by "|".

       Examples:
       meta:ip-mac or scada:node
       --> (meta:ip-mac | scada:node)

       meta:role[@publisher-id = "myPubId" or name="myRole"] or meta:ip-mac
       --> (meta:role[@publisher-id = "myPubId" or name="myRole"] | meta:ip-mac)

       standard XPath does not support predicate expressions that begin with [; need to add *
    */

    if(!ifmapFilter.isEmpty() && ifmapFilter != "*")
    {
        // (LFu) - determine if the filter looks like "ns-1:elem-1 or ... or ns-n:elem-n"
        // and provide simplified metadata matching in this case:
        QRegExp rx("((\\w|-)+:(\\w|-)+)(\\s+(or|OR)\\s+((\\w|-)+:(\\w|-)+))*");
        if(rx.exactMatch(ifmapFilter))
        {
            _simFilter = new SimplifiedFilter();
            // qDebug() << "~~regex matches filter: " << ifmapFilter;
            int pos = 0;
            QRegExp rx2("((\\w|-)+):((\\w|-)+)(\\s+(or|OR))?");
            while ((pos = rx2.indexIn(ifmapFilter, pos)) != -1) {
                _simFilter->append(QPair<QString, QString>(rx2.cap(1), rx2.cap(3)));
                // qDebug() << "~~\tns:" << rx2.cap(1) << " elem:" << rx2.cap(3);
                pos += rx2.matchedLength();
            }
        }
    }

    // TODO: Do this with QRegExp
    _filter = ifmapFilter;
    if (ifmapFilter.contains(" or ", Qt::CaseInsensitive)) {
        //qDebug() << fnName << "WARNING! filter translation is woefully incomplete!";
        //qDebug() << fnName << "filter before translation:" << ifmapFilter;
        _filter.replace(" or "," | ");
        _filter.prepend("(");
        _filter.append(")");
        //qDebug() << fnName << "filter after translation:" << qtFilter;
    }
}
コード例 #14
0
bool CTGitPath::IsValidOnWindows() const
{
	if (m_bIsValidOnWindowsKnown)
		return m_bIsValidOnWindows;

	m_bIsValidOnWindows = false;
	EnsureBackslashPathSet();
	CString sMatch = m_sBackslashPath + _T("\r\n");
	std::wstring sPattern;
	// the 'file://' URL is just a normal windows path:
	if (sMatch.Left(7).CompareNoCase(_T("file:\\\\"))==0)
	{
		sMatch = sMatch.Mid(7);
		sMatch.TrimLeft(_T("\\"));
		sPattern = _T("^(\\\\\\\\\\?\\\\)?(([a-zA-Z]:|\\\\)\\\\)?(((\\.)|(\\.\\.)|([^\\\\/:\\*\\?\"\\|<> ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?))\\\\)*[^\\\\/:\\*\\?\"\\|<> ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?$");
	}
	else
	{
		sPattern = _T("^(\\\\\\\\\\?\\\\)?(([a-zA-Z]:|\\\\)\\\\)?(((\\.)|(\\.\\.)|([^\\\\/:\\*\\?\"\\|<> ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?))\\\\)*[^\\\\/:\\*\\?\"\\|<> ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?$");
	}

	try
	{
		std::tr1::wregex rx(sPattern, std::tr1::regex_constants::icase | std::tr1::regex_constants::ECMAScript);
		std::tr1::wsmatch match;

		std::wstring rmatch = std::wstring((LPCTSTR)sMatch);
		if (std::tr1::regex_match(rmatch, match, rx))
		{
			if (std::wstring(match[0]).compare(sMatch)==0)
				m_bIsValidOnWindows = true;
		}
		if (m_bIsValidOnWindows)
		{
			// now check for illegal filenames
			std::tr1::wregex rx2(_T("\\\\(lpt\\d|com\\d|aux|nul|prn|con)(\\\\|$)"), std::tr1::regex_constants::icase | std::tr1::regex_constants::ECMAScript);
			rmatch = m_sBackslashPath;
			if (std::tr1::regex_search(rmatch, rx2, std::tr1::regex_constants::match_default))
				m_bIsValidOnWindows = false;
		}
	}
	catch (std::exception) {}

	m_bIsValidOnWindowsKnown = true;
	return m_bIsValidOnWindows;
}
コード例 #15
0
ファイル: memsensor.cpp プロジェクト: serghei/kde3-kdeutils
int MemSensor::getCached()
{
#ifdef Q_OS_FREEBSD
    static int mem = 0;
    size_t size = sizeof(mem);

    sysctlbyname("vm.stats.vm.v_cache_count", &mem, &size, NULL, 0);
    return (pagetok(mem));
#elif defined(Q_OS_NETBSD)
    return 0;
#else
    QRegExp rx1( "Cached:\\s*(\\d+)" );
    QRegExp rx2( "SwapCached:\\s*(\\d+)" );
    rx1.search( meminfo );
    rx2.search( meminfo );
    return ( rx1.cap(1).toInt() + rx2.cap(1).toInt() );
#endif
}
コード例 #16
0
void DashcoinWallet::init_ui()
{
    ui->panel_generate->hide();
    ui->panel_send_confirm->hide();
    show_wallet(false);
    syncLabel = new QLabel(this);
    messageLabel = new QLabel(this);
    syncLabel->setContentsMargins(9,0,9,0);
    messageLabel->setContentsMargins(9,0,9,0);
    ui->bar_status->addPermanentWidget(syncLabel);
    ui->bar_status->addPermanentWidget(messageLabel, 1);
    QRegularExpression rx1("[a-zA-Z0-9]*");
    QValidator *alphaNum = new QRegularExpressionValidator(rx1, this);
    ui->txt_send_address->setValidator(alphaNum);
    QRegularExpression rx2("[a-fA-F0-9]*");
    QValidator *hexOnly = new QRegularExpressionValidator(rx2, this);
    ui->txt_send_paymentid->setValidator(hexOnly);
}
コード例 #17
0
void principal::on_pushButton_7_clicked(){
    QFile  archivo("/home/jossy/proyecto/base09.txt");
    archivo.open(QIODevice::ReadOnly | QIODevice::Text);
    QTextStream escribir(&archivo);
    QString line;
     while (!escribir.atEnd()){
             line = escribir.readLine();
             qDebug() << "linea: "<<line;
             QRegExp rx(",");
             QStringList query = line.split(rx);
             Carros* car = new   Carros(query[2].toInt(0,10),query[0],query[1],"");
             lista.push_back(car);
        }

     QFile  archivo1("/home/jossy/proyecto/llenados.txt");
     archivo1.open(QIODevice::ReadOnly | QIODevice::Text);
     QTextStream escribir1(&archivo1);
     QString line1;
     while (!escribir1.atEnd()){
             line1 = escribir1.readLine();
             QRegExp rx1(":");
             QStringList query1 = line1.split(rx1);
             for(int q=0;q<lista.size();q++){
                if(lista[q]->getplaca()==query1[0]){
                     for(int o=0;o<query1.size();o++){
                          if(o>0){
                              QRegExp rx2(",");
                               QStringList query2 = query1[o].split(rx2);
                              qDebug() << "sub listas"<<query2;
                              llenado n (query2[0],query2[1].toDouble(0),query2[2].toDouble(0),query2[3].toDouble(0));
                              lista[q]->setLista(n);
                  }
              }
              }
             }
     }







}
コード例 #18
0
ファイル: bpdemainwindow.cpp プロジェクト: ashamin/Bpde
void BpdeMainWindow::filterFile() {
    QFile infile(tempfile);
    infile.open(QFile::ReadOnly);
    QFile outfile(svgfile);
    outfile.open(QFile::WriteOnly | QFile::Truncate);

    QTextStream in(&infile);
    QTextStream out(&outfile);
    QRegExp rx1("<symbol");
    QRegExp rx2("</symbol");
    while (!in.atEnd()) {
        QString line = in.readLine();
        line.replace(rx1, "<g");
        line.replace(rx2, "</g");
        out << line << "\n";
    }
    infile.close();
    outfile.close();
}
コード例 #19
0
ファイル: SvtSoap.cpp プロジェクト: SiteView/genieautorun
void SVT_Soap::setRouteType(const QString &routetype)
{
    QRegExp rx("^CG");
    QRegExp rx2("^DG");

    //which router use 5000 port
    const char * cPara[]={"WNDR3400","WNDR4500"};
    if(routetype.contains(rx)||routetype.contains(rx2))
    {
        mFlags |= IS_CGDG;
    }
    for(int i=0;i<sizeof(cPara)/sizeof(cPara[0]);i++)
    {
        if(routetype.contains(cPara[i],Qt::CaseInsensitive))
        {
            mFlags |= IS_5000PORT;
        }
    }
}
コード例 #20
0
ファイル: qtdensity.cpp プロジェクト: lab616/third_party
void QtDensity::filterFile() {
    // cairoDevice creates richer SVG than Qt can display
    // but per Michaele Lawrence, a simple trick is to s/symbol/g/ which we do here
    QFile infile(m_tempfile);
    infile.open(QFile::ReadOnly);
    QFile outfile(m_svgfile);
    outfile.open(QFile::WriteOnly | QFile::Truncate);
    
    QTextStream in(&infile);
    QTextStream out(&outfile);
    QRegExp rx1("<symbol"); 
    QRegExp rx2("</symbol");    
    while (!in.atEnd()) {
        QString line = in.readLine();
        line.replace(rx1, "<g"); // so '<symbol' becomes '<g ...'
        line.replace(rx2, "</g");// and '</symbol becomes '</g'
        out << line << "\n";
    }
    infile.close();
    outfile.close();
}
コード例 #21
0
ファイル: fileviewer.cpp プロジェクト: hxvu/xstatic
void fileviewer::updateTextEdit(void)
{
    if (!m_iter) 
        return;
    QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
    m_textEditSource->clear();
    m_highlighter->m_intAddlRulesMode = 0; //reset additional rules mode

    QFile file(m_iter->filename);
    if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        QApplication::restoreOverrideCursor();
        return;
    }
    QTextStream in(&file);

    int lang = enHighlightCPP;

    QRegExp rx1("\\.py$", Qt::CaseInsensitive);
    int pos = rx1.indexIn(m_iter->filename);
    if (pos != -1) lang = enHighlightPython;

    QRegExp rx2("\\.java$", Qt::CaseInsensitive);
    pos = rx2.indexIn(m_iter->filename);
    if (pos != -1) lang = enHighlightJava;

    m_highlighter->m_intLanguage = lang;

    while (!in.atEnd())
    {
        m_textEditSource->insertPlainText(in.readAll());
    }
    m_textEditSource->highlightLine(m_iter->linenum.toInt());
    updateFilePathLabel();
    m_pushButtonGoToLine->setEnabled(true);
    m_pushButtonOpenInEditor->setEnabled(true);
    m_pushButtonTextShrink->setEnabled(true);
    m_pushButtonTextEnlarge->setEnabled(true);
    QApplication::restoreOverrideCursor();
}
コード例 #22
0
ファイル: main.cpp プロジェクト: DerekK19/blink1
QString readColorPatternOld(QString str)
{
    QString patt;
    // try match json: '{"pattern":"my_pattern_name"}'
    QRegExp rx("\"?pattern\"?\\s*:\\s*\"(.+)\""); 
    int pos = rx.indexIn(str);
    if( pos != -1 ) { // match
        //qDebug() << "readColorPattern: match1";
        patt = rx.cap(1);
    }
    else {  // not json so try format: 'pattern: "my pattern name"'
        QRegExp rx2("pattern\\s*:\\s*(.+)\\s");
        pos = rx2.indexIn(str);
        if( pos != -1 ) { 
            //qDebug() << "readColorPattern: match2";
            patt = rx2.cap(1);
        }
    }
    //patt.replace("\"",""); // shouldn't capture doublequotes but does
    patt.remove(QRegExp("^\\s+\"*|\"*\\s+$")); // stupid qregexp doesn't allow non-greedy text capture
    return patt;
}
コード例 #23
0
ファイル: oooreportbuilder.cpp プロジェクト: wulff007/Veda
QString OOoReportBuilder::processFormula(const QString formula, int offset)
{
    //example "of:=[.C11]*[.D11]"
    QRegExp rx("\\[\\.[A-Z]{1,2}\\d+\\]");
    QString result = formula;

    int pos = 0;

    while ((pos = rx.indexIn(result,pos)) != -1) {

        QRegExp rx2("\\d+");
        int posDig = rx2.indexIn(result,pos);
        if (posDig != -1) {
            QString rowNo = QString::number(result.mid(posDig,rx2.matchedLength()).toInt() + offset);
            result.replace(posDig,rx2.matchedLength(),rowNo);
        }

        pos += rx2.matchedLength();
    }

    return result;
}
コード例 #24
0
ファイル: datawin.cpp プロジェクト: chaitu236/spim
int dataTextEdit::addrFromPos(QTextCursor* cursor)
{
    // Position of context menu is location user right-click. Find the line at this point
    // and compute the address of the memory location the user clicked on.
    //
    QPoint mouseViewportPos = this->viewport()->mapFromGlobal(contextGlobalPos);
    QTextCursor mouseCursor = this->cursorForPosition(mouseViewportPos);
    *cursor = mouseCursor;

    cursor->select(QTextCursor::LineUnderCursor);
    QString line = cursor->selectedText();

    QRegExp rx("\\[([0-9a-fA-F]{8})\\]"); // Address of instruction

    rx.indexIn(line);
    QString addrStr = rx.cap(1);
    if (addrStr != "")
    {
        bool ok;
        mem_addr addr = addrStr.toUInt(&ok, 16);
        if (ok)
        {
            // [...]<sp><sp><sp><sp>#<sp><sp>#<sp><sp>#<sp><sp>#<sp><sp>
            //
            int offset = mouseCursor.position() - cursor->anchor(); // Start of line to mouse location
            line.truncate(offset);                                  // Remove address
            line.remove(0, 14);                                     // Remove line after mouse position

            QRegExp rx2("^([0-9a-fA-F]+\\s*)?([0-9a-fA-F]+\\s*)?([0-9a-fA-F]+\\s*)?([0-9a-fA-F]+\\s*)?");
            rx2.indexIn(line, 0);
            return addr
                + (rx2.cap(1) == "" ? 0 : 0)
                + (rx2.cap(2) == "" ? 0 : BYTES_PER_WORD)
                + (rx2.cap(3) == "" ? 0 : BYTES_PER_WORD)
                + (rx2.cap(4) == "" ? 0 : BYTES_PER_WORD);
        }
    }
    return 0;
}
コード例 #25
0
ファイル: operaimporter.cpp プロジェクト: admiral0/QupZilla
QList<BookmarksModel::Bookmark> OperaImporter::exportBookmarks()
{
    QList<BookmarksModel::Bookmark> list;

    QString bookmarks = m_file.readAll();
    m_file.close();

    QRegExp rx("#URL(.*)CREATED", Qt::CaseSensitive);
    rx.setMinimal(true);

    int pos = 0;
    while ((pos = rx.indexIn(bookmarks, pos)) != -1) {
        QString string = rx.cap(1);
        pos += rx.matchedLength();

        QRegExp rx2("NAME=(.*)\\n");
        rx2.setMinimal(true);
        rx2.indexIn(string);
        QString name = rx2.cap(1);

        rx2.setPattern("URL=(.*)\\n");
        rx2.indexIn(string);
        QString url = rx2.cap(1);

        if (name.isEmpty() || url.isEmpty()) {
            continue;
        }

        BookmarksModel::Bookmark b;
        b.folder = "Opera Import";
        b.title = name;
        b.url = url;

        list.append(b);
    }

    return list;
}
コード例 #26
0
ファイル: Cinefacts.cpp プロジェクト: BlitzGLEP1326/MediaElch
void Cinefacts::parseAndAssignActors(QString html, Movie *movie, QList<int> infos)
{
    QRegExp rx;
    rx.setMinimal(true);
    if (infos.contains(MovieScraperInfos::Director)) {
        rx.setPattern("<h4>Regie</h4></header><div class=\"teasers  teasers_full\"><article><div class=\"item_content\"><header><h5><a href=\"[^\"]*\">(.*)</a></h5>");
        if (rx.indexIn(html) != 1)
            movie->setDirector(rx.cap(1));
    }

    if (infos.contains(MovieScraperInfos::Writer)) {
        rx.setPattern("<h4>Drehbuch</h4></header><div class=\"teasers  teasers_full\"><article><div class=\"item_content\"><header><h5><a href=\"[^\"]*\">(.*)</a>");
        if (rx.indexIn(html) != 1)
            movie->setWriter(rx.cap(1));
    }

    if (infos.contains(MovieScraperInfos::Actors)) {
        rx.setPattern("<section><header><h4>Darsteller</h4></header><div class=\"teasers  teasers_bild\">(.*)</div></section>");
        if (rx.indexIn(html) != -1) {
            QString actors = rx.cap(1);
            QRegExp rx2("<article><figure class=\"item_img\"><a href=\"[^\"]*\"><img  src=\"(.*)\" class=\"thumb\" ></a></figure><div class=\"item_content\"><header><h5><a href=\".*\">(.*)</a><span class=\"right2\"> Rolle: (.*)</span></h5></header>");
            rx2.setMinimal(true);
            int pos = 0;
            while ((pos = rx2.indexIn(actors, pos)) != -1) {
                QString thumb = rx2.cap(1);
                if (!thumb.startsWith("http://"))
                    thumb.prepend("http://www.cinefacts.de");
                Actor a;
                a.name = rx2.cap(2);
                a.role = rx2.cap(3);
                a.thumb = thumb;
                movie->addActor(a);
                pos += rx2.matchedLength();
            }
        }
    }
}
コード例 #27
0
void QtDialog::on_doubleSpinBox_valueChanged(double arg1)
{
  const auto m_tempfile = QString::fromStdString(Rcpp::as<std::string>(m_r_inside->parseEval("tfile <- tempfile()")));
  const auto m_svgfile  = QString::fromStdString(Rcpp::as<std::string>(m_r_inside->parseEval("sfile <- tempfile()")));

  (*m_r_inside)["a"] = arg1;
  std::string cmd0 = "svg(width=6,height=6,pointsize=10,filename=tfile); ";
  std::string cmd1 = "x <- seq(0,2*pi,0.01);";
  std::string cmd2 = "y <- sin(x * a);";
  std::string cmd3 = "plot(x,y,t='line',main=\"CppRinsideExample4\");";
  std::string cmd4 = "dev.off();";
  std::string cmd = cmd0 + cmd1 + cmd2 + cmd3 + cmd4;
  m_r_inside->parseEvalQ(cmd);

  {
    // cairoDevice creates richer SVG than Qt can display
    // but per Michaele Lawrence, a simple trick is to s/symbol/g/ which we do here
    QFile infile(m_tempfile);
    infile.open(QFile::ReadOnly);
    QFile outfile(m_svgfile);
    outfile.open(QFile::WriteOnly | QFile::Truncate);

    QTextStream in(&infile);
    QTextStream out(&outfile);
    QRegExp rx1("<symbol");
    QRegExp rx2("</symbol");
    while (!in.atEnd()) {
      QString line = in.readLine();
      line.replace(rx1, "<g"); // so '<symbol' becomes '<g ...'
      line.replace(rx2, "</g");// and '</symbol becomes '</g'
      out << line << "\n";
    }
    infile.close();
    outfile.close();
  }
  m_svg_widget->load(m_svgfile);
}
コード例 #28
0
ファイル: Cinefacts.cpp プロジェクト: BlitzGLEP1326/MediaElch
/**
 * @brief Parses the search results
 * @param html Downloaded HTML data
 * @return List of search results
 */
QList<ScraperSearchResult> Cinefacts::parseSearch(QString html)
{
    QList<ScraperSearchResult> results;
    int pos = 0;
    QRegExp rx("<a class=\"s_link\" href=\"/Filme/([^\"]*)\">([^<]*)</a>");
    rx.setMinimal(true);
    while ((pos = rx.indexIn(html, pos)) != -1) {
        ScraperSearchResult result;
        result.id = rx.cap(1);

        QRegExp rx2("(.*) \\[([0-9]{4})\\]");
        rx2.setMinimal(true);
        if (rx2.indexIn(rx.cap(2)) != -1) {
            result.name = rx2.cap(1);
            result.released = QDate::fromString(rx2.cap(2), "yyyy");
        } else {
            result.name = rx.cap(2);
        }

        results.append(result);
        pos += rx.matchedLength();
    }
    return results;
}
コード例 #29
0
void XDateEdit::parseDate()
{
  QString dateString = text().trimmed();
  bool    isNumeric;

  if (DEBUG)
    qDebug("%s::parseDate() with dateString %s, _currentDate %s, _allowNull %d",
           qPrintable(parent() ? parent()->objectName() : objectName()),
           qPrintable(dateString),
           qPrintable(_currentDate.toString()), _allowNull);

#ifdef GUIClient_h
  QDate today = ofmgThis->dbDate();
#else
  QDate today = QDate::currentDate();
#endif

  if (_parsed)
  {
    if (DEBUG)
      qDebug("%s::parseDate() looks like we've already parsed this string",
             qPrintable(parent() ? parent()->objectName() : objectName()));
    return;
  }

  _valid = false;

  if (dateString == _nullString || dateString.isEmpty())
    setNull();

  else if (dateString == "0")                           // today
    setDate(today, TRUE);

  else if (dateString.contains(QRegExp("^[+-][0-9]+"))) // offset from today
  {
    int offset = dateString.toInt(&isNumeric);
    if (isNumeric)
      setDate(today.addDays(offset), true);
  }

  else if (dateString[0] == '#')                        // julian day
  {
    int offset = dateString.right(dateString.length() - 1).toInt(&isNumeric);
    if (isNumeric)
      setDate(QDate(today.year(), 1, 1).addDays(offset - 1), TRUE);
  }

  else if (dateString.contains(QRegExp("^[0-9][0-9]?$"))) // date in month
  {
    int offset = dateString.toInt(&isNumeric, 10);
    if (isNumeric)
    {
      if (offset > today.daysInMonth())
        offset = today.daysInMonth();
 
      setDate(QDate(today.year(), today.month(), 1).addDays(offset - 1), TRUE);
    }
  }

  else                                                  // interpret with locale
  {
    QString dateFormatStr = QLocale().dateFormat(QLocale::ShortFormat);
    if (DEBUG)
      qDebug("%s::parseDate() trying to parse with %s",
             qPrintable(parent() ? parent()->objectName() : objectName()),
             qPrintable(dateFormatStr));

    QDate tmp = QDate::fromString(dateString, dateFormatStr);
    bool twodigitformat = !(dateFormatStr.indexOf(QRegExp("y{4}")) >= 0);
    if (tmp.isValid())
    {
      if (twodigitformat && tmp.year() < 1950) // Qt docs say 2-digit years are 1900-based so
      {
        qDebug("%s::parseDate() found valid 2-digit year %d",
               qPrintable(parent() ? parent()->objectName() : objectName()),
               tmp.year());
        tmp = tmp.addYears(100); // add backwards-compat with pre-3.0 DLineEdit
        qDebug("%s::parseDate() altered year to %d",
               qPrintable(parent() ? parent()->objectName() : objectName()),
               tmp.year());
      }
    }
    else if (twodigitformat)
    {
      // try 4 digits, ignoring the possibility of '-literals in the format str
      dateFormatStr.replace(QRegExp("y{2}"), "yyyy");
      if (DEBUG)
        qDebug("%s::parseDate() rewriting 2-digit year format string to %s",
               qPrintable(parent() ? parent()->objectName() : objectName()),
               qPrintable(dateFormatStr));
      tmp = QDate::fromString(dateString, dateFormatStr);

      if (tmp.isValid())
      {
        if (tmp.year() < 10)
          tmp = tmp.addYears(today.year() - today.year() % 100);
        if (DEBUG)
          qDebug("%s::parseDate() after changing to 4-digit year, year = %d",
                 qPrintable(parent() ? parent()->objectName() : objectName()),
                 tmp.year());
      }
      else if (DEBUG)
        qDebug("%s::parseDate() after changing to 4-digit year, date still isn't valid",
               qPrintable(parent() ? parent()->objectName() : objectName()));

    }
    else
    {
      // try 2 digits, ignoring the possibility of '-literals in the format str
      dateFormatStr.replace(QRegExp("y{4}"), "yy");
      if (DEBUG)
        qDebug("%s::parseDate() rewriting 4-digit year format string to %s",
               qPrintable(parent() ? parent()->objectName() : objectName()),
               qPrintable(dateFormatStr));
      tmp = QDate::fromString(dateString, dateFormatStr);
      if (tmp.isValid() && tmp.year() < 1950) // Qt docs say 2-digit years are 1900-based so
      {
        qDebug("%s::parseDate() found valid 2-digit year %d",
               qPrintable(parent() ? parent()->objectName() : objectName()),
               tmp.year());
        tmp = tmp.addYears(100); // add backwards-compat with pre-3.0 DLineEdit
        qDebug("%s::parseDate() altered year to %d",
               qPrintable(parent() ? parent()->objectName() : objectName()),
               tmp.year());
      }
    }
    if(!tmp.isValid())
    {
      // still no match -- we will decompose the format and input and
      // build a date based on that information
      QRegExp rx("(\\d+)");
      QRegExp rx2("(m+|y+|d+)");
      rx2.setCaseSensitivity(Qt::CaseInsensitive);
      QStringList numberList;
      QStringList formatList;
      int pos = 0;
      while ((pos = rx.indexIn(dateString, pos)) != -1)
      {
        numberList << rx.cap(1);
        pos += rx.matchedLength();
      }
      pos = 0;
      while((pos = rx2.indexIn(dateFormatStr, pos)) != -1)
      {
        formatList << rx2.cap(1);
        pos += rx2.matchedLength();
      }

      if (DEBUG)
        qDebug("%s::parseDate() aligning numberList %s with formatList %s",
               qPrintable(parent() ? parent()->objectName() : objectName()),
               qPrintable(numberList.join(":")), qPrintable(formatList.join(":")));

      // if we don't have exactly 3 and the numberList is not 2 or 3 then don't bother
      if(formatList.size() == 3 && (numberList.size() == 2 || numberList.size() == 3))
      {
        int year = today.year();
        int day = -1;
        int month = -1;

        pos = 0;
        for (int i = 0; i < formatList.size(); ++i)
        {
          QChar ch = formatList.at(i).toLower().at(0);
          if(ch == 'y' && numberList.size() == 3)
          {
            year = numberList.at(pos).toInt();
            pos++;
          }
          else if(ch == 'm')
          {
            month = numberList.at(pos).toInt();
            pos++;
          }
          else if(ch == 'd')
          {
            day = numberList.at(pos).toInt();
            pos++;
          }
        }

        // if single digit year, move it to the current century
        if (year < 10)
          year += today.year() - today.year() % 100;

        if(day > 0 && month > 0 && year > 0)
          tmp = QDate(year, month, day);
      }
      else if(formatList.size() == 3 && numberList.size() == 1)
      {
        QString ns = numberList.at(0);
        bool isNumber = false;
        (void)ns.toInt(&isNumber);
        if(isNumber && (ns.length() == 6 || ns.length() == 8))
        {
          int year = today.year();
          int day = -1;
          int month = -1;

          pos = 0;
          for (int i = 0; i < formatList.size(); ++i)
          {
            QChar ch = formatList.at(i).toLower().at(0);
            if(ch == 'y')
            {
              if(ns.length() == 8)
              {
                year = ns.mid(pos, 4).toInt();
                pos+=4;
              }
              else
              {
                year = ns.mid(pos, 2).toInt(&isNumber);
                pos+=2;
                if(isNumber)
                {
                  if(year < 50)
                    year += 2000;
                  else
                    year += 1900;
                }
              }
            }
            else if(ch == 'm')
            {
              month = ns.mid(pos, 2).toInt();
              pos+=2;
            }
            else if(ch == 'd')
            {
              day = ns.mid(pos, 2).toInt();
              pos+=2;
            }
          }

          if(day > 0 && month > 0 && year > 0)
            tmp = QDate(year, month, day);
        }
      }
    }

    setDate(QDate(tmp.year(), tmp.month(), tmp.day()), true );
  }

  if (!_valid)
    setText("");

  _parsed = true;
}
コード例 #30
0
ファイル: eqtoolbutton.cpp プロジェクト: JustDevZero/bulmages
/**
\param parent
**/
EQToolButton::EQToolButton ( QWidget *parent ) : QToolButton ( parent )
{
    BL_FUNC_DEBUG
    
    /// Buscamos alguna otra instancia y si la hay nos quitamos de enmedio
    EQToolButton *tool = parent->findChild<EQToolButton *>("EQToolButtonN");
    if (tool) {
      hide();
      return;
    } // end if
    setObjectName("EQToolButtonN");
    
    
    connect ( parent, SIGNAL ( pintaMenu ( QMenu * ) ), this, SLOT ( pintaMenu ( QMenu * ) ) );
    connect ( parent, SIGNAL ( trataMenu ( QAction * ) ), this, SLOT ( trataMenu ( QAction * ) ) );
    m_BlForm = ( BlForm * ) parent;
    

    
    
    
    QFrame *plugbotones = m_BlForm->findChild<QFrame *>("mui_plugbotones");
    if (plugbotones) {
	QHBoxLayout *m_hboxLayout1 = plugbotones->findChild<QHBoxLayout *> ( "hboxLayout1" );
	if ( !m_hboxLayout1 ) {
	    m_hboxLayout1 = new QHBoxLayout ( plugbotones );
	    m_hboxLayout1->setSpacing ( 5 );
	    m_hboxLayout1->setMargin ( 0 );
	    m_hboxLayout1->setObjectName ( QString::fromUtf8 ( "hboxLayout1" ) );
	} // end if
	m_hboxLayout1->addWidget ( this );

	setMinimumSize ( QSize ( 32, 32 ) );
        setMaximumSize ( QSize ( 32, 32 ) );
	setIcon ( QIcon ( ":/Images/template2ods.png" ) );
	setIconSize ( QSize ( 32, 32 ) );  	
	setPopupMode(QToolButton::InstantPopup);  
	
	/// Creamos el menu
	QMenu *menu = new QMenu(this);
	
	/// Buscamos ficheros que tengan el nombre de la tabla
	QDir dir ( g_confpr->value( CONF_DIR_OPENREPORTS ) );
	dir.setFilter ( QDir::Files | QDir::NoSymLinks );
	dir.setSorting ( QDir::Size | QDir::Reversed );
	/// Hacemos un filtrado de busqueda
	QStringList filters;
	filters << "*impers_" + m_BlForm->tableName() + "*.pys";
	dir.setNameFilters ( filters );


	QFileInfoList list = dir.entryInfoList();
	// Si no hay elementos que mostrar entonces ocultamos el boton ya que no lleva a ninguna parte.
	if (list.size() == 0) {
	    hide();
	    return;
	} // end if
	for ( int i = 0; i < list.size(); ++i ) {
	    QFileInfo fileInfo = list.at ( i );


	    QFile file;
	    file.setFileName ( g_confpr->value( CONF_DIR_OPENREPORTS ) + fileInfo.fileName() );
	    file.open ( QIODevice::ReadOnly );
	    QTextStream stream ( &file );
	    QString buff = stream.readAll();
	    file.close();

	    /// Buscamos Query's por tratar
	    QString titulo = fileInfo.fileName();
	    QRegExp rx1 ( " title\\s*=\\s*\"(.*)\"" );
	    rx1.setMinimal ( true );
	    if ( rx1.indexIn ( buff, 0 )  != -1 ) {
		titulo = rx1.cap ( 1 );
	    } // end while


            /// Buscamos Query's por tratar
            QString icon = ":/Images/template2ods.png";
            QRegExp rx2 ( " icon\\s*=\\s*\"(.*)\"" );
            rx2.setMinimal ( true );
            if ( rx2.indexIn ( buff, 0 )  != -1 ) {
                icon = rx2.cap ( 1 );
            } // end if


	    QAction *accion = menu->addAction ( titulo );
	    accion->setObjectName ( fileInfo.fileName() );
	    accion->setIcon(QIcon(icon));
	    connect ( accion, SIGNAL ( triggered ( bool ) ), this, SLOT ( trataMenu ( ) ) );
	}
	setMenu(menu);
    } else {