Skip to content

Commit

Permalink
QString::fromAscii() is obsolete in Qt5. Replace it with fromLatin1().
Browse files Browse the repository at this point in the history
This change is Qt4/Qt5 neutral.
  • Loading branch information
f3nix authored and wwmayer committed Apr 15, 2016
1 parent 3df6064 commit b551992
Show file tree
Hide file tree
Showing 28 changed files with 104 additions and 104 deletions.
2 changes: 1 addition & 1 deletion src/Gui/DAGView/DAGFilter.cpp
Expand Up @@ -33,7 +33,7 @@
using namespace Gui;
using namespace DAG;

FilterBase::FilterBase() : name(QString::fromAscii("empty name")), enabled(true), type(Type::Exclusion)
FilterBase::FilterBase() : name(QString::fromLatin1("empty name")), enabled(true), type(Type::Exclusion)
{

}
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/DAGView/DAGModel.cpp
Expand Up @@ -856,7 +856,7 @@ void Model::updateStates()
else
(*theGraph)[currentVertex].stateIcon->setPixmap(pendingPixmap);
}
(*theGraph)[currentVertex].stateIcon->setToolTip(QString::fromAscii(record.DObject->getStatusString()));
(*theGraph)[currentVertex].stateIcon->setToolTip(QString::fromLatin1(record.DObject->getStatusString()));
(*theGraph)[currentVertex].lastFeatureState = currentFeatureState;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/MainWindow.cpp
Expand Up @@ -386,7 +386,7 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f)
{
DAG::DockWindow *dagDockWindow = new DAG::DockWindow(nullptr, this);
dagDockWindow->setObjectName
(QString::fromAscii(QT_TRANSLATE_NOOP("QDockWidget","DAG View")));
(QString::fromLatin1(QT_TRANSLATE_NOOP("QDockWidget","DAG View")));
pDockMgr->registerDockWindow("Std_DAGView", dagDockWindow);
}

Expand Down
6 changes: 3 additions & 3 deletions src/Gui/Selection.cpp
Expand Up @@ -493,9 +493,9 @@ bool SelectionSingleton::setPreselect(const char* pDocName, const char* pObjectN
}
msg.append(
QObject::tr(" %1.%2.%3 ")
.arg(QString::fromAscii(pDocName))
.arg(QString::fromAscii(pObjectName))
.arg(QString::fromAscii(pSubName))
.arg(QString::fromLatin1(pDocName))
.arg(QString::fromLatin1(pObjectName))
.arg(QString::fromLatin1(pSubName))
);

