ExternalFileDataParser::EFileLineType ExternalFileDataParser::determineLineType(const std::string & line)
	{
		if (line.empty())
		{
			return EFileLineType::EmptyLine;
		}

		if ('#' == line.front())
		{
			return EFileLineType::Comment;
		}

		{
			std::regex regExp("numberOfSamples.*");
			if (std::regex_match(line, regExp))
			{
				return EFileLineType::NumberOfSamples;
			}
		}

		{
			std::regex regExp("samplePeriod.*");
			if (std::regex_match(line, regExp))
			{
				return EFileLineType::SamplePeriod;
			}
		}

		{
			std::regex regExp("description.*");
			if (std::regex_match(line, regExp))
			{
				return EFileLineType::Description;
			}
		}
		
		{
			std::regex regExp("data.*");
			if (std::regex_match(line, regExp))
			{
				return EFileLineType::DataKeyWord;
			}
		}

		if (Utilities::isDouble(line))
		{
			return EFileLineType::Data;
		}

		return EFileLineType::Unknown;
	}
示例#2
0
bool auxiliary::regExp(const char* R, const char* C)
{
  if (*R=='*' && *(R+1)==0) 
  {
    return true;
  }
  if (*C==0)
  {
    return *R==0; 
  }
  
  switch(*R) { 
    case 0: 
      return false;
    
    case '\\':
      return *(++R)==*C ? regExp(++R, ++C) : false;
  
    case '!':
      return *(++R)!=*C ? regExp(++R, ++C) : false;
      
    case '~':
      return *(++R)!=*C ? regExp(R+1, C) || regExp(R+1, C+1) : false;
      
    case '?': 
      return regExp(++R, ++C);
    
    case '*': 
      return regExp(R+1,C) || regExp(R,C+1 );

    default:
      return (*R)==(*C) ? regExp(++R, ++C) : false;
  }
}
QString DiffAnalystWindow::getNextDiffSessionName()
{
	QString defaultName = "Untitled-";
	int counter = 1;
	QStringList nameList;
	QString ret = "";

	QWidgetList wl = m_pWs->windowList(QWorkspace::CreationOrder);
	QWidgetList::iterator it = wl.begin();
	QWidgetList::iterator end = wl.end();
	for( ; it != end ; it++)
	{
		nameList.push_back( (*it)->name() );
	}

	while(1)
	{
		QString pattern = QString("^")+ defaultName + QString::number(counter) + "$";
		QRegExp regExp(pattern);
		if(nameList.grep(regExp).size() == 0)
		{
			ret = defaultName + QString::number(counter);
			break;
		}else{
			counter++;
		}
	}
	return ret;	
}
IGPrecisionDialog::IGPrecisionDialog(QWidget* parent):
    QDialog(parent)
{
    setupUi(this);
    QRegExp regExp("[1-9][0-9]{0,1}");
    lineEdit->setValidator( new QRegExpValidator(regExp, this) );
}
示例#5
0
Style_Edit::Style_Edit(QWidget *parent, QWidget *dwFrom)
   : QDialog(parent), ui(new Ui::Style_Edit)
{
   ui->setupUi(this);
   m_dwFrom = dwFrom;

   QRegExp regExp(".(.*)\\+?Style");
   QString defaultStyle = QApplication::style()->metaObject()->className();

   if (regExp.exactMatch(defaultStyle)) {
      defaultStyle = regExp.cap(1);
   }

   // 1
   ui->styleCombo->addItems(QStyleFactory::keys());
   ui->styleCombo->setCurrentIndex(ui->styleCombo->findText(defaultStyle, Qt::MatchContains));

   // 2
   ui->styleSheetCombo->setCurrentIndex(ui->styleSheetCombo->findText(Style_Edit::qssName));

   QString styleSheet = this->readStyleSheet(Style_Edit::qssName);
   ui->styleTextEdit->setPlainText(styleSheet);
   ui->applyPB->setEnabled(false);

   // signal
   connect(ui->closePB, SIGNAL(clicked()), this, SLOT(actionClose()));
}
示例#6
0
QSObject QSRegExpClass::fetchValue( const QSObject *objPtr,
				    const QSMember &mem ) const
{
    if ( mem.type() != QSMember::Custom )
	return QSWritableClass::fetchValue( objPtr, mem );

    QRegExp *re = regExp( objPtr );
    switch ( mem.index() ) {
    case Valid:
	return createBoolean( re->isValid() );
    case Empty:
	return createBoolean( re->isEmpty() );
    case MLength:
	return createNumber( re->matchedLength() );
    case Source:
	return createString( source(objPtr) );
    case Global:
	return createBoolean( isGlobal(objPtr) );
    case IgnoreCase:
	return createBoolean( isIgnoreCase(objPtr) );
    case CTexts: {
 	QSArray array( env() );
 	QStringList ct = re->capturedTexts();
 	QStringList::ConstIterator it = ct.begin();
 	int i = 0;
 	for ( ; it != ct.end(); ++it, ++i )
 	    array.put( QString::number( i ), createString( *it ) );
	array.put( QString::fromLatin1("length"), createNumber( i ) );
 	return array;
    }
    default:
	return createUndefined();
    }
}
示例#7
0
K3b::Msf K3b::Msf::fromString( const QString& s, bool* ok )
{
  QRegExp rx = regExp();

  K3b::Msf msf;

  if( rx.exactMatch( s ) ) {
    //
    // first number - cap(1)
    // second number - cap(2)
    // third number - cap(3)
    //
    if( rx.cap(2).isEmpty() ) {
      msf.m_frames = rx.cap(1).toInt();
    }
    else {
      msf.m_minutes = rx.cap(1).toInt();
      msf.m_seconds = rx.cap(2).toInt();
      msf.m_frames = rx.cap(3).toInt();
    }

    if( ok )
      *ok = true;
  }
  else if( ok )
    *ok = false;

  msf.makeValid();

  return msf;
}
QStringList PluginGame5GraphDialog::parseTrace()
{
	QFile trcFile(getTraceFile());
	QString trcString;
	if (trcFile.open(QIODevice::ReadOnly))
	{
		trcString = QString(trcFile.readAll());
	}

	int begin = trcString.indexOf("SB");
	int end   = trcString.indexOf("SEN", begin + 2);
	QString trcStringS;
	trcStringS = trcString.mid(begin + 2, end - begin - 2);

	QRegExp regExp("(STN|STR)(((\\s)-?\\d{1,5}){8}((\\s)(\\s)(\\d{1,2})(\\s)(\\d{1,2})))(((\\nSRK)((\\s)\\d){4})(\\s\\d{1,2})((\\nSRK)((\\s)\\d){3})(\\s\\d{1,2}))?");
	QStringList list;
	int pos=0;
	while((pos = regExp.indexIn(trcStringS, pos))!= -1)
	{
		list << regExp.cap(2) + regExp.cap(16) + regExp.cap(21);
		pos += regExp.matchedLength();
	}
	trcFile.close();
	return list;
}
示例#9
0
bool rspfDtedInfo::open(const rspfFilename& file)
{
   bool result = false;

   // Test for extension, like dt0, dt1...
   rspfString ext = file.ext();
   rspfRegExp regExp("^[d|D][t|T][0-9]");
   
   if ( regExp.find( ext.c_str() ) )
   {
      rspfDtedVol vol(file, 0);
      rspfDtedHdr hdr(file, vol.stopOffset());
      rspfDtedUhl uhl(file, hdr.stopOffset());
      rspfDtedDsi dsi(file, uhl.stopOffset());
      rspfDtedAcc acc(file, dsi.stopOffset());
      
      //---
      // Check for errors.  Must have uhl, dsi and acc records.  vol and hdr
      // are for magnetic tape only; hence, may or may not be there.
      //---
      if ( (uhl.getErrorStatus() == rspfErrorCodes::RSPF_OK) &&
           (dsi.getErrorStatus() == rspfErrorCodes::RSPF_OK) &&
           (acc.getErrorStatus() == rspfErrorCodes::RSPF_OK) )
      {
         theFile = file;
         result = true;
      }
      else
      {
         theFile.clear();
      }
   }

   return result;
}
示例#10
0
EditUserDlg::EditUserDlg(int iType,QWidget *parent) :
    QDialog(parent),
    ui(new Ui::EditUserDlg)
{
    ui->setupUi(this);

    QPalette palette;
    palette.setColor(QPalette::Background, QColor(224,237,254));
    setPalette(palette);
    //setWindowOpacity(0.95);

    QRegExp regExp("[0-9A-Za-z_]*");
    QValidator *validator = new QRegExpValidator(regExp, this);
    ui->edit_password->setValidator(validator);
    ui->edit_password->setToolTip(tr("有效字符:A-Z,a-z,0-9,_"));

    ui->edit_name->setValidator(validator);
    ui->edit_name->setToolTip(tr("有效字符:A-Z,a-z,0-9,_"));


    ui->label_confirm->hide();
    ui->edit_confirm->hide();

    setFixedSize(size());
    iOpenType = iType; //-1标示新建,大于等于0的数表示打开属性修改
    setWindowTitle(tr("用户属性"));
    ui->edit_name->setFocus();
    init();
}
示例#11
0
void SearchView::executeRequestFromIndex(int index)
{
    SearchViewItem *it = (SearchViewItem*)mWidgets.at(index);

    if (index <= mGoogleSearch.count())
    {
        QString url = mServices.value("Google").arg(it->getText());
        Application::getWindow()->getWebContainer()->getWebView()->load(QUrl(url));

        this->hide();
    }
    else if (index <= mGoogleSearch.count() + mServices.keys().count() + 2)
    {
        QRegExp regExp("\".*\" on (.*)");
        if (regExp.exactMatch(it->getText()))
        {
            QString url = mServices.value(regExp.capturedTexts().at(1)).arg(mWord);
            Application::getWindow()->getWebContainer()->getWebView()->load(QUrl(url));

            this->hide();
        }
    }
    else
    {
        Application::getWindow()->getWebContainer()->getWebView()->findText("", QWebPage::HighlightAllOccurrences);
        Application::getWindow()->getWebContainer()->getWebView()->findText(mWord, QWebPage::HighlightAllOccurrences);

        this->hide();
    }
}
示例#12
0
void KFindDialog::slotOk()
{
    // Nothing to find?
    if (pattern().isEmpty())
    {
        KMessageBox::error(this, i18n("You must enter some text to search for."));
        return;
    }

    if (m_regExp->isChecked())
    {
        // Check for a valid regular expression.
        TQRegExp regExp(pattern());

        if (!regExp.isValid())
        {
            KMessageBox::error(this, i18n("Invalid regular expression."));
            return;
        }
    }
    m_find->addToHistory(pattern());
    emit okClicked();
    if ( testWFlags( WShowModal ) )
        accept();
}
示例#13
0
void MainWindow::filter_topics( const QString & text ) {
    QRegExp regExp(text);
    topicFilter->setDynamicSortFilter(true);
    topicFilter->setFilterKeyColumn(1);
    topicFilter->setFilterRegExp(regExp);
    topicFilter->setFilterCaseSensitivity(Qt::CaseInsensitive);
}
示例#14
0
FormationData::FormationData(QString data)
{
    QStringList temp;
    temp = data.split("=");
    index = temp[0].toInt();
    data = temp[1];
    QRegExp regExp("[(][-]?[0-9]*\\.?[0-9]*,[-]?[0-9]*\\.?[0-9]*[)]");
    if(regExp.indexIn(data)!=-1)
    {
        QString t = regExp.cap(0);
        data = data.mid(t.length());
        ball.x = t.mid(1,t.indexOf(",")-1).toDouble();
        t = t.mid(t.indexOf(",")+1);
        t = t.mid(0,t.length()-1);
        ball.y = t.toDouble();
    }
    while(regExp.indexIn(data)!=-1)
    {
        QString t = regExp.cap(0);
        data = data.mid(t.length());
        Vector2D vec;
        vec.x = t.mid(1,t.indexOf(",")-1).toDouble();
        t = t.mid(t.indexOf(",")+1);
        t = t.mid(0,t.indexOf(")"));
        vec.y = t.toDouble();
        robots.append(vec);
    }
}
示例#15
0
QString ParentFolderMethod::rename(QString path, QString fileName, QString query, bool caseSensitive, QString renameString)
{
    const QString format = "<p(\\d*)>";
    QRegExp regExp(format);
    regExp.setCaseSensitivity(Qt::CaseInsensitive);
    int pos = 0;
    pos = regExp.indexIn(fileName, pos);
    if(pos == -1) return fileName;

    int hierarchy = 1;
    /*遡る階層数を決定*/
    if(regExp.cap(1) != ""){
        hierarchy = regExp.cap(1).toInt();
    }

    QString parentPath = path;
    for (int i = 0; i < hierarchy - 1; i++){
        parentPath += QDir::separator() + QString("..");
    }

    QString parentFolder;
    QDir dir(QDir(parentPath).canonicalPath());
    if(dir.exists()){
        parentFolder = dir.dirName();
    } else {
        //親フォルダが存在しない場合は空文字を返す
        parentFolder = "";
    }

    QString renamed = fileName;
    renamed.replace(QRegExp(regExp.cap(0)), parentFolder);

    // 同一置換文字列内に複数の<f>リテラルがあった場合に対処するため、再帰処理にする。
    return rename(path, renamed, query, caseSensitive, renameString);
}
GMCharTools::GMCharTools(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::GMCharTools)
{
    ui->setupUi(this);

    addCBills = 0;
    addXP = 0;

//    QRegExp regExp("[0-9]{0,}[.][0-9]{1,2}");
    QRegExp regExp("[0-9]{0,}");
    ui->ToMoneyAddGm->setValidator(new QRegExpValidator(regExp,this));
    ui->FromMoneyAddGm->setValidator(new QRegExpValidator(regExp,this));
    QRegExp regExpXP("[0-9]{0,}");
    ui->XPAddGM->setValidator(new QRegExpValidator(regExpXP,this));

//    double a = 12345.12;
//    double b = 54321.12;
//    double c;

//    c = a*b;

//    QString str;
//    str = QVariant(c).toString();

//    qDebug() << str;
}
示例#17
0
QList<QString>
CXParamData::getImages(const QString& aFileName, const QString& aType)
{
  QList<QString> res;

  QXmlQuery xmlQuery(QXmlQuery::XQuery10);
  xmlQuery.setQuery(
      QString("doc('%1')/Settings/ui-TechParams/%2/assembly").arg(aFileName).arg(
          aType));

  if (!xmlQuery.isValid())
    return res;

  QString text;
  if (xmlQuery.evaluateTo(&text))
    {
      QRegExp regExp("<item +path=\"([^\"]+)\"[^>]*/>");
      regExp.setMinimal(true);

      int index = regExp.indexIn(text);
      while (index >= 0)
        {
          res.append(regExp.cap(1));

          index += regExp.matchedLength();
          index = regExp.indexIn(text, index);
        }
    }

  return res;
}
示例#18
0
QMap<QString, QString>
CXParamData::getFixedKeys(const QString& aFileName, const QString& aType)
{
  QMap<QString, QString> res;

  QXmlQuery xmlQuery(QXmlQuery::XQuery10);
  xmlQuery.setQuery(
      QString("doc('%1')/Settings/ui-TechParams/%2/fixed").arg(aFileName).arg(
          aType));

  if (!xmlQuery.isValid())
    return res;

  QString text;
  if (xmlQuery.evaluateTo(&text))
    {
      QRegExp regExp("<([^<]+) +value=\"([^\"]+)\" */>");
      regExp.setMinimal(true);

      int index = regExp.indexIn(text);
      while (index >= 0)
        {
          if (regExp.cap(4).isEmpty() || regExp.cap(4) != "0")
            {
              res.insert(regExp.cap(1), regExp.cap(2));
            }

          index += regExp.matchedLength();
          index = regExp.indexIn(text, index);
        }
    }

  return res;
}
示例#19
0
int QRegExpValidator::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QValidator::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    
#ifndef QT_NO_PROPERTIES
     if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QRegExp*>(_v) = regExp(); break;
        }
        _id -= 1;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setRegExp(*reinterpret_cast< QRegExp*>(_v)); break;
        }
        _id -= 1;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 1;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
