コード例 #1
0
/* This function returns true if the given stack frame line is the base of the backtrace
   and thus the parser should not rate any frames below that one. */
static bool lineIsStackBase(const BacktraceLine & line)
{
    //optimization. if there is no function name, do not bother to check it
    if ( line.rating() == BacktraceLine::MissingEverything
            || line.rating() == BacktraceLine::MissingFunction )
        return false;

    //this is the base frame for all threads except the main thread
    //FIXME that probably works only on linux
    if ( line.functionName() == QLatin1String("start_thread") )
        return true;

    QRegExp regExp;
    regExp.setPattern(QStringLiteral("(kde)?main")); //main() or kdemain() is the base for the main thread
    if ( regExp.exactMatch(line.functionName()) )
        return true;

    //HACK for better rating. we ignore all stack frames below any function that matches
    //the following regular expression. The functions that match this expression are usually
    //"QApplicationPrivate::notify_helper", "QApplication::notify" and similar, which
    //are used to send any kind of event to the Qt application. All stack frames below this,
    //with or without debug symbols, are useless to KDE developers, so we ignore them.
    regExp.setPattern(QStringLiteral("(Q|K)(Core)?Application(Private)?::notify.*"));
    if ( regExp.exactMatch(line.functionName()) )
        return true;

    //attempt to recognize crashes that happen after main has returned (bug 200993)
    if ( line.functionName() == QLatin1String("~KCleanUpGlobalStatic") ||
            line.functionName() == QLatin1String("~QGlobalStatic") ||
            line.functionName() == QLatin1String("exit") ||
            line.functionName() == QLatin1String("*__GI_exit") )
        return true;

    return false;
}
コード例 #2
0
ファイル: cprivateinfo.cpp プロジェクト: Manhelp/ChatOnline
bool CPrivateInfo::informationRestrain()
{
    QRegExp regExp;
    regExp.setPattern("^[A-Za-z][A-Za-z0-9]{2,19}$");
    if(!regExp.exactMatch(ui->accountLineEdit->text()))
    {
        //QMessageBox::critical(this, "Error", "帐号格式错误,请再试一遍");
        QMessageBox::critical(this, tr("Error"),
            tr("Account's Format is wrong. Please try again"));
        return false;
    }

    if(ui->nicknameLineEdit->text().isEmpty()
        || ui->nicknameLineEdit->text().size() > 40)
    {
        //QMessageBox::critical(this, "Error", "呢称格式错误,请再试一遍");
        QMessageBox::critical(this, tr("Error"),
            tr("Nickname's Format is wrong. Please try again"));
        return false;
    }
    regExp.setPattern("(^(\\d{3,4}-)\\d{7,8})$|(1[0-9]{10})");
    if(!ui->phoneNumLineEdit->text().isEmpty() &&
        !regExp.exactMatch(ui->phoneNumLineEdit->text()))
    {
        //QMessageBox::critical(this, "Error", "密码格式错误,请再试一遍");
        QMessageBox::critical(this, tr("Error"),
            tr("Phone number's Format is wrong. Please try again"));
        return false;
    }
    if(!ui->mobileNumLineEdit->text().isEmpty() &&
        !regExp.exactMatch(ui->mobileNumLineEdit->text()))
    {
        //QMessageBox::critical(this, "Error", "密码格式错误,请再试一遍");
        QMessageBox::critical(this, tr("Error"),
            tr("Mobile number's Format is wrong. Please try again"));
        return false;
    }
    regExp.setPattern("^\\d{4}-\\d{1,2}-\\d{1,2}$");
    if( !regExp.exactMatch(ui->birthdayLineEdit->text())
        && !ui->birthdayLineEdit->text().isEmpty())
    {
        //QMessageBox::critical(this, "Error", "出生日期格式错误,请再试一遍");
        QMessageBox::critical(this, tr("Error"),
            tr("Birthday's Format is wrong. Please try again"));
        return false;
    }
    if(ui->cityLineEdit->text().size() > 40)
    {
        QMessageBox::critical(this, tr("Error"),
            tr("City's Format is wrong. Please try again"));
        return false;
    }
    if(ui->aboutTextEdit->toPlainText().size() > 400)
    {
        QMessageBox::critical(this, tr("Error"),
            tr("About myself's Format is wrong. Please try again"));
        return false;
    }
    return true;
}
コード例 #3
0
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void elMundo::pasteFile (QString filename, int atX, int atY)
{
    QFile file(filename);
    if (! file.open(QIODevice::ReadOnly | QIODevice::Text)) return;
    QTextStream in(&file);
    setRules(0x8,0xC);
    while (! in.atEnd()) {
        QString line = in.readLine();
        if (line.isEmpty()) continue; // always ignore completely empty lines
        else if (line.startsWith('#')) {
            if (line.startsWith("#R"))
                continue; // TODO: process rules
            else if (reCellBlock.exactMatch(line))
                pasteStart(atX + reCellBlock.cap(1).toInt(),
                           atY + reCellBlock.cap(2).toInt());
            else if (line.startsWith("#C") || line.startsWith("#C"))
                continue; // TODO: keep comments somewhere
        }
        else if (line.startsWith('!')) { // dblife-style comments
            continue; // TODO: keep comments somewhere
        }
        else if (reRLEstart.exactMatch(line)) {
            if (!reRLEstart.cap(3).isEmpty()) setRules(reRLEstart.cap(3).cStr());
            pasteStart(atX, atY);
            while (!in.atEnd())
                if (pasteRLEX_add(in.readLine())) break;
            break;
        }
        else pasteLIFE_add(line);
    }
    file.close();
}
コード例 #4
0
ファイル: ksambashare.cpp プロジェクト: emmanuel099/kio
bool KSambaSharePrivate::sync()
{
    const QRegExp headerRx(QString::fromLatin1("^\\s*\\["
                                         "([^%<>*\?|/\\+=;:\",]+)"
                                         "\\]"));

    const QRegExp OptValRx(QString::fromLatin1("^\\s*([\\w\\d\\s]+)"
                                         "="
                                         "(.*)$"));

    QTextStream stream(getNetUserShareInfo());
    QString currentShare;
    QStringList shareList;

    while (!stream.atEnd()) {
        const QString line = stream.readLine().trimmed();

        if (headerRx.exactMatch(line)) {
            currentShare = headerRx.cap(1).trimmed();
            shareList << currentShare;

            if (!data.contains(currentShare)) {
                KSambaShareData shareData;
                shareData.dd->name = currentShare;
                data.insert(currentShare, shareData);
            }
        } else if (OptValRx.exactMatch(line)) {
            const QString key = OptValRx.cap(1).trimmed();
            const QString value = OptValRx.cap(2).trimmed();
            KSambaShareData shareData = getShareByName(currentShare);

            if (key == QLatin1String("path")) {
                shareData.dd->path = value;
            } else if (key == QLatin1String("comment")) {
                shareData.dd->comment = value;
            } else if (key == QLatin1String("usershare_acl")) {
                shareData.dd->acl = value;
            } else if (key == QLatin1String("guest_ok")) {
                shareData.dd->guestPermission = value;
            } else {
                qWarning() << "Something nasty happen while parsing 'net usershare info'"
                           << "share:" << currentShare << "key:" << key;
            }
        } else if (line.trimmed().isEmpty()) {
            continue;
        } else {
            return false;
        }
    }

    QMutableMapIterator<QString, KSambaShareData> i(data);
    while (i.hasNext()) {
        i.next();
        if (!shareList.contains(i.key())) {
            i.remove();
        }
    }

    return true;
}
コード例 #5
0
ファイル: kis_num_parser.cpp プロジェクト: KDE/krita
/*!
 * \brief treatFuncs treat the last level of recursion: parenthesis
 * \param expr The expression to parse.
 * \param noProblem A reference to a bool set to true if no problem happened, false otherwise.
 * \return The value of the parsed subexpression or 0 in case of error.
 *
 * The expression should not contain operators not nested anymore. The subexpressions within parenthesis will be treated by recalling the level 1 function.
 */
