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;
}
Beispiel #2
0
void SettingsDialog::filtersFromModel(const ApiTraceFilter *model)
{
    ApiTraceFilter::FilterOptions opts = model->filterOptions();
    extensionsBox->setChecked(opts & ApiTraceFilter::ExtensionsFilter);
    functionsBox->setChecked(opts & ApiTraceFilter::ResolutionsFilter);
    errorsBox->setChecked(opts & ApiTraceFilter::ErrorsQueryFilter);
    statesBox->setChecked(opts & ApiTraceFilter::ExtraStateFilter);

    QRegExp regexp = model->filterRegexp();
    if (regexp.isEmpty()) {
        showFilterBox->setChecked(false);
    } else {
        showFilterBox->setChecked(true);
        QMap<QString, QRegExp>::const_iterator itr;
        int i = 0;
        for (itr = m_showFilters.constBegin();
             itr != m_showFilters.constEnd(); ++itr, ++i) {
            if (itr.value() == regexp) {
                showFilterCB->setCurrentIndex(i);
                showFilterEdit->setText(itr.value().pattern());
                return;
            }
        }
        /* custom filter */
        showFilterCB->setCurrentIndex(m_showFilters.count());
        showFilterEdit->setText(regexp.pattern());
    }
}
QSObject QSRegExpClass::fetchValue( const QSObject *objPtr,
				    const QSMember &mem ) const
{
    if ( mem.type() != QSMember::Custom )
	return QSWritableClass::fetchValue( objPtr, mem );

    QRegExp *re = regExp( objPtr );
    switch ( mem.index() ) {
    case Valid:
	return createBoolean( re->isValid() );
    case Empty:
	return createBoolean( re->isEmpty() );
    case MLength:
	return createNumber( re->matchedLength() );
    case Source:
	return createString( source(objPtr) );
    case Global:
	return createBoolean( isGlobal(objPtr) );
    case IgnoreCase:
	return createBoolean( isIgnoreCase(objPtr) );
    case CTexts: {
 	QSArray array( env() );
 	QStringList ct = re->capturedTexts();
 	QStringList::ConstIterator it = ct.begin();
 	int i = 0;
 	for ( ; it != ct.end(); ++it, ++i )
 	    array.put( QString::number( i ), createString( *it ) );
	array.put( QString::fromLatin1("length"), createNumber( i ) );
 	return array;
    }
    default:
	return createUndefined();
    }
}
/*!
    Reads the given \a spec and displays its values
    in this PluginDetailsView.
*/
void PluginDetailsView::update(PluginSpec *spec)
{
    m_ui->name->setText(spec->name());
    m_ui->version->setText(spec->version());
    m_ui->compatVersion->setText(spec->compatVersion());
    m_ui->vendor->setText(spec->vendor());
    const QString link = QString::fromLatin1("<a href=\"%1\">%1</a>").arg(spec->url());
    m_ui->url->setText(link);
    QString component = tr("None");
    if (!spec->category().isEmpty())
        component = spec->category();
    m_ui->component->setText(component);
    m_ui->location->setText(QDir::toNativeSeparators(spec->filePath()));
    m_ui->description->setText(spec->description());
    m_ui->copyright->setText(spec->copyright());
    m_ui->license->setText(spec->license());
    const QRegExp platforms = spec->platformSpecification();
    m_ui->platforms->setText(platforms.isEmpty() ? tr("All") : platforms.pattern());
    QStringList depStrings;
    foreach (const PluginDependency &dep, spec->dependencies()) {
        QString depString = dep.name;
        depString += QLatin1String(" (");
        depString += dep.version;
        if (dep.type == PluginDependency::Optional)
            depString += QLatin1String(", optional");
        depString += QLatin1Char(')');
        depStrings.append(depString);
    }
    m_ui->dependencies->addItems(depStrings);
}
Beispiel #5
0
int GenericCodeEditor::findAll( const QRegExp &expr, QTextDocument::FindFlags options )
{
    mSearchSelections.clear();

    if(expr.isEmpty()) {
        this->updateExtraSelections();
        return 0;
    }

    QTextEdit::ExtraSelection selection;
    selection.format = mSearchResultTextFormat;

    QTextDocument *doc = QPlainTextEdit::document();
    QTextBlock block = doc->begin();
    QTextCursor cursor;

    while (block.isValid()) {
        int blockPos = block.position();
        int offset = 0;
        while(findInBlock(doc, block, expr, offset, options, cursor)) {
            offset = cursor.selectionEnd() - blockPos;

            if (cursor.hasSelection()) {
                selection.cursor = cursor;
                mSearchSelections.append(selection);
            } else
                offset += 1;
        }
        block = block.next();
    }

    this->updateExtraSelections();

    return mSearchSelections.count();
}
Beispiel #6
0
void ItemText::highlight(const QRegExp &re, const QFont &highlightFont, const QPalette &highlightPalette)
{
    QList<QTextBrowser::ExtraSelection> selections;

    if ( !re.isEmpty() ) {
        QTextBrowser::ExtraSelection selection;
        selection.format.setBackground( highlightPalette.base() );
        selection.format.setForeground( highlightPalette.text() );
        selection.format.setFont(highlightFont);

        QTextCursor cur = m_textDocument.find(re);
        int a = cur.position();
        while ( !cur.isNull() ) {
            if ( cur.hasSelection() ) {
                selection.cursor = cur;
                selections.append(selection);
            } else {
                cur.movePosition(QTextCursor::NextCharacter);
            }
            cur = m_textDocument.find(re, cur);
            int b = cur.position();
            if (a == b) {
                cur.movePosition(QTextCursor::NextCharacter);
                cur = m_textDocument.find(re, cur);
                b = cur.position();
                if (a == b) break;
            }
            a = b;
        }
    }

    setExtraSelections(selections);

    update();
}
Beispiel #7
0
bool AppLinkItem::compare(const QRegExp &regExp) const
{
    if (regExp.isEmpty())
        return false;

    return mProgram.contains(regExp) ||
           mTitle.contains(regExp) ;
}
Beispiel #8
0
QgsNewNameDialog::QgsNewNameDialog( const QString &source, const QString &initial,
                                    const QStringList &extensions, const QStringList &existing,
                                    const QRegExp &regexp, Qt::CaseSensitivity cs,
                                    QWidget *parent, Qt::WindowFlags flags )
  : QgsDialog( parent, flags, QDialogButtonBox::Ok | QDialogButtonBox::Cancel )
  , mExiting( existing )
  , mExtensions( extensions )
  , mCaseSensitivity( cs )
  , mNamesLabel( nullptr )
  , mRegexp( regexp )
  , mOverwriteEnabled( true )
{
  setWindowTitle( tr( "New name" ) );
  QDialog::layout()->setSizeConstraint( QLayout::SetMinimumSize );
  layout()->setSizeConstraint( QLayout::SetMinimumSize );
  layout()->setSpacing( 6 );
  mOkString = buttonBox()->button( QDialogButtonBox::Ok )->text();
  QString hintString;
  QString nameDesc = mExtensions.isEmpty() ? tr( "name" ) : tr( "base name" );
  if ( source.isEmpty() )
  {
    hintString = tr( "Enter new %1" ).arg( nameDesc );
  }
  else
  {
    hintString = tr( "Enter new %1 for %2" ).arg( nameDesc, source );
  }
  mHintLabel = new QLabel( hintString, this );
  layout()->addWidget( mHintLabel );

  mLineEdit = new QLineEdit( initial, this );
  if ( !regexp.isEmpty() )
  {
    QRegExpValidator *validator = new QRegExpValidator( regexp, this );
    mLineEdit->setValidator( validator );
  }
  mLineEdit->setMinimumWidth( mLineEdit->fontMetrics().width( QStringLiteral( "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ) ) );
  connect( mLineEdit, &QLineEdit::textChanged, this, &QgsNewNameDialog::nameChanged );
  layout()->addWidget( mLineEdit );

  mNamesLabel = new QLabel( QStringLiteral( " " ), this );
  mNamesLabel->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
  if ( !mExtensions.isEmpty() )
  {
    mNamesLabel->setWordWrap( true );
    layout()->addWidget( mNamesLabel );
  }

  mErrorLabel = new QLabel( QStringLiteral( " " ), this );
  mErrorLabel->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
  mErrorLabel->setWordWrap( true );
  layout()->addWidget( mErrorLabel );

  mLineEdit->setFocus();
  mLineEdit->selectAll();

  nameChanged();
}
QStringList IniConfig::keys( const QRegExp & regEx ) const
{
	QStringList ret;
	QList<QString> keys = mValMap[mSection].keys();
	foreach( QString it, keys )
		if( regEx.isEmpty() || regEx.exactMatch( it ) )
			ret += it;
	return ret;
}
Beispiel #10
0
void ItemWeb::highlight(const QRegExp &re, const QFont &, const QPalette &)
{
    // FIXME: Set hightlight color and font!
    // FIXME: Hightlight text matching regular expression!
    findText( QString(), QWebPage::HighlightAllOccurrences );

    if ( !re.isEmpty() )
        findText( re.pattern(), QWebPage::HighlightAllOccurrences );
}
Beispiel #11
0
bool MainWindow::checkRegx(QRegExp rx)
{
    if (!rx.isValid() && rx.isEmpty() && rx.exactMatch("")){
        QMessageBox::information(this, "", "Not valid regx");
        return false;
    }
    else
       return true;
}
QString ModelGrouper::groupValue( const QModelIndex & idx )
{
	QRegExp regEx = columnGroupRegex(mGroupColumn);
	QString strValue = model()->data( idx.column() == mGroupColumn ? idx : idx.sibling(idx.row(),mGroupColumn), Qt::DisplayRole ).toString();
	if( !regEx.isEmpty() && regEx.isValid() && strValue.contains(regEx) )
		strValue = regEx.cap(regEx.captureCount() > 1 ? 1 : 0);
	//LOG_5( QString("Index %1 grouped with value %2").arg(indexToStr(idx)).arg(strValue) );
	return strValue;
}
Beispiel #13
0
void ItemEditorWidget::search(const QRegExp &re)
{
    if ( !re.isValid() || re.isEmpty() )
        return;

    auto tc = textCursor();
    tc.setPosition(tc.selectionStart());
    setTextCursor(tc);
    findNext(re);
}
void RedisConnectionsManager::setFilter(QRegExp & pattern)
{
    if (pattern.isEmpty()) {
        return;
    }

    filter = pattern;

    updateFilter();
}
Beispiel #15
0
void GenericProperty::setStringRegExp(const QRegExp &new_value) {
    if (!new_value.isValid() || new_value.isEmpty())
        return;

    if (d->string_reg_exp != new_value) {
        if (d->type == TypeString && !new_value.exactMatch(d->value))
            setValueString(d->default_value);
        d->string_reg_exp = new_value;
        emit possibleValuesDisplayedChanged(this);
    }
}
Beispiel #16
0
bool AppLinkItem::compare(const QRegExp &regExp) const
{
    if (regExp.isEmpty())
        return false;

    QRegExp re(regExp);

    re.setCaseSensitivity(Qt::CaseInsensitive);
    return mProgram.contains(re) ||
           mTitle.contains(re) ;
}
void TextFindReplacePanel::replace()
{
    if (!mEditor) return;

    QRegExp expr = regexp();
    if (expr.isEmpty()) return;

    mEditor->replace(expr, replaceString(), flags());

    mSearchPosition = -1;
}
void TextFindReplacePanel::findAll()
{
    if (!mEditor) return;

    QRegExp expr = regexp();

    // NOTE: empty expression removes any search highlighting
    int count = mEditor->findAll(expr, flags());

    if (!expr.isEmpty())
        reportFoundOccurrencies(count);
}
void XMLUtility::write(QXmlStreamWriter& writer, const QRegExp& regExp, const QString& name)
{
  if (regExp.isEmpty() || !regExp.isValid() || name.length() == 0)
  {
    return;
  }

  writer.writeStartElement(name);
  writer.writeAttribute("IsMinimal", booleanToString(regExp.isMinimal()));
  writer.writeAttribute("CaseSensitive", caseToString(regExp.caseSensitivity()));
  writer.writeAttribute("PatternSyntax", getEnumMapper().PatternSyntaxToString(regExp.patternSyntax()));
  writer.writeCharacters(regExp.pattern());
  writer.writeEndElement();
}
Beispiel #20
0
bool GenericCodeEditor::replace( const QRegExp &expr, const QString &replacement, QTextDocument::FindFlags options )
{
    if(expr.isEmpty()) return true;

    QTextCursor cursor = textCursor();
    if (cursor.hasSelection() && expr.exactMatch(cursor.selectedText()))
    {
        QString rstr = replacement;
        if(expr.patternSyntax() != QRegExp::FixedString)
            rstr = resolvedReplacement(rstr, expr);
        cursor.insertText(rstr);
    }

    return find(expr, options);
}
void TextFindReplacePanel::replaceAll()
{
    if (!mEditor) return;

    QRegExp expr = regexp();
    if (expr.isEmpty())
        return;

    QTextDocument::FindFlags opt = flags();

    int count = mEditor->replaceAll(expr, replaceString(), opt);

    reportReplacedOccurrencies( count );

    mSearchPosition = -1;
}
Beispiel #22
0
void FilterRules::updateChecking()
{
	QRegExp regex;
	isValid=!ui->search->text().isEmpty();
	if(isValid)
	{
		QString tempString;
		if(ui->search_type->currentIndex()==0)
		{
			tempString=QRegExp::escape(ui->search->text());
			if(tempString.contains('/') || tempString.contains('\\'))
				isValid=false;
		}
		else if(ui->search_type->currentIndex()==1)
		{
			tempString=QRegExp::escape(ui->search->text());
			tempString.replace("\\*","[^\\\\/]*");
		}
		else if(ui->search_type->currentIndex()==2)
		{
			tempString=ui->search->text();
			if(tempString.startsWith('^') && tempString.endsWith('$'))
			{
				ui->need_match_all->setChecked(true);
				tempString.remove(QRegExp("^\\^"));
				tempString.remove(QRegExp("\\$$"));
				ui->search->setText(tempString);
			}
		}
		if(isValid)
		{
			if(ui->need_match_all->isChecked())
				tempString="^"+tempString+"$";
			regex=QRegExp(tempString);
			isValid=regex.isValid() && !regex.isEmpty();
		}
	}

	ui->isValid->setChecked(isValid);
	ui->testString->setEnabled(isValid);
	ui->label_test_string->setEnabled(isValid);
	ui->matched->setEnabled(isValid);
	ui->matched->setChecked(isValid && ui->testString->text().contains(regex));
	ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(isValid);
}
void TextFindReplacePanel::find (bool backwards)
{
    // Non incremental search!

    if (!mEditor) return;

    QRegExp expr = regexp();
    if (expr.isEmpty()) return;

    QTextDocument::FindFlags opt = flags();
    if (backwards)
        opt |= QTextDocument::FindBackward;

    mEditor->find(expr, opt);

    // This was not incremental search, so reset search position
    mSearchPosition = -1;
}
Beispiel #24
0
void TextEdit::findButton(const QRegExp searchString)
{
    QTextDocument *document = textEdit->document();
    if (isFirstTime == false)
        document->undo();
    highLightRows.clear();
    curHighlightRow = -1;
    if (searchString.isEmpty())
    {
        return;
    }
    else
    {
        QTextCursor highlightCursor(document);
        QTextCursor cursor(document);
        cursor.beginEditBlock();
        QTextCharFormat plainFormat(highlightCursor.charFormat());
        QTextCharFormat colorFormat = plainFormat;
        colorFormat.setBackground(Qt::yellow);

        //qDebug() << searchString.pattern().size();
        while (!highlightCursor.isNull() && !highlightCursor.atEnd())
        {
            //highlightCursor = document->find(searchString, highlightCursor, QTextDocument::FindWholeWords);
            highlightCursor = document->find(searchString, highlightCursor);

            if (!highlightCursor.isNull())
            {
                //highlightCursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
                //highlightCursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, searchString.pattern().size());
                //highlightCursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
                highlightCursor.movePosition(QTextCursor::NoMove, QTextCursor::KeepAnchor);
                highlightCursor.mergeCharFormat(colorFormat);
                if(!highLightRows.contains(highlightCursor.blockNumber()))
                       highLightRows.append(highlightCursor.blockNumber());
            }
        }
        cursor.endEditBlock();
        isFirstTime = false;
        if(!highLightRows.isEmpty())
            curHighlightRow = highLightRows[0];
        select_cur_line();
    }
}
Beispiel #25
0
bool ContactListFrontModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
	QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
	const QRegExp regexp = filterRegExp();
	switch (index.data(ItemTypeRole).toInt()) {
	case ContactType: {
		Contact *contact = qobject_cast<Contact*>(index.data(BuddyRole).value<Buddy*>());
		Q_ASSERT(contact);
		if (!regexp.isEmpty()) {
			return contact->id().contains(regexp) || contact->name().contains(regexp);
		} else {
			if (index.data(NotificationRole).toInt() >= Notification::IncomingMessage)
				return true;
			if (!m_filterTags.isEmpty()) {
				bool hasAny = false;
				foreach (const QString &tag, contact->tags()) {
					hasAny |= bool(m_filterTags.contains(tag));
					if (hasAny)
						break;
				}
				if (!hasAny)
					return false;
			}
			if (!m_showOffline) {
				const Status status = index.data(StatusRole).value<Status>();
				return status != Status::Offline;
			}
		}
		break;
	}
	case TagType: {
		if (!m_filterTags.isEmpty() && !m_filterTags.contains(index.data(TagNameRole).toString()))
			return false;
		int count = sourceModel()->rowCount(index);
		for (int i = 0; i < count; ++i) {
			if (filterAcceptsRow(i, index))
				return true;
		}
		return false;
	}
	default:
		break;
	};
/*!
    Reads the given \a spec and displays its values
    in this PluginDetailsView.
*/
void PluginDetailsView::update(ExtensionSystem::PluginSpec *spec)
{
    m_ui->name->setText(spec->name());
    m_ui->version->setText(spec->version());
    m_ui->compatVersion->setText(spec->compatVersion());
    m_ui->vendor->setText(spec->vendor());
    const QString link = QString::fromLatin1("<a href=\"%1\">%1</a>").arg(spec->url());
    m_ui->url->setText(link);
    QString component = tr("None");
    if (!spec->category().isEmpty())
        component = spec->category();
    m_ui->component->setText(component);
    m_ui->location->setText(QDir::toNativeSeparators(spec->filePath()));
    m_ui->description->setText(spec->description());
    m_ui->copyright->setText(spec->copyright());
    m_ui->license->setText(spec->license());
    const QRegExp platforms = spec->platformSpecification();
    const QString pluginPlatformString = platforms.isEmpty() ? tr("All") : platforms.pattern();
    const QString platformString = tr("%1 (current: \"%2\")").arg(pluginPlatformString,
                                                                  PluginManager::platformName());
    m_ui->platforms->setText(platformString);
    QStringList depStrings;
    foreach (const PluginDependency &dep, spec->dependencies()) {
        QString depString = dep.name;
        depString += QLatin1String(" (");
        depString += dep.version;
        switch (dep.type) {
        case PluginDependency::Required:
            break;
        case PluginDependency::Optional:
            depString += QLatin1String(", optional");
            break;
        case PluginDependency::Test:
            depString += QLatin1String(", test");
            break;
        }
        depString += QLatin1Char(')');
        depStrings.append(depString);
    }
    m_ui->dependencies->addItems(depStrings);
}
Beispiel #27
0
void ItemText::highlight(const QRegExp &re, const QFont &highlightFont, const QPalette &highlightPalette)
{
    m_searchTextDocument.clear();
    if ( re.isEmpty() ) {
        setDocument(&m_textDocument);
    } else {
        bool plain = m_textFormat == Qt::PlainText;
        const QString &text = plain ? m_textDocument.toPlainText() : m_textDocument.toHtml();
        if (plain)
            m_searchTextDocument.setPlainText(text);
        else
            m_searchTextDocument.setHtml(text);

        QTextCursor cur = m_searchTextDocument.find(re);
        int a = cur.position();
        while ( !cur.isNull() ) {
            QTextCharFormat fmt = cur.charFormat();
            if ( cur.hasSelection() ) {
                fmt.setBackground( highlightPalette.base() );
                fmt.setForeground( highlightPalette.text() );
                fmt.setFont(highlightFont);
                cur.setCharFormat(fmt);
            } else {
                cur.movePosition(QTextCursor::NextCharacter);
            }
            cur = m_searchTextDocument.find(re, cur);
            int b = cur.position();
            if (a == b) {
                cur.movePosition(QTextCursor::NextCharacter);
                cur = m_searchTextDocument.find(re, cur);
                b = cur.position();
                if (a == b) break;
            }
            a = b;
        }
        setDocument(&m_searchTextDocument);
    }

    update();
}
Beispiel #28
0
void GraphTableWidget::setRowFilter(QRegExp regExp,bool showOnlySelectedElements,int columnFilter) {
  //Unset the filter
  if(regExp.isEmpty() && !showOnlySelectedElements) {
    unsetRowFilter();
  }
  else {
    if(_filterModel == NULL) {
      _filterModel = new TulipFilterProxyModel(this);
      _filterModel->setDynamicSortFilter(true);
      _filterModel->setGraphTableModel(_tulipTableModel);
      _filterModel->setShowOnlySelectedElement(showOnlySelectedElements);
      _filterModel->setFilterKeyColumn(columnFilter);
      _filterModel->setFilterRegExp(regExp);
      QTableView::setModel(_filterModel);
    }
    else {
      _filterModel->setShowOnlySelectedElement(showOnlySelectedElements);
      _filterModel->setFilterKeyColumn(columnFilter);
      _filterModel->setFilterRegExp(regExp);
    }
  }
}
Beispiel #29
0
int GenericCodeEditor::replaceAll( const QRegExp &expr, const QString &replacement, QTextDocument::FindFlags options )
{
    mSearchSelections.clear();
    updateExtraSelections();

    if(expr.isEmpty()) return 0;

    int replacements = 0;
    bool caps = expr.patternSyntax() != QRegExp::FixedString;

    QTextDocument *doc = QPlainTextEdit::document();
    QTextBlock block = doc->begin();
    QTextCursor cursor;

    QTextCursor(doc).beginEditBlock();

    while (block.isValid())
    {
        int blockPos = block.position();
        int offset = 0;
        while(findInBlock(doc, block, expr, offset, options, cursor))
        {
            QString rstr = replacement;
            if(caps)
                rstr = resolvedReplacement(rstr, expr);
            cursor.insertText(rstr);
            ++replacements;
            offset = cursor.selectionEnd() - blockPos;
        }
        block = block.next();
    }

    QTextCursor(doc).endEditBlock();

    return replacements;
}
Beispiel #30
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;
}