Gui: use emplace_back

This commit is contained in:
berniev
2022-08-05 16:06:02 +10:00
committed by wwmayer
parent e7357c1a99
commit 6ac4d8392e
19 changed files with 52 additions and 52 deletions

View File

@@ -2438,7 +2438,7 @@ App::Document *Application::reopen(App::Document *doc) {
for(auto d : doc->getDependentDocuments(true)) {
if(d->testStatus(App::Document::PartialDoc)
|| d->testStatus(App::Document::PartialRestore) )
docs.push_back(d->FileName.getValue());
docs.emplace_back(d->FileName.getValue());
}
if(docs.empty()) {

View File

@@ -106,12 +106,12 @@ PyObject* CommandPy::listByShortcut(PyObject *args)
}
if (re.indexIn(action->shortcut().toString().remove(spc).toUpper()) != -1) {
matches.push_back(c->getName());
matches.emplace_back(c->getName());
}
}
else if (action->shortcut().toString().remove(spc).toUpper() ==
QString::fromLatin1(shortcut_to_find).remove(spc).toUpper()) {
matches.push_back(c->getName());
matches.emplace_back(c->getName());
}
}
}

View File

@@ -205,7 +205,7 @@ void DlgPreferencesImp::addPage(const std::string& className, const std::string&
// This is a new group: create it, with its one page
std::list<std::string> pages;
pages.push_back(className);
_pages.push_back(std::make_pair(group, pages));
_pages.emplace_back(group, pages);
}
if (DlgPreferencesImp::_activeDialog) {

View File

@@ -1188,7 +1188,7 @@ void MainWindow::processMessages(const QList<QByteArray> & msg)
QByteArray action("OpenFile:");
for (QList<QByteArray>::const_iterator it = msg.begin(); it != msg.end(); ++it) {
if (it->startsWith(action))
files.push_back(std::string(it->mid(action.size()).constData()));
files.emplace_back(it->mid(action.size()).constData());
}
files = App::Application::processFiles(files);
for (std::list<std::string>::iterator it = files.begin(); it != files.end(); ++it) {

View File

@@ -617,17 +617,17 @@ void NaviCubeImplementation::addFace(float gap, const Vector3f& x, const Vector3
int t = m_VertexArray.size();
m_VertexArray.push_back(z - x - y);
m_VertexArray2.push_back(z - x2 - y2);
m_VertexArray.emplace_back(z - x - y);
m_VertexArray2.emplace_back(z - x2 - y2);
m_TextureCoordArray.emplace_back(0, 0);
m_VertexArray.push_back(z + x - y);
m_VertexArray2.push_back(z + x2 - y2);
m_VertexArray.emplace_back(z + x - y);
m_VertexArray2.emplace_back(z + x2 - y2);
m_TextureCoordArray.emplace_back(1, 0);
m_VertexArray.push_back(z + x + y);
m_VertexArray2.push_back(z + x2 + y2);
m_VertexArray.emplace_back(z + x + y);
m_VertexArray2.emplace_back(z + x2 + y2);
m_TextureCoordArray.emplace_back(1, 1);
m_VertexArray.push_back(z - x + y);
m_VertexArray2.push_back(z - x2 + y2);
m_VertexArray.emplace_back(z - x + y);
m_VertexArray2.emplace_back(z - x2 + y2);
m_TextureCoordArray.emplace_back(0, 1);
// TEX_TOP, TEX_FRONT_FACE, TEX_TOP
@@ -1790,11 +1790,11 @@ QMenu* NaviCubeImplementation::createNaviCubeMenu() {
vector<string> commands = NaviCubeImplementation::m_commands;
if (commands.empty()) {
commands.push_back("ViewOrthographicCmd");
commands.push_back("ViewPerspectiveCmd");
commands.push_back("ViewIsometricCmd");
commands.push_back("Separator");
commands.push_back("ViewZoomToFit");
commands.emplace_back("ViewOrthographicCmd");
commands.emplace_back("ViewPerspectiveCmd");
commands.emplace_back("ViewIsometricCmd");
commands.emplace_back("Separator");
commands.emplace_back("ViewZoomToFit");
}
for (vector<string>::iterator i = commands.begin(); i != commands.end(); ++i) {

View File

@@ -62,14 +62,14 @@ PyObject* PythonWorkbenchPy::appendMenu(PyObject *args)
PyObject* item = PyList_GetItem(pPath, j);
if (PyUnicode_Check(item)) {
const char* pItem = PyUnicode_AsUTF8(item);
path.push_back(pItem);
path.emplace_back(pItem);
} else {
continue;
}
}
} else if (PyUnicode_Check(pPath)) {
const char* pItem = PyUnicode_AsUTF8(pPath);
path.push_back(pItem);
path.emplace_back(pItem);
} else {
PyErr_SetString(PyExc_AssertionError, "Expected either a string or a stringlist as first argument");
return nullptr;
@@ -83,14 +83,14 @@ PyObject* PythonWorkbenchPy::appendMenu(PyObject *args)
PyObject* item = PyList_GetItem(pItems, i);
if (PyUnicode_Check(item)) {
const char* pItem = PyUnicode_AsUTF8(item);
items.push_back(pItem);
items.emplace_back(pItem);
} else {
continue;
}
}
} else if (PyUnicode_Check(pItems)) {
const char* pItem = PyUnicode_AsUTF8(pItems);
items.push_back(pItem);
items.emplace_back(pItem);
} else {
PyErr_SetString(PyExc_AssertionError, "Expected either a string or a stringlist as first argument");
return nullptr;
@@ -132,14 +132,14 @@ PyObject* PythonWorkbenchPy::appendContextMenu(PyObject *args)
PyObject* item = PyList_GetItem(pPath, j);
if (PyUnicode_Check(item)) {
const char* pItem = PyUnicode_AsUTF8(item);
path.push_back(pItem);
path.emplace_back(pItem);
} else {
continue;
}
}
} else if (PyUnicode_Check(pPath)) {
const char* pItem = PyUnicode_AsUTF8(pPath);
path.push_back(pItem);
path.emplace_back(pItem);
} else {
PyErr_SetString(PyExc_AssertionError, "Expected either a string or a stringlist as first argument");
return nullptr;
@@ -153,14 +153,14 @@ PyObject* PythonWorkbenchPy::appendContextMenu(PyObject *args)
PyObject* item = PyList_GetItem(pItems, i);
if (PyUnicode_Check(item)) {
const char* pItem = PyUnicode_AsUTF8(item);
items.push_back(pItem);
items.emplace_back(pItem);
} else {
continue;
}
}
} else if (PyUnicode_Check(pItems)) {
const char* pItem = PyUnicode_AsUTF8(pItems);
items.push_back(pItem);
items.emplace_back(pItem);
} else {
PyErr_SetString(PyExc_AssertionError, "Expected either a string or a stringlist as first argument");
return nullptr;
@@ -204,7 +204,7 @@ PyObject* PythonWorkbenchPy::appendToolbar(PyObject *args)
PyObject* item = PyList_GetItem(pObject, i);
if (PyUnicode_Check(item)) {
const char* pItem = PyUnicode_AsUTF8(item);
items.push_back(pItem);
items.emplace_back(pItem);
} else {
continue;
}
@@ -247,7 +247,7 @@ PyObject* PythonWorkbenchPy::appendCommandbar(PyObject *args)
PyObject* item = PyList_GetItem(pObject, i);
if (PyUnicode_Check(item)) {
const char* pItem = PyUnicode_AsUTF8(item);
items.push_back(pItem);
items.emplace_back(pItem);
} else {
continue;
}

View File

@@ -536,7 +536,7 @@ std::vector<SelectionObject> SelectionSingleton::getObjectList(const char* pDocN
if (subelement && *subelement) {
if (resolve != ResolveMode::NoResolve && !temp[it->second]._SubNameSet.insert(subelement).second)
continue;
temp[it->second].SubNames.push_back(subelement);
temp[it->second].SubNames.emplace_back(subelement);
temp[it->second].SelPoses.emplace_back(sel.x,sel.y,sel.z);
}
}
@@ -548,7 +548,7 @@ std::vector<SelectionObject> SelectionSingleton::getObjectList(const char* pDocN
// create a new entry
temp.emplace_back(obj);
if (subelement && *subelement) {
temp.back().SubNames.push_back(subelement);
temp.back().SubNames.emplace_back(subelement);
temp.back().SelPoses.emplace_back(sel.x,sel.y,sel.z);
if (resolve != ResolveMode::NoResolve)
temp.back()._SubNameSet.insert(subelement);

View File

@@ -50,7 +50,7 @@ SelectionObject::SelectionObject(const Gui::SelectionChanges& msg)
DocName = msg.pDocName ? msg.pDocName : "";
TypeName = msg.pTypeName ? msg.pTypeName : "";
if (msg.pSubName) {
SubNames.push_back(msg.pSubName);
SubNames.emplace_back(msg.pSubName);
SelPoses.emplace_back(msg.x, msg.y, msg.z);
}
}

View File

@@ -4308,7 +4308,7 @@ DocumentObjectItem* DocumentItem::findItem(
if (select) {
item->selected += 2;
if (std::find(item->mySubs.begin(), item->mySubs.end(), subname) == item->mySubs.end())
item->mySubs.push_back(subname);
item->mySubs.emplace_back(subname);
}
return item;
}
@@ -4322,7 +4322,7 @@ DocumentObjectItem* DocumentItem::findItem(
if (select) {
item->selected += 2;
if (std::find(item->mySubs.begin(), item->mySubs.end(), subname) == item->mySubs.end())
item->mySubs.push_back(subname);
item->mySubs.emplace_back(subname);
}
return item;
}
@@ -4367,7 +4367,7 @@ DocumentObjectItem* DocumentItem::findItem(
TREE_TRACE("element " << subname << " not found");
item->selected += 2;
if (std::find(item->mySubs.begin(), item->mySubs.end(), subname) == item->mySubs.end())
item->mySubs.push_back(subname);
item->mySubs.emplace_back(subname);
}
return res;
}

View File

@@ -167,8 +167,8 @@ std::vector<std::string> ViewProviderAnnotation::getDisplayModes(void) const
{
// add modes
std::vector<std::string> StrList;
StrList.push_back("Screen");
StrList.push_back("World");
StrList.emplace_back("Screen");
StrList.emplace_back("World");
return StrList;
}
@@ -337,8 +337,8 @@ std::vector<std::string> ViewProviderAnnotationLabel::getDisplayModes(void) cons
{
// add modes
std::vector<std::string> StrList;
StrList.push_back("Line");
StrList.push_back("Object");
StrList.emplace_back("Line");
StrList.emplace_back("Object");
return StrList;
}

View File

@@ -339,7 +339,7 @@ void ViewProviderDocumentObject::attach(App::DocumentObject *pcObj)
aDisplayModesArray = this->getDisplayModes();
if (aDisplayModesArray.empty())
aDisplayModesArray.push_back("");
aDisplayModesArray.emplace_back("");
// We must collect the const char* of the strings and give it to PropertyEnumeration,
// but we are still responsible for them, i.e. the property class must not delete the literals.

View File

@@ -97,7 +97,7 @@ void ViewProviderExtern::setModeBySoInput(const char* name, SoInput &ivFileInput
::iterator,string>(modes.begin(),modes.end(),string(name));
if (pos == modes.end()) {
// new mode
modes.push_back(name);
modes.emplace_back(name);
addDisplayMaskMode(root, name);
setDisplayMaskMode(name);
}

View File

@@ -135,7 +135,7 @@ std::vector<std::string> ViewProviderGeoFeatureGroupExtension::extensionGetDispl
std::vector<std::string> StrList = ViewProviderGroupExtension::extensionGetDisplayModes();
// add your own modes
StrList.push_back("Group");
StrList.emplace_back("Group");
return StrList;
}

View File

@@ -80,9 +80,9 @@ void ViewProviderInventorObject::setDisplayMode(const char* ModeName)
std::vector<std::string> ViewProviderInventorObject::getDisplayModes(void) const
{
std::vector<std::string> StrList;
StrList.push_back("File+Buffer");
StrList.push_back("Buffer");
StrList.push_back("File");
StrList.emplace_back("File+Buffer");
StrList.emplace_back("Buffer");
StrList.emplace_back("File");
return StrList;
}

View File

@@ -1675,8 +1675,8 @@ void ViewProviderLink::reattach(App::DocumentObject *obj) {
std::vector<std::string> ViewProviderLink::getDisplayModes(void) const
{
std::vector<std::string> StrList = inherited::getDisplayModes();
StrList.push_back("Link");
StrList.push_back("ChildView");
StrList.emplace_back("Link");
StrList.emplace_back("ChildView");
return StrList;
}

View File

@@ -145,7 +145,7 @@ std::vector<std::string> ViewProviderMeasureDistance::getDisplayModes(void) cons
{
// add modes
std::vector<std::string> StrList;
StrList.push_back("Base");
StrList.emplace_back("Base");
return StrList;
}

View File

@@ -160,7 +160,7 @@ std::vector<std::string> ViewProviderOriginFeature::getDisplayModes () const
{
// add modes
std::vector<std::string> StrList;
StrList.push_back("Base");
StrList.emplace_back("Base");
return StrList;
}

View File

@@ -67,7 +67,7 @@ std::vector<std::string> ViewProviderPlacement::getDisplayModes(void) const
{
// add modes
std::vector<std::string> StrList;
StrList.push_back("Base");
StrList.emplace_back("Base");
return StrList;
}

View File

@@ -89,7 +89,7 @@ void ViewProviderVRMLObject::setDisplayMode(const char* ModeName)
std::vector<std::string> ViewProviderVRMLObject::getDisplayModes(void) const
{
std::vector<std::string> StrList;
StrList.push_back("VRML");
StrList.emplace_back("VRML");
return StrList;
}
@@ -165,7 +165,7 @@ void ViewProviderVRMLObject::addResource(const SbString& url, std::list<std::str
if (fi.exists()) {
// add the resource file if not yet listed
if (std::find(resources.begin(), resources.end(), found.getString()) == resources.end()) {
resources.push_back(found.getString());
resources.emplace_back(found.getString());
}
}
}
@@ -187,7 +187,7 @@ void ViewProviderVRMLObject::getLocalResources(SoNode* node, std::list<std::stri
if (url.getLength() > 0) {
// add the resource file if not yet listed
if (std::find(resources.begin(), resources.end(), url.getString()) == resources.end()) {
resources.push_back(url.getString());
resources.emplace_back(url.getString());
}
// if the resource file could be loaded check if it references further resources