double treatFuncsInt(QString const& expr, bool & noProblem)
{

    noProblem = true;

    QRegExp funcExpInteger = funcExprInteger;
    QRegExp integerExp = integerExpr;
    QRegExp numberExp = numberExpr;

    if (funcExpInteger.exactMatch(expr.trimmed())) {

        int sign = funcExpInteger.capturedTexts()[1].isEmpty() ? 1 : -1;
        QString subExpr = funcExpInteger.capturedTexts()[2];

        double val = treatLevel1Int(subExpr, noProblem);

        if (!noProblem) {
            return 0;
        }

        return sign*val;

    } else if(numberExp.exactMatch(expr.trimmed())) {
        double value = QVariant(expr).toDouble(&noProblem);
        return value;
    }

    noProblem = false;
    return 0;

}
コード例 #6
0
void ConnectionDialog::uriChanged (const QString& uri)
{
	QRegExp serverPortRegExp ("^irc://([a-zA-Z0-9\\.\\-]+):([0-9]+)/(\\S+)$");
	QRegExp serverRegExp ("^irc://([a-zA-Z0-9\\.\\-]+)/(\\S+)$");

	QString server;
	QString room;

	if(serverPortRegExp.exactMatch(uri)) {
		server = serverPortRegExp.cap(1);
		room = serverPortRegExp.cap(3);
	} else if(serverRegExp.exactMatch(uri)) {
		server = serverRegExp.cap(1);
		room = serverRegExp.cap(2);
	} else {
		serverEdit->setCurrentIndex (-1);
		return;
	}

	int index = serverEdit->findText(server, Qt::MatchFixedString);

	if (index >= 0)
		serverEdit->setCurrentIndex(index);
	else
		serverEdit->setEditText(server);

	index = roomEdit->findText(room, Qt::MatchFixedString);

	if (index >= 0)
		roomEdit->setCurrentIndex(index);
	else
		roomEdit->setEditText(room);
}
コード例 #7
0
ファイル: main.cpp プロジェクト: thomas7/hw5
int checkValues(QList<QStringList> matrix) {
    checkRowLength(matrix); //make sure rows have matching number of columns
    bool typeCheck;
    isInt = intPattern.exactMatch(matrix[0][0]); //check first number for type
    isFloat = floatPattern.exactMatch(matrix[0][0]);

    if (!isInt && !isFloat)  //handle case where value isn't an int or float
        throw "The values used do not match the correct data type.";

    for(int i =0; i < matrix.length(); i++) {
        for(int j =0; j<matrix[0].length(); j++) {
            if (isInt)
                typeCheck = intPattern.exactMatch(matrix[i][j]);
            if (isFloat)
                typeCheck = floatPattern.exactMatch(matrix[i][j]);
            if (!typeCheck)
                throw "The values used do not match the correct data type.";
        }
    }
    if (isInt)
        return 1; //type is int
    else if (isFloat)
        return 2; //type is float
    else
        return -1; //something went wrong
}
コード例 #8
0
ファイル: vmdeditor.cpp プロジェクト: vscanf/vnote
static void insertSequenceToHeader(QTextBlock p_block,
                                   QRegExp &p_reg,
                                   QRegExp &p_preReg,
                                   const QString &p_seq)
{
    if (!p_block.isValid()) {
        return;
    }

    QString text = p_block.text();
    bool matched = p_reg.exactMatch(text);
    Q_ASSERT(matched);

    matched = p_preReg.exactMatch(text);
    Q_ASSERT(matched);

    int start = p_reg.cap(1).length() + 1;
    int end = p_preReg.cap(1).length();

    Q_ASSERT(start <= end);

    QTextCursor cursor(p_block);
    cursor.setPosition(p_block.position() + start);
    if (start != end) {
        cursor.setPosition(p_block.position() + end, QTextCursor::KeepAnchor);
    }

    if (p_seq.isEmpty()) {
        cursor.removeSelectedText();
    } else {
        cursor.insertText(p_seq + ' ');
    }
}
コード例 #9
0
void EditorsDialog::slotJobExited( bool normalExit, int exitStatus )
{
    if (!normalExit)
    {
        KMessageBox::sorry( this, i18n("Log failed with exitStatus == %1").arg( exitStatus), i18n("Log Failed") );
        return;
    }

    static QRegExp re("([^\\s]+)\\s([^\\s]+)\\s([^\\s]+)\\s([^\\s]+)\\s([^\\s]+)\\s"
                        "([^\\s]+)\\s([^\\s]+)\\s([^\\s]+)\\s([^\\s]+)\\s(.*)");
    static QRegExp subre("([^\\s]+)\\s([^\\s]+)\\s([^\\s]+)\\s([^\\s]+)\\s"
                        "([^\\s]+)\\s([^\\s]+)\\s([^\\s]+)\\s([^\\s]+)\\s(.*)");
	QString lastfilename;

    QStringList lines = QStringList::split( "\n", m_output );
    int found = 0;
    for (size_t i=0; i<lines.count(); ++i) {
        QString s = lines[i].simplifyWhiteSpace();
    	kdDebug(9006) << "editors:---" << s << "---" << endl;
    	kdDebug(9006) << "       : lastfile was " << lastfilename << endl;

        if (re.exactMatch(s)) {
            QString file = re.cap( 1 );
            QString locker = re.cap( 2 );
            QString date = re.cap(5)+" "+re.cap(4)+" "+re.cap(7)+" "+re.cap(6);
            
            m_textBrowser->append( "<b>"+i18n("File")+": <code>"+file+"</code></b>" );
            m_textBrowser->append( "<b>"+i18n("User")+":</b> "+locker );
            m_textBrowser->append( "<b>"+i18n("Date")+":</b> "+date );
            m_textBrowser->append( "<hr>" );
            found++;

            lastfilename = file;
        } else {
	        if (subre.exactMatch(s)) {
				QString file = lastfilename;
				QString locker = subre.cap( 1 );
				QString date = subre.cap(4)+" "+subre.cap(3)+" "+subre.cap(6)+" "+subre.cap(5);
				
				m_textBrowser->append( "<b>"+i18n("File")+": <code>"+file+"</code></b>" );
				m_textBrowser->append( "<b>"+i18n("User")+":</b> "+locker );
				m_textBrowser->append( "<b>"+i18n("Date")+":</b> "+date );
				m_textBrowser->append( "<hr>" );
				found++;
 			}
    	}
	}

    if (!found)
        m_textBrowser->append(i18n("No files from your query are marked as being edited."));

    m_textBrowser->source();

    if (m_cvsJob) {
        disconnectDCOPSignal( m_cvsJob->app(), m_cvsJob->obj(), "jobExited(bool, int)", "slotJobExited(bool, int)" );
        delete m_cvsJob;
        m_cvsJob=NULL;
    }
}
コード例 #10
0
ファイル: cvslogjob.cpp プロジェクト: KDE/kdevplatform
void CvsLogJob::parseOutput(const QString& jobOutput, QList<QVariant>& events)
{
    static QRegExp rx_sep( "[-=]+" );
    static QRegExp rx_rev( "revision ((\\d+\\.?)+)" );
    static QRegExp rx_branch( "branches:\\s+(.*)" );
    static QRegExp rx_date( "date:\\s+([^;]*);\\s+author:\\s+([^;]*).*" );


    QStringList lines = jobOutput.split('\n');

    KDevelop::VcsEvent item;
    bool firstSeperatorReached = false;
    QString log;

    for (int i=0; i<lines.count(); ++i) {
        QString s = lines[i];
//         qCDebug(PLUGIN_CVS) << "line:" << s ;

        if (rx_rev.exactMatch(s)) {
//             qCDebug(PLUGIN_CVS) << "MATCH REVISION" ;
            KDevelop::VcsRevision rev;
            rev.setRevisionValue( rx_rev.cap(1), KDevelop::VcsRevision::FileNumber );
            item.setRevision( rev );
        } else if (rx_branch.exactMatch(s)) {
//             qCDebug(PLUGIN_CVS) << "MATCH BRANCH" ;
        } else if (rx_date.exactMatch(s)) {
//             qCDebug(PLUGIN_CVS) << "MATCH DATE" ;
            QString date = rx_date.cap(1);
            // cut out the part that matches the Qt::ISODate format
            date.truncate(19);

            item.setDate( QDateTime::fromString( date, Qt::ISODate ) );
            item.setAuthor( rx_date.cap(2) );
        } else  if (rx_sep.exactMatch(s)) {
//             qCDebug(PLUGIN_CVS) << "MATCH SEPARATOR" ;
            if (firstSeperatorReached) {
                item.setMessage( log );
                log.clear();

                events.append( qVariantFromValue( item ) );

                KDevelop::VcsEvent empty;
                item = empty;
            } else {
                firstSeperatorReached = true;
            }
        } else {
            if (firstSeperatorReached) {
//                 qCDebug(PLUGIN_CVS) << "ADDING LOG" ;
                log += s+'\n';
            }
        }
    }
}
コード例 #11
0
ファイル: main.cpp プロジェクト: vasyutin/hpro
	bool processString(const QString &WLine_) {
		if(m_VariableWithValue.exactMatch(WLine_)) {
			m_Parameters.Variables.insert(m_VariableWithValue.cap(1), m_VariableWithValue.cap(2));
			return true;
			}
		if(m_VariableWithoutValue.exactMatch(WLine_)) {
			m_Parameters.Variables.insert(m_VariableWithValue.cap(0), QString());
			return true;
			}
		return false;
		}
コード例 #12
0
ファイル: cvslogpage.cpp プロジェクト: serghei/kde3-kdevelop
void CVSLogPage::slotJobExited( bool normalExit, int exitStatus )
{
//    m_part->core()->running( m_part, false );
    if (!normalExit)
    {
        KMessageBox::sorry( this, i18n("Log failed with exitStatus == %1").arg( exitStatus), i18n("Log Failed") );
        return;
    }

    static QRegExp rx_sep( "\\-+" );
    static QRegExp rx_sep2( "=+" );
    static QRegExp rx_date( "date: .* author: .* state: .* lines: .*" );
    // "revision" followed by one or more decimals followed by a optional dot
    static QRegExp rx_rev( "revision ((\\d+\\.?)+)" );
    m_textBrowser->setTextFormat( QTextBrowser::PlainText );

    for (size_t i=0; i<m_diffStrings.count(); ++i) {
        QString s = m_diffStrings[i];
        kdDebug(9006) << "Examining line: " << s << endl;
        if ( rx_rev.exactMatch(s) )
        {
            QString ver = rx_rev.cap( 1 );
            QString dstr = "<b>" + s + "</b> ";
            int lastVer = ver.section( '.', -1 ).toInt() - 1;
            if ( lastVer > 0 ) {
                QString lv = ver.left( ver.findRev( "." ) + 1 ) + QString::number( lastVer );
                dstr += " [<a href=\"diff:/" + m_pathName + "/" + lv + "_" + ver + "\">diff to " + lv + "</a>]";
            }
            m_textBrowser->setTextFormat( QTextBrowser::RichText );
            m_textBrowser->append( dstr );
            m_textBrowser->setTextFormat( QTextBrowser::PlainText );
        }
        else if ( rx_date.exactMatch(s) )
        {
            m_textBrowser->setTextFormat( QTextBrowser::RichText );
            m_textBrowser->append( "<i>" + s + "</i>" );
            m_textBrowser->setTextFormat( QTextBrowser::PlainText );
        }
        else if ( rx_sep.exactMatch(s) || rx_sep2.exactMatch(s) )
        {
            m_textBrowser->append( "\n" );
            m_textBrowser->setTextFormat( QTextBrowser::RichText );
            m_textBrowser->append( "<hr>" );
            m_textBrowser->setTextFormat( QTextBrowser::PlainText );
        } else
        {
            m_textBrowser->append( s );
        }
    }
    m_logTextBackup = m_textBrowser->source();

//    emit jobFinished( normalExit, exitStatus );
}
コード例 #13
0
ファイル: KeyboardTranslator.cpp プロジェクト: Maijin/konsole
QList<KeyboardTranslatorReader::Token> KeyboardTranslatorReader::tokenize(const QString& line)
{
    QString text = line.simplified();

    // comment line: # comment
    static QRegExp comment("\\#.*");
    // title line: keyboard "title"
    static QRegExp title("keyboard\\s+\"(.*)\"");
    // key line: key KeySequence : "output"
    // key line: key KeySequence : command
    static QRegExp key("key\\s+([\\w\\+\\s\\-]+)\\s*:\\s*(\"(.*)\"|\\w+)");

    QList<Token> list;

    if ( text.isEmpty() || comment.exactMatch(text) )
    {
        return list;
    }

    if ( title.exactMatch(text) )
    {
        Token titleToken = { Token::TitleKeyword , QString() };
        Token textToken = { Token::TitleText , title.capturedTexts()[1] };
    
        list << titleToken << textToken;
    }
    else if  ( key.exactMatch(text) )
    {
        Token keyToken = { Token::KeyKeyword , QString() };
        Token sequenceToken = { Token::KeySequence , key.capturedTexts()[1].remove(' ') };

        list << keyToken << sequenceToken;

        if ( key.capturedTexts()[3].isEmpty() )
        {
            // capturedTexts()[2] is a command
            Token commandToken = { Token::Command , key.capturedTexts()[2] };
            list << commandToken;    
        }   
        else
        {
            // capturedTexts()[3] is the output string
           Token outputToken = { Token::OutputText , key.capturedTexts()[3] };
           list << outputToken;
        }     
    }
    else
    {
        kWarning() << "Line in keyboard translator file could not be understood:" << text;
    }

    return list;
}
コード例 #14
0
bool DatabaseGroupWidget::IsFiltered()
{
    if(Filter.isEmpty())
        return false;

    QRegExp Regexp;
    Regexp.setPatternSyntax(QRegExp::Wildcard);
    Regexp.setPattern("*" + Filter + "*");
    Regexp.setCaseSensitivity(Qt::CaseInsensitive);
    return !(Regexp.exactMatch(GetName()) || Regexp.exactMatch(GetDescription()));

}
コード例 #15
0
ファイル: engnumbervalidator.cpp プロジェクト: DinBan/qtdmm
// TODO: RegExp is still a simple hack
//
QValidator::State
EngNumberValidator::validate( QString & input, int & pos ) const
{
  static QRegExp doubleRe( "-?\\d+\\.?\\d*"  );
  static QRegExp fullRe( "-?\\d+\\.?\\d*[munpkMGT]?"  );
  
  input = input.stripWhiteSpace();
  pos = QMIN( (int)input.length(), pos );
  
  if (fullRe.exactMatch( input )) return Acceptable;
  if (doubleRe.exactMatch( input )) return Intermediate;

  return Invalid;  
}
コード例 #16
0
ファイル: ArchiveThread.cpp プロジェクト: bratao/NeoLoader
QStringList CArchiveThread::ListParts(const QString &ArchivePath, bool NamesOnly)
{
	QStringList Parts;

	StrPair PathName = Split2(ArchivePath, "/", true);
	StrPair NameEx = Split2(PathName.second, ".", true);
	QRegExp Pattern;
	if(NameEx.second == "rar")
		Pattern = QRegExp(QRegExp::escape(NameEx.first) + "(\\.part[0-9]*)?\\.rar", Qt::CaseInsensitive);
	else
		Pattern = QRegExp(QRegExp::escape(NameEx.first + "." + NameEx.second) + "(\\.[0-9]*)?", Qt::CaseInsensitive);
	
	QDir Dir(PathName.first);
	foreach (const QString& File, Dir.entryList())
	{
		if (File.compare(".") == 0 || File.compare("..") == 0)
			continue;
		if(Pattern.exactMatch(File))
		{
			if(NamesOnly)
				Parts.append(File);
			else
				Parts.append(PathName.first + "/" + File);
		}
	}
	return Parts;
}
コード例 #17
0
//------------------------------------------------------------------------------
//
QStringList QEPvNameSearch::getMatchingPvNames (const QRegExp& regExp,
                                                const bool exactMatch) const
{
   QStringList result;
   int n;
   int j;

   if (exactMatch) {
      // QStringList::filter (regExp) does not do an exact match, so we must
      // do own element-by-element filtering.
      //
      n = this->pvNameList.count ();
      for (j = 0; j < n; j++) {
         QString pvName = this->pvNameList.value (j);

         if (regExp.exactMatch (pvName)) {
            result.append (pvName);
         }
      }
   } else {
      // No exact match required - can use in built function.
      //
      result = this->pvNameList.filter (regExp);
   }
   return result;
}
コード例 #18
0
ファイル: qhelp_global.cpp プロジェクト: AtlantisCD9/Qt
QString QHelpGlobal::codecFromXmlData(const QByteArray &data)
{
    QString head = QString::fromUtf8(data.constData(), qMin(1000, data.size()));
    const QRegExp encodingExp(QLatin1String("^\\s*<\\?xml version="
        "\"\\d\\.\\d\" encoding=\"([^\"]+)\"\\?>.*"));
    return encodingExp.exactMatch(head) ? encodingExp.cap(1) : QString();
}
コード例 #19
0
void MPlayerControl::processOutput(QString line)
{
//	qDebug() << Q_FUNC_INFO;
	qDebug() << "\t" << line;

	static QRegExp rx_playing("^Playing (.+)\\.$");
//	static QRegExp rx_playing_ok("^Playing (.+)\.$");

	if (rx_playing.exactMatch(line))
	{
		// Установить только в первый раз
		if (m_current_url.isEmpty())
		{
			m_current_url = rx_playing.cap(1);
			qDebug() << "---" << m_current_url;
		}
	}
	else if (line == "Starting playback...")
	{
		qDebug() << "+++";
		emit sig_urlStatus(m_current_url, true);

		cmd("get_property volume");
	}

	emit sig_videoOutput(line);
}
コード例 #20
0
ファイル: layout_propertysheet.cpp プロジェクト: Fale/qtmoko
static bool isIntegerList(const QString &s)
{
    // Check for empty string or comma-separated list of integers
    static const QRegExp re(QLatin1String("[0-9]+(,[0-9]+)+"));
    Q_ASSERT(re.isValid());
    return s.isEmpty() || re.exactMatch(s);
}
コード例 #21
0
	void FileSystemModel::updateModel()
	{
		static QRegExp rx("^.*\\.(jpg|png|gif|bmp)$");
		beginResetModel();
		m_filesInRoot.clear();
		const QDir rootDir(m_rootPath);

		QDir::Filters filters;

		switch (m_filter)
		{
		case ALL:
			filters = QDir::Dirs | QDir::Files;
			break;
		case DIR_ONLY:
			filters = QDir::Dirs;
			break;
		case FILES_ONLY:
			filters = QDir::Files;
			break;
		}

		const auto files = rootDir.entryInfoList(filters | QDir::NoDot, QDir::Size);
		for (const QFileInfo& info : files)
		{
			if (info.isDir() || rx.exactMatch(info.fileName().toLower()))
			{
				m_filesInRoot.push_back(info);
			}

		}
		endResetModel();
	}
