Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit c68eabbb authored by Dominik Haumann's avatar Dominik Haumann

Port trivial cases of QRegExp to QRegularExpression

parent 4de6b812
......@@ -27,7 +27,7 @@
#include <QApplication>
#include <QGroupBox>
#include <QListWidget>
#include <QRegExp>
#include <QRegularExpression>
#include <QStyle>
#include <QVBoxLayout>
......@@ -156,7 +156,7 @@ void KateFileBrowserConfigPage::init()
<< QStringLiteral("tree view") << QStringLiteral("detailed tree view")
<< QStringLiteral("show hidden") /*<< QStringLiteral("view menu") << QStringLiteral("properties")*/
<< QStringLiteral("bookmarks") << QStringLiteral("sync_dir") << QStringLiteral("configure");
QRegExp re(QStringLiteral ("&(?=[^&])"));
QRegularExpression re(QStringLiteral("&(?=[^&])"));
QAction *ac = nullptr;
QListWidget *lb;
for ( QStringList::Iterator it = allActions.begin(); it != allActions.end(); ++it )
......
......@@ -451,16 +451,16 @@ void KateCTagsView::jumpToTag(const QString &file, const QString &pattern, const
if (unescaped.endsWith(QStringLiteral("$/"))) {
reduced = unescaped.mid(2, unescaped.length() - 4);
escaped = QRegExp::escape(reduced);
escaped = QRegularExpression::escape(reduced);
re_string = QStringLiteral("^%1$").arg(escaped);
}
else {
reduced = unescaped.mid( 2, unescaped.length() -3 );
escaped = QRegExp::escape(reduced);
escaped = QRegularExpression::escape(reduced);
re_string = QStringLiteral("^%1").arg(escaped);
}
QRegExp re(re_string);
QRegularExpression re(re_string);
// save current location
TagJump from;
......
......@@ -329,7 +329,7 @@ QStringList KateProjectWorker::filesFromMercurial(const QDir &dir, bool recursiv
return files;
}
const QStringList relFiles = QString::fromLocal8Bit(hg.readAllStandardOutput()).split(QRegExp(QStringLiteral("[\n\r]")), QString::SkipEmptyParts);
const QStringList relFiles = QString::fromLocal8Bit(hg.readAllStandardOutput()).split(QRegularExpression(QStringLiteral("[\n\r]")), QString::SkipEmptyParts);
for (const QString &relFile : relFiles) {
if (!recursive && (relFile.indexOf(QStringLiteral("/")) != -1)) {
......@@ -363,7 +363,7 @@ QStringList KateProjectWorker::filesFromSubversion(const QDir &dir, bool recursi
/**
* get output and split up into lines
*/
const QStringList lines = QString::fromLocal8Bit(svn.readAllStandardOutput()).split(QRegExp(QStringLiteral("[\n\r]")), QString::SkipEmptyParts);
const QStringList lines = QString::fromLocal8Bit(svn.readAllStandardOutput()).split(QRegularExpression(QStringLiteral("[\n\r]")), QString::SkipEmptyParts);
/**
* remove start of line that is no filename, sort out unknown and ignore
......
......@@ -82,7 +82,7 @@ QString KateProjectCodeAnalysisToolCppcheck::notInstalledMessage() const
QStringList KateProjectCodeAnalysisToolCppcheck::parseLine(const QString &line) const
{
return line.split(QRegExp(QStringLiteral("////")), QString::SkipEmptyParts);
return line.split(QRegularExpression(QStringLiteral("////")), QString::SkipEmptyParts);
}
QString KateProjectCodeAnalysisToolCppcheck::stdinMessages()
......
......@@ -92,7 +92,7 @@ QString KateProjectCodeAnalysisToolFlake8::notInstalledMessage() const
QStringList KateProjectCodeAnalysisToolFlake8::parseLine(const QString &line) const
{
return line.split(QRegExp(QStringLiteral("////")), QString::SkipEmptyParts);
return line.split(QRegularExpression(QStringLiteral("////")), QString::SkipEmptyParts);
}
QString KateProjectCodeAnalysisToolFlake8::stdinMessages()
......
......@@ -79,13 +79,13 @@ void KatePluginSymbolViewerView::parseBashSymbols(void)
// skip line if no function defined
// note: function name must match regex: [a-zA-Z0-9-_]+
if(!currline.contains(QRegExp(QLatin1String("^(function )*[a-zA-Z0-9-_]+ *\\( *\\)")))
&& !currline.contains(QRegExp(QLatin1String("^function [a-zA-Z0-9-_]+"))))
if(!currline.contains(QRegularExpression(QLatin1String("^(function )*[a-zA-Z0-9-_]+ *\\( *\\)")))
&& !currline.contains(QRegularExpression(QLatin1String("^function [a-zA-Z0-9-_]+"))))
continue;
// strip everything unneeded and get the function's name
currline.remove(QRegExp(QLatin1String("^(function )*")));
funcName = currline.split(QRegExp(QLatin1String("((\\( *\\))|[^a-zA-Z0-9-_])")))[0].simplified();
currline.remove(QRegularExpression(QLatin1String("^(function )*")));
funcName = currline.split(QRegularExpression(QLatin1String("((\\( *\\))|[^a-zA-Z0-9-_])")))[0].simplified();
if(!funcName.size())
continue;
funcName.append(QLatin1String("()"));
......
......@@ -66,8 +66,8 @@ void KatePluginSymbolViewerView::parsePerlSymbols(void)
//qDebug()<< "Line " << i << " : "<< cl;
if(cl.isEmpty() || cl.at(0) == QLatin1Char('#')) continue;
if(cl.indexOf(QRegExp(QLatin1String("^=[a-zA-Z]"))) >= 0) comment = 1;
if(cl.indexOf(QRegExp(QLatin1String("^=cut$"))) >= 0)
if(cl.indexOf(QRegularExpression(QLatin1String("^=[a-zA-Z]"))) >= 0) comment = 1;
if(cl.indexOf(QRegularExpression(QLatin1String("^=cut$"))) >= 0)
{
comment = 0;
continue;
......@@ -78,10 +78,10 @@ void KatePluginSymbolViewerView::parsePerlSymbols(void)
cl = cl.trimmed();
//qDebug()<<"Trimmed line " << i << " : "<< cl;
if(cl.indexOf(QRegExp(QLatin1String("^use +[A-Z]"))) == 0 && m_macro->isChecked())
if(cl.indexOf(QRegularExpression(QLatin1String("^use +[A-Z]"))) == 0 && m_macro->isChecked())
{
QString stripped=cl.remove( QRegExp(QLatin1String("^use +")) );
//stripped=stripped.replace( QRegExp(QLatin1String(";$")), "" ); // Doesn't work ??
QString stripped=cl.remove( QRegularExpression(QLatin1String("^use +")) );
//stripped=stripped.replace( QRegularExpression(QLatin1String(";$")), "" ); // Doesn't work ??
stripped = stripped.left(stripped.indexOf(QLatin1Char(';')));
if (m_treeOn->isChecked())
{
......@@ -96,10 +96,10 @@ void KatePluginSymbolViewerView::parsePerlSymbols(void)
node->setText(1, QString::number( i, 10));
}
#if 1
if(cl.indexOf(QRegExp(QLatin1String("^use +[a-z]"))) == 0 && m_struct->isChecked())
if(cl.indexOf(QRegularExpression(QLatin1String("^use +[a-z]"))) == 0 && m_struct->isChecked())
{
QString stripped=cl.remove( QRegExp(QLatin1String("^use +")) );
stripped=stripped.remove( QRegExp(QLatin1String(";$")) );
QString stripped=cl.remove( QRegularExpression(QLatin1String("^use +")) );
stripped=stripped.remove( QRegularExpression(QLatin1String(";$")) );
if (m_treeOn->isChecked())
{
node = new QTreeWidgetItem(sctNode, lastSctNode);
......@@ -114,10 +114,10 @@ void KatePluginSymbolViewerView::parsePerlSymbols(void)
}
#endif
#if 1
if(cl.indexOf(QRegExp(QLatin1String("^sub +")))==0 && m_func->isChecked())
if(cl.indexOf(QRegularExpression(QLatin1String("^sub +")))==0 && m_func->isChecked())
{
QString stripped=cl.remove( QRegExp(QLatin1String("^sub +")) );
stripped=stripped.remove( QRegExp(QLatin1String("[{;] *$")) );
QString stripped=cl.remove( QRegularExpression(QLatin1String("^sub +")) );
stripped=stripped.remove( QRegularExpression(QLatin1String("[{;] *$")) );
if (m_treeOn->isChecked())
{
node = new QTreeWidgetItem(clsNode, lastClsNode);
......
......@@ -76,10 +76,10 @@ for (int i=0; i<kv->lines(); i++)
break;
}
if(cl.indexOf( QRegExp(QLatin1String("^class [a-zA-Z0-9_,\\s\\(\\).]+:")) ) >= 0) in_class = 1;
if(cl.indexOf( QRegularExpression(QLatin1String("^class [a-zA-Z0-9_,\\s\\(\\).]+:")) ) >= 0) in_class = 1;
//if(cl.find( QRegExp(QLatin1String("[\\s]+def [a-zA-Z_]+[^#]*:")) ) >= 0) in_class = 2;
if(cl.indexOf( QRegExp(QLatin1String("^def\\s+[a-zA-Z_]+[^#]*:")) ) >= 0 ) in_class = 0;
//if(cl.find( QRegularExpression(QLatin1String("[\\s]+def [a-zA-Z_]+[^#]*:")) ) >= 0) in_class = 2;
if(cl.indexOf( QRegularExpression(QLatin1String("^def\\s+[a-zA-Z_]+[^#]*:")) ) >= 0 ) in_class = 0;
if (cl.indexOf(QLatin1String("def ")) >= 0 || (cl.indexOf(QLatin1String("class ")) >= 0 && in_class == 1))
{
......
......@@ -58,7 +58,7 @@ void KatePluginSymbolViewerView::parseRubySymbols(void)
cl = kv->line(i);
cl = cl.trimmed();
if (cl.indexOf( QRegExp(QLatin1String("^class [a-zA-Z0-9]+[^#]")) ) >= 0)
if (cl.indexOf( QRegularExpression(QLatin1String("^class [a-zA-Z0-9]+[^#]")) ) >= 0)
{
if (m_func->isChecked())
{
......@@ -76,7 +76,7 @@ void KatePluginSymbolViewerView::parseRubySymbols(void)
node->setText(1, QString::number( i, 10));
}
}
if (cl.indexOf( QRegExp(QLatin1String("^def [a-zA-Z_]+[^#]")) ) >= 0 )
if (cl.indexOf( QRegularExpression(QLatin1String("^def [a-zA-Z_]+[^#]")) ) >= 0 )
{
if (m_struct->isChecked())
{
......
......@@ -77,18 +77,18 @@ void KatePluginSymbolViewerView::parseXsltSymbols(void)
cl = kv->line(i);
cl = cl.trimmed();
if(cl.indexOf(QRegExp(QLatin1String("<!--"))) >= 0) { comment = 1; }
if(cl.indexOf(QRegExp(QLatin1String("-->"))) >= 0) { comment = 0; continue; }
if(cl.indexOf(QRegularExpression(QLatin1String("<!--"))) >= 0) { comment = 1; }
if(cl.indexOf(QRegularExpression(QLatin1String("-->"))) >= 0) { comment = 0; continue; }
if(cl.indexOf(QRegExp(QLatin1String("^</xsl:template>"))) >= 0) { templ = 0; continue; }
if(cl.indexOf(QRegularExpression(QLatin1String("^</xsl:template>"))) >= 0) { templ = 0; continue; }
if (comment==1) { continue; }
if (templ==1) { continue; }
if(cl.indexOf(QRegExp(QLatin1String("^<xsl:param "))) == 0 && m_macro->isChecked())
if(cl.indexOf(QRegularExpression(QLatin1String("^<xsl:param "))) == 0 && m_macro->isChecked())
{
QString stripped = cl.remove(QRegExp(QLatin1String("^<xsl:param +name=\"")));
stripped = stripped.remove(QRegExp(QLatin1String("\".*")));
QString stripped = cl.remove(QRegularExpression(QLatin1String("^<xsl:param +name=\"")));
stripped = stripped.remove(QRegularExpression(QLatin1String("\".*")));
if (m_treeOn->isChecked())
{
......@@ -101,10 +101,10 @@ void KatePluginSymbolViewerView::parseXsltSymbols(void)
node->setText(1, QString::number( i, 10));
}
if(cl.indexOf(QRegExp(QLatin1String("^<xsl:variable "))) == 0 && m_struct->isChecked())
if(cl.indexOf(QRegularExpression(QLatin1String("^<xsl:variable "))) == 0 && m_struct->isChecked())
{
QString stripped = cl.remove(QRegExp(QLatin1String("^<xsl:variable +name=\"")));
stripped = stripped.remove(QRegExp(QLatin1String("\".*")));
QString stripped = cl.remove(QRegularExpression(QLatin1String("^<xsl:variable +name=\"")));
stripped = stripped.remove(QRegularExpression(QLatin1String("\".*")));
if (m_treeOn->isChecked())
{
......@@ -117,10 +117,10 @@ void KatePluginSymbolViewerView::parseXsltSymbols(void)
node->setText(1, QString::number( i, 10));
}
if(cl.indexOf(QRegExp(QLatin1String("^<xsl:template +match="))) == 0 && m_func->isChecked())
if(cl.indexOf(QRegularExpression(QLatin1String("^<xsl:template +match="))) == 0 && m_func->isChecked())
{
QString stripped = cl.remove(QRegExp(QLatin1String("^<xsl:template +match=\"")));
stripped = stripped.remove(QRegExp(QLatin1String("\".*")));
QString stripped = cl.remove(QRegularExpression(QLatin1String("^<xsl:template +match=\"")));
stripped = stripped.remove(QRegularExpression(QLatin1String("\".*")));
if (m_treeOn->isChecked())
{
......@@ -133,10 +133,10 @@ void KatePluginSymbolViewerView::parseXsltSymbols(void)
node->setText(1, QString::number( i, 10));
}
if(cl.indexOf(QRegExp(QLatin1String("^<xsl:template +name="))) == 0 && m_func->isChecked())
if(cl.indexOf(QRegularExpression(QLatin1String("^<xsl:template +name="))) == 0 && m_func->isChecked())
{
QString stripped = cl.remove(QRegExp(QLatin1String("^<xsl:template +name=\"")));
stripped = stripped.remove(QRegExp(QLatin1String("\".*")));
QString stripped = cl.remove(QRegularExpression(QLatin1String("^<xsl:template +name=\"")));
stripped = stripped.remove(QRegularExpression(QLatin1String("\".*")));
if (m_treeOn->isChecked())
{
......@@ -150,7 +150,7 @@ void KatePluginSymbolViewerView::parseXsltSymbols(void)
}
if(cl.indexOf(QRegExp(QLatin1String("<xsl:template"))) >= 0)
if(cl.indexOf(QRegularExpression(QLatin1String("<xsl:template"))) >= 0)
{
templ = 1;
}
......
......@@ -396,12 +396,12 @@ bool PseudoDTD::parseEntities(QDomDocument *doc, QProgressDialog *progress)
QString exp = expandedElem.text();
// TODO: support more than one &#...; in the expanded text
/* TODO include do this when the unicode font problem is solved:
if( exp.contains(QRegExp("^&#x[a-zA-Z0-9]+;$")) ) {
if( exp.contains(QRegularExpression("^&#x[a-zA-Z0-9]+;$")) ) {
// hexadecimal numbers, e.g. "&#x236;"
uint end = exp.find( ";" );
exp = exp.mid( 3, end-3 );
exp = QChar();
} else if( exp.contains(QRegExp("^&#[0-9]+;$")) ) {
} else if( exp.contains(QRegularExpression("^&#[0-9]+;$")) ) {
// decimal numbers, e.g. "&#236;"
uint end = exp.find( ";" );
exp = exp.mid( 2, end-2 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment