QString::toAscii() is obsolete in Qt5. Replace it with toLatin1().

This change is Qt4/Qt5 neutral.
This commit is contained in:
Mateusz Skowroński
2015-12-15 06:58:54 +01:00
committed by wmayer
parent e55ba2d24d
commit d5c074f80d
61 changed files with 191 additions and 191 deletions

View File

@@ -165,7 +165,7 @@ Gui::Action * CmdDrawingNewPage::createAction(void)
if (file.open(QFile::ReadOnly)) {
QString s = QString::fromAscii("style=\"font-size:22px\">%1%2</tspan></text>").arg(paper).arg(id);
QByteArray data = file.readAll();
data.replace("style=\"font-size:22px\">A0</tspan></text>", s.toAscii());
data.replace("style=\"font-size:22px\">A0</tspan></text>", s.toLatin1());
a->setIcon(Gui::BitmapFactory().pixmapFromSvg(data, QSize(64,64)));
}

View File

@@ -221,15 +221,15 @@ void VisualInspection::accept()
if (sel->checkState(0) == Qt::Checked) {
QString actualName = sel->data(0, Qt::UserRole).toString();
Gui::Application::Instance->runCommand(
true, "App_activeDocument___InspectionGroup.newObject(\"Inspection::Feature\",\"%s_Inspect\")", (const char*)actualName.toAscii());
true, "App_activeDocument___InspectionGroup.newObject(\"Inspection::Feature\",\"%s_Inspect\")", (const char*)actualName.toLatin1());
Gui::Application::Instance->runCommand(
true, "App.ActiveDocument.ActiveObject.Actual=App.ActiveDocument.%s\n"
"App_activeDocument___activeObject___Nominals=list()\n"
"App.ActiveDocument.ActiveObject.SearchRadius=%.3f\n"
"App.ActiveDocument.ActiveObject.Thickness=%.3f\n", (const char*)actualName.toAscii(), searchRadius, thickness);
"App.ActiveDocument.ActiveObject.Thickness=%.3f\n", (const char*)actualName.toLatin1(), searchRadius, thickness);
for (QStringList::Iterator it = nominalNames.begin(); it != nominalNames.end(); ++it) {
Gui::Application::Instance->runCommand(
true, "App_activeDocument___activeObject___Nominals.append(App.ActiveDocument.%s)\n", (const char*)(*it).toAscii());
true, "App_activeDocument___activeObject___Nominals.append(App.ActiveDocument.%s)\n", (const char*)(*it).toLatin1());
}
Gui::Application::Instance->runCommand(
true, "App.ActiveDocument.ActiveObject.Nominals=App_activeDocument___activeObject___Nominals\n"
@@ -249,7 +249,7 @@ void VisualInspection::accept()
if (sel->checkState(0) == Qt::Checked) {
Gui::Application::Instance->runCommand(
true, "Gui.ActiveDocument.getObject(\"%s\").Visibility=False"
, (const char*)sel->data(0, Qt::UserRole).toString().toAscii());
, (const char*)sel->data(0, Qt::UserRole).toString().toLatin1());
}
}
@@ -258,7 +258,7 @@ void VisualInspection::accept()
if (sel->checkState(0) == Qt::Checked) {
Gui::Application::Instance->runCommand(
true, "Gui.ActiveDocument.getObject(\"%s\").Visibility=False"
, (const char*)sel->data(0, Qt::UserRole).toString().toAscii());
, (const char*)sel->data(0, Qt::UserRole).toString().toLatin1());
}
}
}

View File

