modernize C++: replace boost::function with std::function
This commit is contained in:
@@ -23,8 +23,8 @@
|
||||
#ifndef EXPRESSIONENGINE_H
|
||||
#define EXPRESSIONENGINE_H
|
||||
|
||||
#include <functional>
|
||||
#include <boost/unordered/unordered_map.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost_signals2.hpp>
|
||||
#include <boost_graph_adjacency_list.hpp>
|
||||
#include <boost/graph/topological_sort.hpp>
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
virtual Property *CopyOnLinkReplace(const App::DocumentObject *parent,
|
||||
App::DocumentObject *oldObj, App::DocumentObject *newObj) const override;
|
||||
|
||||
typedef boost::function<std::string (const App::ObjectIdentifier & path, std::shared_ptr<const App::Expression> expr)> ValidatorFunc;
|
||||
typedef std::function<std::string (const App::ObjectIdentifier & path, std::shared_ptr<const App::Expression> expr)> ValidatorFunc;
|
||||
|
||||
/**
|
||||
* @brief The ExpressionInfo struct encapsulates an expression.
|
||||
|
||||
@@ -38,9 +38,9 @@ namespace Gui {
|
||||
class ActionFunctionPrivate
|
||||
{
|
||||
public:
|
||||
QMap<QAction*, boost::function<void()> > triggerMap;
|
||||
QMap<QAction*, boost::function<void(bool)> > toggleMap;
|
||||
QMap<QAction*, boost::function<void()> > hoverMap;
|
||||
QMap<QAction*, std::function<void()> > triggerMap;
|
||||
QMap<QAction*, std::function<void(bool)> > toggleMap;
|
||||
QMap<QAction*, std::function<void()> > hoverMap;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ ActionFunction::~ActionFunction()
|
||||
{
|
||||
}
|
||||
|
||||
void ActionFunction::trigger(QAction* action, boost::function<void()> func)
|
||||
void ActionFunction::trigger(QAction* action, std::function<void()> func)
|
||||
{
|
||||
Q_D(ActionFunction);
|
||||
|
||||
@@ -66,19 +66,19 @@ void ActionFunction::triggered()
|
||||
Q_D(ActionFunction);
|
||||
|
||||
QAction* a = qobject_cast<QAction*>(sender());
|
||||
QMap<QAction*, boost::function<void()> >::iterator it = d->triggerMap.find(a);
|
||||
QMap<QAction*, std::function<void()> >::iterator it = d->triggerMap.find(a);
|
||||
if (it != d->triggerMap.end()) {
|
||||
// invoke the class function here
|
||||
it.value()();
|
||||
}
|
||||
}
|
||||
|
||||
void ActionFunction::toggle(QAction* action, boost::function<void(bool)> func)
|
||||
void ActionFunction::toggle(QAction* action, std::function<void(bool)> func)
|
||||
{
|
||||
Q_D(ActionFunction);
|
||||
|
||||
d->toggleMap[action] = func;
|
||||
connect(action, SIGNAL(toggled(bool)), this, SLOT(toggled(bool)));
|
||||
connect(action, &QAction::toggled, this, &ActionFunction::toggled);
|
||||
}
|
||||
|
||||
void ActionFunction::toggled(bool on)
|
||||
@@ -86,19 +86,19 @@ void ActionFunction::toggled(bool on)
|
||||
Q_D(ActionFunction);
|
||||
|
||||
QAction* a = qobject_cast<QAction*>(sender());
|
||||
QMap<QAction*, boost::function<void(bool)> >::iterator it = d->toggleMap.find(a);
|
||||
QMap<QAction*, std::function<void(bool)> >::iterator it = d->toggleMap.find(a);
|
||||
if (it != d->toggleMap.end()) {
|
||||
// invoke the class function here
|
||||
it.value()(on);
|
||||
}
|
||||
}
|
||||
|
||||
void ActionFunction::hover(QAction* action, boost::function<void()> func)
|
||||
void ActionFunction::hover(QAction* action, std::function<void()> func)
|
||||
{
|
||||
Q_D(ActionFunction);
|
||||
|
||||
d->hoverMap[action] = func;
|
||||
connect(action, SIGNAL(hovered()), this, SLOT(hovered()));
|
||||
connect(action, &QAction::hovered, this, &ActionFunction::hovered);
|
||||
}
|
||||
|
||||
void ActionFunction::hovered()
|
||||
@@ -106,7 +106,7 @@ void ActionFunction::hovered()
|
||||
Q_D(ActionFunction);
|
||||
|
||||
QAction* a = qobject_cast<QAction*>(sender());
|
||||
QMap<QAction*, boost::function<void()> >::iterator it = d->hoverMap.find(a);
|
||||
QMap<QAction*, std::function<void()> >::iterator it = d->hoverMap.find(a);
|
||||
if (it != d->hoverMap.end()) {
|
||||
// invoke the class function here
|
||||
it.value()();
|
||||
@@ -119,9 +119,9 @@ namespace Gui {
|
||||
class TimerFunctionPrivate
|
||||
{
|
||||
public:
|
||||
boost::function<void()> timeoutFunc;
|
||||
boost::function<void(QObject*)> timeoutFuncQObject;
|
||||
boost::function<void(QVariant)> timeoutFuncQVariant;
|
||||
std::function<void()> timeoutFunc;
|
||||
std::function<void(QObject*)> timeoutFuncQObject;
|
||||
std::function<void(QVariant)> timeoutFuncQVariant;
|
||||
bool autoDelete;
|
||||
QPointer<QObject> argQObject;
|
||||
QVariant argQVariant;
|
||||
@@ -138,20 +138,20 @@ TimerFunction::~TimerFunction()
|
||||
{
|
||||
}
|
||||
|
||||
void TimerFunction::setFunction(boost::function<void()> func)
|
||||
void TimerFunction::setFunction(std::function<void()> func)
|
||||
{
|
||||
Q_D(TimerFunction);
|
||||
d->timeoutFunc = func;
|
||||
}
|
||||
|
||||
void TimerFunction::setFunction(boost::function<void(QObject*)> func, QObject* args)
|
||||
void TimerFunction::setFunction(std::function<void(QObject*)> func, QObject* args)
|
||||
{
|
||||
Q_D(TimerFunction);
|
||||
d->timeoutFuncQObject = func;
|
||||
d->argQObject = args;
|
||||
}
|
||||
|
||||
void TimerFunction::setFunction(boost::function<void(QVariant)> func, QVariant args)
|
||||
void TimerFunction::setFunction(std::function<void(QVariant)> func, QVariant args)
|
||||
{
|
||||
Q_D(TimerFunction);
|
||||
d->timeoutFuncQVariant = func;
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
#include <boost/function.hpp>
|
||||
#include <functional>
|
||||
#include <FCGlobal.h>
|
||||
|
||||
class QAction;
|
||||
|
||||
@@ -46,13 +47,13 @@ class ActionFunctionPrivate;
|
||||
Gui::ActionFunction* func = new Gui::ActionFunction(menu);
|
||||
|
||||
QAction* a1 = menu->addAction(QObject::tr("Menu item 1..."));
|
||||
func->triggered(a1, boost::bind(&MyViewProvider::doItem1, this));
|
||||
func->triggered(a1, std::bind(&MyViewProvider::doItem1, this));
|
||||
|
||||
QAction* a2 = menu->addAction(QObject::tr("Menu item 2..."));
|
||||
func->triggered(a2, boost::bind(&MyViewProvider::doItem2, this));
|
||||
func->triggered(a2, std::bind(&MyViewProvider::doItem2, this));
|
||||
|
||||
QAction* a3 = menu->addAction(QObject::tr("Menu item 3..."));
|
||||
func->triggered(a3, boost::bind(&MyViewProvider::doItem3, this));
|
||||
func->triggered(a3, std::bind(&MyViewProvider::doItem3, this));
|
||||
}
|
||||
\endcode
|
||||
|
||||
@@ -72,9 +73,9 @@ public:
|
||||
/*!
|
||||
Connects the QAction's triggered() signal with the function \a func
|
||||
*/
|
||||
void trigger(QAction* a, boost::function<void()> func);
|
||||
void toggle(QAction* a, boost::function<void(bool)> func);
|
||||
void hover(QAction* a, boost::function<void()> func);
|
||||
void trigger(QAction* a, std::function<void()> func);
|
||||
void toggle(QAction* a, std::function<void(bool)> func);
|
||||
void hover(QAction* a, std::function<void()> func);
|
||||
|
||||
private Q_SLOTS:
|
||||
void triggered();
|
||||
@@ -98,9 +99,9 @@ public:
|
||||
TimerFunction(QObject* = nullptr);
|
||||
virtual ~TimerFunction();
|
||||
|
||||
void setFunction(boost::function<void()> func);
|
||||
void setFunction(boost::function<void(QObject*)> func, QObject* args);
|
||||
void setFunction(boost::function<void(QVariant)> func, QVariant args);
|
||||
void setFunction(std::function<void()> func);
|
||||
void setFunction(std::function<void(QObject*)> func, QObject* args);
|
||||
void setFunction(std::function<void(QVariant)> func, QVariant args);
|
||||
void setAutoDelete(bool);
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
@@ -403,7 +403,7 @@ void TaskView::keyPressEvent(QKeyEvent* ke)
|
||||
func->setAutoDelete(true);
|
||||
Gui::Document* doc = Gui::Application::Instance->getDocument(ActiveDialog->getDocumentName().c_str());
|
||||
if (doc) {
|
||||
func->setFunction(boost::bind(&Document::resetEdit, doc));
|
||||
func->setFunction(std::bind(&Document::resetEdit, doc));
|
||||
QTimer::singleShot(0, func, SLOT(timeout()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ void ViewProvider::eventCallback(void * ud, SoEventCallback * node)
|
||||
|
||||
Gui::TimerFunction* func = new Gui::TimerFunction();
|
||||
func->setAutoDelete(true);
|
||||
func->setFunction(boost::bind(&Document::resetEdit, doc));
|
||||
func->setFunction(std::bind(&Document::resetEdit, doc));
|
||||
QTimer::singleShot(0, func, SLOT(timeout()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ void ViewProviderDocumentObject::addDefaultAction(QMenu* menu, const QString& te
|
||||
QAction* act = menu->addAction(text);
|
||||
act->setData(QVariant((int)ViewProvider::Default));
|
||||
Gui::ActionFunction* func = new Gui::ActionFunction(menu);
|
||||
func->trigger(act, boost::bind(&ViewProviderDocumentObject::startDefaultEditMode, this));
|
||||
func->trigger(act, std::bind(&ViewProviderDocumentObject::startDefaultEditMode, this));
|
||||
}
|
||||
|
||||
void ViewProviderDocumentObject::setModeSwitch() {
|
||||
|
||||
@@ -71,7 +71,7 @@ void ViewProviderPart::setupContextMenu(QMenu* menu, QObject* receiver, const ch
|
||||
{
|
||||
Gui::ActionFunction* func = new Gui::ActionFunction(menu);
|
||||
QAction* act = menu->addAction(QObject::tr("Toggle active part"));
|
||||
func->trigger(act, boost::bind(&ViewProviderPart::doubleClicked, this));
|
||||
func->trigger(act, std::bind(&ViewProviderPart::doubleClicked, this));
|
||||
|
||||
ViewProviderDragger::setupContextMenu(menu, receiver, member);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ void ViewProviderTextDocument::setupContextMenu(QMenu* menu, QObject* receiver,
|
||||
{
|
||||
Gui::ActionFunction* func = new Gui::ActionFunction(menu);
|
||||
QAction* act = menu->addAction(QObject::tr("Edit text"));
|
||||
func->trigger(act, boost::bind(&ViewProviderTextDocument::doubleClicked, this));
|
||||
func->trigger(act, std::bind(&ViewProviderTextDocument::doubleClicked, this));
|
||||
|
||||
ViewProviderDocumentObject::setupContextMenu(menu, receiver, member);
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ void ViewProviderFemAnalysis::setupContextMenu(QMenu* menu, QObject* , const cha
|
||||
{
|
||||
Gui::ActionFunction* func = new Gui::ActionFunction(menu);
|
||||
QAction* act = menu->addAction(tr("Activate analysis"));
|
||||
func->trigger(act, boost::bind(&ViewProviderFemAnalysis::doubleClicked, this));
|
||||
func->trigger(act, std::bind(&ViewProviderFemAnalysis::doubleClicked, this));
|
||||
}
|
||||
|
||||
bool ViewProviderFemAnalysis::setEdit(int ModNum)
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
#include <Mod/Part/App/Attacher.h>
|
||||
#include <boost/function.hpp>
|
||||
#include <functional>
|
||||
|
||||
|
||||
class Ui_TaskAttacher;
|
||||
@@ -53,8 +53,8 @@ class PartGuiExport TaskAttacher : public Gui::TaskView::TaskBox, public Gui::Se
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
typedef boost::function<void (bool, const std::string &, Gui::ViewProviderDocumentObject*,
|
||||
App::DocumentObject *, const std::string&)> VisibilityFunction;
|
||||
typedef std::function<void (bool, const std::string &, Gui::ViewProviderDocumentObject*,
|
||||
App::DocumentObject *, const std::string&)> VisibilityFunction;
|
||||
|
||||
TaskAttacher(Gui::ViewProviderDocumentObject *ViewProvider, QWidget *parent = nullptr,
|
||||
QString picture = QString(),
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#ifndef TASKCHECKGEOMETRY_H
|
||||
#define TASKCHECKGEOMETRY_H
|
||||
|
||||
#include <functional>
|
||||
#include <tuple>
|
||||
#include <BRepCheck_Analyzer.hxx>
|
||||
#include <BRepCheck_Status.hxx>
|
||||
@@ -73,7 +74,7 @@ void goSetupResultInvalidCurveSurface(ResultEntry *entry);
|
||||
void goSetupResultInvalidSameParameterFlag(ResultEntry *entry);
|
||||
void goSetupResultUnorientableShapeFace(ResultEntry *entry);
|
||||
|
||||
typedef boost::function<void (ResultEntry *entry)> ResultFunction;
|
||||
typedef std::function<void (ResultEntry *entry)> ResultFunction;
|
||||
typedef std::tuple<TopAbs_ShapeEnum, BRepCheck_Status, ResultFunction> FunctionMapType;
|
||||
|
||||
class ResultModel : public QAbstractItemModel
|
||||
|
||||
@@ -118,7 +118,7 @@ void ViewProviderAttachExtension::extensionSetupContextMenu(QMenu* menu, QObject
|
||||
QAction* act = menu->addAction(QObject::tr("Attachment editor"));
|
||||
if (Gui::Control().activeDialog())
|
||||
act->setDisabled(true);
|
||||
func->trigger(act, boost::bind(&ViewProviderAttachExtension::showAttachmentEditor, this));
|
||||
func->trigger(act, std::bind(&ViewProviderAttachExtension::showAttachmentEditor, this));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ void ViewProviderPrimitive::setupContextMenu(QMenu* menu, QObject* receiver, con
|
||||
Gui::ActionFunction* func = new Gui::ActionFunction(menu);
|
||||
QAction* act = menu->addAction(QObject::tr("Edit %1").arg(QString::fromUtf8(getObject()->Label.getValue())));
|
||||
act->setData(QVariant((int)ViewProvider::Default));
|
||||
func->trigger(act, boost::bind(&ViewProviderPrimitive::startDefaultEditMode, this));
|
||||
func->trigger(act, std::bind(&ViewProviderPrimitive::startDefaultEditMode, this));
|
||||
|
||||
ViewProviderPart::setupContextMenu(menu, receiver, member);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
|
||||
|
||||
using namespace PartGui;
|
||||
namespace bp = boost::placeholders;
|
||||
namespace sp = std::placeholders;
|
||||
|
||||
|
||||
PROPERTY_SOURCE(PartGui::ViewProviderSpline, PartGui::ViewProviderPartExt)
|
||||
@@ -99,7 +99,7 @@ void ViewProviderSplineExtension::extensionSetupContextMenu(QMenu* menu, QObject
|
||||
QAction* act = menu->addAction(QObject::tr("Show control points"));
|
||||
act->setCheckable(true);
|
||||
act->setChecked(ControlPoints.getValue());
|
||||
func->toggle(act, boost::bind(&ViewProviderSplineExtension::toggleControlPoints, this, bp::_1));
|
||||
func->toggle(act, std::bind(&ViewProviderSplineExtension::toggleControlPoints, this, sp::_1));
|
||||
}
|
||||
|
||||
void ViewProviderSplineExtension::extensionUpdateData(const App::Property* prop)
|
||||
|
||||
@@ -979,7 +979,7 @@ unsigned validateSketches(std::vector<App::DocumentObject*>& sketches,
|
||||
}
|
||||
|
||||
void prepareProfileBased(PartDesign::Body *pcActiveBody, Gui::Command* cmd, const std::string& which,
|
||||
boost::function<void (Part::Feature*, App::DocumentObject*)> func)
|
||||
std::function<void (Part::Feature*, App::DocumentObject*)> func)
|
||||
{
|
||||
auto base_worker = [=](App::DocumentObject* feature, const std::vector<string> &subs) {
|
||||
|
||||
@@ -2167,7 +2167,7 @@ bool CmdPartDesignThickness::isActive(void)
|
||||
//===========================================================================
|
||||
|
||||
void prepareTransformed(PartDesign::Body *pcActiveBody, Gui::Command* cmd, const std::string& which,
|
||||
boost::function<void(App::DocumentObject*, std::vector<App::DocumentObject*>)> func)
|
||||
std::function<void(App::DocumentObject*, std::vector<App::DocumentObject*>)> func)
|
||||
{
|
||||
std::string FeatName = cmd->getUniqueObjectName(which.c_str(), pcActiveBody);
|
||||
|
||||
|
||||
@@ -534,10 +534,10 @@ void TaskFeaturePick::showExternal(bool val)
|
||||
|
||||
TaskDlgFeaturePick::TaskDlgFeaturePick( std::vector<App::DocumentObject*> &objects,
|
||||
const std::vector<TaskFeaturePick::featureStatus> &status,
|
||||
boost::function<bool (std::vector<App::DocumentObject*>)> afunc,
|
||||
boost::function<void (std::vector<App::DocumentObject*>)> wfunc,
|
||||
std::function<bool (std::vector<App::DocumentObject*>)> afunc,
|
||||
std::function<void (std::vector<App::DocumentObject*>)> wfunc,
|
||||
bool singleFeatureSelect,
|
||||
boost::function<void (void)> abortfunc /* = NULL */ )
|
||||
std::function<void (void)> abortfunc /* = NULL */ )
|
||||
: TaskDialog(), accepted(false)
|
||||
{
|
||||
pick = new TaskFeaturePick(objects, status, singleFeatureSelect);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#ifndef PARTDESIGNGUI_FeaturePickDialog_H
|
||||
#define PARTDESIGNGUI_FeaturePickDialog_H
|
||||
|
||||
#include <functional>
|
||||
#include <QListWidgetItem>
|
||||
|
||||
#include <App/DocumentObject.h>
|
||||
@@ -106,10 +107,10 @@ class TaskDlgFeaturePick : public Gui::TaskView::TaskDialog
|
||||
public:
|
||||
TaskDlgFeaturePick( std::vector<App::DocumentObject*> &objects,
|
||||
const std::vector<TaskFeaturePick::featureStatus> &status,
|
||||
boost::function<bool (std::vector<App::DocumentObject*>)> acceptfunc,
|
||||
boost::function<void (std::vector<App::DocumentObject*>)> workfunc,
|
||||
std::function<bool (std::vector<App::DocumentObject*>)> acceptfunc,
|
||||
std::function<void (std::vector<App::DocumentObject*>)> workfunc,
|
||||
bool singleFeatureSelect,
|
||||
boost::function<void (void)> abortfunc = 0);
|
||||
std::function<void (void)> abortfunc = 0);
|
||||
~TaskDlgFeaturePick();
|
||||
|
||||
public:
|
||||
@@ -135,9 +136,9 @@ public:
|
||||
protected:
|
||||
TaskFeaturePick *pick;
|
||||
bool accepted;
|
||||
boost::function<bool (std::vector<App::DocumentObject*>)> acceptFunction;
|
||||
boost::function<void (std::vector<App::DocumentObject*>)> workFunction;
|
||||
boost::function<void (void)> abortFunction;
|
||||
std::function<bool (std::vector<App::DocumentObject*>)> acceptFunction;
|
||||
std::function<void (std::vector<App::DocumentObject*>)> workFunction;
|
||||
std::function<void (void)> abortFunction;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ void ViewProviderBody::setupContextMenu(QMenu* menu, QObject* receiver, const ch
|
||||
Q_UNUSED(member);
|
||||
Gui::ActionFunction* func = new Gui::ActionFunction(menu);
|
||||
QAction* act = menu->addAction(tr("Toggle active body"));
|
||||
func->trigger(act, boost::bind(&ViewProviderBody::doubleClicked, this));
|
||||
func->trigger(act, std::bind(&ViewProviderBody::doubleClicked, this));
|
||||
|
||||
Gui::ViewProviderGeometryObject::setupContextMenu(menu, receiver, member);
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ void ViewProviderBalloon::setupContextMenu(QMenu* menu, QObject* receiver, const
|
||||
Gui::ActionFunction* func = new Gui::ActionFunction(menu);
|
||||
QAction* act = menu->addAction(QObject::tr("Edit %1").arg(QString::fromUtf8(getObject()->Label.getValue())));
|
||||
act->setData(QVariant((int)ViewProvider::Default));
|
||||
func->trigger(act, boost::bind(&ViewProviderBalloon::startDefaultEditMode, this));
|
||||
func->trigger(act, std::bind(&ViewProviderBalloon::startDefaultEditMode, this));
|
||||
|
||||
ViewProviderDrawingView::setupContextMenu(menu, receiver, member);
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ void ViewProviderDimension::setupContextMenu(QMenu* menu, QObject* receiver, con
|
||||
Gui::ActionFunction* func = new Gui::ActionFunction(menu);
|
||||
QAction* act = menu->addAction(QObject::tr("Edit %1").arg(QString::fromUtf8(getObject()->Label.getValue())));
|
||||
act->setData(QVariant((int)ViewProvider::Default));
|
||||
func->trigger(act, boost::bind(&ViewProviderDimension::startDefaultEditMode, this));
|
||||
func->trigger(act, std::bind(&ViewProviderDimension::startDefaultEditMode, this));
|
||||
|
||||
ViewProviderDrawingView::setupContextMenu(menu, receiver, member);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user