• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ rx函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中rx函数的典型用法代码示例。如果您正苦于以下问题:C++ rx函数的具体用法?C++ rx怎么用?C++ rx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了rx函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: rxCTL_ACK

void
AnimPacket::parseWifi(std::string metaInfo)
{
    QRegExp rxCTL_ACK("ns3::WifiMacHeader \\(CTL_ACK .*RA=(..:..:..:..:..:..)");
    int pos = 0;
    if ((pos = rxCTL_ACK.indexIn(metaInfo.c_str())) != -1)
    {
        m_wifiMacInfo = new WifiMacInfo;
        m_wifiMacInfo->type = "CTL_ACK";
        m_wifiMacInfo->Ra = rxCTL_ACK.cap(1).toAscii().data();
       return;

    }
    QRegExp rxCTL_RTS("ns3::WifiMacHeader \\(CTL_RTS .*RA=(..:..:..:..:..:..), TA=(..:..:..:..:..:..)");
    pos = 0;
    if ((pos = rxCTL_RTS.indexIn(metaInfo.c_str())) != -1)
    {
        m_wifiMacInfo = new WifiMacInfo;
        m_wifiMacInfo->type = "CTL_RTS";
        m_wifiMacInfo->Ra = rxCTL_RTS.cap(1).toAscii().data();
        m_wifiMacInfo->Sa = rxCTL_RTS.cap(2).toAscii().data();

       return;

    }

    QRegExp rxCTL_CTS("ns3::WifiMacHeader \\(CTL_CTS .*RA=(..:..:..:..:..:..)");
    pos = 0;
    if ((pos = rxCTL_CTS.indexIn(metaInfo.c_str())) != -1)
    {
        m_wifiMacInfo = new WifiMacInfo;
        m_wifiMacInfo->type = "CTL_CTS";
        m_wifiMacInfo->Ra = rxCTL_CTS.cap(1).toAscii().data();
        return;

    }

    QRegExp rx("ns3::WifiMacHeader \\((\\S+) ToDS=(0|1), FromDS=(0|1), .*DA=(..:..:..:..:..:..), SA=(..:..:..:..:..:..), BSSID=(..:..:..:..:..:..)");
    pos = 0;
    if ((pos = rx.indexIn(metaInfo.c_str())) == -1)
        return;
    m_wifiMacInfo = new WifiMacInfo;
    m_wifiMacInfo->type = rx.cap(1).toAscii().data();
    m_wifiMacInfo->toDs = rx.cap(2).toAscii().data();
    m_wifiMacInfo->fromDs = rx.cap(3).toAscii().data();
    m_wifiMacInfo->Da = rx.cap(4).toAscii().data();
    m_wifiMacInfo->Sa = rx.cap(5).toAscii().data();
    m_wifiMacInfo->Bssid = rx.cap(6).toAscii().data();

    if(m_wifiMacInfo->type == "MGT_ASSOCIATION_REQUEST")
    {
        QRegExp rx("ns3::MgtAssocRequestHeader \\(ssid=(\\S+),");
        int pos = 0;
        if ((pos = rx.indexIn(metaInfo.c_str())) == -1)
            return;
        m_wifiMacInfo->SSid = rx.cap(1).toAscii().data();
    }
    if(m_wifiMacInfo->type == "MGT_ASSOCIATION_RESPONSE")
    {
        QRegExp rx("ns3::MgtAssocResponseHeader \\(status code=(\\S+), rates");
        int pos = 0;
        if ((pos = rx.indexIn(metaInfo.c_str())) == -1)
            return;
        m_wifiMacInfo->assocResponseStatus = rx.cap(1).toAscii().data();
    }


}
开发者ID:DunamisEric,项目名称:RepSys_Manets_NS-3.17,代码行数:68,代码来源:animpacket.cpp


示例2: QDialog

DialogSpectrumTemplate::DialogSpectrumTemplate(Qpx::Spectrum::Template newTemplate,
                                               std::vector<Qpx::Detector> current_dets,
                                               bool edit, QWidget *parent) :
  QDialog(parent),
  current_dets_(current_dets),
  ui(new Ui::DialogSpectrumTemplate)
{
  ui->setupUi(this);
  for (auto &q : Qpx::Spectrum::Factory::getInstance().types())
    ui->comboType->addItem(QString::fromStdString(q));
  ui->colPicker->setStandardColors();
  connect(ui->colPicker, SIGNAL(colorChanged(QColor)), this, SLOT(colorChanged(QColor)));

  QRegExp rx("^\\w*$");
  QValidator *validator = new QRegExpValidator(rx, this);
  ui->lineName->setValidator(validator);

  if (edit) {
    myTemplate = newTemplate;
    ui->lineName->setEnabled(false);
    ui->comboType->setEnabled(false);
    Qpx::Spectrum::Template *newtemp = Qpx::Spectrum::Factory::getInstance().create_template(newTemplate.type);
    if (newtemp != nullptr) {
      myTemplate.description = newtemp->description;
      myTemplate.input_types = newtemp->input_types;
      myTemplate.output_types = newtemp->output_types;
    } else
      PL_WARN << "Problem with spectrum type. Factory cannot make template for " << newTemplate.type;
  } else {
    Qpx::Spectrum::Template *newtemp = Qpx::Spectrum::Factory::getInstance().create_template(ui->comboType->currentText().toStdString());
    if (newtemp != nullptr) {
      myTemplate = *newtemp;
      size_t sz = current_dets_.size();

      Qpx::Setting pattern;

      pattern = myTemplate.generic_attributes.get(Qpx::Setting("pattern_coinc"));
      pattern.value_pattern.resize(sz);
      myTemplate.generic_attributes.replace(pattern);

      pattern = myTemplate.generic_attributes.get(Qpx::Setting("pattern_anti"));
      pattern.value_pattern.resize(sz);
      myTemplate.generic_attributes.replace(pattern);

      pattern = myTemplate.generic_attributes.get(Qpx::Setting("pattern_add"));
      pattern.value_pattern.resize(sz);
      myTemplate.generic_attributes.replace(pattern);

      myTemplate.match_pattern.resize(sz);
      myTemplate.add_pattern.resize(sz);
    } else
      PL_WARN << "Problem with spectrum type. Factory cannot make template for " << ui->comboType->currentText().toStdString();
    myTemplate.appearance = generateColor().rgba();
  }

  table_model_.eat(&myTemplate.generic_attributes);
  ui->tableGenericAttrs->setModel(&table_model_);
  ui->tableGenericAttrs->setItemDelegate(&special_delegate_);
  ui->tableGenericAttrs->verticalHeader()->hide();
  ui->tableGenericAttrs->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
  ui->tableGenericAttrs->horizontalHeader()->setStretchLastSection(true);
  ui->tableGenericAttrs->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
  ui->tableGenericAttrs->setSelectionMode(QAbstractItemView::SingleSelection);
  ui->tableGenericAttrs->show();

  updateData();

  ui->tableGenericAttrs->resizeColumnsToContents();

}
开发者ID:ayuzer,项目名称:qpx-gamma,代码行数:70,代码来源:dialog_spectra_templates.cpp


