Start: [skip ci] replace QTextStream and its manipulators with stringstream to avoid deprecation warnings with Qt 5.15

This commit is contained in:
wmayer
2020-09-24 13:46:15 +02:00
parent 3e3006d015
commit a3cd010c82

View File

@@ -25,7 +25,6 @@
#ifndef _PreComp_
# include <QCoreApplication>
# include <QTextStream>
#endif
#include "Workbench.h"
@@ -83,39 +82,38 @@ void StartGui::Workbench::loadStartPage()
try {
QByteArray utf8Title = title.toUtf8();
std::string escapedstr = Base::Tools::escapedUnicodeFromUtf8(utf8Title);
QByteArray cmd;
QTextStream str(&cmd);
str << "import WebGui,sys,Start" << endl;
str << "from StartPage import StartPage" << endl;
str << endl;
str << "class WebPage(object):" << endl;
str << " def __init__(self):" << endl;
str << " self.browser=WebGui.openBrowserWindow(u'" << escapedstr.c_str() << "')" << endl;
std::stringstream str;
str << "import WebGui,sys,Start" << std::endl;
str << "from StartPage import StartPage" << std::endl;
str << std::endl;
str << "class WebPage(object):" << std::endl;
str << " def __init__(self):" << std::endl;
str << " self.browser=WebGui.openBrowserWindow(u'" << escapedstr.c_str() << "')" << std::endl;
#if defined(FC_OS_WIN32)
str << " self.browser.setHtml(StartPage.handle(), App.getResourceDir() + 'Mod/Start/StartPage/')" << endl;
str << " self.browser.setHtml(StartPage.handle(), App.getResourceDir() + 'Mod/Start/StartPage/')" << std::endl;
#else
str << " self.browser.setHtml(StartPage.handle(), 'file://' + App.getResourceDir() + 'Mod/Start/StartPage/')" << endl;
str << " self.browser.setHtml(StartPage.handle(), 'file://' + App.getResourceDir() + 'Mod/Start/StartPage/')" << std::endl;
#endif
str << " def onChange(self, par, reason):" << endl;
str << " if reason == 'RecentFiles':" << endl;
str << " def onChange(self, par, reason):" << std::endl;
str << " if reason == 'RecentFiles':" << std::endl;
#if defined(FC_OS_WIN32)
str << " self.browser.setHtml(StartPage.handle(), App.getResourceDir() + 'Mod/Start/StartPage/')" << endl;
str << " self.browser.setHtml(StartPage.handle(), App.getResourceDir() + 'Mod/Start/StartPage/')" << std::endl;
#else
str << " self.browser.setHtml(StartPage.handle(), 'file://' + App.getResourceDir() + 'Mod/Start/StartPage/')" << endl;
str << " self.browser.setHtml(StartPage.handle(), 'file://' + App.getResourceDir() + 'Mod/Start/StartPage/')" << std::endl;
#endif
str << endl;
str << "class WebView(object):" << endl;
str << " def __init__(self):" << endl;
str << " self.pargrp = FreeCAD.ParamGet('User parameter:BaseApp/Preferences/RecentFiles')" << endl;
str << " self.webPage = WebPage()" << endl;
str << " self.pargrp.Attach(self.webPage)" << endl;
str << " def __del__(self):" << endl;
str << " self.pargrp.Detach(self.webPage)" << endl;
str << endl;
str << "webView=WebView()" << endl;
str << "StartPage.checkPostOpenStartPage()" << endl;
str << std::endl;
str << "class WebView(object):" << std::endl;
str << " def __init__(self):" << std::endl;
str << " self.pargrp = FreeCAD.ParamGet('User parameter:BaseApp/Preferences/RecentFiles')" << std::endl;
str << " self.webPage = WebPage()" << std::endl;
str << " self.pargrp.Attach(self.webPage)" << std::endl;
str << " def __del__(self):" << std::endl;
str << " self.pargrp.Detach(self.webPage)" << std::endl;
str << std::endl;
str << "webView=WebView()" << std::endl;
str << "StartPage.checkPostOpenStartPage()" << std::endl;
Base::Interpreter().runString(cmd);
Base::Interpreter().runString(str.str().c_str());
// Gui::Command::runCommand(Gui::Command::Gui, cmd);
}
catch (const Base::Exception& e) {