示例#20
0
QString VPreviewManager::fetchImageUrlToPreview(const QString &p_text, int &p_width, int &p_height)
{
    QRegExp regExp(VUtils::c_imageLinkRegExp);

    p_width = p_height = -1;

    int index = regExp.indexIn(p_text);
    if (index == -1) {
        return QString();
    }

    int lastIndex = regExp.lastIndexIn(p_text);
    if (lastIndex != index) {
        return QString();
    }

    QString tmp(regExp.cap(7));
    if (!tmp.isEmpty()) {
        p_width = tmp.toInt();
        if (p_width <= 0) {
            p_width = -1;
        }
    }

    tmp = regExp.cap(8);
    if (!tmp.isEmpty()) {
        p_height = tmp.toInt();
        if (p_height <= 0) {
            p_height = -1;
        }
    }

    return regExp.cap(2).trimmed();
}
std::vector<int> PluginGame5GraphDialog::getSolutionNodes()
{
	QFile trcFile(getTraceFile());
	QString trcString;
	if (trcFile.open(QIODevice::ReadOnly))
	{
		trcString = QString(trcFile.readAll());
	}

	QString solutionStr;
	int begin = trcString.indexOf("SD");
	int end;
	if (begin > 0)
	{
		end = trcString.indexOf("SES", begin);
		solutionStr = trcString.mid(begin + 2, end - begin - 2);
	}

	QRegExp regExp("(\\d{1,5})((\\s\\d){3}\\s\\s\\d{1,2}\\s\\d{1,2})");
	std::vector<int> list;
	list.push_back(1);

	int pos=0;
	while((pos = regExp.indexIn(solutionStr, pos))!= -1)
	{
		list.push_back(regExp.cap(1).toInt());
		pos += regExp.matchedLength();
	}

	trcFile.close();
	return list;
}
TypeDocForm::TypeDocForm(QString id, QWidget *parent, bool onlyForRead) :
    QDialog(parent)
{
    exchangeFile.setFileName("Message.txt");
    if(!exchangeFile.isOpen()){
        exchangeFile.open(QIODevice::ReadWrite);
    }

    indexTemp = id;

    QFile file(":/ToolButtonStyle.txt");
    file.open(QFile::ReadOnly);
    //QString styleSheetString = QLatin1String(file.readAll());

    labelName = new QLabel(trUtf8("Prichina Obuch:"));
    editName = new LineEdit;
    editName->setReadOnly(onlyForRead);
    QRegExp regExp("[\\x0410-\\x044f 0-9 ()\" -]{150}");
    editName->setValidator(new QRegExpValidator(regExp,this));
    labelName->setBuddy(editName);

    savePushButton = new QPushButton(trUtf8("Save"));
    connect(savePushButton,SIGNAL(clicked()),this,SLOT(editRecord()));
    savePushButton->setToolTip(trUtf8("Save And Close Button"));

    cancelPushButton = new QPushButton(trUtf8("Cancel"));
    cancelPushButton->setDefault(true);
    cancelPushButton->setStyleSheet("QPushButton:hover {color: red}");
    connect(cancelPushButton,SIGNAL(clicked()),this,SLOT(accept()));
    cancelPushButton->setToolTip(trUtf8("Cancel Button"));

    buttonBox = new QDialogButtonBox;
    buttonBox->addButton(cancelPushButton,QDialogButtonBox::ActionRole);
    buttonBox->addButton(savePushButton,QDialogButtonBox::ActionRole);

    if(indexTemp != ""){
        QSqlQuery query;
        query.prepare("SELECT typedocname FROM typedoc WHERE typedocid = :typedocid");
        query.bindValue(":typedocid",indexTemp);
        query.exec();
        while(query.next()){
            editName->setText(query.value(0).toString());
        }
    }else{
        editName->clear();
    }

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(labelName,0,0);
    mainLayout->addWidget(editName,0,1);
    if(!onlyForRead){
        mainLayout->addWidget(buttonBox,1,1);
        editName->selectAll();
    }

    setLayout(mainLayout);

    setWindowTitle(trUtf8("Type doc"));
    readSettings();
}
// Shared implementation used by test and exec.
bool RegExpObject::match(ExecState* exec)
{
    RegExpConstructor* regExpConstructor = exec->lexicalGlobalObject()->regExpConstructor();

    UString input = !exec->argumentCount() ? regExpConstructor->input() : exec->argument(0).toString(exec);
    if (input.isNull()) {
        throwError(exec, createError(exec, makeString("No input to ", toString(exec), ".")));
        return false;
    }

    if (!regExp()->global()) {
        int position;
        int length;
        regExpConstructor->performMatch(d->regExp.get(), input, 0, position, length);
        return position >= 0;
    }

    if (d->lastIndex < 0 || d->lastIndex > input.length()) {
        d->lastIndex = 0;
        return false;
    }

    int position;
    int length = 0;
    regExpConstructor->performMatch(d->regExp.get(), input, static_cast<int>(d->lastIndex), position, length);
    if (position < 0) {
        d->lastIndex = 0;
        return false;
    }

    d->lastIndex = position + length;
    return true;
}
示例#24
0
// Shared implementation used by test and exec.
bool RegExpObject::match(ExecState* exec, const ArgList& args)
{
    RegExpConstructor* regExpConstructor = exec->lexicalGlobalObject()->regExpConstructor();

    UString input = args.isEmpty() ? regExpConstructor->input() : args.at(0).toString(exec);
    if (input.isNull()) {
        throwError(exec, GeneralError, "No input to " + toString(exec) + ".");
        return false;
    }

    if (!regExp()->global()) {
        int position;
        int length;
        regExpConstructor->performMatch(d->regExp.get(), input, 0, position, length);
        return position >= 0;
    }

    if (d->lastIndex < 0 || d->lastIndex > input.size()) {
        d->lastIndex = 0;
        return false;
    }

    int position;
    int length = 0;
    regExpConstructor->performMatch(d->regExp.get(), input, static_cast<int>(d->lastIndex), position, length);
    if (position < 0) {
        d->lastIndex = 0;
        return false;
    }

    d->lastIndex = position + length;
    return true;
}
示例#25
0
void MessageWidget::filterContacts(QString filter)
{
    QString pattern;
    pattern = /*".*"+*/filter/*+".*"*/;
    QRegExp regExp(pattern, Qt::CaseInsensitive, QRegExp::FixedString);
    this->sortContactModel.setFilterRegExp(regExp);
}
示例#26
0
文件: k3bmsf.cpp 项目: franhaufer/k3b
K3b::Msf K3b::Msf::fromString( const QString& s, bool* ok )
{
    QRegExp rx = regExp();

    K3b::Msf msf;

    if( rx.exactMatch( s ) ) {
        //
        // first number - cap(1)
        // second number - cap(2)
        // third number - cap(3)
        //
        if( rx.cap(2).isEmpty() ) {
            msf.d->setValue( 0, 0, rx.cap(1).toInt() );
        }
        else {
            msf.d->setValue( rx.cap(1).toInt(), rx.cap(2).toInt(), rx.cap(3).toInt() );
        }

        if( ok ) {
            *ok = true;
        }
    }
    else if( ok ) {
        *ok = false;
    }

    return msf;
}
示例#27
0
QString VUtils::generateImageFileName(const QString &path,
                                      const QString &title,
                                      const QString &format)
{
    QRegExp regExp("\\W");
    QString baseName(title.toLower());

    // Remove non-character chars.
    baseName.remove(regExp);

    // Constrain the length of the name.
    baseName.truncate(10);

    if (!baseName.isEmpty()) {
        baseName.prepend('_');
    }

    // Add current time and random number to make the name be most likely unique
    baseName = baseName + '_' + QString::number(QDateTime::currentDateTime().toTime_t());
    baseName = baseName + '_' + QString::number(qrand());

    QDir dir(path);
    QString imageName = baseName + "." + format.toLower();
    int index = 1;

    while (fileExists(dir, imageName, true)) {
        imageName = QString("%1_%2.%3").arg(baseName).arg(index++)
                                       .arg(format.toLower());
    }

    return imageName;
}
示例#28
0
QString ReplaceModifier::parseOperation(ParseSettings& settings)
{
    Q_UNUSED(settings);

    const QRegExp& reg  = regExp();
    QString original    = reg.cap(2);
    QString replacement = reg.cap(3);
    QString result      = settings.str2Modify;
    QString options     = reg.cap(5);
    Qt::CaseSensitivity caseType = (!options.isEmpty() && options.contains('i'))
                                   ? Qt::CaseInsensitive
                                   : Qt::CaseSensitive;

    QRegExp ro(original);
    ro.setCaseSensitivity(caseType);

    if (!options.isEmpty() && options.contains('r'))
    {
        result.replace(ro, replacement);
    }
    else
    {
        result.replace(original, replacement, caseType);
    }

    return result;
}
示例#29
0
//-----------------------------------------------------------------------------
// Function: BusDefGroup::BusDefGroup()
//-----------------------------------------------------------------------------
BusDefGroup::BusDefGroup(QWidget *parent):
    QGroupBox(tr("General (Bus Definition)"), parent),
    busDef_(),
    directConnection_(tr("Allow direct master-slave connection"), this),
    isAddressable_(tr("Addressable bus"), this),
    maxMasters_(this),
    maxSlaves_(this),
    descriptionEditor_(this)
{
    QRegExp regExp(QString("[0-9]*"), Qt::CaseInsensitive, QRegExp::W3CXmlSchema11);
    QRegExpValidator* validator = new QRegExpValidator(regExp, this);
    maxMasters_.setValidator(validator);
    maxSlaves_.setValidator(validator);

    maxMasters_.setPlaceholderText(tr("unbound"));
    maxSlaves_.setPlaceholderText(tr("unbound"));

    setupLayout();

    connect(&maxMasters_, SIGNAL(editingFinished()), this, SLOT(onMastersChanged()), Qt::UniqueConnection);
    connect(&maxSlaves_, SIGNAL(editingFinished()),	this, SLOT(onSlavesChanged()), Qt::UniqueConnection);

    connect(&directConnection_, SIGNAL(toggled(bool)),
            this, SLOT(onDirectConnectionChanged(bool)), Qt::UniqueConnection);
    connect(&isAddressable_, SIGNAL(toggled(bool)),
            this, SLOT(onIsAddressableChanged(bool)), Qt::UniqueConnection);

    connect(&descriptionEditor_, SIGNAL(textChanged()), this, SLOT(onDescriptionChanged()), Qt::UniqueConnection);
}
示例#30
0
void MyLogin::checkInput()
{
	try
	{
		QRegExp regExp(utf8("[0-9]{11}"));
		if (!regExp.exactMatch(self->lineEdit->text()))
			throw Warning("请输入正确的号码!");

		bool ok = false;
		int byte = self->lineEdit_2->text().toInt(&ok);
		if (!ok || byte < 0 || byte > 255)
			throw Warning("请输入正确的IP地址!");
		byte = self->lineEdit_3->text().toInt(&ok);
		if (!ok || byte < 0 || byte > 255)
			throw Warning("请输入正确的IP地址!");
		byte = self->lineEdit_4->text().toInt(&ok);
		if (!ok || byte < 0 || byte > 255)
			throw Warning("请输入正确的IP地址!");
		byte = self->lineEdit_5->text().toInt(&ok);
		if (!ok || byte < 0 || byte > 255)
			throw Warning("请输入正确的IP地址!");
	}
	catch (...)
	{
		throw;
	}
}