Added new option "In layout" to context menu tool Detail.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-10-14 20:41:37 +03:00
parent 710558812a
commit d38e81cecb
6 changed files with 44 additions and 22 deletions

View File

@ -3510,6 +3510,7 @@ void MainWindow::InitDocksContain()
detailsWidget = new VWidgetDetails(pattern, doc, this);
connect(doc, &VPattern::FullUpdateFromFile, detailsWidget, &VWidgetDetails::UpdateList);
connect(doc, &VPattern::UpdateInLayoutList, detailsWidget, &VWidgetDetails::UpdateList);
connect(detailsWidget, &VWidgetDetails::Highlight, sceneDetails, &VMainGraphicsScene::HighlightItem);
detailsWidget->setVisible(false);
}

View File

@ -1202,6 +1202,12 @@ void VAbstractPattern::ClearScene()
emit ClearMainWindow();
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::CheckInLayoutList()
{
emit UpdateInLayoutList();
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::ToolExists(const quint32 &id) const
{

View File

@ -291,6 +291,7 @@ signals:
void UndoCommand();
void SetEnabledGUI(bool enabled);
void CheckLayout();
void UpdateInLayoutList();
void SetCurrentPP(const QString &patterPiece);
public slots:
@ -298,6 +299,7 @@ public slots:
void haveLiteChange();
void NeedFullParsing();
void ClearScene();
void CheckInLayoutList();
protected:
/** @brief nameActivDraw name current pattern peace. */

View File

@ -156,9 +156,9 @@ const val VContainer::GetObject(const QHash<key, val> &obj, key id) const
*/
const VDetail VContainer::GetDetail(quint32 id) const
{
if (d->details.contains(id))
if (d->details->contains(id))
{
return d->details.value(id);
return d->details->value(id);
}
else
{
@ -188,8 +188,8 @@ quint32 VContainer::AddGObject(VGObject *obj)
*/
quint32 VContainer::AddDetail(const VDetail &detail)
{
quint32 id = getNextId();
d->details[id] = detail;
const quint32 id = getNextId();
d->details->insert(id, detail);
return id;
}
@ -260,7 +260,7 @@ void VContainer::Clear()
qCDebug(vCon, "Clearing container data.");
_id = NULL_ID;
d->details.clear();
d->details->clear();
ClearVariables();
ClearGObjects();
ClearUniqueNames();
@ -272,7 +272,7 @@ void VContainer::ClearForFullParse()
qCDebug(vCon, "Clearing container data for full parse.");
_id = NULL_ID;
d->details.clear();
d->details->clear();
ClearVariables(VarType::Increment);
ClearVariables(VarType::LineAngle);
ClearVariables(VarType::LineLength);
@ -496,7 +496,7 @@ void VContainer::UpdateGObject(quint32 id, VGObject* obj)
void VContainer::UpdateDetail(quint32 id, const VDetail &detail)
{
Q_ASSERT_X(id != NULL_ID, Q_FUNC_INFO, "id == 0"); //-V654 //-V712
d->details[id] = detail;
d->details->insert(id, detail);
UpdateId(id);
}
@ -653,7 +653,7 @@ const QMap<QString, QSharedPointer<T> > VContainer::DataVar(const VarType &type)
// cppcheck-suppress unusedFunction
void VContainer::ClearDetails()
{
d->details.clear();
d->details->clear();
}
//---------------------------------------------------------------------------------------------------------------------
@ -731,7 +731,7 @@ const QHash<quint32, QSharedPointer<VGObject> > *VContainer::DataGObjects() cons
*/
const QHash<quint32, VDetail> *VContainer::DataDetails() const
{
return &d->details;
return d->details.data();
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -79,13 +79,18 @@ public:
VContainerData(const VTranslateVars *trVars, const Unit *patternUnit)
: gObjects(QHash<quint32, QSharedPointer<VGObject> >()),
variables(QHash<QString, QSharedPointer<VInternalVariable> > ()), details(QHash<quint32, VDetail>()),
variables(QHash<QString, QSharedPointer<VInternalVariable> > ()),
details(QSharedPointer<QHash<quint32, VDetail>>(new QHash<quint32, VDetail>())),
trVars(trVars), patternUnit(patternUnit)
{}
VContainerData(const VContainerData &data)
:QSharedData(data), gObjects(data.gObjects),
variables(data.variables), details(data.details), trVars(data.trVars), patternUnit(data.patternUnit)
: QSharedData(data),
gObjects(data.gObjects),
variables(data.variables),
details(data.details),
trVars(data.trVars),
patternUnit(data.patternUnit)
{}
virtual ~VContainerData();
@ -102,7 +107,7 @@ public:
/**
* @brief details container of details
*/
QHash<quint32, VDetail> details;
QSharedPointer<QHash<quint32, VDetail>> details;
const VTranslateVars *trVars;
const Unit *patternUnit;

View File

@ -76,6 +76,7 @@
#include "../undocommands/deletedetail.h"
#include "../undocommands/movedetail.h"
#include "../undocommands/savedetailoptions.h"
#include "../undocommands/toggledetailinlayout.h"
#include "../vgeometry/varc.h"
#include "../vgeometry/vcubicbezier.h"
#include "../vgeometry/vcubicbezierpath.h"
@ -731,15 +732,15 @@ void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
QMenu menu;
QAction *actionOption = menu.addAction(QIcon::fromTheme("preferences-other"), tr("Options"));
QAction *inLayoutOption = menu.addAction(tr("In layout"));
inLayoutOption->setCheckable(true);
const VDetail detail = VAbstractTool::data.GetDetail(id);
inLayoutOption->setChecked(detail.IsInLayout());
QAction *actionRemove = menu.addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));
if (_referens > 1)
{
actionRemove->setEnabled(false);
}
else
{
actionRemove->setEnabled(true);
}
_referens > 1 ? actionRemove->setEnabled(false) : actionRemove->setEnabled(true);
QAction *selectedAction = menu.exec(event->screenPos());
if (selectedAction == actionOption)
{
@ -751,6 +752,13 @@ void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
setDialog();
dialog->show();
}
else if (selectedAction == inLayoutOption)
{
ToggleDetailInLayout *togglePrint = new ToggleDetailInLayout(id, selectedAction->isChecked(),
&(VAbstractTool::data), doc);
connect(togglePrint, &ToggleDetailInLayout::UpdateList, doc, &VAbstractPattern::CheckInLayoutList);
qApp->getUndoStack()->push(togglePrint);
}
else if (selectedAction == actionRemove)
{
try