diff --git a/Source/GUI/Qt/WebCommonPage.cpp b/Source/GUI/Qt/WebCommonPage.cpp index 3d183246..943d7a34 100644 --- a/Source/GUI/Qt/WebCommonPage.cpp +++ b/Source/GUI/Qt/WebCommonPage.cpp @@ -14,6 +14,7 @@ #include #include #include +#include namespace MediaConch { @@ -82,7 +83,6 @@ namespace MediaConch return; QTextStream out(&file); - out.setCodec("UTF-8"); out << report; } @@ -795,34 +795,25 @@ namespace MediaConch //--------------------------------------------------------------------------- bool WebCommonPage::report_is_html(const QString& report) { - QRegExp reg("^(<\\!DOCTYPE.*html|.*$)", Qt::CaseInsensitive); + QRegularExpression reg("^(<\\!DOCTYPE.*html|.*$)", QRegularExpression::CaseInsensitiveOption); - if (reg.indexIn(report.trimmed(), 0) != -1) - return true; - - return false; + return reg.match(report.trimmed()).hasMatch(); } //--------------------------------------------------------------------------- bool WebCommonPage::report_is_xml(const QString& report) { - QRegExp reg("<\\?xml ", Qt::CaseInsensitive); - - if (reg.indexIn(report, 0) != -1) - return true; + QRegularExpression reg("<\\?xml ", QRegularExpression::CaseInsensitiveOption); - return false; + return reg.match(report).hasMatch(); } //--------------------------------------------------------------------------- bool WebCommonPage::report_is_json(const QString& report) { - QRegExp reg("^\\{.*\\}$", Qt::CaseInsensitive); - - if (reg.indexIn(report.trimmed(), 0) != -1) - return true; + QRegularExpression reg("^\\{.*\\}$", QRegularExpression::CaseInsensitiveOption); - return false; + return reg.match(report.trimmed()).hasMatch(); } QString WebCommonPage::get_file_tool(const QString& file) diff --git a/Source/GUI/Qt/WebEnginePage.cpp b/Source/GUI/Qt/WebEnginePage.cpp index 0325eeed..f372a50f 100644 --- a/Source/GUI/Qt/WebEnginePage.cpp +++ b/Source/GUI/Qt/WebEnginePage.cpp @@ -76,9 +76,9 @@ namespace MediaConch { QString value_input; if (select_file_name == "checkerRepository_directory") - value_input = QFileDialog::getExistingDirectory(view(), NULL, suggested); + value_input = QFileDialog::getExistingDirectory(NULL, NULL, suggested); else - value_input = QFileDialog::getOpenFileName(view(), NULL, suggested); + value_input = QFileDialog::getOpenFileName(NULL, NULL, suggested); QMap::iterator it = file_selector.find(select_file_name); if (!value_input.length()) @@ -103,7 +103,7 @@ namespace MediaConch } else { - QStringList names = QFileDialog::getOpenFileNames(view(), QString::null, suggested); + QStringList names = QFileDialog::getOpenFileNames(NULL, QString(), suggested); if (names.size()) { diff --git a/Source/GUI/Qt/checkerwindow.cpp b/Source/GUI/Qt/checkerwindow.cpp index d94031a6..d18a924a 100644 --- a/Source/GUI/Qt/checkerwindow.cpp +++ b/Source/GUI/Qt/checkerwindow.cpp @@ -17,9 +17,9 @@ #include #include -#include #include #include +#include #if QT_VERSION >= 0x050000 #include #else @@ -213,17 +213,16 @@ void CheckerWindow::create_parsespeed_options(QString& parsespeed) //--------------------------------------------------------------------------- void CheckerWindow::add_policy_to_html_selection(QString& policies, QString& html, const QString& selector) { - QRegExp reg("class=\"policyList form-control\">"); + QRegularExpression reg("class=\"policyList form-control\">", QRegularExpression::InvertedGreedinessOption); int pos = html.indexOf(selector); - reg.setMinimal(true); - if (pos == -1) return; - if ((pos = reg.indexIn(html, pos)) != -1) + QRegularExpressionMatch match = reg.match(html, pos); + if ((pos = match.capturedStart()) != -1) { - pos += reg.matchedLength(); + pos += match.capturedLength(); html.insert(pos, policies); } } @@ -231,16 +230,16 @@ void CheckerWindow::add_policy_to_html_selection(QString& policies, QString& htm //--------------------------------------------------------------------------- void CheckerWindow::add_display_to_html_selection(QString& displays, QString& html, const QString& selector) { - QRegExp reg("class=\"displayList form-control\">"); - reg.setMinimal(true); + QRegularExpression reg("class=\"displayList form-control\">", QRegularExpression::InvertedGreedinessOption); int pos = html.indexOf(selector); if (pos == -1) return; - if ((pos = reg.indexIn(html, pos)) != -1) + QRegularExpressionMatch match = reg.match(html, pos); + if ((pos = match.capturedStart()) != -1) { - pos += reg.matchedLength(); + pos += match.capturedLength(); html.insert(pos, displays); } } @@ -248,16 +247,16 @@ void CheckerWindow::add_display_to_html_selection(QString& displays, QString& ht //--------------------------------------------------------------------------- void CheckerWindow::add_verbosity_to_html_selection(QString& verbosity, QString& html, const QString& selector) { - QRegExp reg("class=\"verbosityList form-control\">"); - reg.setMinimal(true); + QRegularExpression reg("class=\"verbosityList form-control\">", QRegularExpression::InvertedGreedinessOption); int pos = html.indexOf(selector); if (pos == -1) return; - if ((pos = reg.indexIn(html, pos)) != -1) + QRegularExpressionMatch match = reg.match(html, pos); + if ((pos = match.capturedStart()) != -1) { - pos += reg.matchedLength(); + pos += match.capturedLength(); html.insert(pos, verbosity); } } @@ -265,16 +264,16 @@ void CheckerWindow::add_verbosity_to_html_selection(QString& verbosity, QString& //--------------------------------------------------------------------------- void CheckerWindow::add_parsespeed_to_html_selection(QString& parsespeed, QString& html, const QString& selector) { - QRegExp reg("class=\"parsespeedList form-control\">"); - reg.setMinimal(true); + QRegularExpression reg("class=\"parsespeedList form-control\">", QRegularExpression::InvertedGreedinessOption); int pos = html.indexOf(selector); if (pos == -1) return; - if ((pos = reg.indexIn(html, pos)) != -1) + QRegularExpressionMatch match = reg.match(html, pos); + if ((pos = match.capturedStart()) != -1) { - pos += reg.matchedLength(); + pos += match.capturedLength(); html.insert(pos, parsespeed); } } @@ -282,19 +281,20 @@ void CheckerWindow::add_parsespeed_to_html_selection(QString& parsespeed, QStrin //--------------------------------------------------------------------------- void CheckerWindow::load_include_in_template(QString& html) { - QRegExp reg("\\{\\{[\\s]+include\\('AppBundle:(\\w+):(\\w+).html.twig'(,[\\s]*\\{ '\\w+':[\\s]*\\w+[\\s]*\\})?\\)[\\s]\\}\\}"); + QRegularExpression reg("\\{\\{[\\s]+include\\('AppBundle:(\\w+):(\\w+).html.twig'(,[\\s]*\\{ '\\w+':[\\s]*\\w+[\\s]*\\})?\\)[\\s]\\}\\}"); + QRegularExpressionMatch match; int pos = 0; - while ((pos = reg.indexIn(html, pos)) != -1) + while ((pos = (match = reg.match(html, pos)).capturedStart()) != -1) { - QString app = reg.cap(1); - QString module = reg.cap(2); + QString app = match.captured(1); + QString module = match.captured(2); if (app == "Default" && module == "quotaExceeded") { - html.replace(pos, reg.matchedLength(), ""); + html.replace(match.capturedStart(), match.capturedLength(), ""); continue; } - html.replace(pos, reg.matchedLength(), ""); + html.replace(match.capturedStart(), match.capturedLength(), ""); pos = 0; } } @@ -302,50 +302,47 @@ void CheckerWindow::load_include_in_template(QString& html) //--------------------------------------------------------------------------- void CheckerWindow::remove_element_in_template(QString& html) { - QRegExp reg("\\{% (.*) %\\}"); - int pos = 0; - - reg.setMinimal(true); - while ((pos = reg.indexIn(html, pos)) != -1) - html.replace(pos, reg.matchedLength(), ""); + QRegularExpression reg("\\{% (.*) %\\}", QRegularExpression::InvertedGreedinessOption); + html.replace(reg, ""); } //--------------------------------------------------------------------------- void CheckerWindow::change_collapse_form(QString& html) { - QRegExp reg("class=\"panel-collapse collapse in\""); - int pos = 0; - - while ((pos = reg.indexIn(html, pos)) != -1) - html.replace(pos, reg.matchedLength(), "class=\"panel-collapse collapse\""); + QRegularExpression reg("class=\"panel-collapse collapse in\""); + html.replace(reg, "class=\"panel-collapse collapse\""); } //--------------------------------------------------------------------------- void CheckerWindow::load_form_in_template(QString& html) { - QRegExp reg("\\{\\{[\\s]+form\\((\\w+)\\)[\\s]\\}\\}"); - int pos = 0; + QRegularExpression reg("\\{\\{[\\s]+form\\((\\w+)\\)[\\s]\\}\\}"); + QRegularExpressionMatch match; bool has_libcurl = main_window->mil_has_curl_enabled(); - while ((pos = reg.indexIn(html, pos)) != -1) + + int pos = 0; + while ((pos = (match = reg.match(html)).capturedStart()) != -1) { - QString value = reg.cap(1); + QString value = match.captured(1); if (value == "formUpload") - html.replace(pos, reg.matchedLength(), create_form_upload()); + { + html.replace(match.capturedStart(), match.capturedLength(), create_form_upload()); + } else if (value == "formOnline") { if (has_libcurl) - html.replace(pos, reg.matchedLength(), create_form_online()); + html.replace(match.capturedStart(), match.capturedLength(), create_form_online()); else { remove_form_online(pos, html); - remove_li_online(pos, html); + remove_li_online(html); } } else if (value == "formRepository") - html.replace(pos, reg.matchedLength(), create_form_repository()); + html.replace(match.capturedStart(), match.capturedLength(), create_form_repository()); else - html.replace(pos, reg.matchedLength(), ""); + html.replace(match.capturedStart(), match.capturedLength(), ""); } change_collapse_form(html); @@ -413,40 +410,31 @@ QString CheckerWindow::create_form_online() void CheckerWindow::remove_form_online(int pos, QString& html) { int start_div_pos = pos; - QRegExp reg("
"); - reg.setMinimal(true); - start_div_pos = reg.lastIndexIn(html, start_div_pos); + start_div_pos = html.lastIndexOf("
", start_div_pos); - reg = QRegExp("
"); - reg.setMinimal(true); - int end_div_pos = pos; - if ((end_div_pos = reg.indexIn(html, end_div_pos)) != -1) - end_div_pos += reg.matchedLength(); + int end_div_pos = html.indexOf("
", start_div_pos); + if (end_div_pos != -1) + end_div_pos += 6; if (end_div_pos != -1 && start_div_pos != -1) html.remove(start_div_pos, end_div_pos - start_div_pos); } //--------------------------------------------------------------------------- -void CheckerWindow::remove_li_online(int& pos, QString& html) +void CheckerWindow::remove_li_online(QString& html) { - QRegExp reg("
  • "); - reg.setMinimal(true); - int end_pos = -1; - if ((end_pos = reg.indexIn(html, start)) != -1) - end_pos += reg.matchedLength(); + int end_pos = html.indexOf("
  • ", start); + if (end_pos != -1) + end_pos += 5; if (end_pos != -1 && start != -1) { int len = end_pos - start; html.remove(start, len); - pos -= len; } } @@ -503,23 +491,24 @@ void CheckerWindow::create_html_checker(QString& checker) //--------------------------------------------------------------------------- void CheckerWindow::change_checker_in_template(const QString& checker, QString& html) { - QRegExp reg("\\{% block checker %\\}\\{% endblock %\\}"); + QRegularExpression reg("\\{% block checker %\\}\\{% endblock %\\}", QRegularExpression::InvertedGreedinessOption); int pos = 0; - reg.setMinimal(true); - while ((pos = reg.indexIn(html, pos)) != -1) - html.replace(pos, reg.matchedLength(), checker); + QRegularExpressionMatch match; + while ((match = reg.match(html, pos)).hasMatch()) + { + pos = match.capturedStart(); + html.replace(pos, match.capturedLength(), checker); + } } //--------------------------------------------------------------------------- void CheckerWindow::change_body_script_in_template(QString& html) { - QRegExp reg("\\{\\{ QT_SCRIPTS \\}\\}"); + QRegularExpression reg("\\{\\{ QT_SCRIPTS \\}\\}", QRegularExpression::InvertedGreedinessOption); QString script; int pos = 0; - reg.setMinimal(true); - #if defined(WEB_MACHINE_KIT) script += " \n"; #elif defined(WEB_MACHINE_ENGINE) @@ -539,25 +528,26 @@ void CheckerWindow::change_body_script_in_template(QString& html) " \n" " \n"; - if ((pos = reg.indexIn(html, pos)) != -1) - html.replace(pos, reg.matchedLength(), script); + QRegularExpressionMatch match = reg.match(html, pos); + if ((pos = match.capturedStart()) != -1) + html.replace(pos, match.capturedLength(), script); } //--------------------------------------------------------------------------- void CheckerWindow::set_webmachine_script_in_template(QString& html) { - QRegExp reg("\\{\\{[\\s]+webmachine[\\s]\\}\\}"); + QRegularExpression reg("\\{\\{[\\s]+webmachine[\\s]\\}\\}", QRegularExpression::InvertedGreedinessOption); QString machine; int pos = 0; - reg.setMinimal(true); #if defined(WEB_MACHINE_KIT) machine = "WEB_MACHINE_KIT"; #elif defined(WEB_MACHINE_ENGINE) machine = "WEB_MACHINE_ENGINE"; #endif - if ((pos = reg.indexIn(html, pos)) != -1) - html.replace(pos, reg.matchedLength(), machine); + QRegularExpressionMatch match = reg.match(html, pos); + if ((pos = match.capturedStart()) != -1) + html.replace(pos, match.capturedLength(), machine); } //--------------------------------------------------------------------------- diff --git a/Source/GUI/Qt/checkerwindow.h b/Source/GUI/Qt/checkerwindow.h index cc83fa65..72826922 100644 --- a/Source/GUI/Qt/checkerwindow.h +++ b/Source/GUI/Qt/checkerwindow.h @@ -65,7 +65,7 @@ class CheckerWindow : public CommonWebWindow QString create_form_online(); QString create_form_repository(); void remove_form_online(int pos, QString& html); - void remove_li_online(int& pos, QString& html); + void remove_li_online(QString& html); void change_collapse_form(QString& html); void change_checker_in_template(const QString& checker, QString& html); void change_body_script_in_template(QString& html); diff --git a/Source/GUI/Qt/databasewindow.cpp b/Source/GUI/Qt/databasewindow.cpp index 1d44ad86..b5076b68 100644 --- a/Source/GUI/Qt/databasewindow.cpp +++ b/Source/GUI/Qt/databasewindow.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #if QT_VERSION >= 0x050000 #include #else @@ -79,11 +80,10 @@ void DatabaseWindow::create_html_base(QString& base, const QString& database) //--------------------------------------------------------------------------- void DatabaseWindow::change_qt_scripts_in_template(QString& html) { - QRegExp reg("\\{\\{ QT_SCRIPTS \\}\\}"); + QRegularExpression reg("\\{\\{ QT_SCRIPTS \\}\\}", QRegularExpression::InvertedGreedinessOption); QString script; int pos = 0; - reg.setMinimal(true); #if defined(WEB_MACHINE_KIT) script += " \n" " \n"; @@ -95,47 +95,40 @@ void DatabaseWindow::change_qt_scripts_in_template(QString& html) #endif script += " \n"; script += " \n"; - if ((pos = reg.indexIn(html, pos)) != -1) - html.replace(pos, reg.matchedLength(), script); + QRegularExpressionMatch match = reg.match(html, pos); + if ((pos = match.capturedStart()) != -1) + html.replace(pos, match.capturedLength(), script); } //--------------------------------------------------------------------------- void DatabaseWindow::set_webmachine_script_in_template(QString& html) { - QRegExp reg("\\{\\{[\\s]+webmachine[\\s]\\}\\}"); + QRegularExpression reg("\\{\\{[\\s]+webmachine[\\s]\\}\\}", QRegularExpression::InvertedGreedinessOption); QString machine; int pos = 0; - reg.setMinimal(true); #if defined(WEB_MACHINE_KIT) machine = "WEB_MACHINE_KIT"; #elif defined(WEB_MACHINE_ENGINE) machine = "WEB_MACHINE_ENGINE"; #endif - if ((pos = reg.indexIn(html, pos)) != -1) - html.replace(pos, reg.matchedLength(), machine); + QRegularExpressionMatch match = reg.match(html, pos); + if ((pos = match.capturedStart()) != -1) + html.replace(pos, match.capturedLength(), machine); } //--------------------------------------------------------------------------- void DatabaseWindow::change_checker_in_template(QString& html, const QString& database) { - QRegExp reg("\\{% block checker %\\}\\{% endblock %\\}"); - int pos = 0; - - reg.setMinimal(true); - while ((pos = reg.indexIn(html, pos)) != -1) - html.replace(pos, reg.matchedLength(), database); + QRegularExpression reg("\\{% block checker %\\}\\{% endblock %\\}", QRegularExpression::InvertedGreedinessOption); + html.replace(reg, database); } //--------------------------------------------------------------------------- void DatabaseWindow::remove_result_in_template(QString& html) { - QRegExp reg("\\{% block result %\\}\\{% endblock %\\}"); - int pos = 0; - - reg.setMinimal(true); - while ((pos = reg.indexIn(html, pos)) != -1) - html.replace(pos, reg.matchedLength(), ""); + QRegularExpression reg("\\{% block result %\\}\\{% endblock %\\}", QRegularExpression::InvertedGreedinessOption); + html.replace(reg, ""); } } diff --git a/Source/GUI/Qt/displaywindow.cpp b/Source/GUI/Qt/displaywindow.cpp index 6b73359b..c3e2a7b2 100644 --- a/Source/GUI/Qt/displaywindow.cpp +++ b/Source/GUI/Qt/displaywindow.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #if QT_VERSION >= 0x050000 #include #else @@ -246,11 +247,10 @@ void DisplayWindow::create_html_base(QString& base, const QString& display) //--------------------------------------------------------------------------- void DisplayWindow::change_qt_scripts_in_template(QString& html) { - QRegExp reg("\\{\\{ QT_SCRIPTS \\}\\}"); + QRegularExpression reg("\\{\\{ QT_SCRIPTS \\}\\}", QRegularExpression::InvertedGreedinessOption); QString script; int pos = 0; - reg.setMinimal(true); #if defined(WEB_MACHINE_KIT) script = " \n"; #elif defined(WEB_MACHINE_ENGINE) @@ -260,47 +260,41 @@ void DisplayWindow::change_qt_scripts_in_template(QString& html) #endif script += " \n"; script += " \n"; - if ((pos = reg.indexIn(html, pos)) != -1) - html.replace(pos, reg.matchedLength(), script); + + QRegularExpressionMatch match = reg.match(html, pos); + if ((pos = match.capturedStart()) != -1) + html.replace(pos, match.capturedLength(), script); } //--------------------------------------------------------------------------- void DisplayWindow::set_webmachine_script_in_template(QString& html) { - QRegExp reg("\\{\\{[\\s]+webmachine[\\s]\\}\\}"); + QRegularExpression reg("\\{\\{[\\s]+webmachine[\\s]\\}\\}", QRegularExpression::InvertedGreedinessOption); QString machine; int pos = 0; - reg.setMinimal(true); #if defined(WEB_MACHINE_KIT) machine = "WEB_MACHINE_KIT"; #elif defined(WEB_MACHINE_ENGINE) machine = "WEB_MACHINE_ENGINE"; #endif - if ((pos = reg.indexIn(html, pos)) != -1) - html.replace(pos, reg.matchedLength(), machine); + QRegularExpressionMatch match = reg.match(html, pos); + if ((pos = match.capturedStart()) != -1) + html.replace(pos, match.capturedLength(), machine); } //--------------------------------------------------------------------------- void DisplayWindow::change_checker_in_template(QString& html, const QString& display) { - QRegExp reg("\\{% block checker %\\}\\{% endblock %\\}"); - int pos = 0; - - reg.setMinimal(true); - while ((pos = reg.indexIn(html, pos)) != -1) - html.replace(pos, reg.matchedLength(), display); + QRegularExpression reg("\\{% block checker %\\}\\{% endblock %\\}", QRegularExpression::InvertedGreedinessOption); + html.replace(reg, display); } //--------------------------------------------------------------------------- void DisplayWindow::remove_result_in_template(QString& html) { - QRegExp reg("\\{% block result %\\}\\{% endblock %\\}"); - int pos = 0; - - reg.setMinimal(true); - while ((pos = reg.indexIn(html, pos)) != -1) - html.replace(pos, reg.matchedLength(), ""); + QRegularExpression reg("\\{% block result %\\}\\{% endblock %\\}", QRegularExpression::InvertedGreedinessOption); + html.replace(reg, ""); } } diff --git a/Source/GUI/Qt/helpwindow.cpp b/Source/GUI/Qt/helpwindow.cpp index 7ed10c12..cc3a6218 100644 --- a/Source/GUI/Qt/helpwindow.cpp +++ b/Source/GUI/Qt/helpwindow.cpp @@ -8,10 +8,10 @@ #include #include #include -#include #include #include #include +#include namespace MediaConch { @@ -22,9 +22,10 @@ namespace MediaConch { //--------------------------------------------------------------------------- Help::Help(QWidget *parent) : QDialog(parent) { - move(QApplication::desktop()->screenGeometry().width()/5, y()); - resize(QApplication::desktop()->screenGeometry().width()-QApplication::desktop()->screenGeometry().width()/5*2, - QApplication::desktop()->screenGeometry().height()*3/4); + + QRect ScreenGeometry = QGuiApplication::primaryScreen()->geometry(); + move(ScreenGeometry.width()/5, y()); + resize(ScreenGeometry.width()-ScreenGeometry.width()/5*2, ScreenGeometry.height()*3/4); setWindowFlags(windowFlags()&(0xFFFFFFFF-Qt::WindowContextHelpButtonHint)); setWindowTitle("MediaConch help"); diff --git a/Source/GUI/Qt/mainwindow.cpp b/Source/GUI/Qt/mainwindow.cpp index 0f61674d..73373772 100644 --- a/Source/GUI/Qt/mainwindow.cpp +++ b/Source/GUI/Qt/mainwindow.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -46,14 +45,9 @@ #include #include #include -#if QT_VERSION >= 0x050000 +#include #include -#else -#include -#endif -#if QT_VERSION >= 0x050200 - #include -#endif +#include #include namespace MediaConch { @@ -138,14 +132,14 @@ MainWindow::MainWindow(QWidget *parent) : // Window setWindowIcon(QIcon(":/icon/icon.png")); int left=70; - int width=QApplication::desktop()->screenGeometry().width(); + int width=QGuiApplication::primaryScreen()->geometry().width(); if (width>1366) { left+=(width-1366)/2; width=1366; } move(left, 70); - resize(width-140, QApplication::desktop()->screenGeometry().height()-140); + resize(width-140, QGuiApplication::primaryScreen()->geometry().height()-140); setAcceptDrops(false); // Status bar diff --git a/Source/GUI/Qt/mainwindow.h b/Source/GUI/Qt/mainwindow.h index 67866148..a2ed7264 100644 --- a/Source/GUI/Qt/mainwindow.h +++ b/Source/GUI/Qt/mainwindow.h @@ -8,6 +8,7 @@ #define MAINWINDOW_H #include +#include #include #include #include @@ -26,7 +27,6 @@ namespace Ui { class QVBoxLayout; class QLabel; class QFile; -class QStringList; class QLineEdit; namespace MediaConch { diff --git a/Source/GUI/Qt/policieswindow.cpp b/Source/GUI/Qt/policieswindow.cpp index 3c304e6c..12924beb 100644 --- a/Source/GUI/Qt/policieswindow.cpp +++ b/Source/GUI/Qt/policieswindow.cpp @@ -11,6 +11,8 @@ #include "WebView.h" #include "progressbar.h" +#include + namespace MediaConch { //*************************************************************************** @@ -51,11 +53,10 @@ int PoliciesWindow::add_new_policies(const QStringList& files) //--------------------------------------------------------------------------- void PoliciesWindow::change_qt_scripts_in_template(QString& html) { - QRegExp reg("\\{\\{ QT_SCRIPTS \\}\\}"); + QRegularExpression reg("\\{\\{ QT_SCRIPTS \\}\\}", QRegularExpression::InvertedGreedinessOption); QString script; int pos = 0; - reg.setMinimal(true); #if defined(WEB_MACHINE_KIT) script += " \n" " \n"; @@ -76,47 +77,41 @@ void PoliciesWindow::change_qt_scripts_in_template(QString& html) script += " \n"; script += " \n"; script += " \n"; - if ((pos = reg.indexIn(html, pos)) != -1) - html.replace(pos, reg.matchedLength(), script); + + QRegularExpressionMatch match = reg.match(html, pos); + if ((pos = match.capturedStart()) != -1) + html.replace(pos, match.capturedLength(), script); } //--------------------------------------------------------------------------- void PoliciesWindow::set_webmachine_script_in_template(QString& html) { - QRegExp reg("\\{\\{[\\s]+webmachine[\\s]\\}\\}"); + QRegularExpression reg("\\{\\{[\\s]+webmachine[\\s]\\}\\}", QRegularExpression::InvertedGreedinessOption); QString machine; int pos = 0; - reg.setMinimal(true); #if defined(WEB_MACHINE_KIT) machine = "WEB_MACHINE_KIT"; #elif defined(WEB_MACHINE_ENGINE) machine = "WEB_MACHINE_ENGINE"; #endif - if ((pos = reg.indexIn(html, pos)) != -1) - html.replace(pos, reg.matchedLength(), machine); + QRegularExpressionMatch match = reg.match(html, pos); + if ((pos = match.capturedStart()) != -1) + html.replace(pos, match.capturedLength(), machine); } //--------------------------------------------------------------------------- void PoliciesWindow::remove_result_in_template(QString& html) { - QRegExp reg("\\{% block result %\\}\\{% endblock %\\}"); - int pos = 0; - - reg.setMinimal(true); - while ((pos = reg.indexIn(html, pos)) != -1) - html.replace(pos, reg.matchedLength(), ""); + QRegularExpression reg("\\{% block result %\\}\\{% endblock %\\}", QRegularExpression::InvertedGreedinessOption); + html.replace(reg, ""); } //--------------------------------------------------------------------------- void PoliciesWindow::change_checker_in_template(const QString& policy, QString& html) { - QRegExp reg("\\{% block checker %\\}\\{% endblock %\\}"); - int pos = 0; - - reg.setMinimal(true); - while ((pos = reg.indexIn(html, pos)) != -1) - html.replace(pos, reg.matchedLength(), policy); + QRegularExpression reg("\\{% block checker %\\}\\{% endblock %\\}", QRegularExpression::InvertedGreedinessOption); + html.replace(reg, policy); } //--------------------------------------------------------------------------- diff --git a/Source/GUI/Qt/policieswindow.h b/Source/GUI/Qt/policieswindow.h index e0e35bf8..030323e6 100644 --- a/Source/GUI/Qt/policieswindow.h +++ b/Source/GUI/Qt/policieswindow.h @@ -7,6 +7,7 @@ #ifndef POLICIESWINDOW_H #define POLICIESWINDOW_H +#include #include #include #include "commonwebwindow.h" @@ -15,7 +16,6 @@ class QVBoxLayout; class QLabel; class QTreeWidgetItem; class QFile; -class QStringList; class QFrame; namespace MediaConch { diff --git a/Source/GUI/Qt/publicpolicieswindow.cpp b/Source/GUI/Qt/publicpolicieswindow.cpp index 10dee163..c9fbf7ae 100644 --- a/Source/GUI/Qt/publicpolicieswindow.cpp +++ b/Source/GUI/Qt/publicpolicieswindow.cpp @@ -11,6 +11,7 @@ #include "WebView.h" #include "progressbar.h" #include +#include namespace MediaConch { @@ -39,11 +40,10 @@ void PublicPoliciesWindow::display_public_policies() //--------------------------------------------------------------------------- void PublicPoliciesWindow::change_qt_scripts_in_template(QString& html) { - QRegExp reg("\\{\\{ QT_SCRIPTS \\}\\}"); + QRegularExpression reg("\\{\\{ QT_SCRIPTS \\}\\}", QRegularExpression::InvertedGreedinessOption); QString script; int pos = 0; - reg.setMinimal(true); #if defined(WEB_MACHINE_KIT) script += " \n" " \n"; @@ -58,47 +58,40 @@ void PublicPoliciesWindow::change_qt_scripts_in_template(QString& html) script += " \n"; script += " \n"; script += " \n"; - if ((pos = reg.indexIn(html, pos)) != -1) - html.replace(pos, reg.matchedLength(), script); + QRegularExpressionMatch match = reg.match(html, pos); + if ((pos = match.capturedStart()) != -1) + html.replace(pos, match.capturedLength(), script); } //--------------------------------------------------------------------------- void PublicPoliciesWindow::set_webmachine_script_in_template(QString& html) { - QRegExp reg("\\{\\{[\\s]+webmachine[\\s]\\}\\}"); + QRegularExpression reg("\\{\\{[\\s]+webmachine[\\s]\\}\\}", QRegularExpression::InvertedGreedinessOption); QString machine; int pos = 0; - reg.setMinimal(true); #if defined(WEB_MACHINE_KIT) machine = "WEB_MACHINE_KIT"; #elif defined(WEB_MACHINE_ENGINE) machine = "WEB_MACHINE_ENGINE"; #endif - if ((pos = reg.indexIn(html, pos)) != -1) - html.replace(pos, reg.matchedLength(), machine); + QRegularExpressionMatch match = reg.match(html, pos); + if ((pos = match.capturedStart()) != -1) + html.replace(pos, match.capturedLength(), machine); } //--------------------------------------------------------------------------- void PublicPoliciesWindow::remove_result_in_template(QString& html) { - QRegExp reg("\\{% block result %\\}\\{% endblock %\\}"); - int pos = 0; - - reg.setMinimal(true); - while ((pos = reg.indexIn(html, pos)) != -1) - html.replace(pos, reg.matchedLength(), ""); + QRegularExpression reg("\\{% block result %\\}\\{% endblock %\\}", QRegularExpression::InvertedGreedinessOption); + html.replace(reg, ""); } //--------------------------------------------------------------------------- void PublicPoliciesWindow::change_checker_in_template(const QString& policy, QString& html) { - QRegExp reg("\\{% block checker %\\}\\{% endblock %\\}"); - int pos = 0; - - reg.setMinimal(true); - while ((pos = reg.indexIn(html, pos)) != -1) - html.replace(pos, reg.matchedLength(), policy); + QRegularExpression reg("\\{% block checker %\\}\\{% endblock %\\}", QRegularExpression::InvertedGreedinessOption); + html.replace(reg, policy); } //--------------------------------------------------------------------------- diff --git a/Source/GUI/Qt/publicpolicieswindow.h b/Source/GUI/Qt/publicpolicieswindow.h index b51acf9b..63937512 100644 --- a/Source/GUI/Qt/publicpolicieswindow.h +++ b/Source/GUI/Qt/publicpolicieswindow.h @@ -7,6 +7,7 @@ #ifndef PUBLICPOLICIESWINDOW_H #define PUBLICPOLICIESWINDOW_H +#include #include #include #include "WebChoose.h" @@ -16,7 +17,6 @@ class QVBoxLayout; class QLabel; class QTreeWidgetItem; class QFile; -class QStringList; class QFrame; namespace MediaConch { diff --git a/Source/GUI/Qt/settingswindow.cpp b/Source/GUI/Qt/settingswindow.cpp index 3464133e..bb009a25 100644 --- a/Source/GUI/Qt/settingswindow.cpp +++ b/Source/GUI/Qt/settingswindow.cpp @@ -11,6 +11,7 @@ #include "progressbar.h" #include #include +#include namespace MediaConch { @@ -315,17 +316,16 @@ void SettingsWindow::create_displaycaptions_options(QString& displaycaptions) //--------------------------------------------------------------------------- void SettingsWindow::add_policy_to_html_selection(QString& policies, QString& html, const QString& selector) { - QRegExp reg("class=\"policyList form-control\">"); + QRegularExpression reg("class=\"policyList form-control\">", QRegularExpression::InvertedGreedinessOption); int pos = html.indexOf(selector); - reg.setMinimal(true); - if (pos == -1) return; - if ((pos = reg.indexIn(html, pos)) != -1) + QRegularExpressionMatch match = reg.match(html, pos); + if ((pos = match.capturedStart()) != -1) { - pos += reg.matchedLength(); + pos += match.capturedLength(); html.insert(pos, policies); } } @@ -333,16 +333,16 @@ void SettingsWindow::add_policy_to_html_selection(QString& policies, QString& ht //--------------------------------------------------------------------------- void SettingsWindow::add_display_to_html_selection(QString& displays, QString& html, const QString& selector) { - QRegExp reg("class=\"displayList form-control\">"); - reg.setMinimal(true); + QRegularExpression reg("class=\"displayList form-control\">", QRegularExpression::InvertedGreedinessOption); int pos = html.indexOf(selector); if (pos == -1) return; - if ((pos = reg.indexIn(html, pos)) != -1) + QRegularExpressionMatch match = reg.match(html, pos); + if ((pos = match.capturedStart()) != -1) { - pos += reg.matchedLength(); + pos += match.capturedLength(); html.insert(pos, displays); } } @@ -350,16 +350,16 @@ void SettingsWindow::add_display_to_html_selection(QString& displays, QString& h //--------------------------------------------------------------------------- void SettingsWindow::add_verbosity_to_html_selection(QString& verbosity, QString& html, const QString& selector) { - QRegExp reg("class=\"verbosityList form-control\">"); - reg.setMinimal(true); + QRegularExpression reg("class=\"verbosityList form-control\">", QRegularExpression::InvertedGreedinessOption); int pos = html.indexOf(selector); if (pos == -1) return; - if ((pos = reg.indexIn(html, pos)) != -1) + QRegularExpressionMatch match = reg.match(html, pos); + if ((pos = match.capturedStart()) != -1) { - pos += reg.matchedLength(); + pos += match.capturedLength(); html.insert(pos, verbosity); } } @@ -367,16 +367,16 @@ void SettingsWindow::add_verbosity_to_html_selection(QString& verbosity, QString //--------------------------------------------------------------------------- void SettingsWindow::add_parsespeed_to_html_selection(QString& parsespeed, QString& html, const QString& selector) { - QRegExp reg("class=\"parsespeedList form-control\">"); - reg.setMinimal(true); + QRegularExpression reg("class=\"parsespeedList form-control\">", QRegularExpression::InvertedGreedinessOption); int pos = html.indexOf(selector); if (pos == -1) return; - if ((pos = reg.indexIn(html, pos)) != -1) + QRegularExpressionMatch match = reg.match(html, pos); + if ((pos = match.capturedStart()) != -1) { - pos += reg.matchedLength(); + pos += match.capturedLength(); html.insert(pos, parsespeed); } } @@ -384,33 +384,24 @@ void SettingsWindow::add_parsespeed_to_html_selection(QString& parsespeed, QStri //--------------------------------------------------------------------------- void SettingsWindow::change_checker_in_template(QString& html, const QString& settings) { - QRegExp reg("\\{% block checker %\\}\\{% endblock %\\}"); - int pos = 0; - - reg.setMinimal(true); - while ((pos = reg.indexIn(html, pos)) != -1) - html.replace(pos, reg.matchedLength(), settings); + QRegularExpression reg("\\{% block checker %\\}\\{% endblock %\\}", QRegularExpression::InvertedGreedinessOption); + html.replace(reg, settings); } //--------------------------------------------------------------------------- void SettingsWindow::remove_result_in_template(QString& html) { - QRegExp reg("\\{% block result %\\}\\{% endblock %\\}"); - int pos = 0; - - reg.setMinimal(true); - while ((pos = reg.indexIn(html, pos)) != -1) - html.replace(pos, reg.matchedLength(), ""); + QRegularExpression reg("\\{% block result %\\}\\{% endblock %\\}", QRegularExpression::InvertedGreedinessOption); + html.replace(reg, ""); } //--------------------------------------------------------------------------- void SettingsWindow::change_qt_scripts_in_template(QString& html) { - QRegExp reg("\\{\\{ QT_SCRIPTS \\}\\}"); + QRegularExpression reg("\\{\\{ QT_SCRIPTS \\}\\}", QRegularExpression::InvertedGreedinessOption); QString script; int pos = 0; - reg.setMinimal(true); #if defined(WEB_MACHINE_KIT) script = " \n"; #elif defined(WEB_MACHINE_ENGINE) @@ -421,25 +412,26 @@ void SettingsWindow::change_qt_scripts_in_template(QString& html) script += " \n"; script += " \n"; - if ((pos = reg.indexIn(html, pos)) != -1) - html.replace(pos, reg.matchedLength(), script); + QRegularExpressionMatch match = reg.match(html, pos); + if ((pos = match.capturedStart()) != -1) + html.replace(pos, match.capturedLength(), script); } //--------------------------------------------------------------------------- void SettingsWindow::set_webmachine_script_in_template(QString& html) { - QRegExp reg("\\{\\{[\\s]+webmachine[\\s]\\}\\}"); + QRegularExpression reg("\\{\\{[\\s]+webmachine[\\s]\\}\\}", QRegularExpression::InvertedGreedinessOption); QString machine; int pos = 0; - reg.setMinimal(true); #if defined(WEB_MACHINE_KIT) machine = "WEB_MACHINE_KIT"; #elif defined(WEB_MACHINE_ENGINE) machine = "WEB_MACHINE_ENGINE"; #endif - if ((pos = reg.indexIn(html, pos)) != -1) - html.replace(pos, reg.matchedLength(), machine); + QRegularExpressionMatch match = reg.match(html, pos); + if ((pos = match.capturedStart()) != -1) + html.replace(pos, match.capturedLength(), machine); } //---------------------------------------------------------------------------