コード例 #22
0
  bool isValidColumnName( const QString& columnName )
  {
    // identifier name with possible accents
    static QRegExp columnNameRx( "[a-zA-Z_\x80-\xFF][a-zA-Z0-9_\x80-\xFF]*" );

    return columnNameRx.exactMatch( columnName );
  }
コード例 #23
0
ファイル: ksambashare.cpp プロジェクト: emmanuel099/kio
KSambaShareData::UserShareError KSambaSharePrivate::isAclValid(const QString &acl) const
{
    const QRegExp aclRx(QStringLiteral("(?:(?:(\\w+\\s*)\\\\|)(\\w+\\s*):([fFrRd]{1})(?:,|))*"));
    // TODO: check if user is a valid smb user
    return aclRx.exactMatch(acl) ? KSambaShareData::UserShareAclOk
           : KSambaShareData::UserShareAclInvalid;
}
コード例 #24
0
ファイル: toolconfigwidget.cpp プロジェクト: KDE/kile
	void ToolConfig::writeDefaults()
	{
		if (KMessageBox::warningContinueCancel(this, i18n("All your tool settings will be overwritten with the default settings, are you sure you want to continue?")) == KMessageBox::Continue) {
			QStringList groups = m_config->groupList();
			QRegExp re = QRegExp("Tool/(.+)/.+");
			for(int i = 0; i < groups.count(); ++i) {
				if (re.exactMatch(groups[i])) {
					m_config->deleteGroup(groups[i]);
				}
			}
			// magic names, defined in kilestdtools.rc
			m_config->deleteGroup("ToolsGUI");
			m_config->deleteGroup("Tools");

			m_manager->factory()->readStandardToolConfig();
			m_config->sync();
			updateToollist();
  			QStringList tools = KileTool::toolList(m_config, true);
			for (int i = 0; i < tools.count(); ++i) {
				switchTo(tools[i], false);// needed to retrieve the new map
 				switchTo(tools[i],true); // this writes the newly retrieved entry map (and not an perhaps changed old one)
			}
			int index = indexQuickBuild();
			if(!tools.empty()) {
				switchTo(tools[index], false);
				m_configWidget->m_lstbTools->item(index)->setSelected(true);
			}
		}
	}
