Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
QString::fromAscii() is obsolete in Qt5. Replace it with fromLatin1().
This change is Qt4/Qt5 neutral.
  • Loading branch information
f3nix authored and wwmayer committed Jan 5, 2016
1 parent d5c074f commit cd2db00
Show file tree
Hide file tree
Showing 154 changed files with 836 additions and 836 deletions.
2 changes: 1 addition & 1 deletion src/App/Application.cpp
Expand Up @@ -1164,7 +1164,7 @@ void Application::initConfig(int argc, char ** argv)
// Now it's time to read-in the file branding.xml if it exists
Branding brand;
QString binDir = QString::fromUtf8((mConfig["AppHomePath"] + "bin").c_str());
QFileInfo fi(binDir, QString::fromAscii("branding.xml"));
QFileInfo fi(binDir, QString::fromLatin1("branding.xml"));
if (brand.readFile(fi.absoluteFilePath())) {
Branding::XmlConfig cfg = brand.getUserDefines();
for (Branding::XmlConfig::iterator it = cfg.begin(); it != cfg.end(); ++it) {
Expand Down
2 changes: 1 addition & 1 deletion src/Base/UnitsApi.cpp
Expand Up @@ -123,7 +123,7 @@ QString UnitsApi::schemaTranslate(Base::Quantity quant,double &factor,QString &u
//{
// return UserPrefSystem->toStrWithUserPrefs(t,Value);
// //double UnitValue = Value/UserPrefFactor[t];
// //return QString::fromAscii("%1 %2").arg(UnitValue).arg(UserPrefUnit[t]);
// //return QString::fromLatin1("%1 %2").arg(UnitValue).arg(UserPrefUnit[t]);
//}
//
//void UnitsApi::toStrWithUserPrefs(QuantityType t,double Value,QString &outValue,QString &outUnit)
Expand Down
2 changes: 1 addition & 1 deletion src/Base/Uuid.cpp
Expand Up @@ -75,7 +75,7 @@ std::string Uuid::createUuid(void)
void Uuid::setValue(const char* sString)
{
if (sString) {
QUuid uuid(QString::fromAscii(sString));
QUuid uuid(QString::fromLatin1(sString));
if (uuid.isNull())
throw std::runtime_error("invalid uuid");
// remove curly braces
Expand Down
12 changes: 6 additions & 6 deletions src/Gui/Action.cpp
Expand Up @@ -60,15 +60,15 @@ using namespace Gui::Dialog;
Action::Action (Command* pcCmd, QObject * parent)
: QObject(parent), _action(new QAction( this )), _pcCmd(pcCmd)
{
_action->setObjectName(QString::fromAscii(_pcCmd->getName()));
_action->setObjectName(QString::fromLatin1(_pcCmd->getName()));
connect(_action, SIGNAL(triggered(bool)), this, SLOT(onActivated()));
}

Action::Action (Command* pcCmd, QAction* action, QObject * parent)
: QObject(parent), _action(action), _pcCmd(pcCmd)
{
_action->setParent(this);
_action->setObjectName(QString::fromAscii(_pcCmd->getName()));
_action->setObjectName(QString::fromLatin1(_pcCmd->getName()));
connect(_action, SIGNAL(triggered(bool)), this, SLOT(onActivated()));
}

Expand Down Expand Up @@ -589,7 +589,7 @@ void WorkbenchGroup::slotAddWorkbench(const char* name)
QList<QAction*> workbenches = _group->actions();
for (QList<QAction*>::Iterator it = workbenches.begin(); it != workbenches.end(); ++it) {
if (!(*it)->isVisible()) {
QString wb = QString::fromAscii(name);
QString wb = QString::fromLatin1(name);
QPixmap px = Application::Instance->workbenchIcon(wb);
QString text = Application::Instance->workbenchMenuText(wb);
QString tip = Application::Instance->workbenchToolTip(wb);
Expand All @@ -606,7 +606,7 @@ void WorkbenchGroup::slotAddWorkbench(const char* name)

void WorkbenchGroup::slotRemoveWorkbench(const char* name)
{
QString workbench = QString::fromAscii(name);
QString workbench = QString::fromLatin1(name);
QList<QAction*> workbenches = _group->actions();
for (QList<QAction*>::Iterator it = workbenches.begin(); it != workbenches.end(); ++it) {
if ((*it)->objectName() == workbench) {
Expand Down Expand Up @@ -668,7 +668,7 @@ void RecentFilesAction::setFiles(const QStringList& files)
int numRecentFiles = std::min<int>(recentFiles.count(), files.count());
for (int index = 0; index < numRecentFiles; index++) {
QFileInfo fi(files[index]);
recentFiles[index]->setText(QString::fromAscii("&%1 %2").arg(index+1).arg(fi.fileName()));
recentFiles[index]->setText(QString::fromLatin1("&%1 %2").arg(index+1).arg(fi.fileName()));
recentFiles[index]->setStatusTip(tr("Open file %1").arg(files[index]));
recentFiles[index]->setToolTip(files[index]); // set the full name that we need later for saving
recentFiles[index]->setData(QVariant(index));
Expand Down Expand Up @@ -769,7 +769,7 @@ void RecentFilesAction::save()
QList<QAction*> recentFiles = _group->actions();
int num = std::min<int>(count, recentFiles.count());
for (int index = 0; index < num; index++) {
QString key = QString::fromAscii("MRU%1").arg(index);
QString key = QString::fromLatin1("MRU%1").arg(index);
QString value = recentFiles[index]->toolTip();
if (value.isEmpty())
break;
Expand Down
22 changes: 11 additions & 11 deletions src/Gui/Application.cpp
Expand Up @@ -1050,7 +1050,7 @@ bool Application::activateWorkbench(const char* name)
ok = true; // already active
// now try to create and activate the matching workbench object
else if (WorkbenchManager::instance()->activate(name, type)) {
getMainWindow()->activateWorkbench(QString::fromAscii(name));
getMainWindow()->activateWorkbench(QString::fromLatin1(name));
this->signalActivateWorkbench(name);
ok = true;
}
Expand Down Expand Up @@ -1095,7 +1095,7 @@ bool Application::activateWorkbench(const char* name)
}
catch (Py::Exception&) {
Base::PyException e; // extract the Python error text
QString msg = QString::fromAscii(e.what());
QString msg = QString::fromLatin1(e.what());
QRegExp rx;
// ignore '<type 'exceptions.ImportError'>' prefixes
rx.setPattern(QLatin1String("^\\s*<type 'exceptions.ImportError'>:\\s*"));
Expand Down Expand Up @@ -1251,13 +1251,13 @@ QStringList Application::workbenches(void) const
const char* start = (st != config.end() ? st->second.c_str() : "<none>");
QStringList hidden, extra;
if (ht != config.end()) {
QString items = QString::fromAscii(ht->second.c_str());
QString items = QString::fromLatin1(ht->second.c_str());
hidden = items.split(QLatin1Char(';'), QString::SkipEmptyParts);
if (hidden.isEmpty())
hidden.push_back(QLatin1String(""));
}
if (et != config.end()) {
QString items = QString::fromAscii(et->second.c_str());
QString items = QString::fromLatin1(et->second.c_str());
extra = items.split(QLatin1Char(';'), QString::SkipEmptyParts);
if (extra.isEmpty())
extra.push_back(QLatin1String(""));
Expand All @@ -1273,18 +1273,18 @@ QStringList Application::workbenches(void) const
// add only allowed workbenches
bool ok = true;
if (!extra.isEmpty()&&ok) {
ok = (extra.indexOf(QString::fromAscii(wbName)) != -1);
ok = (extra.indexOf(QString::fromLatin1(wbName)) != -1);
}
if (!hidden.isEmpty()&&ok) {
ok = (hidden.indexOf(QString::fromAscii(wbName)) == -1);
ok = (hidden.indexOf(QString::fromLatin1(wbName)) == -1);
}

// okay the item is visible
if (ok)
wb.push_back(QString::fromAscii(wbName));
wb.push_back(QString::fromLatin1(wbName));
// also allow start workbench in case it is hidden
else if (strcmp(wbName, start) == 0)
wb.push_back(QString::fromAscii(wbName));
wb.push_back(QString::fromLatin1(wbName));
}

return wb;
Expand Down Expand Up @@ -1718,7 +1718,7 @@ void Application::runApplication(void)
// if the auto workbench is not visible then force to use the default workbech
// and replace the wrong entry in the parameters
QStringList wb = app.workbenches();
if (!wb.contains(QString::fromAscii(start.c_str()))) {
if (!wb.contains(QString::fromLatin1(start.c_str()))) {
start = App::Application::Config()["StartWorkbench"];
App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")->
SetASCII("AutoloadModule", start.c_str());
Expand Down Expand Up @@ -1805,11 +1805,11 @@ void Application::runApplication(void)
void Application::checkForPreviousCrashes()
{
QDir tmp = QString::fromUtf8(App::Application::getTempPath().c_str());
tmp.setNameFilters(QStringList() << QString::fromAscii("*.lock"));
tmp.setNameFilters(QStringList() << QString::fromLatin1("*.lock"));
tmp.setFilter(QDir::Files);

QList<QFileInfo> restoreDocFiles;
QString exeName = QString::fromAscii(App::GetApplication().getExecutableName());
QString exeName = QString::fromLatin1(App::GetApplication().getExecutableName());
QList<QFileInfo> locks = tmp.entryInfoList();
for (QList<QFileInfo>::iterator it = locks.begin(); it != locks.end(); ++it) {
QString bn = it->baseName();
Expand Down
20 changes: 10 additions & 10 deletions src/Gui/BitmapFactory.cpp
Expand Up @@ -84,8 +84,8 @@ BitmapFactoryInst& BitmapFactoryInst::instance(void)
}
_pcSingleton->addPath(path);
}
_pcSingleton->addPath(QString::fromAscii("%1/icons").arg(QString::fromUtf8(App::GetApplication().getHomePath())));
_pcSingleton->addPath(QString::fromAscii("%1/icons").arg(QString::fromUtf8(App::GetApplication().Config()["UserAppData"].c_str())));
_pcSingleton->addPath(QString::fromLatin1("%1/icons").arg(QString::fromUtf8(App::GetApplication().getHomePath())));
_pcSingleton->addPath(QString::fromLatin1("%1/icons").arg(QString::fromUtf8(App::GetApplication().Config()["UserAppData"].c_str())));
_pcSingleton->addPath(QLatin1String(":/icons/"));
_pcSingleton->addPath(QLatin1String(":/Icons/"));

Expand Down Expand Up @@ -148,7 +148,7 @@ QStringList BitmapFactoryInst::findIconFiles() const
QStringList files, filters;
QList<QByteArray> formats = QImageReader::supportedImageFormats();
for (QList<QByteArray>::iterator it = formats.begin(); it != formats.end(); ++it)
filters << QString::fromAscii("*.%1").arg(QString::fromAscii(*it).toLower());
filters << QString::fromLatin1("*.%1").arg(QString::fromLatin1(*it).toLower());

QStringList paths = QDir::searchPaths(QString::fromLatin1("icons"));
#if QT_VERSION >= 0x040500
Expand Down Expand Up @@ -252,8 +252,8 @@ QPixmap BitmapFactoryInst::pixmap(const char* name) const
if (!loadPixmap(fileName, icon)) {
// Go through supported file formats
for (QList<QByteArray>::iterator fm = formats.begin(); fm != formats.end(); ++fm) {
QString path = QString::fromAscii("%1.%2").arg(fileName).
arg(QString::fromAscii((*fm).toLower().constData()));
QString path = QString::fromLatin1("%1.%2").arg(fileName).
arg(QString::fromLatin1((*fm).toLower().constData()));
if (loadPixmap(path, icon)) {
break;
}
Expand Down Expand Up @@ -316,8 +316,8 @@ QPixmap BitmapFactoryInst::pixmapFromSvg(const QByteArray& contents, const QSize
QPalette pal = webView.palette();
pal.setColor(QPalette::Background, Qt::transparent);
webView.setPalette(pal);
webView.setContent(contents, QString::fromAscii("image/svg+xml"));
QString node = QString::fromAscii("document.rootElement.nodeName");
webView.setContent(contents, QString::fromLatin1("image/svg+xml"));
QString node = QString::fromLatin1("document.rootElement.nodeName");
QWebFrame* frame = webView.page()->mainFrame();
if (!frame) {
return QPixmap();
Expand All @@ -328,8 +328,8 @@ QPixmap BitmapFactoryInst::pixmapFromSvg(const QByteArray& contents, const QSize
return QPixmap();
}

QString w = QString::fromAscii("document.rootElement.width.baseVal.value");
QString h = QString::fromAscii("document.rootElement.height.baseVal.value");
QString w = QString::fromLatin1("document.rootElement.width.baseVal.value");
QString h = QString::fromLatin1("document.rootElement.height.baseVal.value");
double ww = frame->evaluateJavaScript(w).toDouble();
double hh = frame->evaluateJavaScript(h).toDouble();
if (ww == 0.0 || hh == 0.0)
Expand Down Expand Up @@ -361,7 +361,7 @@ QPixmap BitmapFactoryInst::pixmapFromSvg(const QByteArray& contents, const QSize
if (!frame) {
return QPixmap();
}
frame->setContent(contents, QString::fromAscii("image/svg+xml"));
frame->setContent(contents, QString::fromLatin1("image/svg+xml"));
// Important to exclude user events here because otherwise
// it may happen that an item the icon is created for gets
// deleted in the meantime. This happens e.g. dragging over
Expand Down
4 changes: 2 additions & 2 deletions src/Gui/CallTips.cpp
Expand Up @@ -321,7 +321,7 @@ void CallTipsList::extractTipsFromObject(Py::Object& obj, Py::List& list, QMap<Q
Py::Object attr = obj.getAttr(attrname.as_string());

CallTip tip;
QString str = QString::fromAscii(attrname.as_string().c_str());
QString str = QString::fromLatin1(attrname.as_string().c_str());
tip.name = str;

if (attr.isCallable()) {
Expand Down Expand Up @@ -387,7 +387,7 @@ void CallTipsList::extractTipsFromProperties(Py::Object& obj, QMap<QString, Call

for (std::map<std::string,App::Property*>::const_iterator It=Map.begin();It!=Map.end();++It) {
CallTip tip;
QString str = QString::fromAscii(It->first.c_str());
QString str = QString::fromLatin1(It->first.c_str());
tip.name = str;
tip.type = CallTip::Property;
QString longdoc = QString::fromUtf8(container->getPropertyDocumentation(It->second));
Expand Down
6 changes: 3 additions & 3 deletions src/Gui/Command.cpp
Expand Up @@ -676,7 +676,7 @@ Action * Command::createAction(void)
Action *pcAction;

pcAction = new Action(this,getMainWindow());
pcAction->setShortcut(QString::fromAscii(sAccel));
pcAction->setShortcut(QString::fromLatin1(sAccel));
applyCommandData(this->className(), pcAction);
if (sPixmap)
pcAction->setIcon(Gui::BitmapFactory().iconFromTheme(sPixmap));
Expand Down Expand Up @@ -751,7 +751,7 @@ Action * MacroCommand::createAction(void)
pcAction->setWhatsThis(QString::fromUtf8(sWhatsThis));
if (sPixmap)
pcAction->setIcon(Gui::BitmapFactory().pixmap(sPixmap));
pcAction->setShortcut(QString::fromAscii(sAccel));
pcAction->setShortcut(QString::fromLatin1(sAccel));

QString accel = pcAction->shortcut().toString(QKeySequence::NativeText);
if (!accel.isEmpty()) {
Expand Down Expand Up @@ -959,7 +959,7 @@ Action * PythonCommand::createAction(void)
Action *pcAction;

pcAction = new Action(this, qtAction, getMainWindow());
pcAction->setShortcut(QString::fromAscii(getAccel()));
pcAction->setShortcut(QString::fromLatin1(getAccel()));
applyCommandData(this->getName(), pcAction);
if (strcmp(getResource("Pixmap"),"") != 0)
pcAction->setIcon(Gui::BitmapFactory().iconFromTheme(getResource("Pixmap")));
Expand Down
6 changes: 3 additions & 3 deletions src/Gui/CommandDoc.cpp
Expand Up @@ -397,7 +397,7 @@ StdCmdNew::StdCmdNew()
void StdCmdNew::activated(int iMsg)
{
QString cmd;
cmd = QString::fromAscii("App.newDocument(\"%1\")")
cmd = QString::fromLatin1("App.newDocument(\"%1\")")
.arg(qApp->translate("StdCmdNew","Unnamed"));
doCommand(Command::Doc,(const char*)cmd.toUtf8());
}
Expand Down Expand Up @@ -752,7 +752,7 @@ Action * StdCmdUndo::createAction(void)
Action *pcAction;

pcAction = new UndoAction(this,getMainWindow());
pcAction->setShortcut(QString::fromAscii(sAccel));
pcAction->setShortcut(QString::fromLatin1(sAccel));
applyCommandData(this->className(), pcAction);
if (sPixmap)
pcAction->setIcon(Gui::BitmapFactory().iconFromTheme(sPixmap));
Expand Down Expand Up @@ -795,7 +795,7 @@ Action * StdCmdRedo::createAction(void)
Action *pcAction;

pcAction = new RedoAction(this,getMainWindow());
pcAction->setShortcut(QString::fromAscii(sAccel));
pcAction->setShortcut(QString::fromLatin1(sAccel));
applyCommandData(this->className(), pcAction);
if (sPixmap)
pcAction->setIcon(Gui::BitmapFactory().iconFromTheme(sPixmap));
Expand Down
4 changes: 2 additions & 2 deletions src/Gui/CommandStd.cpp
Expand Up @@ -124,7 +124,7 @@ Action * StdCmdWorkbench::createAction(void)
Action *pcAction;

pcAction = new WorkbenchGroup(this,getMainWindow());
pcAction->setShortcut(QString::fromAscii(sAccel));
pcAction->setShortcut(QString::fromLatin1(sAccel));
applyCommandData(this->className(), pcAction);
if (sPixmap)
pcAction->setIcon(Gui::BitmapFactory().iconFromTheme(sPixmap));
Expand Down Expand Up @@ -206,7 +206,7 @@ Action * StdCmdAbout::createAction(void)
QCoreApplication::CodecForTr).arg(exe));
pcAction->setWhatsThis(QLatin1String(sWhatsThis));
pcAction->setIcon(QApplication::windowIcon());
pcAction->setShortcut(QString::fromAscii(sAccel));
pcAction->setShortcut(QString::fromLatin1(sAccel));
//Prevent Qt from using AboutRole -- fixes issue #0001485
pcAction->setMenuRole(QAction::ApplicationSpecificRole);

Expand Down
4 changes: 2 additions & 2 deletions src/Gui/CommandTest.cpp
Expand Up @@ -69,8 +69,8 @@ Std_TestQM::Std_TestQM()
void Std_TestQM::activated(int iMsg)
{
QStringList files = QFileDialog::getOpenFileNames(getMainWindow(),
QString::fromAscii("Test translation"), QString(),
QString::fromAscii("Translation (*.qm)"));
QString::fromLatin1("Test translation"), QString(),
QString::fromLatin1("Translation (*.qm)"));
if (!files.empty()) {
Translator::instance()->activateLanguage("English");
QList<QTranslator*> i18n = qApp->findChildren<QTranslator*>();
Expand Down

0 comments on commit cd2db00

Please sign in to comment.