void CustomParserConfigDialog::changed()
{
    QRegExp rx;
    rx.setPattern(ui->errorPattern->text());
    rx.setMinimal(true);

    QPalette palette;
    palette.setColor(QPalette::Text, rx.isValid() ? Qt::black : Qt::red);
    ui->errorPattern->setPalette(palette);
    ui->errorPattern->setToolTip(rx.isValid() ? QString() : rx.errorString());

    int pos = rx.indexIn(ui->errorMessage->text());
    if (rx.isEmpty() || !rx.isValid() || pos < 0) {
        QString error = QLatin1String("<font color=\"red\">") + tr("Not applicable: ");
        if (rx.isEmpty())
            error += tr("Pattern is empty.");
        else if (!rx.isValid())
            error += rx.errorString();
        else
            error += tr("Pattern does not match the error message.");

        ui->fileNameTest->setText(error);
        ui->lineNumberTest->setText(error);
        ui->messageTest->setText(error);
        ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
        return;
    }

    ui->fileNameTest->setText(rx.cap(ui->fileNameCap->value()));
    ui->lineNumberTest->setText(rx.cap(ui->lineNumberCap->value()));
    ui->messageTest->setText(rx.cap(ui->messageCap->value()));
    ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
    m_dirty = true;
}
void MainWindow::readListOutput() {
    static QRegExp nameRegExp("\\sName: (alsa.+)$");
    static QRegExp deviceDescRegExp("^\\s+device\\.description = \"(.+)\"\\s*$");
    if(!deviceDescRegExp.isValid())
        qWarning() << deviceDescRegExp.errorString();
    disconnect(processConnection);

    QString alsaDeviceName;
    //QDebug debug(QtDebugMsg);
    while(process.canReadLine()) {
        QByteArray line = process.readLine();
        if(nameRegExp.exactMatch(line)) {
            alsaDeviceName = nameRegExp.cap(1).trimmed();
            qDebug() << "device found" << alsaDeviceName;
        } else if(!alsaDeviceName.isEmpty() &&
                  deviceDescRegExp.exactMatch(line)) {
            QString deviceName = deviceDescRegExp.cap(1).trimmed();
            qDebug() << "device name found" << deviceName;

            devices.insert(alsaDeviceName, deviceName);
            alsaDeviceName.clear();
        }/* else
            debug << line;*/
    }
    ui->addStream->setEnabled(true);
    ui->tableWidget->setEnabled(true);
    ui->startRecording->setEnabled(true);
    ui->actionRefresh->setEnabled(true);
    ui->status->setText("Ready");
    ui->progressBar->hide();

    if(ui->tableWidget->rowCount() == 0)
        on_addStream_clicked();
    else {
        // TODO: Clear hanging pointers
        updateSelections();
    }
}
Exemple #3
0
bool pasteWithCtrlV(PlatformWindow &window)
{
    const QRegExp re( QSettings().value(optionName).toString() );
    if (re.isEmpty())
        return false;

    if (!re.isValid()) {
        log(QString("Invalid regular expression in option \"%1\": %2")
            .arg(optionName, re.errorString()), LogWarning);
        return false;
    }

    const QString windowTitle = window.getTitle();

    if (re.indexIn(windowTitle) == -1) {
        COPYQ_LOG(QString("Paste with standard shortcut to window \"%1\".")
                  .arg(windowTitle));
        return false;
    }

    COPYQ_LOG(QString("Paste with Ctrl+V requested with option \"%1\" for window \"%2\".")
              .arg(optionName, windowTitle));
    return true;
}
Exemple #4
0
void FilterDialog::validate()
{
    QString
    error =  "Could not parse %1 regular expression. \n";
    error += "Please correct the error or remove the regular expression.\n";
    error += "Expression: '%2' \n";
    error += "Error: %3 ";


    if(!(getEnableRegexp_Context()||getEnableRegexp_Header()||getEnableRegexp_Payload()))
    {
        emit accept();
        return;
    }

    QRegExp rx;
    rx.setPattern(getPayloadText());
    if(!rx.isValid()) {
        QMessageBox::warning(this, "Warning", error.arg("PAYLOAD").arg(rx.pattern()).arg(rx.errorString()));
        return;
    }

    rx.setPattern(getHeaderText());
    if(!rx.isValid()) {
        QMessageBox::warning(this, "Warning", error.arg("HEADER").arg(rx.pattern()).arg(rx.errorString()));
        return;
    }

    rx.setPattern(getContextId());
    if(!rx.isValid()) {
        QMessageBox::warning(this, "Warning", error.arg("CONTEXTID").arg(rx.pattern()).arg(rx.errorString()));
        return;
    }

    emit accept();
}