@@ -468,7 +468,7 @@ void CmdMeshExport::activated(int iMsg)
QObject::tr("Export mesh"), dir, filter.join(QLatin1String(";;")), &format);
if (!fn.isEmpty()) {
QFileInfo fi(fn);
QByteArray extension = fi.suffix().toAscii();
QByteArray extension = fi.suffix().toLatin1();
for (QList<QPair<QString, QByteArray> >::iterator it = ext.begin(); it != ext.end(); ++it) {
if (it->first == format) {
extension = it->second;

View File

@@ -202,7 +202,7 @@ void MeshGui::DlgRegularSolidImp::on_createSolidButton_clicked()
// Execute the Python block
QString solid = tr("Create %1").arg(comboBox1->currentText());
Gui::Application::Instance->activeDocument()->openCommand(solid.toUtf8());
Gui::Command::doCommand(Gui::Command::Doc, (const char*)cmd.toAscii());
Gui::Command::doCommand(Gui::Command::Doc, (const char*)cmd.toLatin1());
Gui::Application::Instance->activeDocument()->commitCommand();
Gui::Command::doCommand(Gui::Command::Doc, "App.activeDocument().recompute()");
Gui::Command::doCommand(Gui::Command::Gui, "Gui.SendMsgToActiveView(\"ViewFit\")");

View File

@@ -450,7 +450,7 @@ public:
QStringList lines = s.split(QLatin1String("\n"));
std::vector<std::string> text;
for (QStringList::Iterator it = lines.begin(); it != lines.end(); ++it)
text.push_back((const char*)it->toAscii());
text.push_back((const char*)it->toLatin1());
anno->LabelText.setValues(text);
std::stringstream str;
str << "Curvature info (" << group->Group.getSize() << ")";

View File

@@ -223,7 +223,7 @@ bool Tessellation::accept()
return false;
}
App::Document* activeDoc = App::GetApplication().getDocument((const char*)this->document.toAscii());
App::Document* activeDoc = App::GetApplication().getDocument((const char*)this->document.toLatin1());
if (!activeDoc) {
QMessageBox::critical(this, windowTitle(),
tr("No such document '%1'.").arg(this->document));

View File

@@ -820,8 +820,8 @@ void CmdPartImportCurveNet::activated(int iMsg)
if (!fn.isEmpty()) {
QFileInfo fi; fi.setFile(fn);
openCommand("Part Import Curve Net");
doCommand(Doc,"f = App.activeDocument().addObject(\"Part::CurveNet\",\"%s\")", (const char*)fi.baseName().toAscii());
doCommand(Doc,"f.FileName = \"%s\"",(const char*)fn.toAscii());
doCommand(Doc,"f = App.activeDocument().addObject(\"Part::CurveNet\",\"%s\")", (const char*)fi.baseName().toLatin1());
doCommand(Doc,"f.FileName = \"%s\"",(const char*)fn.toLatin1());
commitCommand();
updateActive();
}
@@ -896,7 +896,7 @@ void CmdPartMakeSolid::activated(int iMsg)
try {
if (!str.isEmpty())
doCommand(Doc, (const char*)str.toAscii());
doCommand(Doc, (const char*)str.toLatin1());
}
catch (const Base::Exception& e) {
Base::Console().Error("Cannot convert %s because %s.\n",
@@ -950,7 +950,7 @@ void CmdPartReverseShape::activated(int iMsg)
try {
if (!str.isEmpty())
doCommand(Doc, (const char*)str.toAscii());
doCommand(Doc, (const char*)str.toLatin1());
}
catch (const Base::Exception& e) {
Base::Console().Error("Cannot convert %s because %s.\n",

View File

@@ -244,13 +244,13 @@ void CrossSections::apply()
"wires=list()\n"
"shape=FreeCAD.getDocument(\"%1\").%2.Shape\n")
.arg(QLatin1String(doc->getName()))
.arg(QLatin1String((*it)->getNameInDocument())).toAscii());
.arg(QLatin1String((*it)->getNameInDocument())).toLatin1());
for (std::vector<double>::iterator jt = d.begin(); jt != d.end(); ++jt) {
app->runPythonCode(QString::fromAscii(
"for i in shape.slice(Base.Vector(%1,%2,%3),%4):\n"
" wires.append(i)\n"
).arg(a).arg(b).arg(c).arg(*jt).toAscii());
).arg(a).arg(b).arg(c).arg(*jt).toLatin1());
seq.next();
}
@@ -261,7 +261,7 @@ void CrossSections::apply()
"slice.purgeTouched()\n"
"del slice,comp,wires,shape")
.arg(QLatin1String(doc->getName()))
.arg(QLatin1String(s.c_str())).toAscii());
.arg(QLatin1String(s.c_str())).toLatin1());
seq.next();
}

View File

@@ -187,7 +187,7 @@ void DlgExtrusion::apply()
bool makeSolid = ui->makeSolid->isChecked();
// inspect geometry
App::DocumentObject* obj = activeDoc->getObject((const char*)shape.toAscii());
App::DocumentObject* obj = activeDoc->getObject((const char*)shape.toLatin1());
if (!obj || !obj->isDerivedFrom(Part::Feature::getClassTypeId())) continue;
Part::Feature* fea = static_cast<Part::Feature*>(obj);
const TopoDS_Shape& data = fea->Shape.getValue();
@@ -227,9 +227,9 @@ void DlgExtrusion::apply()
.arg(makeSolid ? QLatin1String("True") : QLatin1String("False"))
.arg(angle)
.arg(label);
Gui::Application::Instance->runPythonCode((const char*)code.toAscii());
QByteArray to = name.toAscii();
QByteArray from = shape.toAscii();
Gui::Application::Instance->runPythonCode((const char*)code.toLatin1());
QByteArray to = name.toLatin1();
QByteArray from = shape.toLatin1();
Gui::Command::copyVisual(to, "ShapeColor", from);
Gui::Command::copyVisual(to, "LineColor", from);
Gui::Command::copyVisual(to, "PointColor", from);