示例3: QStringLiteral

QUrl QgsHelp::helpUrl( const QString &key )
{
  QUrl helpNotFound = QUrl::fromLocalFile( QgsApplication::pkgDataPath() + "/doc/nohelp.html" );

  QgsSettings settings;
  QStringList paths = settings.value( QStringLiteral( "help/helpSearchPath" ) ).toStringList();
  if ( paths.isEmpty() )
  {
    return helpNotFound;
  }

  std::unique_ptr<QgsExpressionContextScope> scope( QgsExpressionContextUtils::globalScope() );

  QUrl helpUrl;
  QString helpPath, fullPath;
  bool helpFound = false;

  Q_FOREACH ( const QString &path, paths )
  {
    if ( path.endsWith( "\\" ) || path.endsWith( "/" ) )
    {
      fullPath = path.left( path.size() - 1 );
    }
    else
    {
      fullPath = path;
    }

    Q_FOREACH ( const QString &var, scope->variableNames() )
    {
      QRegularExpression rx( QStringLiteral( "(<!\\$\\$)*(\\$%1)" ).arg( var ) );
      fullPath.replace( rx, scope->variable( var ).toString() );
    }
    fullPath.replace( QRegularExpression( "(\\$\\$)" ), "$" );

    helpPath = QStringLiteral( "%1/%2" ).arg( fullPath, key );

    if ( helpPath.startsWith( QStringLiteral( "http" ) ) )
    {
      if ( !QgsHelp::urlExists( helpPath ) )
      {
        continue;
      }
      helpUrl = QUrl( helpPath );
    }
    else
    {
      QString filePath = helpPath.mid( 0, helpPath.lastIndexOf( "#" ) );
      if ( !QFileInfo::exists( filePath ) )
      {
        continue;
      }
      helpUrl = QUrl::fromLocalFile( filePath );
      int pos = helpPath.lastIndexOf( "#" );
      if ( pos != -1 )
      {
        helpUrl.setFragment( helpPath.mid( helpPath.lastIndexOf( "#" ) + 1, -1 ) );
      }
    }

    helpFound = true;
    break;
  }

  return helpFound ? helpUrl : helpNotFound;
}
开发者ID:exlimit,项目名称:QGIS,代码行数:66,代码来源:qgshelp.cpp


示例4: rx

/*
 * gibt den ermittelten Buchstaben zurück einschließliech Umlaute
 */
