Delete src/Tools/RegExp directory
remove unnecessary tool
This commit is contained in:
@@ -1,60 +0,0 @@
|
||||
project(RegExp)
|
||||
set(APP_VERSION "1.0")
|
||||
|
||||
cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR)
|
||||
|
||||
find_package(Qt5)
|
||||
|
||||
include_directories(
|
||||
${QT_INCLUDE_DIR}
|
||||
${QT_QTCORE_INCLUDE_DIR}
|
||||
${QT_QTGUI_INCLUDE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
link_directories(${QT_LIBRARY_DIR})
|
||||
|
||||
add_definitions(-D_UNICODE)
|
||||
|
||||
QT5_WRAP_CPP(RegExp_MOC_SRCS
|
||||
regexpdialog.h
|
||||
)
|
||||
|
||||
QT5_WRAP_UI(RegExp_UIC_HDRS
|
||||
regexpdialog.ui
|
||||
)
|
||||
|
||||
SET(RegExp_SRCS
|
||||
${RegExp_UIC_HDRS}
|
||||
${RegExp_MOC_SRCS}
|
||||
main.cpp
|
||||
regexpdialog.cpp
|
||||
regexpdialog.h
|
||||
)
|
||||
|
||||
if (WIN32)
|
||||
SET(RegExp_LIBS
|
||||
debug qtmaind.lib
|
||||
optimized qtmain.lib
|
||||
)
|
||||
endif(WIN32)
|
||||
|
||||
SET(RegExp_LIBS
|
||||
${RegExp_LIBS}
|
||||
${QT_QTCORE_LIBRARY_DEBUG}
|
||||
${QT_QTCORE_LIBRARY}
|
||||
${QT_QTGUI_LIBRARY_DEBUG}
|
||||
${QT_QTGUI_LIBRARY}
|
||||
${QT_QTXML_LIBRARY_DEBUG}
|
||||
${QT_QTXML_LIBRARY}
|
||||
)
|
||||
|
||||
add_executable(RegExp WIN32 ${RegExp_SRCS})
|
||||
|
||||
target_link_libraries(RegExp ${RegExp_LIBS})
|
||||
|
||||
set_target_properties(RegExp PROPERTIES OUTPUT_NAME "RegExp")
|
||||
set_target_properties(RegExp PROPERTIES DEBUG_OUTPUT_NAME "RegExpD")
|
||||
# dirty hack to avoid Debug/Release subdirectory
|
||||
set_target_properties(RegExp PROPERTIES PREFIX "../")
|
||||
set_target_properties(RegExp PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
@@ -1,14 +0,0 @@
|
||||
######################################################################
|
||||
# Automatically generated by qmake (2.01a) Di 3. Jul 11:56:12 2012
|
||||
######################################################################
|
||||
|
||||
TEMPLATE = app
|
||||
TARGET = regexp
|
||||
DEPENDPATH += .
|
||||
INCLUDEPATH += .
|
||||
QT += widgets
|
||||
|
||||
# Input
|
||||
HEADERS += regexpdialog.h
|
||||
FORMS += regexpdialog.ui
|
||||
SOURCES += main.cpp regexpdialog.cpp
|
||||
@@ -1,37 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2005 Werner Mayer <werner.wm.mayer@gmx.de> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "regexpdialog.h"
|
||||
#include <qapplication.h>
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
RegExpDialog dialog(0);
|
||||
app.setActiveWindow(&dialog);
|
||||
dialog.exec();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,173 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2005 Werner Mayer <werner.wm.mayer@gmx.de> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "regexpdialog.h"
|
||||
#include "ui_regexpdialog.h"
|
||||
|
||||
#include <qcheckbox.h>
|
||||
#include <qlabel.h>
|
||||
#include <qlineedit.h>
|
||||
#include <qmessagebox.h>
|
||||
#include <qvalidator.h>
|
||||
|
||||
RegExpDialog::RegExpDialog(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui_RegExpDialog())
|
||||
{
|
||||
ui->setupUi(this);
|
||||
rxhilighter = new RegExpSyntaxHighlighter(ui->textEdit1);
|
||||
|
||||
validator = new QRegularExpressionValidator(this);
|
||||
ui->lineEdit->setValidator(validator);
|
||||
|
||||
connect(ui->lineEditRegExp, &QLineEdit::textChanged, this, &RegExpDialog::performRegExp);
|
||||
connect(ui->caseInsensitiveOption, &QCheckBox::toggled, this, &RegExpDialog::performRegExp);
|
||||
connect(ui->invertedGreedinessOption, &QCheckBox::toggled, this, &RegExpDialog::performRegExp);
|
||||
connect(ui->dotMatchesEverythingOption,
|
||||
&QCheckBox::toggled,
|
||||
this,
|
||||
&RegExpDialog::performRegExp);
|
||||
connect(ui->multilineOption, &QCheckBox::toggled, this, &RegExpDialog::performRegExp);
|
||||
connect(ui->extendedPatternSyntaxOption,
|
||||
&QCheckBox::toggled,
|
||||
this,
|
||||
&RegExpDialog::performRegExp);
|
||||
connect(ui->dontCaptureOption, &QCheckBox::toggled, this, &RegExpDialog::performRegExp);
|
||||
connect(ui->useUnicodePropertiesOption,
|
||||
&QCheckBox::toggled,
|
||||
this,
|
||||
&RegExpDialog::performRegExp);
|
||||
}
|
||||
|
||||
RegExpDialog::~RegExpDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void RegExpDialog::performRegExp()
|
||||
{
|
||||
QString txt = ui->lineEditRegExp->text();
|
||||
if (txt.isEmpty()) {
|
||||
rxhilighter->resethighlight();
|
||||
return;
|
||||
}
|
||||
|
||||
QRegularExpression::PatternOptions options = QRegularExpression::NoPatternOption;
|
||||
if (ui->caseInsensitiveOption->isChecked()) {
|
||||
options |= QRegularExpression::CaseInsensitiveOption;
|
||||
}
|
||||
|
||||
if (ui->invertedGreedinessOption->isChecked()) {
|
||||
options |= QRegularExpression::InvertedGreedinessOption;
|
||||
}
|
||||
|
||||
if (ui->dotMatchesEverythingOption->isChecked()) {
|
||||
options |= QRegularExpression::DotMatchesEverythingOption;
|
||||
}
|
||||
|
||||
if (ui->multilineOption->isChecked()) {
|
||||
options |= QRegularExpression::MultilineOption;
|
||||
}
|
||||
|
||||
if (ui->extendedPatternSyntaxOption->isChecked()) {
|
||||
options |= QRegularExpression::ExtendedPatternSyntaxOption;
|
||||
}
|
||||
|
||||
if (ui->dontCaptureOption->isChecked()) {
|
||||
options |= QRegularExpression::DontCaptureOption;
|
||||
}
|
||||
|
||||
if (ui->useUnicodePropertiesOption->isChecked()) {
|
||||
options |= QRegularExpression::UseUnicodePropertiesOption;
|
||||
}
|
||||
|
||||
QRegularExpression rx(txt, options);
|
||||
|
||||
// evaluate regular expression
|
||||
ui->textLabel4->setText(rx.errorString());
|
||||
if (!rx.isValid()) {
|
||||
rxhilighter->resethighlight();
|
||||
return; // invalid expression
|
||||
}
|
||||
|
||||
rxhilighter->highlightMatchedText(rx);
|
||||
validator->setRegularExpression(rx);
|
||||
}
|
||||
|
||||
void RegExpDialog::about()
|
||||
{
|
||||
QString msg = "This is a tool for playing around with regular expressions.";
|
||||
QMessageBox::information(this, "RegExp Explorer", msg);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------
|
||||
|
||||
RegExpSyntaxHighlighter::RegExpSyntaxHighlighter(QTextEdit* textEdit)
|
||||
: QSyntaxHighlighter(textEdit)
|
||||
{}
|
||||
|
||||
RegExpSyntaxHighlighter::~RegExpSyntaxHighlighter()
|
||||
{}
|
||||
|
||||
void RegExpSyntaxHighlighter::highlightBlock(const QString& text)
|
||||
{
|
||||
QTextCharFormat regFormat;
|
||||
regFormat.setForeground(Qt::black);
|
||||
regFormat.setFontWeight(QFont::Normal);
|
||||
setFormat(0, text.length(), regFormat);
|
||||
|
||||
if (regexp.pattern().isEmpty()) {
|
||||
return; // empty regular expression
|
||||
}
|
||||
|
||||
int pos = 0;
|
||||
int last = -1;
|
||||
regFormat.setFontWeight(QFont::Bold);
|
||||
regFormat.setForeground(Qt::blue);
|
||||
|
||||
QRegularExpressionMatch match;
|
||||
while ((pos = text.indexOf(regexp, pos, &match)) != -1) {
|
||||
if (last == pos) {
|
||||
break;
|
||||
}
|
||||
QString sub = text.mid(pos, match.capturedLength());
|
||||
if (!sub.isEmpty()) {
|
||||
setFormat(pos, sub.length(), regFormat);
|
||||
}
|
||||
|
||||
pos += match.capturedLength();
|
||||
last = pos;
|
||||
}
|
||||
}
|
||||
|
||||
void RegExpSyntaxHighlighter::highlightMatchedText(const QRegularExpression& rx)
|
||||
{
|
||||
regexp = rx;
|
||||
rehighlight();
|
||||
}
|
||||
|
||||
void RegExpSyntaxHighlighter::resethighlight()
|
||||
{
|
||||
regexp.setPattern("");
|
||||
rehighlight();
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2004 Werner Mayer <werner.wm.mayer@gmx.de> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef REG_EXP_DIALOG_H
|
||||
#define REG_EXP_DIALOG_H
|
||||
|
||||
#include <qdialog.h>
|
||||
#include <qregularexpression.h>
|
||||
#include <qsyntaxhighlighter.h>
|
||||
#include <qtextedit.h>
|
||||
|
||||
class QRegularExpressionValidator;
|
||||
class RegExpSyntaxHighlighter;
|
||||
class Ui_RegExpDialog;
|
||||
class RegExpDialog: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RegExpDialog(QWidget* parent = 0);
|
||||
~RegExpDialog();
|
||||
|
||||
void about();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void performRegExp();
|
||||
|
||||
private:
|
||||
RegExpSyntaxHighlighter* rxhilighter;
|
||||
QRegularExpressionValidator* validator;
|
||||
Ui_RegExpDialog* ui;
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------
|
||||
|
||||
class RegExpSyntaxHighlighter: public QSyntaxHighlighter
|
||||
{
|
||||
public:
|
||||
RegExpSyntaxHighlighter(QTextEdit* textEdit);
|
||||
~RegExpSyntaxHighlighter();
|
||||
|
||||
void highlightBlock(const QString& text);
|
||||
void highlightMatchedText(const QRegularExpression&);
|
||||
void resethighlight();
|
||||
|
||||
private:
|
||||
QRegularExpression regexp;
|
||||
};
|
||||
|
||||
#endif // REG_EXP_DIALOG_H
|
||||
@@ -1,212 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>RegExpDialog</class>
|
||||
<widget class="QDialog" name="RegExpDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>693</width>
|
||||
<height>563</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>RegExp Explorer</string>
|
||||
</property>
|
||||
<property name="sizeGripEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QTextEdit" name="textEdit1"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Validator</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="textLabel2">
|
||||
<property name="text">
|
||||
<string>Regular Expression:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Pattern options</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="caseInsensitiveOption">
|
||||
<property name="text">
|
||||
<string>Case insensitive</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QCheckBox" name="multilineOption">
|
||||
<property name="text">
|
||||
<string>Multiline</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="invertedGreedinessOption">
|
||||
<property name="text">
|
||||
<string>Inverted greediness</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QCheckBox" name="dotMatchesEverythingOption">
|
||||
<property name="text">
|
||||
<string>Dot matches everything</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="extendedPatternSyntaxOption">
|
||||
<property name="text">
|
||||
<string>Extended pattern syntax</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="dontCaptureOption">
|
||||
<property name="text">
|
||||
<string>Don't capture</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QCheckBox" name="useUnicodePropertiesOption">
|
||||
<property name="text">
|
||||
<string>Unicode properties</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="textLabel3">
|
||||
<property name="text">
|
||||
<string>Status:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="textLabel4">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonClose">
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Close</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLineEdit" name="lineEditRegExp"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="textLabel1">
|
||||
<property name="text">
|
||||
<string>Text:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<tabstops>
|
||||
<tabstop>textEdit1</tabstop>
|
||||
<tabstop>lineEdit</tabstop>
|
||||
<tabstop>caseInsensitiveOption</tabstop>
|
||||
<tabstop>invertedGreedinessOption</tabstop>
|
||||
<tabstop>dotMatchesEverythingOption</tabstop>
|
||||
<tabstop>multilineOption</tabstop>
|
||||
<tabstop>extendedPatternSyntaxOption</tabstop>
|
||||
<tabstop>dontCaptureOption</tabstop>
|
||||
<tabstop>useUnicodePropertiesOption</tabstop>
|
||||
<tabstop>lineEditRegExp</tabstop>
|
||||
<tabstop>buttonClose</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonClose</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>RegExpDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>400</x>
|
||||
<y>263</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>312</x>
|
||||
<y>283</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user