View File

@@ -413,7 +413,7 @@ void DlgFilletEdges::onSelectEdgesOfFace(const QString& subelement, int type)
Gui::SelectionChanges::MsgType msgType = Gui::SelectionChanges::MsgType(type);
if (msgType == Gui::SelectionChanges::AddSelection) {
Gui::Selection().addSelection(d->object->getDocument()->getName(),
d->object->getNameInDocument(), (const char*)name.toAscii());
d->object->getNameInDocument(), (const char*)name.toLatin1());
}
}
}
@@ -483,13 +483,13 @@ void DlgFilletEdges::toggleCheckState(const QModelIndex& index)
App::Document* doc = d->object->getDocument();
Gui::Selection().addSelection(doc->getName(),
d->object->getNameInDocument(),
(const char*)name.toAscii());
(const char*)name.toLatin1());
}
else {
App::Document* doc = d->object->getDocument();
Gui::Selection().rmvSelection(doc->getName(),
d->object->getNameInDocument(),
(const char*)name.toAscii());
(const char*)name.toLatin1());
}
this->blockConnection(block);
@@ -870,7 +870,7 @@ bool DlgFilletEdges::accept()
"del __fillets__\n"
"FreeCADGui.ActiveDocument.%2.Visibility = False\n")
.arg(name).arg(shape);
Gui::Application::Instance->runPythonCode((const char*)code.toAscii());
Gui::Application::Instance->runPythonCode((const char*)code.toLatin1());
activeDoc->commitTransaction();
activeDoc->recompute();
if (d->fillet) {
@@ -879,8 +879,8 @@ bool DlgFilletEdges::accept()
if (vp) vp->show();
}
QByteArray to = name.toAscii();
QByteArray from = shape.toAscii();
QByteArray to = name.toLatin1();
QByteArray from = shape.toLatin1();
Gui::Command::copyVisual(to, "LineColor", from);
Gui::Command::copyVisual(to, "PointColor", from);
return true;

View File

@@ -102,7 +102,7 @@ void Picker::createPrimitive(QWidget* widget, const QString& descr, Gui::Documen
// Execute the Python block
doc->openCommand(descr.toUtf8());
Gui::Command::doCommand(Gui::Command::Doc, (const char*)cmd.toAscii());
Gui::Command::doCommand(Gui::Command::Doc, (const char*)cmd.toLatin1());
doc->commitCommand();
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.recompute()");
Gui::Command::doCommand(Gui::Command::Gui, "Gui.SendMsgToActiveView(\"ViewFit\")");

View File

@@ -212,9 +212,9 @@ void DlgRevolution::accept()
.arg(ui->angle->value(),0,'f',2)
.arg(solid)
;
Gui::Application::Instance->runPythonCode((const char*)code.toAscii());
QByteArray to = name.toAscii();
QByteArray from = shape.toAscii();
Gui::Application::Instance->runPythonCode((const char*)code.toLatin1());
QByteArray to = name.toLatin1();
QByteArray from = shape.toLatin1();
Gui::Command::copyVisual(to, "ShapeColor", from);
Gui::Command::copyVisual(to, "LineColor", from);
Gui::Command::copyVisual(to, "PointColor", from);

View File

@@ -123,7 +123,7 @@ bool Mirroring::accept()
return false;
}
App::Document* activeDoc = App::GetApplication().getDocument((const char*)this->document.toAscii());
App::Document* activeDoc = App::GetApplication().getDocument((const char*)this->document.toLatin1());
if (!activeDoc) {
QMessageBox::critical(this, windowTitle(),
tr("No such document '%1'.").arg(this->document));
@@ -169,8 +169,8 @@ bool Mirroring::accept()
.arg(this->document).arg(shape).arg(label)
.arg(normx).arg(normy).arg(normz)
.arg(basex).arg(basey).arg(basez);
Gui::Application::Instance->runPythonCode((const char*)code.toAscii());
QByteArray from = shape.toAscii();
Gui::Application::Instance->runPythonCode((const char*)code.toLatin1());
QByteArray from = shape.toLatin1();
Gui::Command::copyVisual("ActiveObject", "ShapeColor", from);
Gui::Command::copyVisual("ActiveObject", "LineColor", from);
Gui::Command::copyVisual("ActiveObject", "PointColor", from);

View File

@@ -561,7 +561,7 @@ void TaskCheckGeometryResults::buildShapeContent(const QString &baseName, const
std::ostringstream stream;
if (!shapeContentString.empty())
stream << std::endl << std::endl;
stream << baseName.toAscii().data() << ":" << std::endl;
stream << baseName.toLatin1().data() << ":" << std::endl;
BRepTools_ShapeSet set;
set.Add(shape);
@@ -709,7 +709,7 @@ void TaskCheckGeometryResults::currentRowChanged (const QModelIndex &current, co
QString doc, object, sub;
if (!this->split((*stringIt), doc, object, sub))
continue;
Gui::Selection().addSelection(doc.toAscii(), object.toAscii(), sub.toAscii());
Gui::Selection().addSelection(doc.toLatin1(), object.toLatin1(), sub.toLatin1());
}
}
}