if (getMainWindow()) {
Expand Down
16 changes: 8 additions & 8 deletions src/Gui/ViewProviderDocumentObjectGroup.cpp
Expand Up @@ -203,21 +203,21 @@ void ViewProviderDocumentObjectGroup::drop(const std::vector<const App::Document
if (par) {
// allow an object to be in one group only
QString cmd;
cmd = QString::fromAscii("App.getDocument(\"%1\").getObject(\"%2\").removeObject("
cmd = QString::fromLatin1("App.getDocument(\"%1\").getObject(\"%2\").removeObject("
"App.getDocument(\"%1\").getObject(\"%3\"))")
.arg(QString::fromAscii(doc->getName()))
.arg(QString::fromAscii(par->getNameInDocument()))
.arg(QString::fromAscii(obj->getNameInDocument()));
.arg(QString::fromLatin1(doc->getName()))
.arg(QString::fromLatin1(par->getNameInDocument()))
.arg(QString::fromLatin1(obj->getNameInDocument()));
Gui::Application::Instance->runPythonCode(cmd.toUtf8());
}

// build Python command for execution
QString cmd;
cmd = QString::fromAscii("App.getDocument(\"%1\").getObject(\"%2\").addObject("
cmd = QString::fromLatin1("App.getDocument(\"%1\").getObject(\"%2\").addObject("
"App.getDocument(\"%1\").getObject(\"%3\"))")
.arg(QString::fromAscii(doc->getName()))
.arg(QString::fromAscii(grp->getNameInDocument()))
.arg(QString::fromAscii(obj->getNameInDocument()));
.arg(QString::fromLatin1(doc->getName()))
.arg(QString::fromLatin1(grp->getNameInDocument()))
.arg(QString::fromLatin1(obj->getNameInDocument()));

Gui::Application::Instance->runPythonCode(cmd.toUtf8());
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/PartDesign/Gui/CommandBody.cpp
Expand Up @@ -635,7 +635,7 @@ void CmdPartDesignMoveFeature::activated(int iMsg)
} catch (Base::Exception &) {
QMessageBox::warning( Gui::getMainWindow(), QObject::tr("Sketch plane cannot be migrated"),
QObject::tr("Please edit '%1' and redefine it to use a Base or Datum plane as the sketch plane.").
arg( QString::fromAscii( sketch->Label.getValue () ) ) );
arg( QString::fromLatin1( sketch->Label.getValue () ) ) );
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Mod/PartDesign/Gui/ReferenceSelection.cpp
Expand Up @@ -231,13 +231,13 @@ void getReferencedSelection(const App::DocumentObject* thisObj, const Gui::Selec
QString getRefStr(const App::DocumentObject* obj, const std::vector<std::string>& sub)
{
if (obj == NULL)
return QString::fromAscii("");
return QString::fromLatin1("");

if (PartDesign::Feature::isDatum(obj))
return QString::fromAscii(obj->getNameInDocument());
return QString::fromLatin1(obj->getNameInDocument());
else if (sub.size()>0)
return QString::fromAscii(obj->getNameInDocument()) + QString::fromAscii(":") +
QString::fromAscii(sub.front().c_str());
return QString::fromLatin1(obj->getNameInDocument()) + QString::fromLatin1(":") +
QString::fromLatin1(sub.front().c_str());
else
return QString();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/PartDesign/Gui/TaskBooleanParameters.cpp
Expand Up @@ -74,7 +74,7 @@ TaskBooleanParameters::TaskBooleanParameters(ViewProviderBoolean *BooleanView,QW
std::vector<App::DocumentObject*> bodies = pcBoolean->Bodies.getValues();
for (std::vector<App::DocumentObject*>::const_iterator b = bodies.begin(); b != bodies.end(); b++)
{
ui->listWidgetBodies->insertItem(0, QString::fromAscii((*b)->getNameInDocument()));
ui->listWidgetBodies->insertItem(0, QString::fromLatin1((*b)->getNameInDocument()));
}
// Create context menu
QAction* action = new QAction(tr("Remove"), this);
Expand Down Expand Up @@ -331,7 +331,7 @@ bool TaskDlgBooleanParameters::accept()
Gui::Command::doCommand(Gui::Command::Doc,str.str().c_str());
}
catch (const Base::Exception& e) {
QMessageBox::warning(parameter, tr("Boolean: Accept: Input error"), QString::fromAscii(e.what()));
QMessageBox::warning(parameter, tr("Boolean: Accept: Input error"), QString::fromLatin1(e.what()));
return false;
}

Expand Down
32 changes: 16 additions & 16 deletions src/Mod/PartDesign/Gui/TaskDatumParameters.cpp
Expand Up @@ -72,21 +72,21 @@ const QString makeRefString(const App::DocumentObject* obj, const std::string& s
if (obj->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId()) ||
obj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId()))
// App::Plane, Liine or Datum feature
return QString::fromAscii(obj->getNameInDocument());
return QString::fromLatin1(obj->getNameInDocument());

if ((sub.size() > 4) && (sub.substr(0,4) == "Face")) {
int subId = std::atoi(&sub[4]);
return QString::fromAscii(obj->getNameInDocument()) + QString::fromAscii(":") + QObject::tr("Face") + QString::number(subId);
return QString::fromLatin1(obj->getNameInDocument()) + QString::fromLatin1(":") + QObject::tr("Face") + QString::number(subId);
} else if ((sub.size() > 4) && (sub.substr(0,4) == "Edge")) {
int subId = std::atoi(&sub[4]);
return QString::fromAscii(obj->getNameInDocument()) + QString::fromAscii(":") + QObject::tr("Edge") + QString::number(subId);
return QString::fromLatin1(obj->getNameInDocument()) + QString::fromLatin1(":") + QObject::tr("Edge") + QString::number(subId);
} else if ((sub.size() > 6) && (sub.substr(0,6) == "Vertex")) {
int subId = std::atoi(&sub[6]);
return QString::fromAscii(obj->getNameInDocument()) + QString::fromAscii(":") + QObject::tr("Vertex") + QString::number(subId);
return QString::fromLatin1(obj->getNameInDocument()) + QString::fromLatin1(":") + QObject::tr("Vertex") + QString::number(subId);
} else {
//something else that face/edge/vertex. Can be empty string.
return QString::fromAscii(obj->getNameInDocument())
+ (sub.length()>0 ? QString::fromAscii(":") : QString())
return QString::fromLatin1(obj->getNameInDocument())
+ (sub.length()>0 ? QString::fromLatin1(":") : QString())
+ QString::fromLatin1(sub.c_str());
}
}
Expand All @@ -107,7 +107,7 @@ void TaskDatumParameters::makeRefStrings(std::vector<QString>& refstrings, std::
}

TaskDatumParameters::TaskDatumParameters(ViewProviderDatum *DatumView,QWidget *parent)
: TaskBox(Gui::BitmapFactory().pixmap((QString::fromAscii("PartDesign_") + DatumView->datumType).toLatin1()),
: TaskBox(Gui::BitmapFactory().pixmap((QString::fromLatin1("PartDesign_") + DatumView->datumType).toLatin1()),
DatumView->datumType + tr(" parameters"), true, parent),
DatumView(DatumView)
{
Expand Down Expand Up @@ -276,7 +276,7 @@ const QString makeHintText(std::set<eRefType> hint)
for (std::set<eRefType>::const_iterator t = hint.begin(); t != hint.end(); t++) {
QString tText;
tText = getShTypeText(*t);
result += QString::fromAscii(result.size() == 0 ? "" : "/") + tText;
result += QString::fromLatin1(result.size() == 0 ? "" : "/") + tText;
}

return result;
Expand All @@ -288,9 +288,9 @@ void TaskDatumParameters::updateUI(std::string message, bool error)
if(!message.empty()) {
ui->message->setText(QString::fromStdString(message));
if(error)
ui->message->setStyleSheet(QString::fromAscii("QLabel{color: red;}"));
ui->message->setStyleSheet(QString::fromLatin1("QLabel{color: red;}"));
else
ui->message->setStyleSheet(QString::fromAscii("QLabel{color: green;}"));
ui->message->setStyleSheet(QString::fromLatin1("QLabel{color: green;}"));
}

ui->checkBoxFlip->setVisible(false);
Expand Down Expand Up @@ -593,9 +593,9 @@ void TaskDatumParameters::onRefName(const QString& text, unsigned idx)
return;
}

QStringList parts = text.split(QChar::fromAscii(':'));
QStringList parts = text.split(QChar::fromLatin1(':'));
if (parts.length() < 2)
parts.push_back(QString::fromAscii(""));
parts.push_back(QString::fromLatin1(""));
// Check whether this is the name of an App::Plane or Part::Datum feature
App::DocumentObject* obj = DatumView->getObject()->getDocument()->getObject(parts[0].toLatin1());
if (obj == NULL) return;
Expand All @@ -617,17 +617,17 @@ void TaskDatumParameters::onRefName(const QString& text, unsigned idx)
QRegExp rx;
std::stringstream ss;

rx.setPattern(QString::fromAscii("^") + tr("Face") + QString::fromAscii("(\\d+)$"));
rx.setPattern(QString::fromLatin1("^") + tr("Face") + QString::fromLatin1("(\\d+)$"));
if (parts[1].indexOf(rx) >= 0) {
int faceId = rx.cap(1).toInt();
ss << "Face" << faceId;
} else {
rx.setPattern(QString::fromAscii("^") + tr("Edge") + QString::fromAscii("(\\d+)$"));
rx.setPattern(QString::fromLatin1("^") + tr("Edge") + QString::fromLatin1("(\\d+)$"));
if (parts[1].indexOf(rx) >= 0) {
int lineId = rx.cap(1).toInt();
ss << "Edge" << lineId;
} else {
rx.setPattern(QString::fromAscii("^") + tr("Vertex") + QString::fromAscii("(\\d+)$"));
rx.setPattern(QString::fromLatin1("^") + tr("Vertex") + QString::fromLatin1("(\\d+)$"));
if (parts[1].indexOf(rx) >= 0) {
int vertexId = rx.cap(1).toInt();
ss << "Vertex" << vertexId;
Expand Down Expand Up @@ -957,7 +957,7 @@ bool TaskDlgDatumParameters::accept()
}
}
catch (const Base::Exception& e) {
QMessageBox::warning(parameter, tr("Datum dialog: Input error"), QString::fromAscii(e.what()));
QMessageBox::warning(parameter, tr("Datum dialog: Input error"), QString::fromLatin1(e.what()));
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Mod/PartDesign/Gui/TaskDraftParameters.cpp
Expand Up @@ -195,7 +195,7 @@ void TaskDraftParameters::onRefDeleted(void)
void TaskDraftParameters::getPlane(App::DocumentObject*& obj, std::vector<std::string>& sub) const
{
sub = std::vector<std::string>(1,"");
QStringList parts = ui->linePlane->text().split(QChar::fromAscii(':'));
QStringList parts = ui->linePlane->text().split(QChar::fromLatin1(':'));
obj = DressUpView->getObject()->getDocument()->getObject(parts[0].toStdString().c_str());
if (parts.size() > 1)
sub[0] = parts[1].toStdString();
Expand All @@ -204,7 +204,7 @@ void TaskDraftParameters::getPlane(App::DocumentObject*& obj, std::vector<std::s
void TaskDraftParameters::getLine(App::DocumentObject*& obj, std::vector<std::string>& sub) const
{
sub = std::vector<std::string>(1,"");
QStringList parts = ui->lineLine->text().split(QChar::fromAscii(':'));
QStringList parts = ui->lineLine->text().split(QChar::fromLatin1(':'));
obj = DressUpView->getObject()->getDocument()->getObject(parts[0].toStdString().c_str());
if (parts.size() > 1)
sub[0] = parts[1].toStdString();
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp
Expand Up @@ -49,7 +49,7 @@ using namespace Gui;

TaskDressUpParameters::TaskDressUpParameters(ViewProviderDressUp *DressUpView, bool selectEdges, bool selectFaces, QWidget *parent)
: TaskBox(Gui::BitmapFactory().pixmap((std::string("PartDesign_") + DressUpView->featureName()).c_str()),
QString::fromAscii((DressUpView->featureName() + " parameters").c_str()),
QString::fromLatin1((DressUpView->featureName() + " parameters").c_str()),
true,
parent),
DressUpView(DressUpView), allowFaces(selectFaces), allowEdges(selectEdges)
Expand Down Expand Up @@ -138,7 +138,7 @@ const std::vector<std::string> TaskDressUpParameters::getReferences() const
// TODO: This code is identical with TaskTransformedParameters::removeItemFromListWidget()
void TaskDressUpParameters::removeItemFromListWidget(QListWidget* widget, const char* itemstr)
{
QList<QListWidgetItem*> items = widget->findItems(QString::fromAscii(itemstr), Qt::MatchExactly);
QList<QListWidgetItem*> items = widget->findItems(QString::fromLatin1(itemstr), Qt::MatchExactly);
if (!items.empty()) {
for (QList<QListWidgetItem*>::const_iterator i = items.begin(); i != items.end(); i++) {
QListWidgetItem* it = widget->takeItem(widget->row(*i));
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/PartDesign/Gui/TaskFeatureParameters.cpp
Expand Up @@ -111,7 +111,7 @@ bool TaskDlgFeatureParameters::accept() {
Gui::Command::commitCommand();
} catch (const Base::Exception& e) {
// Generally the only thing that should fail is feature->isValid() others should be fine
QMessageBox::warning( 0, tr("Input error"), QString::fromAscii(e.what()));
QMessageBox::warning( 0, tr("Input error"), QString::fromLatin1(e.what()));
return false;
}

Expand Down
14 changes: 7 additions & 7 deletions src/Mod/PartDesign/Gui/TaskFeaturePick.cpp
Expand Up @@ -77,7 +77,7 @@ TaskFeaturePick::TaskFeaturePick(std::vector<App::DocumentObject*>& objects,
const std::vector<featureStatus>& status,
QWidget* parent)
: TaskBox(Gui::BitmapFactory().pixmap("edit-select-box"),
QString::fromAscii("Select feature"), true, parent), ui(new Ui_TaskFeaturePick)
QString::fromLatin1("Select feature"), true, parent), ui(new Ui_TaskFeaturePick)
{

proxy = new QWidget(this);
Expand All @@ -100,8 +100,8 @@ TaskFeaturePick::TaskFeaturePick(std::vector<App::DocumentObject*>& objects,
assert(status.size() == objects.size());
for (; statusIt != status.end(); ++statusIt, ++objIt) {
QListWidgetItem* item = new QListWidgetItem(
QString::fromAscii((*objIt)->getNameInDocument()) +
QString::fromAscii(" (") + getFeatureStatusString(*statusIt) + QString::fromAscii(")") );
QString::fromLatin1((*objIt)->getNameInDocument()) +
QString::fromLatin1(" (") + getFeatureStatusString(*statusIt) + QString::fromLatin1(")") );
ui->listWidget->addItem(item);

//check if we need to set any origin in temporary visibility mode
Expand Down Expand Up @@ -191,7 +191,7 @@ std::vector<App::DocumentObject*> TaskFeaturePick::getFeatures() {
continue;

QString t = item->text();
t = t.left(t.indexOf(QString::fromAscii("(")) - 1);
t = t.left(t.indexOf(QString::fromLatin1("(")) - 1);
features.push_back(t);
}

Expand All @@ -216,7 +216,7 @@ std::vector<App::DocumentObject*> TaskFeaturePick::buildFeatures() {
if(item->isSelected() && !item->isHidden()) {

QString t = item->text();
t = t.left(t.indexOf(QString::fromAscii("(")) - 1);
t = t.left(t.indexOf(QString::fromLatin1("(")) - 1);
auto obj = App::GetApplication().getActiveDocument()->getObject(t.toLatin1().data());

//build the dependend copy or reference if wanted by the user
Expand Down Expand Up @@ -389,8 +389,8 @@ void TaskFeaturePick::onSelectionChanged(const Gui::SelectionChanges& msg)

QListWidgetItem *item = ui->listWidget->item(row);
QString t = item->text();
t = t.left(t.indexOf(QString::fromAscii("(")) - 1);
if(t.compare(QString::fromAscii(obj.FeatName))==0) {
t = t.left(t.indexOf(QString::fromLatin1("(")) - 1);
if(t.compare(QString::fromLatin1(obj.FeatName))==0) {
ui->listWidget->setItemSelected(item, true);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/PartDesign/Gui/TaskLinearPatternParameters.cpp
Expand Up @@ -296,7 +296,7 @@ void TaskLinearPatternParameters::onDirectionChanged(int num) {
pcLinearPattern->Direction.Paste(dirLinks.getCurrentLink());
}
} catch (Base::Exception &e) {
QMessageBox::warning(0,tr("Error"),QString::fromAscii(e.what()));
QMessageBox::warning(0,tr("Error"),QString::fromLatin1(e.what()));
}

kickUpdateViewTimer();
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/PartDesign/Gui/TaskLoftParameters.cpp
Expand Up @@ -205,7 +205,7 @@ void TaskLoftParameters::changeEvent(QEvent *e)
ui->changeMode->addItem(tr("Two dimensions"));
ui->changeMode->setCurrentIndex(index);
QStringList parts = ui->lineFaceName->text().split(QChar::fromAscii(':'));
QStringList parts = ui->lineFaceName->text().split(QChar::fromLatin1(':'));
QByteArray upToFace = ui->lineFaceName->property("FaceName").toByteArray();
int faceId = -1;
bool ok = false;
Expand All @@ -216,7 +216,7 @@ void TaskLoftParameters::changeEvent(QEvent *e)
ui->lineFaceName->setPlaceholderText(tr("No face selected"));
#endif
ui->lineFaceName->setText(ok ?
parts[0] + QString::fromAscii(":") + tr("Face") + QString::number(faceId) :
parts[0] + QString::fromLatin1(":") + tr("Face") + QString::number(faceId) :
tr("No face selected"));
ui->spinOffset->blockSignals(false);
ui->lengthEdit->blockSignals(false);
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/PartDesign/Gui/TaskMirroredParameters.cpp
Expand Up @@ -223,7 +223,7 @@ void TaskMirroredParameters::onPlaneChanged(int num) {
pcMirrored->MirrorPlane.Paste(planeLinks.getCurrentLink());
}
} catch (Base::Exception &e) {
QMessageBox::warning(0,tr("Error"),QString::fromAscii(e.what()));
QMessageBox::warning(0,tr("Error"),QString::fromLatin1(e.what()));
}

recomputeFeature();
Expand Down

0 comments on commit b551992

Please sign in to comment.