QString QvkShowkeyGetkey::getKey( QStringList list, int code )
{
  QString keyFromList;
  QStringList splitValuesList;
  QString key;
  
  QRegExp rx( "^" + QString::number( code ) + " " );
  QStringList keyList = list.filter( rx );
  QString keyValues = keyList[0];
  splitValuesList = keyValues.split( " " );
  keyFromList = splitValuesList[ 1 ];
  
  int integer = keyFromList.toInt( 0, 16 );
  key = (QString)integer;
  
  // Bei folgen Tasten Flag setzen und kein Wert zurückgeben
  keyFromList = splitValuesList[ 2 ];
  if ( keyFromList == "Caps_Lock")
  {
     key = "";
     caps_set.insert(code);
  }
  else if ( keyFromList == "Shift_L"   || keyFromList == "Shift_R")
  {
     key = "";
     shift_set.insert(code);
  }
  else if ( keyFromList == "Control_L" || keyFromList == "Control_R")
  {
     key = "";
     ctrl_set.insert(code);
  }
  else if ( keyFromList == "Alt_L"     || keyFromList == "Alt_R")
  {
     key = "";
     alt_set.insert(code);
  }
  else if ( keyFromList == "Meta_L"    || keyFromList == "Meta_R")
  {
     key = "";
     meta_set.insert(code);
  }
  else if ( keyFromList == "Super_L"    || keyFromList == "Super_R")
  {
     key = "";
     meta_set.insert(code);
  }

  // Mit "xset q" kann der status abgefragt werden
  // http://www.qtcentre.org/threads/30180-how-to-determine-if-CapsLock-is-on-crossplatform
  // http://stackoverflow.com/questions/24822505/how-to-tell-if-shift-is-pressed-on-numpad-input-with-numlock-on-or-at-least-get
  
  if ( keyFromList == "F1" ) key = "F1";
  if ( keyFromList == "F2" ) key = "F2";
  if ( keyFromList == "F3" ) key = "F3";
  if ( keyFromList == "F4" ) key = "F4";
  if ( keyFromList == "F5" ) key = "F5";
  if ( keyFromList == "F6" ) key = "F6";
  if ( keyFromList == "F7" ) key = "F7";
  if ( keyFromList == "F8" ) key = "F8";
  if ( keyFromList == "F9" ) key = "F9";
  if ( keyFromList == "F10" ) key = "F10";
  if ( keyFromList == "F11" ) key = "F11";
  if ( keyFromList == "F12" ) key = "F12";
  if ( keyFromList == "Escape" ) key = "Esc";
  if ( keyFromList == "BackSpace" ) key = "Bsp";
  if ( keyFromList == "Tab" ) key = "Tab";
  if ( keyFromList == "Num_Lock" ) key = "";
  if ( keyFromList == "Return" ) key = "Return";
  
  if ( isNumLockOn() == true )
  {
    keyFromList = splitValuesList[ 4 ];
    if ( keyFromList == "KP_0" ) key = "0";
    if ( keyFromList == "KP_1" ) key = "1";
    if ( keyFromList == "KP_2" ) key = "2";
    if ( keyFromList == "KP_3" ) key = "3";
    if ( keyFromList == "KP_4" ) key = "4";
    if ( keyFromList == "KP_5" ) key = "5";
    if ( keyFromList == "KP_6" ) key = "6";
    if ( keyFromList == "KP_7" ) key = "7";
    if ( keyFromList == "KP_8" ) key = "8";
    if ( keyFromList == "KP_9" ) key = "9";
    if ( keyFromList == "KP_Multiply" ) key = "*";
    if ( keyFromList == "KP_Subtract" ) key = "-";
    if ( keyFromList == "KP_Add" ) key = "+";
    if ( keyFromList == "KP_Decimal" ) key = ".";
    if ( keyFromList == "KP_Divide" ) key = "/";
    if ( keyFromList == "KP_Separator" ) key = ",";
  }

  if ( isNumLockOn() == false )
  {
    keyFromList = splitValuesList[ 2 ];
    if ( keyFromList == "KP_Home" )      key = "Home";
    if ( keyFromList == "KP_Up" )        key = "Up";
    if ( keyFromList == "KP_Prior" )     key = "Prior";
//.........这里部分代码省略.........
开发者ID:ShiYw,项目名称:vokoscreen,代码行数:101,代码来源:QvkShowkeyGetkey.cpp


示例5: rx

void QParseSite::parse_page(QString content)
{
    if(!siteurl.isEmpty())
    {

        QRegExp rx("<a[^>]+href=\"([^\"]+)\"[^>]*>(.*)</a>");
        rx.setMinimal(true);
        QStringList list;
        int pos = 0;
        while((pos = rx.indexIn(content, pos)) != -1)
        {
            list << rx.cap(1);
            pos += rx.matchedLength();

        }
        list.removeDuplicates();
        media=list.filter(".mp3");
        links.clear();
        links=list.replaceInStrings(QRegExp(".*.mp3"),"_");
        links=list.replaceInStrings(QRegExp(".*.m3u"),"_");
        links=list.replaceInStrings(QRegExp("javascript:;"),"_");

        links.removeDuplicates();
        QUrl link("");
        int iternal ;
        QString url;
        for( int n = 0; n < links.size(); n++)
        {
            link.setUrl(links.at( n));
            iternal =links.at(n).indexOf("/");
            if(siteurl.host() != link.host())
            {
                if(iternal==1 || iternal==0)
                {
                    url = links.at(n);
                    if(iternal == 1)
                    {
                        url=url.replace("./","/");
                    }

                    /*
                    if(link.host()=="")
                    {
                        ///url = links.at(n);
                        if(url_current.toString().lastIndexOf("/") == url_current.toString().size()-1 &&  url.at(0)=='/')
                        {
                            url.replace(0,1,"");
                        }
                        url=url_current.toString()+url;
                    }
                    else
                          {
                              */
                              url = siteurl.scheme()+"://"+siteurl.host()+url;



                    links.replace(n,url);
                }
                else
                {
                    links.removeAt(n);
                }

            }



        }
        emit page_parsed(links.filter(siteurl.host()),media,"","");
    }


}
开发者ID:pussbb,项目名称:QMediaSiteDownloader,代码行数:74,代码来源:qparsesite.cpp


示例6: if

bool ImageThread::addImage(_IMAGE img) {
    int i,k;
    bool alreadyInList;
    bool fileExists;

    fileExists = false;

    if (_blackList->contains(img.largeURI)) {
        alreadyInList = true;
    }
    else {
        alreadyInList = false;
        k = 2;
        for (i=0; i<images.length(); i++) {
            if (images.at(i).largeURI == img.largeURI) {
                alreadyInList = true;
                break;
            }

            if (images.at(i).originalFilename == img.originalFilename) {
                QStringList tmp;

                tmp = img.originalFilename.split(QRegExp("\\(\\d+\\)"));
                if  (tmp.count() > 1) // Already has a number in brackets in filename
                    img.originalFilename = QString("%1(%2)%3").arg(tmp.at(0)).
                                           arg(k++).
                                           arg(tmp.at(1));
                else
                    img.originalFilename = img.originalFilename.replace("."," (1).");
            }
        }

        if (!alreadyInList) {
            // Check if already downloaded
            QFile f;
            if (_saveWithOriginalFilename)
                f.setFileName(getSavepath()+"/"+img.originalFilename);
            else {
                QRegExp rx(__IMAGEFILE_REGEXP__, Qt::CaseInsensitive, QRegExp::RegExp2);
                QStringList res;
                int pos;

                pos = 0;

                pos = rx.indexIn(img.largeURI);
                res = rx.capturedTexts();

                if (pos != -1) {
                    f.setFileName(getSavepath()+"/"+res.at(1)+res.at(2));
                }
            }

            if (f.exists()) {
                img.downloaded = true;
                fileExists = true;
                img.savedAs = f.fileName();
            }

            images.append(img);
        }
    }

    return (!alreadyInList && !fileExists);
}
开发者ID:J0s3f,项目名称:fourchan-dl,代码行数:64,代码来源:imagethread.cpp


示例7: rx

void CodeSnippet::insertAt(QEditor* editor, QDocumentCursor* cursor, bool usePlaceholders, bool byCompleter) const{
	if (lines.empty()||!editor||!cursor) return;
	
	//find filechooser escape %(   %)
	QString line=lines.join("\n");
	QRegExp rx("%\\((.+)%\\)");
	int pos=rx.indexIn(line,0);
	if(pos>-1){
		FileChooser sfDlg(0,QApplication::tr("Select a File"));
		sfDlg.setFilter(rx.cap(1));
		LatexDocument *doc=qobject_cast<LatexDocument*>(cursor->document());
		QString path=doc->parent->getCompileFileName();
		path=getPathfromFilename(path);
		QString directory;
		if(path.isEmpty()) directory=QDir::homePath();
		else directory=path;
		sfDlg.setDir(directory);
		if (sfDlg.exec()) {
			QString fn=sfDlg.fileName();
			line.replace(rx,getRelativeBaseNameToPath(fn,path));
		} else return;
	}


	QString savedSelection;
	bool alwaysSelect = false;
	bool editBlockOpened = false;
	if (cursor->hasSelection()) {
		savedSelection=cursor->selectedText();
		editBlockOpened = true;
		cursor->beginEditBlock();
		cursor->removeSelectedText();
	}else if(!editor->cutBuffer.isEmpty()){
		savedSelection=editor->cutBuffer;
		editor->cutBuffer.clear();
		alwaysSelect = true;
	}
	bool multiLineSavedSelection = savedSelection.contains("\n");
	QDocumentCursor selector=*cursor;
	QDocumentLine curLine=cursor->line();

	// on multi line commands, replace environments only
	if(autoReplaceCommands && lines.size()>1 && line.contains("\\begin{")){
		QString curLine=cursor->line().text();
		int wordBreak=curLine.indexOf(QRegExp("\\W"),cursor->columnNumber());
		int closeCurl=curLine.indexOf("}",cursor->columnNumber());
		int openCurl=curLine.indexOf("{",cursor->columnNumber());
		int openBracket=curLine.indexOf("[",cursor->columnNumber());
		if(closeCurl>0){
			if(openBracket<0) openBracket=1e9;
			if(openCurl<0) openCurl=1e9;
			if(wordBreak<0) wordBreak=1e9;
			if(closeCurl<openBracket && (closeCurl<=wordBreak || openCurl<=wordBreak)){
				QString oldEnv;
				if(closeCurl<openCurl)
					oldEnv=curLine.mid(cursor->columnNumber(),closeCurl-cursor->columnNumber());
				else
					oldEnv=curLine.mid(openCurl+1,closeCurl-openCurl-1);
				QRegExp rx("\\\\begin\\{(.+)\\}");
				rx.setMinimal(true);
				rx.indexIn(line);
				QString newEnv=rx.cap(1);
				// remove curly brakets as well
				QDocument* doc=cursor->document();
				QString searchWord="\\end{"+oldEnv+"}";
				QString inhibitor="\\begin{"+oldEnv+"}";
				bool backward=false;
				int step=1;
				int startLine=cursor->lineNumber();
				//int startCol=cursor.columnNumber();
				int endLine=doc->findLineContaining(searchWord,startLine+step,Qt::CaseSensitive,backward);
				int inhibitLine=doc->findLineContaining(inhibitor,startLine+step,Qt::CaseSensitive,backward); // not perfect (same line end/start ...)
				while (inhibitLine>0 && endLine>0 && inhibitLine*step<endLine*step) {
					endLine=doc->findLineContaining(searchWord,endLine+step,Qt::CaseSensitive,backward); // not perfect (same line end/start ...)
					inhibitLine=doc->findLineContaining(inhibitor,inhibitLine+step,Qt::CaseSensitive,backward);
				}
				QString endText=doc->line(endLine).text();
				int start=endText.indexOf(searchWord);
				int offset=searchWord.indexOf("{");
				int length=searchWord.length()-offset-1;
				selector.moveTo(endLine,start+1+offset);
				selector.movePosition(length-1,QDocumentCursor::Right,QDocumentCursor::KeepAnchor);
				selector.replaceSelectedText(newEnv);
				cursor->movePosition(closeCurl-cursor->columnNumber()+1,QDocumentCursor::Right,QDocumentCursor::KeepAnchor);
				QString first=lines.first();
				int pos=first.indexOf('{');
				pos=first.indexOf('{',pos+1); //pos of second {
				if(pos>-1)
				    first.remove(pos,first.length()-pos);
				editor->insertText(*cursor,first);
				if (editBlockOpened) cursor->endEditBlock();
				return;
			}
		}
	}

	int baseLine=cursor->lineNumber();
	int baseLineIndent = cursor->columnNumber(); //text before inserted word moves placeholders to the right
	int lastLineRemainingLength = curLine.text().length()-baseLineIndent; //last line will has length: indentation + codesnippet + lastLineRemainingLength
	editor->insertText(*cursor,line); //don't use cursor->insertText to keep autoindentation working
//.........这里部分代码省略.........
开发者ID:svn2github,项目名称:texstudio,代码行数:101,代码来源:codesnippet.cpp


示例8: cityTranslations

QString TimeZone::TimeZone::readAllCities()
{
    // get translation list
    QString lines = cityTranslations();

    QSettings settings;
    int sortOrder = settings.value("sortorder_completeList", "").toInt();
    QList<QByteArray> ids =  QTimeZone::availableTimeZoneIds();
    QString output;
    QString sign;
    QString timeoffset;
    QMultiMap<int, QString> map;
    QMultiMap<QString, QString> sorted_map;
    // QMultiMap is sorted by key by default
    // We use QMultiMap (not QMap) so we can have duplicates
    int dummy_counter_for_sort = 0; // to inverse reverted sorting
    foreach (QByteArray id, ids) {
        QTimeZone zone = QTimeZone(id);
        QDateTime zoneTime = QDateTime(QDate::currentDate(), QTime::currentTime(), zone).toLocalTime();
        int offset = zone.offsetFromUtc(QDateTime::currentDateTime());
        QString countryName = QLocale::countryToString(zone.country());
        QString countryNameOrg = countryName;
        // insert space where appropriate. Can't be done in one regex replace?
        QRegularExpression rx("([a-z])([A-Z])");
        QRegularExpressionMatch match = rx.match(countryName);
        for (int i = 1; i <= 6; i++) {
            match = rx.match(countryName);
            if (match.hasMatch()) {
                QString lowerChar1 = match.captured(1);
                QString upperChar1 = match.captured(2);
                countryName.replace(lowerChar1+upperChar1,lowerChar1 + " " + upperChar1);
            }
        }
        int index = lines.indexOf('\n'+countryName+';', 0, Qt::CaseInsensitive);
        if (index != -1) {
            index++;
            // Replace countryName with translation
            countryName = lines.mid(index+countryName.length()+1, lines.indexOf('\n',index) - lines.indexOf(';',index)-1);
        }
        if ( countryName == "Default") {
            // UTC name
            countryName = "";
        } else {
            countryName = " [" + countryName + "]";
        }
        if (offset < 0)
            sign = "-";
        else
            sign = "+";
        if((offset % 3600)==0)
            // offset equals to whole hour
            timeoffset = QString("UTC %3").arg(sign+QString::number(abs(offset)/3600));
        else
        {
            int minutes = offset/60 %60;
            timeoffset = QString("UTC %3:%4").arg(sign+QString::number(abs(offset)/3600)).arg(abs(minutes));
        }

        const int delimiter = id.lastIndexOf('/');
        int nbrSlashes = id.count("/");
        QString cityNameTr = id.mid(delimiter + 1).replace("_"," ");
        QString continentTr = id.mid(0, delimiter);
        QString stateTr = "";
        if ( nbrSlashes == 2) {
            // eg (America/North Dakota/Beulah)
            continentTr = id.mid(0, id.indexOf('/')); //first part
            stateTr = id.mid(id.indexOf('/')+1, delimiter - continentTr.length() - 1 ); //second part
        }
        if (!lines.isEmpty()) {
            int index = lines.indexOf(cityNameTr+';', 0, Qt::CaseInsensitive);
            if (index != -1) {
                cityNameTr = lines.mid(index+cityNameTr.length()+1, lines.indexOf('\n',index) - lines.indexOf(';',index)-1);
            }
            index = lines.indexOf(continentTr+';', 0, Qt::CaseInsensitive);
            if (index != -1) {
                continentTr = lines.mid(index+continentTr.length()+1, lines.indexOf('\n',index) - lines.indexOf(';',index)-1);
            }
            if (!stateTr.isEmpty()) {
                index = lines.indexOf(stateTr+';', 0, Qt::CaseInsensitive);
                if (index != -1) {
                    stateTr =  lines.mid(index+stateTr.length()+1, lines.indexOf('\n',index) - lines.indexOf(';',index)-1);
                }
                continentTr = continentTr + "/" + stateTr;
            }
        }
        if (sortOrder == 1) {
            dummy_counter_for_sort ++;
            map.insert(offset + dummy_counter_for_sort,timeoffset + " (" + continentTr + "/" + cityNameTr + ")" + countryName + ";" + id + ";" + countryNameOrg);
        } else if (sortOrder == 2) {
            sorted_map.insert(cityNameTr, timeoffset + " (" + continentTr + "/" + cityNameTr + ")" + countryName + ";" + id + ";" + countryNameOrg);
        } else if (sortOrder == 3) {
            sorted_map.insert(countryName, timeoffset + " (" + continentTr + "/" + cityNameTr + ")" + countryName + ";" + id + ";" + countryNameOrg);
        } else {
            output += timeoffset + " (" + continentTr + "/" + cityNameTr + ")" + countryName + ";" + id +  + ";" + countryNameOrg + "\n";
        }

    }
开发者ID:OmarRi,项目名称:worldclock,代码行数:97,代码来源:worldclock.cpp


示例9: sExtMask

// Constructor.
qtractorAudioFileFactory::qtractorAudioFileFactory (void)
{
	// Default file format/type (for capture/record)
	m_pDefaultFormat  = NULL;
	m_iDefaultFormat  = SF_FORMAT_PCM_16;
	m_iDefaultQuality = 4;

	// Second for libsndfile stuff...
	FileFormat *pFormat;
	const QString sExtMask("*.%1");
	const QString sFilterMask("%1 (%2)");
	SF_FORMAT_INFO sffinfo;
	int iCount = 0;
	::sf_command(NULL, SFC_GET_FORMAT_MAJOR_COUNT, &iCount, sizeof(int));
	for (int i = 0 ; i < iCount; ++i) {
		sffinfo.format = i;
		::sf_command(NULL, SFC_GET_FORMAT_MAJOR, &sffinfo, sizeof(sffinfo));
		pFormat = new FileFormat;
		pFormat->type = SndFile;
		pFormat->name = QString(sffinfo.name)
			.replace('/', '-')	// Replace some illegal characters.
			.replace('(', QString::null)
			.replace(')', QString::null);
		pFormat->ext  = sffinfo.extension;
		pFormat->data = sffinfo.format;
		m_formats.append(pFormat);
		// Add for the extension map (should be unique)...
		QString sExt = pFormat->ext;
		QString sExts(sExtMask.arg(sExt));
		if (m_types.find(sExt) == m_types.end()) {
			m_types[sExt] = pFormat;
			// Take care of some old 8.3 convention,
			// specially regarding filename extensions...
			if (sExt.length() > 3) {
				sExt = sExt.left(3);
				if (m_types.find(sExt) == m_types.end()) {
					sExts = sExtMask.arg(sExt) + ' ' + sExts;
					m_types[sExt] = pFormat;
				}
			}
			// Make a stance on the default format...
			if (sExt == "wav") m_pDefaultFormat = pFormat;
		}
		// What we see on dialog is some excerpt...
		m_filters.append(
			sFilterMask.arg(pFormat->name).arg(sExts));
	}

#ifdef CONFIG_LIBVORBIS
	// Add for libvorbis...
	pFormat = new FileFormat;
	pFormat->type = VorbisFile;
	pFormat->name = "OGG Vorbis";
	pFormat->ext  = "ogg";
	pFormat->data = 0;
	m_formats.append(pFormat);
	m_types[pFormat->ext] = pFormat;
	m_filters.append(
		sFilterMask.arg(pFormat->name).arg(sExtMask.arg(pFormat->ext)));
	// Oh yeah, this will be the official default format...
	m_pDefaultFormat = pFormat;
#endif

#ifdef CONFIG_LIBMAD
	// Add for libmad (mp3 read-only)...
	pFormat = new FileFormat;
	pFormat->type = MadFile;
	pFormat->name = "MP3 MPEG-1 Audio Layer 3";
	pFormat->ext  = "mp3";
	pFormat->data = 0;
	m_formats.append(pFormat);
	m_types[pFormat->ext] = pFormat;
	m_filters.append(
		sFilterMask.arg(pFormat->name).arg(sExtMask.arg(pFormat->ext)));
#endif

	// Finally, simply build the all (most commonly) supported files entry.
	QRegExp rx("^(aif(|f)|fla(|c)|mp3|ogg|w(av|64))", Qt::CaseInsensitive);
	QStringList exts;
	FileTypes::ConstIterator iter = m_types.constBegin();
	const FileTypes::ConstIterator& iter_end = m_types.constEnd();
	for ( ; iter != iter_end; ++iter) {
		const QString& sExt = iter.key();
		if (rx.exactMatch(sExt))
			exts.append(sExtMask.arg(sExt));
	}
	m_filters.prepend(QObject::tr("Audio files (%1)").arg(exts.join(" ")));
	m_filters.append(QObject::tr("All files (*.*)"));
}
开发者ID:Icenowy,项目名称:Rtractor,代码行数:90,代码来源:qtractorAudioFile.cpp


示例10: getOption


//.........这里部分代码省略.........

      // Add collocation equation
      eq.push_back(vec(h_*f_res[DAE_ODE] - xp_j));

      // Add the algebraic conditions
      eq.push_back(vec(f_res[DAE_ALG]));

      // Add contribution to the final state
      xf += D[j]*x[j];

      // Add contribution to quadratures
      qf += (B[j]*h_)*f_res[DAE_QUAD];
    }

    // Form forward discrete time dynamics
    vector<MX> F_in(DAE_NUM_IN);
    F_in[DAE_T] = t;
    F_in[DAE_X] = x0;
    F_in[DAE_P] = p;
    F_in[DAE_Z] = v;
    vector<MX> F_out(DAE_NUM_OUT);
    F_out[DAE_ODE] = xf;
    F_out[DAE_ALG] = vertcat(eq);
    F_out[DAE_QUAD] = qf;
    F_ = MXFunction(F_in, F_out);
    F_.init();

    // Backwards dynamics
    // NOTE: The following is derived so that it will give the exact adjoint
    // sensitivities whenever g is the reverse mode derivative of f.
    if (!g_.isNull()) {

      // Symbolic inputs
      MX rx0 = MX::sym("x0", g_.input(RDAE_RX).sparsity());
      MX rp = MX::sym("p", g_.input(RDAE_RP).sparsity());

      // Implicitly defined variables (rz and rx)
      MX rv = MX::sym("v", deg_*(nrx_+nrz_));
      vector<int> rv_offset(1, 0);
      for (int d=0; d<deg_; ++d) {
        rv_offset.push_back(rv_offset.back()+nrx_);
        rv_offset.push_back(rv_offset.back()+nrz_);
      }
      vector<MX> rvv = vertsplit(rv, rv_offset);
      vector<MX>::const_iterator rvv_it = rvv.begin();

      // Collocated states
      vector<MX> rx(deg_+1), rz(deg_+1);
      for (int d=1; d<=deg_; ++d) {
        rx[d] = reshape(*rvv_it++, this->rx0().shape());
        rz[d] = reshape(*rvv_it++, this->rz0().shape());
      }
      casadi_assert(rvv_it==rvv.end());

      // Equations that implicitly define v
      eq.clear();

      // Quadratures
      MX rqf = MX::zeros(g_.output(RDAE_QUAD).sparsity());

      // End state
      MX rxf = D[0]*rx0;

      // For all collocation points
      for (int j=1; j<deg_+1; ++j) {
开发者ID:tmmsartor,项目名称:casadi,代码行数:66,代码来源:collocation_integrator_internal.cpp


示例11: _settings

    SshTunnelTab::SshTunnelTab(ConnectionSettings *settings) :
        _settings(settings)
    {
        SshSettings *info = settings->sshSettings();
        _sshSupport = new QCheckBox("Use SSH tunnel");
        _sshSupport->setStyleSheet("margin-bottom: 7px");
        _sshSupport->setChecked(info->enabled());

        _askForPassword = new QCheckBox(askPasswordText);
        _askForPassword->setChecked(info->askPassword());
        VERIFY(connect(_askForPassword, SIGNAL(stateChanged(int)), this, SLOT(askForPasswordStateChanged(int))));

        _sshHostName = new QLineEdit(QtUtils::toQString(info->host()));
        _userName = new QLineEdit(QtUtils::toQString(info->userName()));

        _sshPort = new QLineEdit(QString::number(info->port()));
        _sshPort->setFixedWidth(40);
        QRegExp rx("\\d+"); //(0-65554)
        _sshPort->setValidator(new QRegExpValidator(rx, this));        

        _security = new QComboBox();
        _security->addItems(QStringList() << "Password" << "Private Key");
        VERIFY(connect(_security, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(securityChange(const QString&))));

        _passwordBox = new QLineEdit(QtUtils::toQString(info->userPassword()));
        _passwordBox->setEchoMode(QLineEdit::Password);
        _passwordEchoModeButton = new QPushButton;
        VERIFY(connect(_passwordEchoModeButton, SIGNAL(clicked()), this, SLOT(togglePasswordEchoMode())));
        togglePasswordEchoMode();

        _privateKeyBox = new QLineEdit(QtUtils::toQString(info->privateKeyFile()));
        
        _passphraseBox = new QLineEdit(QtUtils::toQString(info->passphrase()));
        _passphraseBox->setEchoMode(QLineEdit::Password);
        _passphraseEchoModeButton = new QPushButton;
        VERIFY(connect(_passphraseEchoModeButton, SIGNAL(clicked()), this, SLOT(togglePassphraseEchoMode())));
        togglePassphraseEchoMode();

        _passwordLabel = new QLabel("User Password:");
        _sshPrivateKeyLabel = new QLabel("Private key:");
        _sshPassphraseLabel = new QLabel("Passphrase:");
        _sshAddressLabel = new QLabel("SSH Address:");
        _sshUserNameLabel = new QLabel("SSH User Name:");
        _sshAuthMethodLabel = new QLabel("SSH Auth Method:");

/*
// Commented because of this:
// https://github.com/paralect/robomongo/issues/391

#ifdef Q_OS_WIN
        QRegExp pathx("([a-zA-Z]:)?([\\\\/][a-zA-Z0-9_.-]+)+[\\\\/]?");
#else
        QRegExp pathx("^\\/?([\\d\\w\\.]+)(/([\\d\\w\\.]+))*\\/?$");
#endif // Q_OS_WIN
        _publicKeyBox->setValidator(new QRegExpValidator(pathx, this));
        _privateKeyBox->setValidator(new QRegExpValidator(pathx, this));
*/

        QHBoxLayout *hostAndPasswordLayout = new QHBoxLayout;
        hostAndPasswordLayout->addWidget(_sshHostName);
        hostAndPasswordLayout->addWidget(new QLabel(":"));
        hostAndPasswordLayout->addWidget(_sshPort);

        QGridLayout *connectionLayout = new QGridLayout;
        connectionLayout->setAlignment(Qt::AlignTop);
        connectionLayout->setColumnStretch(1, 1);
        connectionLayout->setColumnMinimumWidth(0, _passwordLabel->sizeHint().width() + 5);

        connectionLayout->addWidget(_sshAddressLabel ,             1, 0);
        connectionLayout->addLayout(hostAndPasswordLayout,         1, 1, 1, 2);

        connectionLayout->addWidget(_sshUserNameLabel,             2, 0);
        connectionLayout->addWidget(_userName,                     2, 1, 1, 2);

        connectionLayout->addWidget(_sshAuthMethodLabel,           4, 0);
        connectionLayout->addWidget(_security,                     4, 1, 1, 2);

        connectionLayout->addWidget(_passwordLabel,                5, 0);
        connectionLayout->addWidget(_passwordBox,                  5, 1);
        connectionLayout->addWidget(_passwordEchoModeButton,       5, 2);

        _selectPrivateFileButton = new QPushButton("...");
        _selectPrivateFileButton->setMaximumWidth(50);

        connectionLayout->addWidget(_sshPrivateKeyLabel,           7, 0);
        connectionLayout->addWidget(_privateKeyBox,                7, 1);
        connectionLayout->addWidget(_selectPrivateFileButton,      7, 2);

        connectionLayout->addWidget(_sshPassphraseLabel,           8, 0);
        connectionLayout->addWidget(_passphraseBox,                8, 1);
        connectionLayout->addWidget(_passphraseEchoModeButton,     8, 2);
        connectionLayout->addWidget(_askForPassword,               9, 1, 1, 2);

        QVBoxLayout *mainLayout = new QVBoxLayout;
        mainLayout->addWidget(_sshSupport);
        mainLayout->addLayout(connectionLayout);
        setLayout(mainLayout);

        if (info->authMethod() == "publickey") {
            utils::setCurrentText(_security, "Private Key");
//.........这里部分代码省略.........
开发者ID:aturki,项目名称:robomongo,代码行数:101,代码来源:SSHTunnelTab.cpp


示例12: propswc

bool SVNDiff::DiffProps(const CTSVNPath& filePath, const SVNRev& rev1, const SVNRev& rev2, svn_revnum_t &baseRev) const
{
    bool retvalue = false;
    // diff the properties
    SVNProperties propswc(filePath, rev1, false, false);
    SVNProperties propsbase(filePath, rev2, false, false);

#define MAX_PATH_LENGTH 80
    WCHAR pathbuf1[MAX_PATH] = {0};
    if (filePath.GetWinPathString().GetLength() >= MAX_PATH)
    {
        std::wstring str = filePath.GetWinPath();
        std::wregex rx(L"^(\\w+:|(?:\\\\|/+))((?:\\\\|/+)[^\\\\/]+(?:\\\\|/)[^\\\\/]+(?:\\\\|/)).*((?:\\\\|/)[^\\\\/]+(?:\\\\|/)[^\\\\/]+)$");
        std::wstring replacement = L"$1$2...$3";
        std::wstring str2 = std::regex_replace(str, rx, replacement);
        if (str2.size() >= MAX_PATH)
            str2 = str2.substr(0, MAX_PATH-2);
        PathCompactPathEx(pathbuf1, str2.c_str(), MAX_PATH_LENGTH, 0);
    }
    else
        PathCompactPathEx(pathbuf1, filePath.GetWinPath(), MAX_PATH_LENGTH, 0);

    if ((baseRev == 0) && (!filePath.IsUrl()) && (rev1.IsBase() || rev2.IsBase()))
    {
        SVNStatus stat;
        CTSVNPath dummy;
        svn_client_status_t * s = stat.GetFirstFileStatus(filePath, dummy);
        if (s)
            baseRev = s->revision;
    }
    // check for properties that got removed
    for (int baseindex = 0; baseindex < propsbase.GetCount(); ++baseindex)
    {
        std::string basename = propsbase.GetItemName(baseindex);
        tstring basenameU = CUnicodeUtils::StdGetUnicode(basename);
        tstring basevalue = (LPCTSTR)CUnicodeUtils::GetUnicode(propsbase.GetItemValue(baseindex).c_str());
        bool bFound = false;
        for (int wcindex = 0; wcindex < propswc.GetCount(); ++wcindex)
        {
            if (basename.compare (propswc.GetItemName(wcindex))==0)
            {
                bFound = true;
                break;
            }
        }
        if (!bFound)
        {
            // write the old property value to temporary file
            CTSVNPath wcpropfile = CTempFiles::Instance().GetTempFilePath(false);
            CTSVNPath basepropfile = CTempFiles::Instance().GetTempFilePath(false);
            FILE * pFile;
            _tfopen_s(&pFile, wcpropfile.GetWinPath(), L"wb");
            if (pFile)
            {
                fclose(pFile);
                FILE * pFile2;
                _tfopen_s(&pFile2, basepropfile.GetWinPath(), L"wb");
                if (pFile2)
                {
                    fputs(CUnicodeUtils::StdGetUTF8(basevalue).c_str(), pFile2);
                    fclose(pFile2);
                }
                else
                    return false;
            }
            else
                return false;
            SetFileAttributes(wcpropfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);
            SetFileAttributes(basepropfile.GetWinPath(), FILE_ATTRIBUTE_READONLY);
            CString n1, n2;
            bool bSwitch = false;
            if (rev1.IsWorking())
                n1.Format(IDS_DIFF_PROP_WCNAME, basenameU.c_str());
            if (rev1.IsBase())
            {
                if (baseRev)
                    n1.FormatMessage(IDS_DIFF_PROP_BASENAMEREV, basenameU.c_str(), baseRev);
                else
                    n1.Format(IDS_DIFF_PROP_BASENAME, basenameU.c_str());
            }
            if (rev1.IsHead())
                n1.Format(IDS_DIFF_PROP_REMOTENAME, basenameU.c_str());
            if (n1.IsEmpty())
            {
                CString temp;
                temp.Format(IDS_DIFF_REVISIONPATCHED, (LONG)rev1);
                n1 = basenameU.c_str();
                n1 += L" " + temp;
                bSwitch = true;
            }
            else
            {
                n1 = CString(pathbuf1) + L" - " + n1;
            }
            if (rev2.IsWorking())
                n2.Format(IDS_DIFF_PROP_WCNAME, basenameU.c_str());
            if (rev2.IsBase())
            {
                if (baseRev)
                    n2.FormatMessage(IDS_DIFF_PROP_BASENAMEREV, basenameU.c_str(), baseRev);
//.........这里部分代码省略.........
开发者ID:code-mx,项目名称:tortoisesvn,代码行数:101,代码来源:SVNDiff.cpp


示例13: rx

/****************************************************************************
**
** Author: Marc Bowes
**
** Replaces emoticon img tags with the shorthand text
**
****************************************************************************/
void Emoticon::HtmlToShorthand(QString &message)
{
  QRegExp rx("<img alt=\"(.*)\" src=\"(.*)\" class=\"emoticon\" />");
  rx.setMinimal(true);
  message.replace(rx, "\\1");
}
开发者ID:marcbowes,项目名称:mxitc,代码行数:13,代码来源:emoticon.cpp


示例14: rx

bool TextItem::isNeedExpandContent() const
{
    QRegExp rx("$*\\{[^{]*\\}");
    return content().contains(rx);
}
开发者ID:fralx,项目名称:LimeReport,代码行数:5,代码来源:lrtextitem.cpp


示例15: parseAssembly

  QByteArray parseAssembly(QTextStream &assembly)
  {
    QByteArray result;

    while (!assembly.atEnd())
    {
        unsigned int instruction = 0;

        QString line1 = assembly.readLine();
        QStringList words = line1.split(' ');


        // parse the instruction name
        if (words[0] == "ADD")
         {
            instruction |= ADD_OP << OP_SHIFT;
            instruction |= ADD_FUNC << FUNC_SHIFT;
         }

        else if (words[0] == "SUB")
         {
             instruction |= SUB_OP << OP_SHIFT;
             instruction |= SUB_FUNC << FUNC_SHIFT;
         }

        else if (words[0] == "ORI")
         {
             instruction |= ORI_OP << OP_SHIFT;
         }

         else if (words[0] == "JUMP")
         {
             instruction |= JMP_OP << OP_SHIFT;
         }

         else if (words[0] == "LW")
         {
             instruction |= LW_OP << OP_SHIFT;
         }

         else if (words[0] == "SW")
         {
             instruction |= SW_OP << OP_SHIFT;
         }

         else if (words[0] == "BEQ_OP")
         {
             instruction |= BEQ_OP << OP_SHIFT;
         }

         else
         {
             Q_ASSERT(false);  // TODO: throw an exception
             return QByteArray();
         }


    switch((instruction & OP_MASK) >> OP_SHIFT)
    {
      case ADD_OP:
//      case SUB_OP:
        {
          // parse the register numbers
          QRegExp rx("^\\s.\\$(\\d+)\\s.,\\s.\\$(\\d+)\\s.,\\s.\\$(\\d+)\\s.$");
          int pos = rx.indexIn(words[1]);

          if(pos < 0)
          {
            Q_ASSERT(false);  // TODO: throw an exception
            return QByteArray();
          }

          QStringList registers = rx.capturedTexts();

          if(registers.length() != 3)
          {
            Q_ASSERT(false);  // TODO: throw an exception
            return QByteArray();
          }

          unsigned int rd = QVariant(registers[0]).toInt();

          if(rd >= NUM_REGISTERS)
          {
            Q_ASSERT(false);  // TODO: throw an exception
            return QByteArray();
          }

          unsigned int rs = QVariant(registers[1]).toInt();

          if(rs >= NUM_REGISTERS)
          {
            Q_ASSERT(false);  // TODO: throw an exception
            return QByteArray();
          }

          unsigned int rt = QVariant(registers[2]).toInt();

          if(rt >= NUM_REGISTERS)
          {
//.........这里部分代码省略.........
开发者ID:auntieNeo,

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ rx_empty函数代码示例发布时间:2022-05-30
下一篇:
C++ rwlock_unlock函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap