예제 #1
0
void AudioCdRecord::checkProgressLine( const QString & str )
{
    QRegExp reg;
    int pos;
    bool ok;

    reg.setPattern( "(\\d+)(?:\\s*)of\\s+\\d+\\s+(KB|MB|GB)" );
    pos = reg.indexIn( str );
    if( pos > -1 )
        p->written_size_int = reg.cap(1).toInt(&ok);

    reg.setPattern( "(\\d+)(?:\\s*)(KB|MB|GB)" );
    pos = reg.indexIn( str );
    if( pos > -1 )
        p->image_size_int = reg.cap(1).toInt(&ok);

    reg.setPattern( "fifo\\s+(\\d+)(?:\\s*)%" );
    pos = reg.indexIn( str );
    if( pos > -1 )
        p->ring_buffer_percent_int = reg.cap(1).toInt(&ok);

    reg.setPattern( "buf\\s+(\\d+)(?:\\s*)%" );
    pos = reg.indexIn( str );
    if( pos > -1 )
        p->buffer_percent_int = reg.cap(1).toInt(&ok);

    reg.setPattern( "(\\d+\\.\\d)(?:\\s*)x\\.$" );
    pos = reg.indexIn( str );
    if( pos > -1 )
        p->written_speed_int = reg.cap(1).toDouble(&ok);

    if( p->image_size_int > 0 )
        p->process_precent = 100 * p->written_size_int / p->image_size_int;

    emit ringBufferChanged( p->ring_buffer_percent_int );
    emit bufferChanged(     p->buffer_percent_int      );
    emit writeSizeChenged(  p->written_size_int        );
    emit writeSpeedChanged( p->written_speed_int       );
    emit percentChanged(    p->process_precent         );
}
예제 #2
0
QString QgsStringUtils::insertLinks( const QString& string, bool *foundLinks )
{
  QString converted = string;

  // http://alanstorm.com/url_regex_explained
  // note - there's more robust implementations available, but we need one which works within the limitation of QRegExp
  static QRegExp urlRegEx( "(\\b(([\\w-]+://?|www[.])[^\\s()<>]+(?:\\([\\w\\d]+\\)|([^!\"#$%&'()*+,\\-./:;<=>?@[\\\\\\]^_`{|}~\\s]|/))))" );
  static QRegExp protoRegEx( "^(?:f|ht)tps?://" );
  static QRegExp emailRegEx( "([\\w._%+-]+@[\\w.-]+\\.[A-Za-z]+)" );

  int offset = 0;
  bool found = false;
  while ( urlRegEx.indexIn( converted, offset ) != -1 )
  {
    found = true;
    QString url = urlRegEx.cap( 1 );
    QString protoUrl = url;
    if ( protoRegEx.indexIn( protoUrl ) == -1 )
    {
      protoUrl.prepend( "http://" );
    }
    QString anchor = QStringLiteral( "<a href=\"%1\">%2</a>" ).arg( Qt::escape( protoUrl ), Qt::escape( url ) );
    converted.replace( urlRegEx.pos( 1 ), url.length(), anchor );
    offset = urlRegEx.pos( 1 ) + anchor.length();
  }
  offset = 0;
  while ( emailRegEx.indexIn( converted, offset ) != -1 )
  {
    found = true;
    QString email = emailRegEx.cap( 1 );
    QString anchor = QStringLiteral( "<a href=\"mailto:%1\">%1</a>" ).arg( Qt::escape( email ), Qt::escape( email ) );
    converted.replace( emailRegEx.pos( 1 ), email.length(), anchor );
    offset = emailRegEx.pos( 1 ) + anchor.length();
  }

  if ( foundLinks )
    *foundLinks = found;

  return converted;
}
예제 #3
0
void loadStylesheet(const QString &name, QHash<QString, StyleData> &dict)
{
   QFile file(name);

   if (! file.open(QIODevice::ReadOnly)) {
      err("Unable to open RTF style sheet file %s, using default file\n", qPrintable(name));
      return;
   }
   msg("Loading RTF style sheet %s\n", qPrintable(name));

   static const QRegExp seperator("[ \t]*=[ \t]*");
   uint lineNr = 1;

   QTextStream t(&file);
   t.setCodec("UTF-8");

   while (! t.atEnd()) {
      QString s = t.readLine().trimmed();

      if (s.isEmpty() || s.at(0) == '#') {
         continue;   // skip blanks & comments
      }

      int sepStart;
      int sepLength;
      
      sepStart  = seperator.indexIn(s);
      sepLength = seperator.matchedLength();  

      if (sepStart <= 0) {
         // no valid assignment statement
         warn(qPrintable(name), lineNr, "Assignment of style sheet name expected\n");
         continue;
      }

      QString key = s.left(sepStart);

      if (! dict.contains(key)) { 
         // not a valid style sheet name
         warn(qPrintable(name), lineNr, "Invalid style sheet name %s ignored.\n", qPrintable(key));
         continue;
      }

      // add command separator   
      StyleData &styleData = dict.find(key).value();

      s += " "; 
      styleData.setStyle(s.mid(sepStart + sepLength), key);

      lineNr++;
   }
}
예제 #4
0
void IniParser::updateOrganism(OrganismPtr organism)
{
    QMutexLocker lock(&organism->mutex);
    const QVariant name = value("organisms", "name");
    const QVariant ref_seq_assembly_id = value("organisms", "ref_seq_assembly_id");
    const QVariant real_chromosome_count = value("organisms", "real_chromosome_count");
    const QVariant common_name = value("organisms", "common_name");

    const QVariant real_mitochondria = value("organisms", "real_mitochondria");
    const QVariant annotation_release = value("organisms", "annotation_release");
    const QVariant annotation_date = value("organisms", "annotation_date");

    if (name.isValid()) {
        organism->name = name.toString();
    }
    if (ref_seq_assembly_id.isValid()) {
        organism->refSeqAssemblyId = ref_seq_assembly_id.toString();
    }
    if (real_chromosome_count.isValid()) {
        organism->realChromosomeCount = real_chromosome_count.toUInt();
    }
    if (common_name.isValid()) {
        organism->commonName = common_name.toString();
    }
    if (real_mitochondria.isValid()) {
        organism->realMitochondria = bool(real_mitochondria.toUInt());
    }
    if (annotation_release.isValid()) {
        organism->annotationRelease = annotation_release.toString();
    }
    if (annotation_date.isValid()) {
        static QRegExp rxDate("(\\d+)\\s+(\\S+)\\s+(\\d\\d\\d\\d)");
        if (-1 != rxDate.indexIn(annotation_date.toString())) {
            int day = rxDate.cap(1).toInt();
            int year = rxDate.cap(3).toInt();
            const QString monthString = rxDate.cap(2).toLower().left(3);
            static const QStringList Months = QStringList()
                    << "jan" << "feb" << "mar"
                    << "apr" << "may" << "jun"
                    << "jul" << "aug" << "sep"
                    << "oct" << "nov" << "dec";
            int month = 1 + Months.indexOf(monthString);
            const bool dayValid = 1 <= day && day <= 31;
            const bool monthValid = 1 <= month && month <= 12;
            const bool yearValid = 1970 <= year && year <= 2039;
            if (dayValid && monthValid && yearValid) {
                organism->annotationDate.setDate(year, month, day);
            }
        }
    }

}
예제 #5
0
	QString Plugin::HandleBody (QString body)
	{
		QRegExp rx ("\\$\\$.+\\$\\$");
		rx.setMinimal (true);
		
		int pos = 0;
		
		QMap<QString, QString> replaceMap;
		while (pos >= 0 && pos < body.size ())
		{
			pos = rx.indexIn (body, pos);
			
			if (pos < 0)
				break;
			
			const QString& match = rx.cap (0);
			pos += rx.matchedLength ();
			
			QString formula = match;
			formula.remove ("$$");
			formula = formula.trimmed ();
			if (formula.isEmpty () || !IsSecure (formula))
				continue;
			
			formula.replace ("&lt;", "<");
			formula.replace ("&gt;", ">");
			formula.replace ("&quot;", "\"");
			formula.replace ("&amp;", "&");
			
			const QImage& rendered = GetRenderedImage (formula);
			if (rendered.isNull ())
				continue;

			replaceMap [match] = Util::GetAsBase64Src (rendered);
		}
		
		if (replaceMap.isEmpty ())
			return body;
		
		Q_FOREACH (const QString& key, replaceMap.keys ())
		{
			QString escFormula = key;
			escFormula.replace ('\"', "&quot;");
			escFormula.remove ("$$");
			const QString img = QString ("<img src=\"%1\" alt=\"%2\" style=\"vertical-align: middle;\" />")
					.arg (replaceMap [key])
					.arg (escFormula.trimmed ().simplified ());
			body.replace (key, img);
		}
		
		return body;
	}
예제 #6
0
QString IrcProtocol::ircFormatToPlainText(const QString &msg)
{
	QString result;
	result.reserve(msg.size());
	int pos = 0, oldPos = 0;
	while ((pos = formatRx.indexIn(msg, pos)) != -1) {
		result += msg.mid(oldPos, pos - oldPos);
		pos += formatRx.matchedLength();
		oldPos = pos;
	}
	result += msg.mid(oldPos);
	return result;
}
예제 #7
0
QString LiteWordCompleter::textUnderCursor(QTextCursor tc) const
{
    QString text = tc.block().text().left(tc.positionInBlock());
    if (text.isEmpty()) {
        return QString();
    }
    static QRegExp reg("[a-zA-Z_]+[a-zA-Z0-9_\\.@]*$");
    int index = reg.indexIn(text);
    if (index < 0) {
        return QString();
    }
    return text.right(reg.matchedLength());
}
예제 #8
0
파일: tags.cpp 프로젝트: niklasf/chessx
QVector<bool> Tags::find(const QRegExp& pattern, QVector<QString>& vector, QMap<QString, QPair<quint32, quint32> > & map)
{
	QVector<bool> result;
	QVector<QString>::iterator it;
	for (it = vector.begin(); it != vector.end(); ++it) {
		if (map.contains(*it) && pattern.indexIn(*it) >= 0) {
			result.push_back(true);
		} else {
			result.push_back(false);
		}
	}
	return result;
}
예제 #9
0
int Shell::memoryUsage() const
{
	QRegExp rx;
	rx.setPattern("VmRSS:\\t\\s+(\\d+)");
	QProcess p;
	p.start("cat /proc/"+ QString::number(m_pid) +"/status");
	p.waitForFinished();
	QString kBString;
	if (rx.indexIn(p.readAll()) != -1) {
		kBString = rx.cap(1);
	}
	return kBString.toInt();
}
예제 #10
0
QString LiteEditorWidget::importUnderCursor(QTextCursor tc) const
{
    QString text = tc.block().text().left(tc.positionInBlock());
    if (text.isEmpty()) {
        return QString();
    }
    static QRegExp reg("[\"`][a-zA-Z0-9_\\-\\.\\/]*$");
    int index = reg.indexIn(text);
    if (index < 0) {
        return QString();
    }
    return text.right(reg.matchedLength()-1);
}
예제 #11
0
void formulesPlugin::processEvent(Event &event)
{
	if(event.args.size()<1)
		return;

	if(event.id == m_new_my_message_1 || event.id == m_new_message)
	{
		QString *msg = (QString *)event.args.at(1);

		QRegExp rx;
		rx.setMinimal(true);
		int pos;

		rx.setPattern("\\[tex\\](.*)\\[/tex\\]");
		pos = 0;
		while (pos >= 0)
		{
			pos = rx.indexIn(*msg, pos);
			if (pos >= 0)
			{
				pos++;
				itemfound(msg, rx.cap(1), 1);
			}
		}

		rx.setPattern("\\$\\$(.*)\\$\\$");
		pos = 0;
		while (pos >= 0)
		{
			pos = rx.indexIn(*msg, pos);
			if (pos >= 0)
			{
				pos++;
				itemfound(msg, rx.cap(1), 2);
			}
		}
	}

}
예제 #12
0
bool KateNewCompletionModel::shouldStartCompletion(KTextEditor::View* view, const QString &insertedText, bool userInsertion, const KTextEditor::Cursor &position)
{
    if (!userInsertion) return false;
    if(insertedText.isEmpty())
        return false;

    KateView *v = qobject_cast<KateView*> (view);

    QString text = view->document()->line(position.line()).left(position.column());
    static const QRegExp ktuan_new_class("((new \\w*)|(gen\\w*)|(get\\w*))$");
    if (ktuan_new_class.indexIn(text) >= 0) return true;
    return false;
}
static QList<QByteArray> parseArguments(const QString &str)
{
    const QRegExp rx("(\"([^\"]*)\"|([^ ]+))", Qt::CaseSensitive, QRegExp::RegExp2);

    QList<QByteArray> res;
    int pos = 0;
    while ((pos = rx.indexIn(str, pos)) >= 0) {
        auto cap2 = rx.cap(2);
        res << ((cap2.isEmpty()) ? rx.cap(3) : cap2).toLocal8Bit();
        pos += rx.matchedLength();
    }
    return res;
}
예제 #14
0
QString GitEditorWidget::fileNameForLine(int line) const
{
    // 7971b6e7 share/qtcreator/dumper/dumper.py   (hjk
    QTextBlock block = document()->findBlockByLineNumber(line - 1);
    QTC_ASSERT(block.isValid(), return source());
    static QRegExp renameExp(QLatin1String("^" CHANGE_PATTERN "\\s+([^(]+)"));
    if (renameExp.indexIn(block.text()) != -1) {
        const QString fileName = renameExp.cap(1).trimmed();
        if (!fileName.isEmpty())
            return fileName;
    }
    return source();
}
예제 #15
0
void
IrcAbstractChannel::CheckWatch (const QString & data)
{
  QList<QRegExp>::iterator lit;
  bool notSeen (true);
  for (lit=watchList.begin(); notSeen && lit != watchList.end(); lit++) {
    QRegExp rX = *lit;
    if (rX.indexIn (data,0) >= 0) {
      emit WatchAlert (chanName, data);
      notSeen = false;
    }
  }
}
예제 #16
0
void TToolbarEditor::stringToAction(const QString& s, QString& action_name, bool& ns, bool&fs) {

	// name|0|1
	static QRegExp rx("^([^|]+)(\\|(\\d+)\\|(\\d+))?");

	if (rx.indexIn(s) >= 0) {
		action_name = rx.cap(1);
		ns = rx.cap(3).trimmed() != "0";
		fs = rx.cap(4).trimmed() != "0";
	} else {
		action_name = "";
	}
}
예제 #17
0
    /*!
        判断指定字符串中是否含有文件名
        预期输入为: ID_FILENAME=/nand2/1.mp3
        输出为:/nand2/1.mp3
                 true
      \param 【IN】QString &line_data mplaer 输出的一行信息
      \param 【OUT】QString &file_name 做为输出
     */
   bool IBMediaControlCData::isFileName(const QString &line_data, QString &file_name)
   {

        int index = -1;
        index = m_rx_file_name.indexIn(line_data);
        if(index>-1)//找到正在播放的文件名
        {
           file_name =  m_rx_file_name.cap(2);// cap(0)是ID_FILENAME=/nand2/1.mp3 ,cap(1)是ID_FILENAME,cap(2)是/nand2/1.mp3
           trace((char *)"\n%s",file_name.toLocal8Bit().data());
           return true;
        }
        return false;
   }
예제 #18
0
/**
 * Returns a reference to regex for unindented code
 * @return
 */
bool InputSplitter::matchesDedent(const QString & str) const
{
  static QRegExp dedentRegex(
      "^\\s+raise(\\s.*)?$" // raise statement (+ space + other stuff, maybe)
      "^\\s+raise\\([^\\)]*\\).*$" // wacky raise with immediate open paren
      "^\\s+return(\\s.*)?$" // normal return (+ space + other stuff, maybe)
      "^\\s+return\\([^\\)]*\\).*$" // wacky return with immediate open paren
      "^\\s+pass\\s*$" // pass (optionally followed by trailing spaces)
      );
  int start = dedentRegex.indexIn(str);
  if(start < 0) return false;
  else return true;
}
예제 #19
0
/**
 * Return the number of initial spaces on the line, tabs count as 1
 * @param line
 * @return A number of whitespace characters at the start
 */
int InputSplitter::numInitialSpaces(const QString & line)
{
  static QRegExp iniSpacesRegex("^([ \t\r\f\v]+)");
  int index = iniSpacesRegex.indexIn(line);
  if( index < 0 )
  {
    return 0;
  }
  else
  {
    return iniSpacesRegex.matchedLength();
  }
}
예제 #20
0
파일: utils.cpp 프로젝트: mezkov/quickbox
QSet<QString> Utils::findCaptions(const QString caption_format)
{
	QSet<QString> ret;
	QRegExp rx;
	rx.setPattern("\\{\\{([A-Za-z][A-Za-z0-9]*(\\.[A-Za-z][A-Za-z0-9]*)*)\\}\\}");
	rx.setPatternSyntax(QRegExp::RegExp);
	int ix = 0;
	while((ix = rx.indexIn(caption_format, ix)) != -1) {
		ret << rx.cap(1);
		ix += rx.matchedLength();
	}
	return ret;
}
예제 #21
0
void Parser::parseCourses(QNetworkReply *reply, QStandardItemModel *itemModel)
{
    // Auslesen der kompletten Antwort
    QString replyText = reply->readAll();

    // Erstellen eines RegExps für das Herausfiltern der Veranstaltungen
    QString regPattern = "<td class=\"ms-vb2\"><a href=\"(/(ws|ss)(\\d{2})/\\d{2}(?:ws|ss)-\\d{5})(?:/information/default.aspx)*\">(.*)</a></td><td";
    QRegExp* regExp = new QRegExp(regPattern, Qt::CaseSensitive);
    regExp->setMinimal(true);

    // Erstellen eines RegExps  für unzulässige Buchstaben im Veranstaltungsnamen
    QString escapePattern = "(:|<|>|/|\\\\|\\||\\*|\\^|\\?|\\\")";
    QRegExp* escapeRegExp = new QRegExp(escapePattern, Qt::CaseSensitive);

    // Speichern der Suchpositionen in der Antwort
    int altePosition = 0;
    int neuePosition = 0;

    // neue Veranstaltung sowie Daten
    Structureelement* neueVeranstaltung;
    QString urlRaum;
    QString veranstaltungName;

    // Durchsuchen der gesamten Antwort nach Veranstaltungen
    while((neuePosition=regExp->indexIn(replyText, altePosition)) != -1)
    {
        // Anpassen der Encodierung wegen der Umlaute
        urlRaum = QString::fromUtf8(regExp->cap(1).toLatin1());
        veranstaltungName = QString::fromUtf8(regExp->cap(4).toLatin1());
        veranstaltungName = veranstaltungName.replace(*escapeRegExp, "").trimmed();
        // if semester suffix. funktioniert nur 2000-2099 AD
        veranstaltungName += " - " + regExp->cap(2).toLatin1().toUpper() + "20" + regExp->cap(3);

        // Erstellen der neuen Veranstaltung
        neueVeranstaltung = new Structureelement(veranstaltungName, QUrl(MainURL % urlRaum), courseItem);// % "/materials/documents/"));
        //neueVeranstaltung = new Strukturelement(veranstaltungName, QUrl(StammURL % urlRaum % "/materials/structured/"));
        neueVeranstaltung->setIcon(QIcon(":/Icons/directory"));

        // Hinzufügen der Veranstaltung zur Liste
        itemModel->appendRow(neueVeranstaltung);

        // Weitersetzen der Suchposition hinter den letzten Fund
        altePosition = neuePosition + regExp->matchedLength();
    }



    // Löschen der RegExps aus dem Speicher
    delete regExp;
    delete escapeRegExp;
}
예제 #22
0
QDateTime parseRssDate(const QString& str)
{
    // match a RFC 822 date for example: "Fri, 26 Feb 2010 13:47:54 +0000"
    const QRegExp rfc822(
        "((Mon|Tue|Wed|Thu|Fri|Sat|Sun),\\s)?(\\d{1,2}) "
        "(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) "
        "(\\d{2,4}) "
        "(\\d{2}):(\\d{2})(:(\\d{2}))?(\\s([-+]\\d{2})\\d{2})?"
        );

    if (rfc822.indexIn(str) != -1)
    {
        // process the captures.
        // cap(0) returns the input matched the whole regular expression.
        // each subsequent index returns the input that matched that part 
        // of the subexpression.
        const auto year  = fourDigitYear(rfc822.cap(5).toInt());
        const auto day   = rfc822.cap(3).toInt();
        const auto hour  = rfc822.cap(6).toInt();
        const auto min   = rfc822.cap(7).toInt();
        const auto sec   = rfc822.cap(9).toInt();
        const auto tmz   = rfc822.cap(11).toInt(); // this is hours only todo: minutes
        const auto month = rfc822.cap(4);    

        const QString months[] = {
            "Jan", "Feb", "Mar", "Apr", "May", "Jun",
            "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
        };
        const auto it = std::find(std::begin(months), std::end(months), month);
        if (it == std::end(months))
            return QDateTime();

        const auto monthno = std::distance(std::begin(months), it) + 1;

        // create a datetime disregarding timezone in the RSS
        const QDateTime datetime(
            QDate(year, monthno, day),
            QTime(hour, min, sec), 
            Qt::UTC);

        if (!datetime.isValid())
            return QDateTime();

        // offset by timezone seconds
        const auto off = -tmz * 3600;
        const auto ret = datetime.addSecs(off);
        return ret;
    }

    return QDateTime();
}
예제 #23
0
bool PythonCodeHighlighter::highlightMultilineString(const QString &text, const QRegExp &delimiter,
                                                     const int inState,
                                                     const QTextCharFormat &style) {
  int start = -1;
  int add = -1;
  int commentPos = -1;

  if (previousBlockState() == inState) {
    start = 0;
    add = 0;
  } else {
    start = delimiter.indexIn(text);
    add = delimiter.matchedLength();
    commentPos = text.indexOf('#');
  }

  if (commentPos < 0 || commentPos > start) {

    while (start >= 0) {
      int end = delimiter.indexIn(text, start + add);
      int length;

      if (end >= add) {
        length = end - start + add + delimiter.matchedLength();
        setCurrentBlockState(0);
      } else {
        setCurrentBlockState(inState);
        length = text.length() - start + add;
      }

      setFormat(start, length, style);
      start = delimiter.indexIn(text, start + length);
      add = delimiter.matchedLength();
    }
  }

  return (currentBlockState() == inState);
}
예제 #24
0
bool QExiv2::xmpGpsCoordinates(const QString &str, double *value) const
{
     if (str.isEmpty()) {
         return false;
     }

     QString s = str.simplified().toUpper();
     QRegExp r;

     r.setPattern(WGS84_LATITUDE_DM);
     if (r.exactMatch(s)) {
         r.indexIn(s);
         *value = gpsCoordinates(r.cap(1).toDouble(), r.cap(2).toDouble(), 0.0, r.cap(3).at(0));
         return true;
     }

     r.setPattern(WGS84_LONGITUDE_DM);
     if (r.exactMatch(s)) {
         r.indexIn(s);
         *value = gpsCoordinates(r.cap(1).toDouble(), r.cap(2).toDouble(), 0.0, r.cap(3).at(0));
         return true;
     }

     r.setPattern(WGS84_LATITUDE_DMS);
     if (r.exactMatch(s)) {
         r.indexIn(s);
         *value = gpsCoordinates(r.cap(1).toDouble(), r.cap(2).toDouble(), r.cap(3).toDouble(), r.cap(4).at(0));
         return true;
     }

     r.setPattern(WGS84_LONGITUDE_DMS);
     if (r.exactMatch(s)) {
         r.indexIn(s);
         *value = gpsCoordinates(r.cap(1).toDouble(), r.cap(2).toDouble(), r.cap(3).toDouble(), r.cap(4).at(0));
         return true;
     }
    return false;
}
예제 #25
0
QString OmaSaunalahti::getSentMessages(QString htmlContent) {
    QTextStream out(stdout);
    QString retval = QString();
    QString messageExpTxt = "<tr><td class=\"tdcontent1\">(.*)</td><td class=\"tdcontent1\">(.*)</td><td class=\"tdcontent1\">(.*)</td></tr>";
    QRegExp messageExp = QRegExp(messageExpTxt);
    QRegExp exp = QRegExp("<table cellpadding=\"7\" cellspacing=\"1\"><tr><td class=\"tdtitleheader\" colspan=\"3\">(.*)</td></tr><tr><td class=\"tdtitle\">(.*)</td><td class=\"tdtitle\">(.*)</td><td class=\"tdtitle\">(.*)</td></tr>("+messageExpTxt+")*");
    int pos = exp.indexIn(htmlContent,0);

    out << exp.cap(1) << endl;
    out << exp.cap(2) << endl;
    out << exp.cap(3) << endl;
    out << exp.cap(4) << endl;
    QString data = exp.cap(4);
    pos = 0;

    while ((pos = messageExp.indexIn(data,pos))!=-1) {
        out << messageExp.cap(1) << "\t" << messageExp.cap(2) << "\t" << messageExp.cap(3) << endl;
        retval += QString("%0;%1;%2\n").arg(messageExp.cap(1)).arg(messageExp.cap(2)).arg(messageExp.cap(3));
        pos += messageExp.matchedLength();
    }

    return retval;
}
예제 #26
0
    void Log (const char * s)
    {
        QString msg(QString::fromUtf8(s));
        QRegExp rx;
        // ignore 'Init:' and 'Mod:' prefixes
        rx.setPattern(QLatin1String("^\\s*(Init:|Mod:)\\s*"));
        int pos = rx.indexIn(msg);
        if (pos != -1) {
            msg = msg.mid(rx.matchedLength());
        }
        else {
            // ignore activation of commands
            rx.setPattern(QLatin1String("^\\s*(\\+App::|Create|CmdC:|CmdG:|Act:)\\s*"));
            pos = rx.indexIn(msg);
            if (pos == 0)
                return;
        }

        splash->showMessage(msg.replace(QLatin1String("\n"), QString()), alignment, textColor);
        QMutex mutex;
        mutex.lock();
        QWaitCondition().wait(&mutex, 50);
    }
