From 423f6b0a08a86d5e47115b87603cddeae4468b49 Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 30 Nov 2016 13:02:09 +0300 Subject: [PATCH] Issue #1854 Recover feature control update --- .../ModuleBase_WidgetConcealedObjects.cpp | 25 ++++++++----------- .../ModuleBase_WidgetConcealedObjects.h | 6 ----- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp b/src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp index 9da48c21c..1b14529e4 100644 --- a/src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp +++ b/src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp @@ -21,7 +21,8 @@ #include #include #include -#include +#include +#include const int DEFAULT_NAME_COLUMN_WIDTH = 200; @@ -54,7 +55,7 @@ bool ModuleBase_WidgetConcealedObjects::storeValueCustom() anAttributeList->clear(); int aSize1 = anAttributeList->size(false); for (int i = 0, aSize = myView->rowCount(); i < aSize; i++) { - QToolButton* aButton = dynamic_cast(myView->cellWidget(i, 0));; + QCheckBox* aButton = dynamic_cast(myView->cellWidget(i, 0)->findChild()); if (aButton->isChecked()) anAttributeList->append(myConcealedResults[i]); } @@ -95,12 +96,11 @@ bool ModuleBase_WidgetConcealedObjects::restoreValueCustom() int aSize = anAttributeList->size(); for (int i = 0, aSize = myView->rowCount(); i < aSize; i++) { ResultPtr aResult = myConcealedResults[i]; - QToolButton* aButton = dynamic_cast(myView->cellWidget(i, 0)); + QCheckBox* aButton = dynamic_cast(myView->cellWidget(i, 0)->findChild()); bool isChecked = anAttributeList->isInList(aResult); bool aBlocked = aButton->blockSignals(true); aButton->setChecked(isChecked); - this->updateItemIcon(aButton); aButton->blockSignals(aBlocked); } return true; @@ -119,13 +119,15 @@ void ModuleBase_WidgetConcealedObjects::addViewRow( int anId = myView->rowCount(); myView->setRowCount(anId+1); - QToolButton* aVisibilityBtn = new QToolButton(this); + QWidget* aVisibilityWdg = new QWidget(this); + QVBoxLayout* aVisibilityLay = new QVBoxLayout(aVisibilityWdg); + aVisibilityLay->setContentsMargins(2, 2, 2, 2); + QCheckBox* aVisibilityBtn = new QCheckBox(aVisibilityWdg); + aVisibilityLay->addWidget(aVisibilityBtn, 0, Qt::AlignHCenter); connect(aVisibilityBtn, SIGNAL(toggled(bool)), this, SLOT(onItemToggled(bool))); - aVisibilityBtn->setCheckable(true); aVisibilityBtn->setChecked(false); - updateItemIcon(aVisibilityBtn); - myView->setCellWidget(anId, 0, aVisibilityBtn); + myView->setCellWidget(anId, 0, aVisibilityWdg); myView->setItem(anId, 1, new QTableWidgetItem(theResult->data()->name().c_str())); if (anId == 1) { @@ -140,10 +142,3 @@ void ModuleBase_WidgetConcealedObjects::onItemToggled(bool theState) updateObject(myFeature); } -void ModuleBase_WidgetConcealedObjects::updateItemIcon(QToolButton* theButton) -{ - bool isChecked = theButton->isChecked(); - theButton->setIcon(isChecked ? QIcon(":icons/concealed_on.png") - : QIcon(":icons/concealed_off.png")); - theButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); -} diff --git a/src/ModuleBase/ModuleBase_WidgetConcealedObjects.h b/src/ModuleBase/ModuleBase_WidgetConcealedObjects.h index 9cd8f092a..b289d7a87 100644 --- a/src/ModuleBase/ModuleBase_WidgetConcealedObjects.h +++ b/src/ModuleBase/ModuleBase_WidgetConcealedObjects.h @@ -18,7 +18,6 @@ class ModelAPI_Object; class QWidget; class QTableWidget; -class QToolButton; /** * \ingroup GUI @@ -59,11 +58,6 @@ private slots: /// \param theState a new state void onItemToggled(bool theState); -private: - /// Updates icon of button - /// \param theButton a button of the table - void updateItemIcon(QToolButton* theButton); - private: std::string myBaseShapeAttribute; ///< attribute of the base object QTableWidget* myView; ///< table view of visibility states -- 2.39.2