View File

@@ -175,7 +175,7 @@ bool LoftWidget::accept()
Gui::Document* doc = Gui::Application::Instance->getDocument(d->document.c_str());
if (!doc) throw Base::Exception("Document doesn't exist anymore");
doc->openCommand("Loft");
Gui::Application::Instance->runPythonCode((const char*)cmd.toAscii(), false, false);
Gui::Application::Instance->runPythonCode((const char*)cmd.toLatin1(), false, false);
doc->getDocument()->recompute();
App::DocumentObject* obj = doc->getDocument()->getActiveObject();
if (obj && !obj->isValid()) {

View File

@@ -201,7 +201,7 @@ void ShapeBuilderWidget::createEdgeFromVertex()
try {
Gui::Application::Instance->activeDocument()->openCommand("Edge");
Gui::Application::Instance->runPythonCode((const char*)cmd.toAscii(), false, false);
Gui::Application::Instance->runPythonCode((const char*)cmd.toLatin1(), false, false);
Gui::Application::Instance->activeDocument()->commitCommand();
}
catch (const Base::Exception&) {
@@ -253,7 +253,7 @@ void ShapeBuilderWidget::createFaceFromVertex()
try {
Gui::Application::Instance->activeDocument()->openCommand("Face");
Gui::Application::Instance->runPythonCode((const char*)cmd.toAscii(), false, false);
Gui::Application::Instance->runPythonCode((const char*)cmd.toLatin1(), false, false);
Gui::Application::Instance->activeDocument()->commitCommand();
}
catch (const Base::Exception&) {
@@ -305,7 +305,7 @@ void ShapeBuilderWidget::createFaceFromEdge()
try {
Gui::Application::Instance->activeDocument()->openCommand("Face");
Gui::Application::Instance->runPythonCode((const char*)cmd.toAscii(), false, false);
Gui::Application::Instance->runPythonCode((const char*)cmd.toLatin1(), false, false);
Gui::Application::Instance->activeDocument()->commitCommand();
}
catch (const Base::Exception&) {
@@ -358,7 +358,7 @@ void ShapeBuilderWidget::createShellFromFace()
try {
Gui::Application::Instance->activeDocument()->openCommand("Shell");
Gui::Application::Instance->runPythonCode((const char*)cmd.toAscii(), false, false);
Gui::Application::Instance->runPythonCode((const char*)cmd.toLatin1(), false, false);
Gui::Application::Instance->activeDocument()->commitCommand();
}
catch (const Base::Exception&) {
@@ -398,7 +398,7 @@ void ShapeBuilderWidget::createSolidFromShell()
try {
Gui::Application::Instance->activeDocument()->openCommand("Solid");
Gui::Application::Instance->runPythonCode((const char*)cmd.toAscii(), false, false);
Gui::Application::Instance->runPythonCode((const char*)cmd.toLatin1(), false, false);
Gui::Application::Instance->activeDocument()->commitCommand();
}
catch (const Base::Exception&) {

View File

@@ -321,7 +321,7 @@ bool SweepWidget::accept()
Gui::Document* doc = Gui::Application::Instance->getDocument(d->document.c_str());
if (!doc) throw Base::Exception("Document doesn't exist anymore");
doc->openCommand("Sweep");
Gui::Application::Instance->runPythonCode((const char*)cmd.toAscii(), false, false);
Gui::Application::Instance->runPythonCode((const char*)cmd.toLatin1(), false, false);
doc->getDocument()->recompute();
App::DocumentObject* obj = doc->getDocument()->getActiveObject();
if (obj && !obj->isValid()) {

View File

@@ -56,7 +56,7 @@ std::vector<App::DocumentObject*> FeaturePickDialog::getFeatures() {
std::vector<App::DocumentObject*> result;
for (std::vector<QString>::const_iterator s = features.begin(); s != features.end(); ++s)
result.push_back(App::GetApplication().getActiveDocument()->getObject(s->toAscii().data()));
result.push_back(App::GetApplication().getActiveDocument()->getObject(s->toLatin1().data()));
return result;
}

View File

@@ -270,7 +270,7 @@ void CmdRobotSetDefaultValues::activated(int iMsg)
QObject::tr("speed: (e.g. 1 m/s or 3 cm/s)"), QLineEdit::Normal,
QString::fromAscii("1 m/s"), &ok);
if ( ok && !text.isEmpty() ) {
doCommand(Doc,"_DefSpeed = '%s'",text.toAscii().constData());
doCommand(Doc,"_DefSpeed = '%s'",text.toLatin1().constData());
}
QStringList items;
@@ -279,7 +279,7 @@ void CmdRobotSetDefaultValues::activated(int iMsg)
QString item = QInputDialog::getItem(0, QObject::tr("set default continuity"),
QObject::tr("continuous ?"), items, 0, false, &ok);
if (ok && !item.isEmpty())
doCommand(Doc,"_DefCont = %s",item.toAscii().constData());
doCommand(Doc,"_DefCont = %s",item.toLatin1().constData());
text.clear();
@@ -287,7 +287,7 @@ void CmdRobotSetDefaultValues::activated(int iMsg)
QObject::tr("acceleration: (e.g. 1 m/s^2 or 3 cm/s^2)"), QLineEdit::Normal,
QString::fromAscii("1 m/s^2"), &ok);
if ( ok && !text.isEmpty() ) {
doCommand(Doc,"_DefAccelaration = '%s'",text.toAscii().constData());
doCommand(Doc,"_DefAccelaration = '%s'",text.toLatin1().constData());
}

View File

@@ -568,7 +568,7 @@ void DrawSketchHandler::renderSuggestConstraintsCursor(std::vector<AutoConstrain
}
if (!iconType.isEmpty()) {
QPixmap icon = Gui::BitmapFactory().pixmap(iconType.toAscii()).scaledToWidth(iconSize);
QPixmap icon = Gui::BitmapFactory().pixmap(iconType.toLatin1()).scaledToWidth(iconSize);
qp.drawPixmap(QPoint(baseIcon.width() + i * iconSize, baseIcon.height() - iconSize), icon);
}
}

View File

@@ -2817,7 +2817,7 @@ void ViewProviderSketch::drawMergedConstraintIcons(IconQueue iconQueue)
}
edit->combinedConstrBoxes[idString] = boundingBoxes;
thisInfo->string.setValue(idString.toAscii().data());
thisInfo->string.setValue(idString.toLatin1().data());
sendConstraintIconToCoin(compositeIcon, thisDest);
}
@@ -2835,7 +2835,7 @@ QImage ViewProviderSketch::renderConstrIcon(const QString &type,
// Constants to help create constraint icons
QString joinStr = QString::fromAscii(", ");
QImage icon = Gui::BitmapFactory().pixmap(type.toAscii()).toImage();
QImage icon = Gui::BitmapFactory().pixmap(type.toLatin1()).toImage();
QFont font = QApplication::font();
font.setPixelSize(11);
@@ -2918,7 +2918,7 @@ void ViewProviderSketch::drawTypicalConstraintIcon(const constrIconQueueItem &i)
QList<QColor>() << color,
i.iconRotation);
i.infoPtr->string.setValue(QString::number(i.constraintId).toAscii().data());
i.infoPtr->string.setValue(QString::number(i.constraintId).toLatin1().data());
sendConstraintIconToCoin(image, i.destination);
}

View File

@@ -116,7 +116,7 @@ Py::Object UnitTestDialogPy::getUnitTest(const Py::Tuple& args)
{
if (!PyArg_ParseTuple(args.ptr(), ""))
throw Py::Exception();
return Py::String((const char*)UnitTestDialog::instance()->getUnitTest().toAscii());
return Py::String((const char*)UnitTestDialog::instance()->getUnitTest().toLatin1());
}
Py::Object UnitTestDialogPy::setStatusText(const Py::Tuple& args)