[TD]lint removal
This commit is contained in:
@@ -68,9 +68,6 @@ using namespace TechDrawGui;
|
||||
using namespace TechDraw;
|
||||
namespace sp = std::placeholders;
|
||||
|
||||
#define _SHOWDRAWING 10
|
||||
#define _TOGGLEUPDATE 11
|
||||
|
||||
PROPERTY_SOURCE(TechDrawGui::ViewProviderPage, Gui::ViewProviderDocumentObject)
|
||||
|
||||
|
||||
@@ -78,19 +75,21 @@ PROPERTY_SOURCE(TechDrawGui::ViewProviderPage, Gui::ViewProviderDocumentObject)
|
||||
// Construction/Destruction
|
||||
|
||||
ViewProviderPage::ViewProviderPage()
|
||||
: m_mdiView(nullptr), m_pageName(""), m_graphicsView(nullptr), m_graphicsScene(nullptr)
|
||||
: m_mdiView(nullptr), m_graphicsView(nullptr), m_graphicsScene(nullptr)
|
||||
{
|
||||
initExtension(this);
|
||||
|
||||
sPixmap = "TechDraw_TreePage";
|
||||
static const char* group = "Grid";
|
||||
|
||||
// NOLINTBEGIN
|
||||
ADD_PROPERTY_TYPE(ShowFrames, (true), group, App::Prop_None,
|
||||
"Show or hide View frames and Labels on this Page");
|
||||
ADD_PROPERTY_TYPE(ShowGrid, (PreferencesGui::showGrid()), group, App::Prop_None,
|
||||
"Show or hide a grid on this Page");
|
||||
ADD_PROPERTY_TYPE(GridSpacing, (PreferencesGui::gridSpacing()), group,
|
||||
(App::PropertyType::Prop_None), "Grid line spacing in mm");
|
||||
// NOLINTEND
|
||||
|
||||
ShowFrames.setStatus(App::Property::Hidden, true);
|
||||
// Do not show in property editor why? wf WF: because DisplayMode applies only to coin and we
|
||||
@@ -118,7 +117,7 @@ void ViewProviderPage::attach(App::DocumentObject* pcFeat)
|
||||
//NOLINTBEGIN
|
||||
auto bnd = std::bind(&ViewProviderPage::onGuiRepaint, this, sp::_1);
|
||||
//NOLINTEND
|
||||
TechDraw::DrawPage* feature = dynamic_cast<TechDraw::DrawPage*>(pcFeat);
|
||||
auto* feature = dynamic_cast<TechDraw::DrawPage*>(pcFeat);
|
||||
if (feature) {
|
||||
connectGuiRepaint = feature->signalGuiPaint.connect(bnd);
|
||||
if (feature->isAttachedToDocument()) {
|
||||
@@ -132,10 +131,8 @@ void ViewProviderPage::attach(App::DocumentObject* pcFeat)
|
||||
|
||||
void ViewProviderPage::onChanged(const App::Property* prop)
|
||||
{
|
||||
if (prop == &(ShowGrid)) {
|
||||
setGrid();
|
||||
}
|
||||
else if (prop == &(GridSpacing)) {
|
||||
if (prop == &(ShowGrid) ||
|
||||
prop == &(GridSpacing)) {
|
||||
setGrid();
|
||||
}
|
||||
else if (prop == &Visibility) {
|
||||
@@ -175,15 +172,17 @@ void ViewProviderPage::updateData(const App::Property* prop)
|
||||
}
|
||||
}
|
||||
else if (prop == &page->Views) {
|
||||
if (!page->isUnsetting())
|
||||
if (!page->isUnsetting()) {
|
||||
m_graphicsScene->fixOrphans();
|
||||
}
|
||||
}
|
||||
|
||||
Gui::ViewProviderDocumentObject::updateData(prop);
|
||||
}
|
||||
|
||||
bool ViewProviderPage::onDelete(const std::vector<std::string>&)
|
||||
bool ViewProviderPage::onDelete(const std::vector<std::string>& parms)
|
||||
{
|
||||
Q_UNUSED(parms)
|
||||
// warn the user if the Page is not empty
|
||||
// but don't do this if there is just the template
|
||||
|
||||
@@ -195,10 +194,7 @@ bool ViewProviderPage::onDelete(const std::vector<std::string>&)
|
||||
// the ExportName of a template always begins with "Template"
|
||||
bool isTemplate = false;
|
||||
for (auto objsIterator : objs) {
|
||||
if (objsIterator->getExportName().substr(0, 8).compare(std::string("Template")) == 0)
|
||||
isTemplate = true;
|
||||
else
|
||||
isTemplate = false;
|
||||
isTemplate = (objsIterator->getExportName().substr(0, 8).compare(std::string("Template")) == 0);
|
||||
}
|
||||
|
||||
if (!objs.empty() && !isTemplate) {
|
||||
@@ -209,8 +205,9 @@ bool ViewProviderPage::onDelete(const std::vector<std::string>&)
|
||||
"Std_Delete",
|
||||
"The page is not empty, therefore the\nfollowing referencing objects might be lost:");
|
||||
bodyMessageStream << '\n';
|
||||
for (auto ObjIterator : objs)
|
||||
for (auto ObjIterator : objs) {
|
||||
bodyMessageStream << '\n' << QString::fromUtf8(ObjIterator->Label.getValue());
|
||||
}
|
||||
bodyMessageStream << "\n\n" << QObject::tr("Are you sure you want to continue?");
|
||||
// show and evaluate the dialog
|
||||
int DialogResult = QMessageBox::warning(
|
||||
@@ -220,8 +217,7 @@ bool ViewProviderPage::onDelete(const std::vector<std::string>&)
|
||||
removeMDIView();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
removeMDIView();
|
||||
@@ -233,18 +229,19 @@ void ViewProviderPage::setupContextMenu(QMenu* menu, QObject* receiver, const ch
|
||||
{
|
||||
Gui::ViewProviderDocumentObject::setupContextMenu(menu, receiver, member);
|
||||
QAction* act = menu->addAction(QObject::tr("Show drawing"), receiver, member);
|
||||
act->setData(QVariant((int)_SHOWDRAWING));
|
||||
act->setData(QVariant((int)ShowDrawing));
|
||||
QAction* act2 = menu->addAction(QObject::tr("Toggle Keep Updated"), receiver, member);
|
||||
act2->setData(QVariant((int)_TOGGLEUPDATE));
|
||||
act2->setData(QVariant((int)ToggleUpdate));
|
||||
}
|
||||
|
||||
bool ViewProviderPage::setEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == _SHOWDRAWING) {
|
||||
if (ModNum == ShowDrawing) {
|
||||
showMDIViewPage();// show the drawing
|
||||
return false; //finished editing
|
||||
}
|
||||
else if (ModNum == _TOGGLEUPDATE) {
|
||||
|
||||
if (ModNum == ToggleUpdate) {
|
||||
auto page = getDrawPage();
|
||||
if (page) {
|
||||
page->KeepUpdated.setValue(!page->KeepUpdated.getValue());
|
||||
@@ -252,9 +249,7 @@ bool ViewProviderPage::setEdit(int ModNum)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return Gui::ViewProviderDocumentObject::setEdit(ModNum);
|
||||
}
|
||||
return Gui::ViewProviderDocumentObject::setEdit(ModNum);
|
||||
}
|
||||
|
||||
void ViewProviderPage::unsetEdit(int ModNum)
|
||||
@@ -263,7 +258,7 @@ void ViewProviderPage::unsetEdit(int ModNum)
|
||||
return;
|
||||
}
|
||||
|
||||
bool ViewProviderPage::doubleClicked(void)
|
||||
bool ViewProviderPage::doubleClicked()
|
||||
{
|
||||
if (Preferences::switchOnClick()) {
|
||||
Gui::Command::assureWorkbench("TechDrawWorkbench");
|
||||
@@ -273,13 +268,13 @@ bool ViewProviderPage::doubleClicked(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
void ViewProviderPage::show(void)
|
||||
void ViewProviderPage::show()
|
||||
{
|
||||
showMDIViewPage();
|
||||
ViewProviderDocumentObject::show();
|
||||
}
|
||||
|
||||
void ViewProviderPage::hide(void)
|
||||
void ViewProviderPage::hide()
|
||||
{
|
||||
if (getMDIView()) {
|
||||
getMDIView()->hide(); // this doesn't remove the mdiViewPage from the mainWindow
|
||||
@@ -345,7 +340,7 @@ void ViewProviderPage::switchToMdiViewPage()
|
||||
}
|
||||
|
||||
//NOTE: removing MDIViewPage (parent) destroys QGVPage (eventually)
|
||||
void ViewProviderPage::removeMDIView(void)
|
||||
void ViewProviderPage::removeMDIView()
|
||||
{
|
||||
if (!m_mdiView.isNull()) {//m_mdiView is a QPointer
|
||||
QList<QWidget*> wList = Gui::getMainWindow()->windows();
|
||||
@@ -356,8 +351,9 @@ void ViewProviderPage::removeMDIView(void)
|
||||
Gui::MDIView* aw =
|
||||
Gui::getMainWindow()
|
||||
->activeWindow();//WF: this bit should be in the remove window logic, not here.
|
||||
if (aw)
|
||||
if (aw) {
|
||||
aw->showMaximized();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -389,7 +385,7 @@ QGITemplate* ViewProviderPage::getQTemplate() const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<App::DocumentObject*> ViewProviderPage::claimChildren(void) const
|
||||
std::vector<App::DocumentObject*> ViewProviderPage::claimChildren() const
|
||||
{
|
||||
std::vector<App::DocumentObject*> temp;
|
||||
|
||||
@@ -410,6 +406,9 @@ std::vector<App::DocumentObject*> ViewProviderPage::claimChildren(void) const
|
||||
|
||||
try {
|
||||
for (auto* obj : getDrawPage()->Views.getValues()) {
|
||||
if (!obj) {
|
||||
continue;
|
||||
}
|
||||
auto* featView = dynamic_cast<TechDraw::DrawView*>(obj);
|
||||
|
||||
// If the child view appoints a parent, skip it
|
||||
@@ -425,20 +424,18 @@ std::vector<App::DocumentObject*> ViewProviderPage::claimChildren(void) const
|
||||
|| (featView && featView->isInClip())) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
temp.push_back(obj);
|
||||
}
|
||||
temp.push_back(obj);
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
catch (...) {
|
||||
return std::vector<App::DocumentObject*>();
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderPage::isShow(void) const { return Visibility.getValue(); }
|
||||
bool ViewProviderPage::isShow() const { return Visibility.getValue(); }
|
||||
|
||||
bool ViewProviderPage::getFrameState() { return ShowFrames.getValue(); }
|
||||
bool ViewProviderPage::getFrameState() const { return ShowFrames.getValue(); }
|
||||
|
||||
void ViewProviderPage::setFrameState(bool state) { ShowFrames.setValue(state); }
|
||||
|
||||
@@ -451,7 +448,7 @@ void ViewProviderPage::toggleFrameState()
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderPage::setTemplateMarkers(bool state)
|
||||
void ViewProviderPage::setTemplateMarkers(bool state) const
|
||||
{
|
||||
App::DocumentObject* templateFeat = nullptr;
|
||||
templateFeat = getDrawPage()->Template.getValue();
|
||||
@@ -528,16 +525,22 @@ Gui::MDIView* ViewProviderPage::getMDIView() const { return m_mdiView.data(); }
|
||||
|
||||
void ViewProviderPage::setGrid()
|
||||
{
|
||||
TechDraw::DrawPage* dp = getDrawPage();
|
||||
if (!dp) {
|
||||
TechDraw::DrawPage* dPage = getDrawPage();
|
||||
if (!dPage) {
|
||||
return;
|
||||
}
|
||||
int pageWidth = 298;
|
||||
int pageHeight = 215;
|
||||
constexpr int A4LandscapeWide{298};
|
||||
constexpr int A4LandscapeHigh{215};
|
||||
|
||||
int pageWidth{A4LandscapeWide};
|
||||
int pageHeight{A4LandscapeHigh};
|
||||
//
|
||||
double gridStep = GridSpacing.getValue() > 0 ? GridSpacing.getValue() : 10.0;
|
||||
if (dp) {
|
||||
pageWidth = dp->getPageWidth();
|
||||
pageHeight = dp->getPageHeight();
|
||||
if (dPage) {
|
||||
pageWidth = floor(dPage->getPageWidth()); // combining these 2 lines
|
||||
pageWidth = std::max(1, pageWidth); // causes 'no matching function' error
|
||||
pageHeight = floor(dPage->getPageHeight()); // and again
|
||||
pageHeight = std::max(1, pageHeight);
|
||||
}
|
||||
QGVPage* widget = getQGVPage();
|
||||
if (widget) {
|
||||
|
||||
@@ -45,11 +45,17 @@ class DrawTemplate;
|
||||
namespace TechDrawGui
|
||||
{
|
||||
|
||||
// ?? is changing the base type worthwhile here? lint thinks so.
|
||||
enum PageEditMode : std::int16_t {
|
||||
ShowDrawing = 10,
|
||||
ToggleUpdate = 11 };
|
||||
|
||||
class MDIViewPage;
|
||||
class QGVPage;
|
||||
class QGSPage;
|
||||
class QGITemplate;
|
||||
|
||||
// NOLINTNEXTLINE
|
||||
class TechDrawGuiExport ViewProviderPage: public Gui::ViewProviderDocumentObject,
|
||||
public ViewProviderPageExtension
|
||||
{
|
||||
@@ -61,11 +67,13 @@ public:
|
||||
/// destructor
|
||||
~ViewProviderPage() override;
|
||||
|
||||
// NOLINTBEGIN
|
||||
App::PropertyBool ShowFrames;
|
||||
App::PropertyBool ShowGrid;
|
||||
App::PropertyDistance GridSpacing;
|
||||
// NOLINTEND
|
||||
|
||||
void attach(App::DocumentObject*) override;
|
||||
void attach(App::DocumentObject* pcFeat) override;
|
||||
|
||||
bool canDragObjects() const override;
|
||||
bool canDragObject(App::DocumentObject* docObj) const override;
|
||||
@@ -89,19 +97,22 @@ public:
|
||||
|
||||
/// Is called by the tree if the user double click on the object
|
||||
bool doubleClicked() override;
|
||||
void setupContextMenu(QMenu*, QObject*, const char*) override;
|
||||
bool onDelete(const std::vector<std::string>&) override;
|
||||
void setupContextMenu(QMenu* menu, QObject* receiver, const char* member) override;
|
||||
bool onDelete(const std::vector<std::string>& parms) override;
|
||||
void onChanged(const App::Property* prop) override;
|
||||
void updateData(const App::Property* prop) override;
|
||||
|
||||
TechDraw::DrawPage* getDrawPage() const;
|
||||
TechDraw::DrawTemplate* getTemplate() const;
|
||||
QGITemplate* getQTemplate(void) const;
|
||||
QGITemplate* getQTemplate() const;
|
||||
|
||||
//slots & connections
|
||||
void onGuiRepaint(const TechDraw::DrawPage* dp);
|
||||
|
||||
// NOLINTBEGIN
|
||||
using Connection = boost::signals2::scoped_connection;
|
||||
Connection connectGuiRepaint;
|
||||
// NOLINTEND
|
||||
|
||||
void unsetEdit(int ModNum) override;
|
||||
MDIViewPage* getMDIViewPage() const;
|
||||
@@ -111,17 +122,17 @@ public:
|
||||
|
||||
Gui::MDIView* getMDIView() const override;
|
||||
|
||||
bool getFrameState();
|
||||
bool getFrameState() const;
|
||||
void setFrameState(bool state);
|
||||
void toggleFrameState();
|
||||
void setTemplateMarkers(bool state);
|
||||
void setTemplateMarkers(bool state) const;
|
||||
|
||||
bool canDelete(App::DocumentObject* obj) const override;
|
||||
|
||||
void setGrid();
|
||||
|
||||
QGSPage* getQGSPage(void) const { return m_graphicsScene; }
|
||||
QGVPage* getQGVPage(void) const { return m_graphicsView; }
|
||||
QGSPage* getQGSPage() const { return m_graphicsScene; }
|
||||
QGVPage* getQGVPage() const { return m_graphicsView; }
|
||||
|
||||
ViewProviderPageExtension* getVPPExtension() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user