예제 #27
0
QList<NickServIdentify> Core::GetNickServIdentifyWithMainParams (const QString& server,
        const QString& nick, const QString& nickserv) const
{
    QList<NickServIdentify> list;
    Q_FOREACH ( const NickServIdentify& nsi, NickServIdentifyList_)
    {
        QRegExp nickMask (nsi.NickServNick_,
                          Qt::CaseInsensitive,
                          QRegExp::Wildcard);
        if ((nsi.Server_ == server) &&
                (nsi.Nick_ == nick) &&
                (nickMask.indexIn (nickserv) == 0))
            list << nsi;
    }
예제 #28
0
//判断Rss来自哪个网站
int RssReader::RssJudge(QString str)
{
    QRegExp rx;
    QStringList rssList;
    rssList << "cnbeta.com" << "sina.com" << "qiushibaike.com";
    for(int i=0;i<3;i++)
    {
        rx.setPattern(rssList.at(i));
        int pos=rx.indexIn(str);
        if(pos > -1)
            return i;
    }
    return 100;
}
예제 #29
0
파일: processor.cpp 프로젝트: vasyutin/hpro
// -----------------------------------------------------------------------
TProcessor::TResult TProcessor::findRegExp(const QString &Line_, QRegExp &RegExp_, 
	QRegExp *UnexpectedRegExp_)
{
int Index = Line_.indexOf(m_NotWhitespaceRegExp);
if(Index >= 0) {
	if(UnexpectedRegExp_) {
		int UnexpectedIndex = UnexpectedRegExp_->indexIn(Line_, Index);
		if(UnexpectedIndex >= 0) return ResultSyntaxError;
		}
	Index = RegExp_.indexIn(Line_, Index);
	if(Index >= 0) return ResultOK;
	}
return ResultNoOperator;
}
예제 #30
0
// aim is to sort senders by their email adresses (field in database contains Name <[email protected]> as string
bool MySortFilterProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const {
    QVariant leftData = sourceModel()->data(source_left);
    QVariant rightData = sourceModel()->data(source_right);

    if (leftData.type() == QVariant::String) {
        static QRegExp emailPattern("[\\w\\.]*@[\\w\\.]*)");

        QString leftString = leftData.toString();
        if (source_left.column() == 2 && emailPattern.indexIn(leftString) != -1) {
            leftString = emailPattern.cap(1);
        }

        QString rightString = rightData.toString();
        if (source_right.column() == 2 && emailPattern.indexIn(rightString) != -1) {
            rightString = emailPattern.cap(1);
        }

        return QString::localeAwareCompare(leftString, rightString) < 0;
    }

    //forward other types to parent class
    return QSortFilterProxyModel::lessThan(source_left, source_right);
}