make details hide of visible depend on its layout status

--HG--
branch : develop
This commit is contained in:
vorzelmir 2019-07-14 21:21:36 +03:00
parent 2563cd8161
commit 389cc1fa7e
3 changed files with 60 additions and 0 deletions

View file

@ -28,10 +28,12 @@
#include "vwidgetdetails.h"
#include "ui_vwidgetdetails.h"
#include "vwidgetdetails.h"
#include "../ifc/xml/vabstractpattern.h"
#include "../vpatterndb/vcontainer.h"
#include "../vmisc/vabstractapplication.h"
#include "../vtools/undocommands/togglepiecestate.h"
#include "../vtools/tools/vtoolseamallowance.h"
#include <QMenu>
#include <QUndoStack>
@ -45,6 +47,8 @@ VWidgetDetails::VWidgetDetails(VContainer *data, VAbstractPattern *doc, QWidget
{
ui->setupUi(this);
ui->checkBoxHideNotInLayout->setChecked(false);
FillTable(m_data->DataPieces());
ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
@ -201,6 +205,8 @@ void VWidgetDetails::ToggleSectionDetails(bool select)
}
}
//---------------------------------------------------------------------------------------------------------------------
void VWidgetDetails::ShowContextMenu(const QPoint &pos)
{
@ -279,3 +285,41 @@ void VWidgetDetails::ShowContextMenu(const QPoint &pos)
qApp->getUndoStack()->endMacro();
}
}
//------------------------------------------------------------------------------------------------------------------
/**
* @brief
* enable "in layout" details visible or "not in layout" hidden
*/
void VWidgetDetails::on_checkBoxHideNotInLayout_stateChanged()
{
//all details that were created and now they are in DocWidget
const QHash<quint32, VPiece> *allDetails = m_data->DataPieces();
//enable slot if shedule of details is not empty
if (not allDetails->isEmpty())
{//search the checked in layout items and make its visible or are not in layout make hidden once
for (int i = 0; i < ui->tableWidget->rowCount(); ++i)
{
QTableWidgetItem *item = ui->tableWidget->item(i, 0);
const quint32 id = item->data(Qt::UserRole).toUInt();
if (item != nullptr)
{
VToolSeamAllowance *tool = qobject_cast<VToolSeamAllowance*>(VAbstractPattern::getTool(id));
if (tool != nullptr)
{
if (ui->checkBoxHideNotInLayout->isChecked())
{
(allDetails->value(id).IsInLayout())? tool->setVisible(true)
: tool->setVisible(false);
}
else
{
tool->setVisible(true);
}
}
}
}
}
}

View file

@ -34,6 +34,7 @@
class VAbstractPattern;
class VContainer;
class VPiece;
class VWidgetGroups;
namespace Ui
{
@ -60,6 +61,8 @@ private slots:
void InLayoutStateChanged(int row, int column);
void ShowContextMenu(const QPoint &pos);
void on_checkBoxHideNotInLayout_stateChanged();
private:
Q_DISABLE_COPY(VWidgetDetails)
Ui::VWidgetDetails *ui;

View file

@ -14,6 +14,19 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="checkBoxHideNotInLayout">
<property name="toolTip">
<string extracomment="hide details that are not in layout"/>
</property>
<property name="toolTipDuration">
<number>1</number>
</property>
<property name="text">
<string>Hide not in layout</string>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="tableWidget">
<property name="alternatingRowColors">