コード例 #25
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;
}
コード例 #26
0
ファイル: checkoutdialog.cpp プロジェクト: KDE/kdevplatform
void CheckoutDialog::jobFinished(KJob * job)
{
    if (job->error()) {
        KMessageBox::error(this, i18n("Error on checkout"), i18n("Checkout Error"));
        return;
    }

    // The job finished, now let's check the output is everything was OK
    CvsJob* cvsjob = dynamic_cast<CvsJob*>(job);

    static QRegExp re_file("^.\\s(.*)");
    bool error = false;
    QStringList lines = cvsjob->output().split('\n');
    foreach(const QString &line, lines) {
        if (line.isEmpty()) {
            // ignore empty lines
            continue;
        } else if (re_file.exactMatch(line)) {
            // line that tell us that a file has been checkedout
            continue;
        } else {
            // any other line must mean that an error occurred
            qCDebug(PLUGIN_CVS) << line;
            error = true;
        }
    }

    if (error) {
        KMessageBox::error(this,
            i18n("Some errors occurred while checking out into %1", localWorkingDir->url().toLocalFile()),
            i18n("Checkout Error"));
    } else {
        QDialog::accept();
    }
}
コード例 #27
0
ファイル: sounddevice.cpp プロジェクト: hippich/recorditnow
QList<SoundDevice> SoundDevice::getDeviceList()
{

    QList<SoundDevice> cards;

    // asound
    QDir asound("/proc/asound");
    if (!asound.exists()) {
        kWarning() << "/proc/asound does not exists.";
        return cards;
    }

    const QRegExp cardRX("^card[0-9]+$");
    const QStringList subDirs = asound.entryList(QStringList(), QDir::Dirs|QDir::NoDotAndDotDot);
    foreach (const QString &dir, subDirs) {
        if (cardRX.exactMatch(dir)) {
            kDebug() << "found card:" << dir;
            cards.append(scanASoundDevice("/proc/asound/"+dir));
        }
    }

    if (!KGlobal::dirs()->findExe("pulseaudio").isEmpty()) {
        SoundDevice dev;
        dev.m_name = "Pulseaudio";
        dev.m_key = "pulse";
        dev.m_icon = "audio-card";
        cards.append(dev);
    }

    return cards;

}
コード例 #28
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;
}
コード例 #29
0
ファイル: IrcChannel.cpp プロジェクト: pasnox/monkeystudio2
/*!
    \details An user join this channel
    \param l is the string from Irc server
*/
void IrcChannel::userJoin(QString l)
{
    //  :[email protected] JOIN :#testmonkeystudio
    QRegExp r (":([^!]+).*\\sJOIN\\s:([^ ]+)");
    if(r.exactMatch(l))
    {
        QStringList t = r.capturedTexts();
        if(t.at(2).toLower() == name())
        {
            if(userName() != t.at(1))
            {
                QListWidgetItem *newItem = new QListWidgetItem;
                newItem->setText(t.at(1));
                mMemberList->addItem(newItem);

                mTextEdit->appendHtml("<font color=\"#00ff00\">* "  + t.at(1) + " has joined " + name()  + "</font>");
            }
            else 
            {
                // this user is me :)
                mTextEdit->appendHtml("<font color=\"#ff0000\">Now talking in " + name() + "</font>");
            }

        }
    }
}
コード例 #30
0
ファイル: cpuinfo.cpp プロジェクト: gustavosbarreto/libqsolid
QString extractCpuInfoLine(int processorNumber, const QString &regExpStr)
{
    if (processorNumber == -1) {
        return QString();
    }

    QFile cpuInfoFile("/proc/cpuinfo");
    if (!cpuInfoFile.open(QIODevice::ReadOnly)) {
        return QString();
    }
    QStringList cpuInfo = QString(cpuInfoFile.readAll()).split('\n', QString::SkipEmptyParts);
    cpuInfoFile.close();

    const QRegExp processorRegExp("processor\\s+:\\s+(\\d+)");
    const QRegExp regExp(regExpStr);

    int line = 0;
    while (line < cpuInfo.size()) {
        if (processorRegExp.exactMatch(cpuInfo.at(line))) {
            int recordProcNum = processorRegExp.capturedTexts()[1].toInt();
            if (recordProcNum == processorNumber) {
                ++line;
                while (line < cpuInfo.size()) {
                    if (regExp.exactMatch(cpuInfo.at(line))) {
                        return regExp.capturedTexts()[1];
                    }
                    ++line;
                }
            }
        }
        ++line;
    }

    return QString();
}