Organization of groups - groups categories. Closes smart-pattern/valentina#15.
This commit is contained in:
parent
a84857afda
commit
c1453f1715
|
@ -46,6 +46,7 @@
|
||||||
- [smart-pattern/valentina#18] Auto-created Visibility Group for group operation.
|
- [smart-pattern/valentina#18] Auto-created Visibility Group for group operation.
|
||||||
- Setting scale factor for export and print.
|
- Setting scale factor for export and print.
|
||||||
- New layout generator option: Prefer one sheet solution.
|
- New layout generator option: Prefer one sheet solution.
|
||||||
|
- [smart-pattern/valentina#15] Organization of groups - groups categories
|
||||||
|
|
||||||
# Version 0.6.2 (unreleased)
|
# Version 0.6.2 (unreleased)
|
||||||
- [#903] Bug in tool Cut Spline path.
|
- [#903] Bug in tool Cut Spline path.
|
||||||
|
|
|
@ -31,7 +31,9 @@
|
||||||
#include "../vtools/dialogs/tools/dialoggroup.h"
|
#include "../vtools/dialogs/tools/dialoggroup.h"
|
||||||
#include "../vtools/undocommands/undogroup.h"
|
#include "../vtools/undocommands/undogroup.h"
|
||||||
#include "../vpatterndb/vcontainer.h"
|
#include "../vpatterndb/vcontainer.h"
|
||||||
|
#include "../vmisc/compatibility.h"
|
||||||
|
|
||||||
|
#include <QCompleter>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QTableWidget>
|
#include <QTableWidget>
|
||||||
|
|
||||||
|
@ -51,6 +53,7 @@ VWidgetGroups::VWidgetGroups(VAbstractPattern *doc, QWidget *parent)
|
||||||
connect(ui->tableWidget, &QTableWidget::cellClicked, this, &VWidgetGroups::GroupVisibilityChanged);
|
connect(ui->tableWidget, &QTableWidget::cellClicked, this, &VWidgetGroups::GroupVisibilityChanged);
|
||||||
connect(ui->tableWidget, &QTableWidget::cellChanged, this, &VWidgetGroups::RenameGroup);
|
connect(ui->tableWidget, &QTableWidget::cellChanged, this, &VWidgetGroups::RenameGroup);
|
||||||
connect(ui->tableWidget, &QTableWidget::customContextMenuRequested, this, &VWidgetGroups::CtxMenu);
|
connect(ui->tableWidget, &QTableWidget::customContextMenuRequested, this, &VWidgetGroups::CtxMenu);
|
||||||
|
connect(ui->lineEditTags, &QLineEdit::textChanged, this, &VWidgetGroups::UpdateGroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -110,6 +113,32 @@ void VWidgetGroups::SetMultipleGroupsVisibility(const QVector<vidtype> &groups,
|
||||||
qApp->getUndoStack()->push(changeGroups);
|
qApp->getUndoStack()->push(changeGroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QMap<quint32, VGroupData> VWidgetGroups::FilterGroups(const QMap<quint32, VGroupData> &groups)
|
||||||
|
{
|
||||||
|
QMap<quint32, VGroupData> filtered;
|
||||||
|
QSet<QString> filterCategories = ConvertToSet<QString>(VAbstractPattern::FilterGroupTags(ui->lineEditTags->text()));
|
||||||
|
|
||||||
|
if (filterCategories.isEmpty())
|
||||||
|
{
|
||||||
|
return groups;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto i = groups.constBegin();
|
||||||
|
while (i != groups.constEnd())
|
||||||
|
{
|
||||||
|
const VGroupData &data = i.value();
|
||||||
|
QSet<QString> groupCategories = ConvertToSet<QString>(data.tags);
|
||||||
|
if (SetIntersects(filterCategories, groupCategories))
|
||||||
|
{
|
||||||
|
filtered.insert(i.key(), data);
|
||||||
|
}
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return filtered;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
int VWidgetGroups::GroupRow(vidtype id) const
|
int VWidgetGroups::GroupRow(vidtype id) const
|
||||||
{
|
{
|
||||||
|
@ -185,7 +214,7 @@ void VWidgetGroups::CtxMenu(const QPoint &pos)
|
||||||
menu->addAction(QIcon(QStringLiteral("://icon/16x16/closed_eye.png")), tr("Hide")) :
|
menu->addAction(QIcon(QStringLiteral("://icon/16x16/closed_eye.png")), tr("Hide")) :
|
||||||
menu->addAction(QIcon(QStringLiteral("://icon/16x16/open_eye.png")), tr("Show"));
|
menu->addAction(QIcon(QStringLiteral("://icon/16x16/open_eye.png")), tr("Show"));
|
||||||
|
|
||||||
QAction *actionRename = menu->addAction(tr("Rename"));
|
QAction *actionPreferences = menu->addAction(QIcon::fromTheme(preferencesOtherIcon), tr("Preferences"));
|
||||||
QAction *actionDelete = menu->addAction(QIcon::fromTheme(editDeleteIcon), tr("Delete"));
|
QAction *actionDelete = menu->addAction(QIcon::fromTheme(editDeleteIcon), tr("Delete"));
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
QAction *actionHideAll = menu->addAction(tr("Hide All"));
|
QAction *actionHideAll = menu->addAction(tr("Hide All"));
|
||||||
|
@ -199,19 +228,22 @@ void VWidgetGroups::CtxMenu(const QPoint &pos)
|
||||||
{
|
{
|
||||||
SetGroupVisibility(id, not doc->GetGroupVisibility(id));
|
SetGroupVisibility(id, not doc->GetGroupVisibility(id));
|
||||||
}
|
}
|
||||||
else if (selectedAction == actionRename)
|
else if (selectedAction == actionPreferences)
|
||||||
{
|
{
|
||||||
QScopedPointer<VContainer> fackeContainer(new VContainer(qApp->TrVars(), qApp->patternUnitP(),
|
QScopedPointer<VContainer> fackeContainer(new VContainer(qApp->TrVars(), qApp->patternUnitP(),
|
||||||
VContainer::UniqueNamespace()));
|
VContainer::UniqueNamespace()));
|
||||||
QScopedPointer<DialogGroup> dialog(new DialogGroup(fackeContainer.data(), NULL_ID, this));
|
QScopedPointer<DialogGroup> dialog(new DialogGroup(fackeContainer.data(), NULL_ID, this));
|
||||||
dialog->SetName(doc->GetGroupName(id));
|
dialog->SetName(doc->GetGroupName(id));
|
||||||
|
dialog->SetTags(doc->GetGroupTags(id));
|
||||||
|
dialog->SetGroupCategories(doc->GetGroupCategories());
|
||||||
const int result = dialog->exec();
|
const int result = dialog->exec();
|
||||||
|
|
||||||
if (result == QDialog::Accepted)
|
if (result == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
::RenameGroup *renameGroup = new ::RenameGroup(doc, id, dialog->GetName());
|
ChangeGroupOptions *changeGroupOptions = new ChangeGroupOptions(doc, id, dialog->GetName(),
|
||||||
connect(renameGroup, &RenameGroup::UpdateGroups, this, &VWidgetGroups::UpdateGroups);
|
dialog->GetTags());
|
||||||
qApp->getUndoStack()->push(renameGroup);
|
connect(changeGroupOptions, &ChangeGroupOptions::UpdateGroups, this, &VWidgetGroups::UpdateGroups);
|
||||||
|
qApp->getUndoStack()->push(changeGroupOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (selectedAction == actionDelete)
|
else if (selectedAction == actionDelete)
|
||||||
|
@ -277,9 +309,13 @@ void VWidgetGroups::UpdateGroups()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VWidgetGroups::FillTable(const QMap<quint32, QPair<QString, bool> > &groups)
|
void VWidgetGroups::FillTable(QMap<quint32, VGroupData> groups)
|
||||||
{
|
{
|
||||||
emit doc->UpdateToolTip();
|
emit doc->UpdateToolTip();
|
||||||
|
ui->lineEditTags->SetCompletion(doc->GetGroupCategories());
|
||||||
|
|
||||||
|
groups = FilterGroups(groups);
|
||||||
|
|
||||||
ui->tableWidget->blockSignals(true);
|
ui->tableWidget->blockSignals(true);
|
||||||
ui->tableWidget->clear();
|
ui->tableWidget->clear();
|
||||||
|
|
||||||
|
@ -290,11 +326,11 @@ void VWidgetGroups::FillTable(const QMap<quint32, QPair<QString, bool> > &groups
|
||||||
while (i != groups.constEnd())
|
while (i != groups.constEnd())
|
||||||
{
|
{
|
||||||
++currentRow;
|
++currentRow;
|
||||||
const QPair<QString, bool> data = i.value();
|
const VGroupData data = i.value();
|
||||||
|
|
||||||
QTableWidgetItem *item = new QTableWidgetItem();
|
QTableWidgetItem *item = new QTableWidgetItem();
|
||||||
item->setTextAlignment(Qt::AlignHCenter);
|
item->setTextAlignment(Qt::AlignHCenter);
|
||||||
(data.second) ? item->setIcon(QIcon("://icon/16x16/open_eye.png"))
|
(data.visible) ? item->setIcon(QIcon("://icon/16x16/open_eye.png"))
|
||||||
: item->setIcon(QIcon("://icon/16x16/closed_eye.png"));
|
: item->setIcon(QIcon("://icon/16x16/closed_eye.png"));
|
||||||
|
|
||||||
item->setData(Qt::UserRole, i.key());
|
item->setData(Qt::UserRole, i.key());
|
||||||
|
@ -306,8 +342,9 @@ void VWidgetGroups::FillTable(const QMap<quint32, QPair<QString, bool> > &groups
|
||||||
|
|
||||||
ui->tableWidget->setItem(currentRow, 0, item);
|
ui->tableWidget->setItem(currentRow, 0, item);
|
||||||
|
|
||||||
item = new QTableWidgetItem(data.first);
|
item = new QTableWidgetItem(data.name);
|
||||||
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
|
item->setToolTip(tr("Categories: %1.").arg(data.tags.join(", ")));
|
||||||
|
|
||||||
if(doc->GroupIsEmpty(i.key()))
|
if(doc->GroupIsEmpty(i.key()))
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
|
|
||||||
class QTableWidgetItem;
|
class QTableWidgetItem;
|
||||||
class VAbstractPattern;
|
class VAbstractPattern;
|
||||||
|
struct VGroupData;
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
|
@ -61,10 +62,12 @@ private:
|
||||||
Ui::VWidgetGroups *ui;
|
Ui::VWidgetGroups *ui;
|
||||||
VAbstractPattern *doc;
|
VAbstractPattern *doc;
|
||||||
|
|
||||||
void FillTable(const QMap<quint32, QPair<QString, bool> > &groups);
|
void FillTable(QMap<quint32, VGroupData> groups);
|
||||||
void SetGroupVisibility(vidtype id, bool visible) const;
|
void SetGroupVisibility(vidtype id, bool visible) const;
|
||||||
void SetMultipleGroupsVisibility(const QVector<vidtype> &groups, bool visible) const;
|
void SetMultipleGroupsVisibility(const QVector<vidtype> &groups, bool visible) const;
|
||||||
|
|
||||||
|
QMap<quint32, VGroupData> FilterGroups(const QMap<quint32, VGroupData> &groups);
|
||||||
|
|
||||||
int GroupRow(vidtype id) const;
|
int GroupRow(vidtype id) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>371</width>
|
<width>371</width>
|
||||||
<height>279</height>
|
<height>438</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -18,6 +18,30 @@
|
||||||
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
|
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Tags:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="VCompleterLineEdit" name="lineEditTags">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Separate each tag with comma.</string>
|
||||||
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Filter by tags</string>
|
||||||
|
</property>
|
||||||
|
<property name="clearButtonEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTableWidget" name="tableWidget">
|
<widget class="QTableWidget" name="tableWidget">
|
||||||
<property name="alternatingRowColors">
|
<property name="alternatingRowColors">
|
||||||
|
@ -47,16 +71,23 @@
|
||||||
<attribute name="verticalHeaderVisible">
|
<attribute name="verticalHeaderVisible">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="verticalHeaderHighlightSections">
|
|
||||||
<bool>false</bool>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="verticalHeaderMinimumSectionSize">
|
<attribute name="verticalHeaderMinimumSectionSize">
|
||||||
<number>10</number>
|
<number>10</number>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<attribute name="verticalHeaderHighlightSections">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>VCompleterLineEdit</class>
|
||||||
|
<extends>QLineEdit</extends>
|
||||||
|
<header>vlineedit.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../../../libs/vmisc/share/resources/icon.qrc"/>
|
<include location="../../../libs/vmisc/share/resources/icon.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -648,6 +648,11 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons
|
||||||
case Tool::PlaceLabel:
|
case Tool::PlaceLabel:
|
||||||
dialogTool->SetPiecesList(doc->GetActivePPPieces());
|
dialogTool->SetPiecesList(doc->GetActivePPPieces());
|
||||||
break;
|
break;
|
||||||
|
case Tool::Rotation:
|
||||||
|
case Tool::Move:
|
||||||
|
case Tool::FlippingByAxis:
|
||||||
|
case Tool::FlippingByLine:
|
||||||
|
dialogTool->SetGroupCategories(doc->GetGroupCategories());
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1241,7 +1246,8 @@ void MainWindow::ClosedDialogGroup(int result)
|
||||||
{
|
{
|
||||||
const QPointer<DialogGroup> dialog = qobject_cast<DialogGroup *>(dialogTool);
|
const QPointer<DialogGroup> dialog = qobject_cast<DialogGroup *>(dialogTool);
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
const QDomElement group = doc->CreateGroup(pattern->getNextId(), dialog->GetName(), dialog->GetGroup());
|
const QDomElement group = doc->CreateGroup(pattern->getNextId(), dialog->GetName(), dialog->GetTags(),
|
||||||
|
dialog->GetGroup());
|
||||||
if (not group.isNull())
|
if (not group.isNull())
|
||||||
{
|
{
|
||||||
AddGroup *addGroup = new AddGroup(group, doc);
|
AddGroup *addGroup = new AddGroup(group, doc);
|
||||||
|
|
|
@ -800,6 +800,7 @@
|
||||||
<xs:attribute name="name" type="xs:string"/>
|
<xs:attribute name="name" type="xs:string"/>
|
||||||
<xs:attribute name="visible" type="xs:boolean"/>
|
<xs:attribute name="visible" type="xs:boolean"/>
|
||||||
<xs:attribute name="tool" type="xs:unsignedInt"/>
|
<xs:attribute name="tool" type="xs:unsignedInt"/>
|
||||||
|
<xs:attribute name="tags" type="xs:string"/>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
</xs:sequence>
|
</xs:sequence>
|
||||||
|
|
|
@ -136,6 +136,7 @@ const QString VAbstractPattern::AttrCheckUniqueness = QStringLiteral("checkUni
|
||||||
const QString VAbstractPattern::AttrManualPassmarkLength = QStringLiteral("manualPassmarkLength");
|
const QString VAbstractPattern::AttrManualPassmarkLength = QStringLiteral("manualPassmarkLength");
|
||||||
const QString VAbstractPattern::AttrPassmarkLength = QStringLiteral("passmarkLength");
|
const QString VAbstractPattern::AttrPassmarkLength = QStringLiteral("passmarkLength");
|
||||||
const QString VAbstractPattern::AttrOpacity = QStringLiteral("opacity");
|
const QString VAbstractPattern::AttrOpacity = QStringLiteral("opacity");
|
||||||
|
const QString VAbstractPattern::AttrTags = QStringLiteral("tags");
|
||||||
|
|
||||||
const QString VAbstractPattern::AttrAll = QStringLiteral("all");
|
const QString VAbstractPattern::AttrAll = QStringLiteral("all");
|
||||||
|
|
||||||
|
@ -283,6 +284,17 @@ QMap<int, QString> AdjustMaterials(QMap<int, QString> materials)
|
||||||
|
|
||||||
return materials;
|
return materials;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString PrepareGroupTags(QStringList tags)
|
||||||
|
{
|
||||||
|
for (auto &tag : tags)
|
||||||
|
{
|
||||||
|
tag = tag.simplified();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ConvertToList(ConvertToSet<QString>(tags)).join(',');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -2428,19 +2440,22 @@ QDomElement VAbstractPattern::CreateGroups()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QDomElement VAbstractPattern::CreateGroup(quint32 id, const QString &name, const QMap<quint32, quint32> &groupData,
|
QDomElement VAbstractPattern::CreateGroup(quint32 id, const QString &name, const QStringList &tags,
|
||||||
vidtype tool)
|
const QMap<quint32, quint32> &groupData, vidtype tool)
|
||||||
{
|
{
|
||||||
if (id == NULL_ID || groupData.isEmpty())
|
if (id == NULL_ID || groupData.isEmpty())
|
||||||
{
|
{
|
||||||
return QDomElement();
|
return QDomElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString preparedTags = PrepareGroupTags(tags);
|
||||||
|
|
||||||
QDomElement group = createElement(TagGroup);
|
QDomElement group = createElement(TagGroup);
|
||||||
SetAttribute(group, AttrId, id);
|
SetAttribute(group, AttrId, id);
|
||||||
SetAttribute(group, AttrName, name);
|
SetAttribute(group, AttrName, name);
|
||||||
SetAttribute(group, AttrVisible, true);
|
SetAttribute(group, AttrVisible, true);
|
||||||
SetAttributeOrRemoveIf(group, AttrTool, tool, tool == null_id);
|
SetAttributeOrRemoveIf(group, AttrTool, tool, tool == null_id);
|
||||||
|
SetAttributeOrRemoveIf(group, AttrTags, preparedTags, preparedTags.isEmpty());
|
||||||
|
|
||||||
auto i = groupData.constBegin();
|
auto i = groupData.constBegin();
|
||||||
while (i != groupData.constEnd())
|
while (i != groupData.constEnd())
|
||||||
|
@ -2502,9 +2517,54 @@ void VAbstractPattern::SetGroupName(quint32 id, const QString &name)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QMap<quint32, QPair<QString, bool> > VAbstractPattern::GetGroups()
|
QStringList VAbstractPattern::GetGroupTags(vidtype id)
|
||||||
{
|
{
|
||||||
QMap<quint32, QPair<QString, bool> > data;
|
QStringList tags;
|
||||||
|
QDomElement group = elementById(id, TagGroup);
|
||||||
|
if (group.isElement())
|
||||||
|
{
|
||||||
|
tags = FilterGroupTags(GetParametrEmptyString(group, AttrTags));
|
||||||
|
}
|
||||||
|
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VAbstractPattern::SetGroupTags(quint32 id, const QStringList &tags)
|
||||||
|
{
|
||||||
|
QDomElement group = elementById(id, TagGroup);
|
||||||
|
if (group.isElement())
|
||||||
|
{
|
||||||
|
const QString rawTags = tags.join(',');
|
||||||
|
SetAttributeOrRemoveIf(group, AttrTags, rawTags, rawTags.isEmpty());
|
||||||
|
modified = true;
|
||||||
|
emit patternChanged(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QStringList VAbstractPattern::GetGroupCategories() const
|
||||||
|
{
|
||||||
|
QSet<QString> categories;
|
||||||
|
|
||||||
|
const QDomNodeList groups = elementsByTagName(TagGroup);
|
||||||
|
for (int i=0; i < groups.size(); ++i)
|
||||||
|
{
|
||||||
|
const QDomElement group = groups.at(i).toElement();
|
||||||
|
if (not group.isNull() && group.hasAttribute(AttrTags))
|
||||||
|
{
|
||||||
|
QStringList groupTags = VAbstractPattern::FilterGroupTags(GetParametrEmptyString(group, AttrTags));
|
||||||
|
categories.unite(ConvertToSet<QString>(groupTags));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ConvertToList(categories);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QMap<quint32, VGroupData> VAbstractPattern::GetGroups()
|
||||||
|
{
|
||||||
|
QMap<quint32, VGroupData> data;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -2521,11 +2581,13 @@ QMap<quint32, QPair<QString, bool> > VAbstractPattern::GetGroups()
|
||||||
{
|
{
|
||||||
if (group.tagName() == TagGroup)
|
if (group.tagName() == TagGroup)
|
||||||
{
|
{
|
||||||
|
VGroupData groupData;
|
||||||
const quint32 id = GetParametrUInt(group, AttrId, QChar('0'));
|
const quint32 id = GetParametrUInt(group, AttrId, QChar('0'));
|
||||||
const bool visible = GetParametrBool(group, AttrVisible, trueStr);
|
groupData.visible = GetParametrBool(group, AttrVisible, trueStr);
|
||||||
const QString name = GetParametrString(group, AttrName, tr("New group"));
|
groupData.name = GetParametrString(group, AttrName, tr("New group"));
|
||||||
|
groupData.tags = FilterGroupTags(GetParametrEmptyString(group, AttrTags));
|
||||||
|
|
||||||
data.insert(id, qMakePair(name, visible));
|
data.insert(id, groupData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2539,7 +2601,7 @@ QMap<quint32, QPair<QString, bool> > VAbstractPattern::GetGroups()
|
||||||
}
|
}
|
||||||
catch (const VExceptionConversionError &)
|
catch (const VExceptionConversionError &)
|
||||||
{
|
{
|
||||||
return QMap<quint32, QPair<QString, bool> >();
|
return QMap<quint32, VGroupData>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
@ -2796,3 +2858,22 @@ QString VAbstractPattern::PieceDrawName(quint32 id)
|
||||||
|
|
||||||
return draw.attribute(VAbstractPattern::AttrName);
|
return draw.attribute(VAbstractPattern::AttrName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QStringList VAbstractPattern::FilterGroupTags(const QString &tags)
|
||||||
|
{
|
||||||
|
if (tags.isEmpty())
|
||||||
|
{
|
||||||
|
return QStringList();
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList list = tags.split(',');
|
||||||
|
for (auto &tag : list)
|
||||||
|
{
|
||||||
|
tag = tag.simplified();
|
||||||
|
}
|
||||||
|
|
||||||
|
list.removeAll("");
|
||||||
|
|
||||||
|
return ConvertToList(ConvertToSet<QString>(list));
|
||||||
|
}
|
||||||
|
|
|
@ -78,6 +78,13 @@ struct VFinalMeasurement
|
||||||
QString description;
|
QString description;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct VGroupData
|
||||||
|
{
|
||||||
|
QString name{};
|
||||||
|
bool visible{true};
|
||||||
|
QStringList tags{};
|
||||||
|
};
|
||||||
|
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
|
|
||||||
class VAbstractPattern : public VDomDocument
|
class VAbstractPattern : public VDomDocument
|
||||||
|
@ -200,18 +207,27 @@ public:
|
||||||
|
|
||||||
void ParseGroups(const QDomElement &domElement);
|
void ParseGroups(const QDomElement &domElement);
|
||||||
QDomElement CreateGroups();
|
QDomElement CreateGroups();
|
||||||
QDomElement CreateGroup(quint32 id, const QString &name, const QMap<quint32, quint32> &groupData,
|
QDomElement CreateGroup(quint32 id, const QString &name, const QStringList &tags,
|
||||||
vidtype tool=null_id);
|
const QMap<quint32, quint32> &groupData, vidtype tool=null_id);
|
||||||
vidtype GroupLinkedToTool(vidtype toolId) const;
|
vidtype GroupLinkedToTool(vidtype toolId) const;
|
||||||
|
|
||||||
QString GetGroupName(quint32 id);
|
QString GetGroupName(quint32 id);
|
||||||
void SetGroupName(quint32 id, const QString &name);
|
void SetGroupName(quint32 id, const QString &name);
|
||||||
QMap<quint32, QPair<QString, bool> > GetGroups();
|
|
||||||
|
QStringList GetGroupTags(vidtype id);
|
||||||
|
void SetGroupTags(quint32 id, const QStringList &tags);
|
||||||
|
|
||||||
|
QStringList GetGroupCategories() const;
|
||||||
|
|
||||||
|
QMap<quint32, VGroupData> GetGroups();
|
||||||
QMap<quint32, QString> GetGroupsContainingItem(quint32 toolId, quint32 objectId, bool containItem);
|
QMap<quint32, QString> GetGroupsContainingItem(quint32 toolId, quint32 objectId, bool containItem);
|
||||||
QDomElement AddItemToGroup(quint32 toolId, quint32 objectId, quint32 groupId);
|
QDomElement AddItemToGroup(quint32 toolId, quint32 objectId, quint32 groupId);
|
||||||
QDomElement RemoveItemFromGroup(quint32 toolId, quint32 objectId, quint32 groupId);
|
QDomElement RemoveItemFromGroup(quint32 toolId, quint32 objectId, quint32 groupId);
|
||||||
bool GroupIsEmpty(quint32 id);
|
bool GroupIsEmpty(quint32 id);
|
||||||
bool GetGroupVisibility(quint32 id);
|
bool GetGroupVisibility(quint32 id);
|
||||||
|
|
||||||
|
static QStringList FilterGroupTags(const QString &tags);
|
||||||
|
|
||||||
QString PieceDrawName(quint32 id);
|
QString PieceDrawName(quint32 id);
|
||||||
|
|
||||||
static const QString TagPattern;
|
static const QString TagPattern;
|
||||||
|
@ -290,6 +306,7 @@ public:
|
||||||
static const QString AttrManualPassmarkLength;
|
static const QString AttrManualPassmarkLength;
|
||||||
static const QString AttrPassmarkLength;
|
static const QString AttrPassmarkLength;
|
||||||
static const QString AttrOpacity;
|
static const QString AttrOpacity;
|
||||||
|
static const QString AttrTags;
|
||||||
|
|
||||||
static const QString AttrAll;
|
static const QString AttrAll;
|
||||||
|
|
||||||
|
|
|
@ -195,4 +195,27 @@ inline void AppendTo(Cont &container, const Input &input)
|
||||||
#endif // QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
|
#endif // QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
template <typename T>
|
||||||
|
inline bool SetIntersects(const QSet<T> &set1, const QSet<T> &set2)
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
||||||
|
return set1.intersects(set2);
|
||||||
|
#else
|
||||||
|
const bool otherIsBigger = set2.size() > set1.size();
|
||||||
|
const QSet<T> &smallestSet = otherIsBigger ? set1 : set2;
|
||||||
|
const QSet<T> &biggestSet = otherIsBigger ? set2 : set1;
|
||||||
|
typename QSet<T>::const_iterator i = smallestSet.cbegin();
|
||||||
|
typename QSet<T>::const_iterator e = smallestSet.cend();
|
||||||
|
while (i != e)
|
||||||
|
{
|
||||||
|
if (biggestSet.contains(*i))
|
||||||
|
return true;
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#endif // COMPATIBILITY_H
|
#endif // COMPATIBILITY_H
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
#include <QCompleter>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
@ -173,6 +174,25 @@ void DialogFlippingByAxis::SetHasLinkedVisibilityGroup(bool linked)
|
||||||
ui->groupBoxVisibilityGroup->setChecked(linked);
|
ui->groupBoxVisibilityGroup->setChecked(linked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogFlippingByAxis::SetVisibilityGroupTags(const QStringList &tags)
|
||||||
|
{
|
||||||
|
ui->lineEditGroupTags->setText(tags.join(", "));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QStringList DialogFlippingByAxis::GetVisibilityGroupTags() const
|
||||||
|
{
|
||||||
|
return ui->lineEditGroupTags->text().split(',');
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogFlippingByAxis::SetGroupCategories(const QStringList &categories)
|
||||||
|
{
|
||||||
|
m_groupTags = categories;
|
||||||
|
ui->lineEditGroupTags->SetCompletion(m_groupTags);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogFlippingByAxis::ShowDialog(bool click)
|
void DialogFlippingByAxis::ShowDialog(bool click)
|
||||||
{
|
{
|
||||||
|
@ -342,6 +362,18 @@ void DialogFlippingByAxis::SaveData()
|
||||||
operation->SetOriginPointId(GetOriginPointId());
|
operation->SetOriginPointId(GetOriginPointId());
|
||||||
operation->SetAxisType(GetAxisType());
|
operation->SetAxisType(GetAxisType());
|
||||||
operation->RefreshGeometry();
|
operation->RefreshGeometry();
|
||||||
|
|
||||||
|
QStringList groupTags = ui->lineEditGroupTags->text().split(',');
|
||||||
|
for (auto &tag : groupTags)
|
||||||
|
{
|
||||||
|
tag = tag.trimmed();
|
||||||
|
if (not m_groupTags.contains(tag))
|
||||||
|
{
|
||||||
|
m_groupTags.append(tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->lineEditGroupTags->SetCompletion(m_groupTags);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -71,6 +71,11 @@ public:
|
||||||
bool HasLinkedVisibilityGroup() const;
|
bool HasLinkedVisibilityGroup() const;
|
||||||
void SetHasLinkedVisibilityGroup(bool linked);
|
void SetHasLinkedVisibilityGroup(bool linked);
|
||||||
|
|
||||||
|
void SetVisibilityGroupTags(const QStringList &tags);
|
||||||
|
QStringList GetVisibilityGroupTags() const;
|
||||||
|
|
||||||
|
virtual void SetGroupCategories(const QStringList &categories) override;
|
||||||
|
|
||||||
virtual void ShowDialog(bool click) override;
|
virtual void ShowDialog(bool click) override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -106,6 +111,8 @@ private:
|
||||||
bool flagGroupName;
|
bool flagGroupName;
|
||||||
bool flagError;
|
bool flagError;
|
||||||
|
|
||||||
|
QStringList m_groupTags{};
|
||||||
|
|
||||||
static void FillComboBoxAxisType(QComboBox *box);
|
static void FillComboBoxAxisType(QComboBox *box);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>304</width>
|
<width>304</width>
|
||||||
<height>207</height>
|
<height>237</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -62,15 +62,15 @@
|
||||||
<property name="checked">
|
<property name="checked">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item>
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="labelGroupName">
|
<widget class="QLabel" name="labelGroupName">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Name:</string>
|
<string>Name:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="0" column="1">
|
||||||
<widget class="QLineEdit" name="lineEditVisibilityGroup">
|
<widget class="QLineEdit" name="lineEditVisibilityGroup">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Flipping by axis</string>
|
<string>Flipping by axis</string>
|
||||||
|
@ -80,6 +80,26 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Tags:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="VCompleterLineEdit" name="lineEditGroupTags">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Separate each tag with comma.</string>
|
||||||
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Add tags</string>
|
||||||
|
</property>
|
||||||
|
<property name="clearButtonEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -95,6 +115,13 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>VCompleterLineEdit</class>
|
||||||
|
<extends>QLineEdit</extends>
|
||||||
|
<header>vlineedit.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
#include <QCompleter>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
@ -168,6 +169,25 @@ void DialogFlippingByLine::SetHasLinkedVisibilityGroup(bool linked)
|
||||||
ui->groupBoxVisibilityGroup->setChecked(linked);
|
ui->groupBoxVisibilityGroup->setChecked(linked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogFlippingByLine::SetVisibilityGroupTags(const QStringList &tags)
|
||||||
|
{
|
||||||
|
ui->lineEditGroupTags->setText(tags.join(", "));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QStringList DialogFlippingByLine::GetVisibilityGroupTags() const
|
||||||
|
{
|
||||||
|
return ui->lineEditGroupTags->text().split(',');
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogFlippingByLine::SetGroupCategories(const QStringList &categories)
|
||||||
|
{
|
||||||
|
m_groupTags = categories;
|
||||||
|
ui->lineEditGroupTags->SetCompletion(m_groupTags);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogFlippingByLine::ShowDialog(bool click)
|
void DialogFlippingByLine::ShowDialog(bool click)
|
||||||
{
|
{
|
||||||
|
@ -366,6 +386,18 @@ void DialogFlippingByLine::SaveData()
|
||||||
operation->SetFirstLinePointId(GetFirstLinePointId());
|
operation->SetFirstLinePointId(GetFirstLinePointId());
|
||||||
operation->SetSecondLinePointId(GetSecondLinePointId());
|
operation->SetSecondLinePointId(GetSecondLinePointId());
|
||||||
operation->RefreshGeometry();
|
operation->RefreshGeometry();
|
||||||
|
|
||||||
|
QStringList groupTags = ui->lineEditGroupTags->text().split(',');
|
||||||
|
for (auto &tag : groupTags)
|
||||||
|
{
|
||||||
|
tag = tag.trimmed();
|
||||||
|
if (not m_groupTags.contains(tag))
|
||||||
|
{
|
||||||
|
m_groupTags.append(tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->lineEditGroupTags->SetCompletion(m_groupTags);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -71,6 +71,11 @@ public:
|
||||||
bool HasLinkedVisibilityGroup() const;
|
bool HasLinkedVisibilityGroup() const;
|
||||||
void SetHasLinkedVisibilityGroup(bool linked);
|
void SetHasLinkedVisibilityGroup(bool linked);
|
||||||
|
|
||||||
|
void SetVisibilityGroupTags(const QStringList &tags);
|
||||||
|
QStringList GetVisibilityGroupTags() const;
|
||||||
|
|
||||||
|
virtual void SetGroupCategories(const QStringList &categories) override;
|
||||||
|
|
||||||
virtual void ShowDialog(bool click) override;
|
virtual void ShowDialog(bool click) override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -105,6 +110,8 @@ private:
|
||||||
bool flagName;
|
bool flagName;
|
||||||
bool flagGroupName;
|
bool flagGroupName;
|
||||||
bool flagError;
|
bool flagError;
|
||||||
|
|
||||||
|
QStringList m_groupTags{};
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>304</width>
|
<width>304</width>
|
||||||
<height>207</height>
|
<height>237</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -66,15 +66,15 @@
|
||||||
<property name="checked">
|
<property name="checked">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item>
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="labelGroupName">
|
<widget class="QLabel" name="labelGroupName">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Name:</string>
|
<string>Name:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="0" column="1">
|
||||||
<widget class="QLineEdit" name="lineEditVisibilityGroup">
|
<widget class="QLineEdit" name="lineEditVisibilityGroup">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Flipping by line</string>
|
<string>Flipping by line</string>
|
||||||
|
@ -84,6 +84,26 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Tags:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="VCompleterLineEdit" name="lineEditGroupTags">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Separate each tag with comma.</string>
|
||||||
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Add tags</string>
|
||||||
|
</property>
|
||||||
|
<property name="clearButtonEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -99,6 +119,13 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>VCompleterLineEdit</class>
|
||||||
|
<extends>QLineEdit</extends>
|
||||||
|
<header>vlineedit.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../../../vmisc/share/resources/icon.qrc"/>
|
<include location="../../../vmisc/share/resources/icon.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include "dialoggroup.h"
|
#include "dialoggroup.h"
|
||||||
|
|
||||||
|
#include <QCompleter>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
|
||||||
#include "ui_dialoggroup.h"
|
#include "ui_dialoggroup.h"
|
||||||
|
@ -63,6 +64,24 @@ QString DialogGroup::GetName() const
|
||||||
return ui->lineEditName->text();
|
return ui->lineEditName->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogGroup::SetTags(const QStringList &tags)
|
||||||
|
{
|
||||||
|
ui->lineEditTags->setText(tags.join(", "));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QStringList DialogGroup::GetTags() const
|
||||||
|
{
|
||||||
|
return ui->lineEditTags->text().split(",");
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogGroup::SetGroupCategories(const QStringList &categories)
|
||||||
|
{
|
||||||
|
ui->lineEditTags->SetCompletion(categories);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogGroup::ShowDialog(bool click)
|
void DialogGroup::ShowDialog(bool click)
|
||||||
{
|
{
|
||||||
|
|
|
@ -54,6 +54,11 @@ public:
|
||||||
void SetName(const QString &name);
|
void SetName(const QString &name);
|
||||||
QString GetName() const;
|
QString GetName() const;
|
||||||
|
|
||||||
|
void SetTags(const QStringList &tags);
|
||||||
|
QStringList GetTags() const;
|
||||||
|
|
||||||
|
void SetGroupCategories(const QStringList &categories);
|
||||||
|
|
||||||
QMap<quint32, quint32> GetGroup() const;
|
QMap<quint32, quint32> GetGroup() const;
|
||||||
|
|
||||||
virtual void ShowDialog(bool click) override;
|
virtual void ShowDialog(bool click) override;
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>397</width>
|
<width>294</width>
|
||||||
<height>80</height>
|
<height>104</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -19,22 +19,45 @@
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item>
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Group name:</string>
|
<string>Group name:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="0" column="1">
|
||||||
<widget class="QLineEdit" name="lineEditName">
|
<widget class="QLineEdit" name="lineEditName">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Unique pattern piece name</string>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="placeholderText">
|
<property name="placeholderText">
|
||||||
<string>Choose group name</string>
|
<string>Choose group name</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="clearButtonEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Tags:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="VCompleterLineEdit" name="lineEditTags">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Separate each tag with comma.</string>
|
||||||
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Add tags</string>
|
||||||
|
</property>
|
||||||
|
<property name="clearButtonEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -51,6 +74,13 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>VCompleterLineEdit</class>
|
||||||
|
<extends>QLineEdit</extends>
|
||||||
|
<header>vlineedit.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../../../vmisc/share/resources/icon.qrc"/>
|
<include location="../../../vmisc/share/resources/icon.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
#include <QCompleter>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
@ -283,6 +284,25 @@ void DialogMove::SetHasLinkedVisibilityGroup(bool linked)
|
||||||
ui->groupBoxVisibilityGroup->setChecked(linked);
|
ui->groupBoxVisibilityGroup->setChecked(linked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogMove::SetVisibilityGroupTags(const QStringList &tags)
|
||||||
|
{
|
||||||
|
ui->lineEditGroupTags->setText(tags.join(", "));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QStringList DialogMove::GetVisibilityGroupTags() const
|
||||||
|
{
|
||||||
|
return ui->lineEditGroupTags->text().split(',');
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogMove::SetGroupCategories(const QStringList &categories)
|
||||||
|
{
|
||||||
|
m_groupTags = categories;
|
||||||
|
ui->lineEditGroupTags->SetCompletion(m_groupTags);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogMove::ShowDialog(bool click)
|
void DialogMove::ShowDialog(bool click)
|
||||||
{
|
{
|
||||||
|
@ -551,6 +571,18 @@ void DialogMove::SaveData()
|
||||||
operation->SetRotationAngle(formulaRotationAngle);
|
operation->SetRotationAngle(formulaRotationAngle);
|
||||||
operation->SetRotationOriginPointId(GetRotationOrigPointId());
|
operation->SetRotationOriginPointId(GetRotationOrigPointId());
|
||||||
operation->RefreshGeometry();
|
operation->RefreshGeometry();
|
||||||
|
|
||||||
|
QStringList groupTags = ui->lineEditGroupTags->text().split(',');
|
||||||
|
for (auto &tag : groupTags)
|
||||||
|
{
|
||||||
|
tag = tag.trimmed();
|
||||||
|
if (not m_groupTags.contains(tag))
|
||||||
|
{
|
||||||
|
m_groupTags.append(tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->lineEditGroupTags->SetCompletion(m_groupTags);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -76,6 +76,11 @@ public:
|
||||||
bool HasLinkedVisibilityGroup() const;
|
bool HasLinkedVisibilityGroup() const;
|
||||||
void SetHasLinkedVisibilityGroup(bool linked);
|
void SetHasLinkedVisibilityGroup(bool linked);
|
||||||
|
|
||||||
|
void SetVisibilityGroupTags(const QStringList &tags);
|
||||||
|
QStringList GetVisibilityGroupTags() const;
|
||||||
|
|
||||||
|
virtual void SetGroupCategories(const QStringList &categories) override;
|
||||||
|
|
||||||
virtual void ShowDialog(bool click) override;
|
virtual void ShowDialog(bool click) override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -138,6 +143,8 @@ private:
|
||||||
bool flagName;
|
bool flagName;
|
||||||
bool flagGroupName;
|
bool flagGroupName;
|
||||||
|
|
||||||
|
QStringList m_groupTags{};
|
||||||
|
|
||||||
void EvalAngle();
|
void EvalAngle();
|
||||||
void EvalRotationAngle();
|
void EvalRotationAngle();
|
||||||
void EvalLength();
|
void EvalLength();
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>304</width>
|
<width>424</width>
|
||||||
<height>402</height>
|
<height>432</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -605,15 +605,15 @@
|
||||||
<property name="checked">
|
<property name="checked">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item>
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="labelGroupName">
|
<widget class="QLabel" name="labelGroupName">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Name:</string>
|
<string>Name:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="0" column="1">
|
||||||
<widget class="QLineEdit" name="lineEditVisibilityGroup">
|
<widget class="QLineEdit" name="lineEditVisibilityGroup">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Move</string>
|
<string>Move</string>
|
||||||
|
@ -623,6 +623,26 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>Tags:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="VCompleterLineEdit" name="lineEditGroupTags">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Separate each tag with comma.</string>
|
||||||
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Add tags</string>
|
||||||
|
</property>
|
||||||
|
<property name="clearButtonEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -639,6 +659,11 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>VCompleterLineEdit</class>
|
||||||
|
<extends>QLineEdit</extends>
|
||||||
|
<header>vlineedit.h</header>
|
||||||
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>VPlainTextEdit</class>
|
<class>VPlainTextEdit</class>
|
||||||
<extends>QPlainTextEdit</extends>
|
<extends>QPlainTextEdit</extends>
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
#include <QCompleter>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
@ -196,6 +197,25 @@ void DialogRotation::SetHasLinkedVisibilityGroup(bool linked)
|
||||||
ui->groupBoxVisibilityGroup->setChecked(linked);
|
ui->groupBoxVisibilityGroup->setChecked(linked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRotation::SetVisibilityGroupTags(const QStringList &tags)
|
||||||
|
{
|
||||||
|
ui->lineEditGroupTags->setText(tags.join(", "));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QStringList DialogRotation::GetVisibilityGroupTags() const
|
||||||
|
{
|
||||||
|
return ui->lineEditGroupTags->text().split(',');
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRotation::SetGroupCategories(const QStringList &categories)
|
||||||
|
{
|
||||||
|
m_groupTags = categories;
|
||||||
|
ui->lineEditGroupTags->SetCompletion(m_groupTags);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogRotation::ShowDialog(bool click)
|
void DialogRotation::ShowDialog(bool click)
|
||||||
{
|
{
|
||||||
|
@ -432,6 +452,18 @@ void DialogRotation::SaveData()
|
||||||
operation->SetOriginPointId(GetOrigPointId());
|
operation->SetOriginPointId(GetOrigPointId());
|
||||||
operation->SetAngle(formulaAngle);
|
operation->SetAngle(formulaAngle);
|
||||||
operation->RefreshGeometry();
|
operation->RefreshGeometry();
|
||||||
|
|
||||||
|
QStringList groupTags = ui->lineEditGroupTags->text().split(',');
|
||||||
|
for (auto &tag : groupTags)
|
||||||
|
{
|
||||||
|
tag = tag.trimmed();
|
||||||
|
if (not m_groupTags.contains(tag))
|
||||||
|
{
|
||||||
|
m_groupTags.append(tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->lineEditGroupTags->SetCompletion(m_groupTags);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -69,6 +69,11 @@ public:
|
||||||
bool HasLinkedVisibilityGroup() const;
|
bool HasLinkedVisibilityGroup() const;
|
||||||
void SetHasLinkedVisibilityGroup(bool linked);
|
void SetHasLinkedVisibilityGroup(bool linked);
|
||||||
|
|
||||||
|
void SetVisibilityGroupTags(const QStringList &tags);
|
||||||
|
QStringList GetVisibilityGroupTags() const;
|
||||||
|
|
||||||
|
virtual void SetGroupCategories(const QStringList &categories) override;
|
||||||
|
|
||||||
virtual void ShowDialog(bool click) override;
|
virtual void ShowDialog(bool click) override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -120,6 +125,8 @@ private:
|
||||||
bool flagName;
|
bool flagName;
|
||||||
bool flagGroupName;
|
bool flagGroupName;
|
||||||
bool flagError;
|
bool flagError;
|
||||||
|
|
||||||
|
QStringList m_groupTags{};
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>392</width>
|
<width>392</width>
|
||||||
<height>252</height>
|
<height>282</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -236,18 +236,38 @@
|
||||||
<property name="checked">
|
<property name="checked">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item>
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Tags:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="lineEditVisibilityGroup">
|
||||||
|
<property name="text">
|
||||||
|
<string>Rotation</string>
|
||||||
|
</property>
|
||||||
|
<property name="clearButtonEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="labelGroupName">
|
<widget class="QLabel" name="labelGroupName">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Name:</string>
|
<string>Name:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="lineEditVisibilityGroup">
|
<widget class="VCompleterLineEdit" name="lineEditGroupTags">
|
||||||
<property name="text">
|
<property name="toolTip">
|
||||||
<string>Rotation</string>
|
<string>Separate each tag with comma.</string>
|
||||||
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Add tags</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="clearButtonEnabled">
|
<property name="clearButtonEnabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
@ -270,6 +290,11 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>VCompleterLineEdit</class>
|
||||||
|
<extends>QLineEdit</extends>
|
||||||
|
<header>vlineedit.h</header>
|
||||||
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>VPlainTextEdit</class>
|
<class>VPlainTextEdit</class>
|
||||||
<extends>QPlainTextEdit</extends>
|
<extends>QPlainTextEdit</extends>
|
||||||
|
|
|
@ -799,6 +799,13 @@ void DialogTool::SetToolId(const quint32 &value)
|
||||||
toolId = value;
|
toolId = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogTool::SetGroupCategories(const QStringList &categories)
|
||||||
|
{
|
||||||
|
Q_UNUSED(categories)
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogTool::ShowDialog(bool click)
|
void DialogTool::ShowDialog(bool click)
|
||||||
{
|
{
|
||||||
|
|
|
@ -90,6 +90,8 @@ public:
|
||||||
quint32 GetToolId() const;
|
quint32 GetToolId() const;
|
||||||
void SetToolId(const quint32 &value);
|
void SetToolId(const quint32 &value);
|
||||||
|
|
||||||
|
virtual void SetGroupCategories(const QStringList &categories);
|
||||||
|
|
||||||
static void MoveListRowTop(QListWidget *list);
|
static void MoveListRowTop(QListWidget *list);
|
||||||
static void MoveListRowUp(QListWidget *list);
|
static void MoveListRowUp(QListWidget *list);
|
||||||
static void MoveListRowDown(QListWidget *list);
|
static void MoveListRowDown(QListWidget *list);
|
||||||
|
|
|
@ -93,6 +93,7 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(const QPointer<DialogTool> &dia
|
||||||
initData.source = dialogTool->GetObjects();
|
initData.source = dialogTool->GetObjects();
|
||||||
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
|
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
|
||||||
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
|
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
|
||||||
|
initData.visibilityGroupTags = dialogTool->GetVisibilityGroupTags();
|
||||||
initData.scene = scene;
|
initData.scene = scene;
|
||||||
initData.doc = doc;
|
initData.doc = doc;
|
||||||
initData.data = data;
|
initData.data = data;
|
||||||
|
|
|
@ -93,6 +93,7 @@ VToolFlippingByLine *VToolFlippingByLine::Create(const QPointer<DialogTool> &dia
|
||||||
initData.source = dialogTool->GetObjects();
|
initData.source = dialogTool->GetObjects();
|
||||||
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
|
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
|
||||||
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
|
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
|
||||||
|
initData.visibilityGroupTags = dialogTool->GetVisibilityGroupTags();
|
||||||
initData.scene = scene;
|
initData.scene = scene;
|
||||||
initData.doc = doc;
|
initData.doc = doc;
|
||||||
initData.data = data;
|
initData.data = data;
|
||||||
|
|
|
@ -609,9 +609,9 @@ void VAbstractOperation::ApplyToolOptions(const QList<quint32> &oldDependencies,
|
||||||
{
|
{
|
||||||
if (group != null_id)
|
if (group != null_id)
|
||||||
{
|
{
|
||||||
RenameGroup *renameGroup = new RenameGroup(doc, group, groupName);
|
ChangeGroupOptions *groupOptions = new ChangeGroupOptions(doc, group, groupName, groupTags);
|
||||||
connect(renameGroup, &RenameGroup::UpdateGroups, doc, &VAbstractPattern::UpdateVisiblityGroups);
|
connect(groupOptions, &ChangeGroupOptions::UpdateGroups, doc, &VAbstractPattern::UpdateVisiblityGroups);
|
||||||
qApp->getUndoStack()->push(renameGroup);
|
qApp->getUndoStack()->push(groupOptions);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -619,6 +619,7 @@ void VAbstractOperation::ApplyToolOptions(const QList<quint32> &oldDependencies,
|
||||||
initData.id = m_id;
|
initData.id = m_id;
|
||||||
initData.hasLinkedVisibilityGroup = hasLinkedGroup;
|
initData.hasLinkedVisibilityGroup = hasLinkedGroup;
|
||||||
initData.visibilityGroupName = groupName;
|
initData.visibilityGroupName = groupName;
|
||||||
|
initData.visibilityGroupTags = groupTags;
|
||||||
initData.data = &(VDataTool::data);
|
initData.data = &(VDataTool::data);
|
||||||
initData.doc = doc;
|
initData.doc = doc;
|
||||||
initData.source = source;
|
initData.source = source;
|
||||||
|
@ -790,7 +791,7 @@ bool VAbstractOperation::NeedUpdateVisibilityGroup() const
|
||||||
{
|
{
|
||||||
if (group != null_id)
|
if (group != null_id)
|
||||||
{
|
{
|
||||||
if (groupName != doc->GetGroupName(group))
|
if (groupName != doc->GetGroupName(group) || groupTags != doc->GetGroupTags(group))
|
||||||
{
|
{
|
||||||
return true; // rename group
|
return true; // rename group
|
||||||
}
|
}
|
||||||
|
@ -916,7 +917,8 @@ void VAbstractOperation::CreateVisibilityGroup(const VAbstractOperationInitData
|
||||||
|
|
||||||
const QMap<quint32, quint32> groupData = VisibilityGroupDataFromSource(initData.data, initData.source);
|
const QMap<quint32, quint32> groupData = VisibilityGroupDataFromSource(initData.data, initData.source);
|
||||||
vidtype groupId = initData.data->getNextId();
|
vidtype groupId = initData.data->getNextId();
|
||||||
const QDomElement group = initData.doc->CreateGroup(groupId, initData.visibilityGroupName, groupData, initData.id);
|
const QDomElement group = initData.doc->CreateGroup(groupId, initData.visibilityGroupName,
|
||||||
|
initData.visibilityGroupTags, groupData, initData.id);
|
||||||
if (not group.isNull())
|
if (not group.isNull())
|
||||||
{
|
{
|
||||||
AddGroup *addGroup = new AddGroup(group, initData.doc);
|
AddGroup *addGroup = new AddGroup(group, initData.doc);
|
||||||
|
|
|
@ -60,6 +60,7 @@ struct VAbstractOperationInitData : VAbstractToolInitData
|
||||||
QVector<quint32> source{};
|
QVector<quint32> source{};
|
||||||
QVector<DestinationItem> destination{};
|
QVector<DestinationItem> destination{};
|
||||||
QString visibilityGroupName{};
|
QString visibilityGroupName{};
|
||||||
|
QStringList visibilityGroupTags{};
|
||||||
bool hasLinkedVisibilityGroup{false};
|
bool hasLinkedVisibilityGroup{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -134,6 +135,7 @@ protected:
|
||||||
|
|
||||||
bool hasLinkedGroup{false};
|
bool hasLinkedGroup{false};
|
||||||
QString groupName{};
|
QString groupName{};
|
||||||
|
QStringList groupTags{};
|
||||||
|
|
||||||
VAbstractOperation(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix,
|
VAbstractOperation(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix,
|
||||||
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
|
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
|
||||||
|
@ -187,6 +189,7 @@ void VAbstractOperation::SetDialogVisibilityGroupData(QPointer<T> dialogTool)
|
||||||
{
|
{
|
||||||
dialogTool->SetHasLinkedVisibilityGroup(true);
|
dialogTool->SetHasLinkedVisibilityGroup(true);
|
||||||
dialogTool->SetVisibilityGroupName(doc->GetGroupName(group));
|
dialogTool->SetVisibilityGroupName(doc->GetGroupName(group));
|
||||||
|
dialogTool->SetVisibilityGroupTags(doc->GetGroupTags(group));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -149,6 +149,7 @@ VToolMove *VToolMove::Create(const QPointer<DialogTool> &dialog, VMainGraphicsSc
|
||||||
initData.source = dialogTool->GetObjects();
|
initData.source = dialogTool->GetObjects();
|
||||||
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
|
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
|
||||||
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
|
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
|
||||||
|
initData.visibilityGroupTags = dialogTool->GetVisibilityGroupTags();
|
||||||
initData.scene = scene;
|
initData.scene = scene;
|
||||||
initData.doc = doc;
|
initData.doc = doc;
|
||||||
initData.data = data;
|
initData.data = data;
|
||||||
|
|
|
@ -117,6 +117,7 @@ VToolRotation *VToolRotation::Create(const QPointer<DialogTool> &dialog, VMainGr
|
||||||
initData.source = dialogTool->GetObjects();
|
initData.source = dialogTool->GetObjects();
|
||||||
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
|
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
|
||||||
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
|
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
|
||||||
|
initData.visibilityGroupTags = dialogTool->GetVisibilityGroupTags();
|
||||||
initData.scene = scene;
|
initData.scene = scene;
|
||||||
initData.doc = doc;
|
initData.doc = doc;
|
||||||
initData.data = data;
|
initData.data = data;
|
||||||
|
|
|
@ -145,6 +145,38 @@ void RenameGroup::redo()
|
||||||
emit UpdateGroups();
|
emit UpdateGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//ChangeGroupOptions
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
ChangeGroupOptions::ChangeGroupOptions(VAbstractPattern *doc, quint32 id, const QString &name, const QStringList &tags,
|
||||||
|
QUndoCommand *parent)
|
||||||
|
: VUndoCommand(QDomElement(), doc, parent),
|
||||||
|
newName(name),
|
||||||
|
newTags(tags)
|
||||||
|
{
|
||||||
|
setText(tr("rename group"));
|
||||||
|
nodeId = id;
|
||||||
|
oldName = doc->GetGroupName(nodeId);
|
||||||
|
oldTags = doc->GetGroupTags(nodeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void ChangeGroupOptions::undo()
|
||||||
|
{
|
||||||
|
qCDebug(vUndo, "Undo.");
|
||||||
|
doc->SetGroupName(nodeId, oldName);
|
||||||
|
doc->SetGroupTags(nodeId, oldTags);
|
||||||
|
emit UpdateGroups();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void ChangeGroupOptions::redo()
|
||||||
|
{
|
||||||
|
qCDebug(vUndo, "Redo.");
|
||||||
|
doc->SetGroupName(nodeId, newName);
|
||||||
|
doc->SetGroupTags(nodeId, newTags);
|
||||||
|
emit UpdateGroups();
|
||||||
|
}
|
||||||
|
|
||||||
//AddItemToGroup
|
//AddItemToGroup
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
AddItemToGroup::AddItemToGroup(const QDomElement &xml, VAbstractPattern *doc, quint32 groupId, QUndoCommand *parent)
|
AddItemToGroup::AddItemToGroup(const QDomElement &xml, VAbstractPattern *doc, quint32 groupId, QUndoCommand *parent)
|
||||||
|
|
|
@ -69,6 +69,25 @@ private:
|
||||||
QString oldName{};
|
QString oldName{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ChangeGroupOptions : public VUndoCommand
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ChangeGroupOptions(VAbstractPattern *doc, quint32 id, const QString &name, const QStringList &tags,
|
||||||
|
QUndoCommand *parent = nullptr);
|
||||||
|
virtual ~ChangeGroupOptions()=default;
|
||||||
|
virtual void undo() override;
|
||||||
|
virtual void redo() override;
|
||||||
|
signals:
|
||||||
|
void UpdateGroups();
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(ChangeGroupOptions)
|
||||||
|
QString newName;
|
||||||
|
QString oldName{};
|
||||||
|
QStringList newTags;
|
||||||
|
QStringList oldTags{};
|
||||||
|
};
|
||||||
|
|
||||||
class AddItemToGroup : public VUndoCommand
|
class AddItemToGroup : public VUndoCommand
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
|
@ -28,6 +28,72 @@
|
||||||
|
|
||||||
#include "vlineedit.h"
|
#include "vlineedit.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QCompleter>
|
||||||
|
#include <QStringListModel>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
#include "../vmisc/compatibility.h"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
class MultiSelectCompleter : public QCompleter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MultiSelectCompleter(QObject* parent=nullptr);
|
||||||
|
MultiSelectCompleter(const QStringList& items, QObject* parent=nullptr);
|
||||||
|
virtual ~MultiSelectCompleter() =default;
|
||||||
|
|
||||||
|
virtual QString pathFromIndex(const QModelIndex& index) const override;
|
||||||
|
virtual QStringList splitPath(const QString& path) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(MultiSelectCompleter)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
//MultiSelectCompleter
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
MultiSelectCompleter::MultiSelectCompleter(QObject *parent)
|
||||||
|
: QCompleter(parent)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
MultiSelectCompleter::MultiSelectCompleter(const QStringList& items, QObject* parent)
|
||||||
|
: QCompleter(items, parent)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString MultiSelectCompleter::pathFromIndex(const QModelIndex& index) const
|
||||||
|
{
|
||||||
|
QString path = QCompleter::pathFromIndex(index);
|
||||||
|
|
||||||
|
QString text = static_cast<QLineEdit*>(widget())->text();
|
||||||
|
|
||||||
|
int pos = text.lastIndexOf(',');
|
||||||
|
if (pos >= 0)
|
||||||
|
{
|
||||||
|
path = text.left(pos) + ", " + path;
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QStringList MultiSelectCompleter::splitPath( const QString& path ) const
|
||||||
|
{
|
||||||
|
int pos = path.lastIndexOf(',') + 1;
|
||||||
|
|
||||||
|
while (pos < path.length() && path.at(pos) == QLatin1Char(' '))
|
||||||
|
{
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QStringList(path.mid(pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
//VLineEdit
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VLineEdit::VLineEdit(QWidget *parent)
|
VLineEdit::VLineEdit(QWidget *parent)
|
||||||
: QLineEdit(parent),
|
: QLineEdit(parent),
|
||||||
|
@ -74,3 +140,59 @@ void VLineEdit::mousePressEvent(QMouseEvent *e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// VCompleterLineEdit
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VCompleterLineEdit::VCompleterLineEdit(QWidget *parent)
|
||||||
|
: VLineEdit(parent),
|
||||||
|
m_model(new QStringListModel(this))
|
||||||
|
{
|
||||||
|
setCompleter(new MultiSelectCompleter());
|
||||||
|
completer()->setModel(m_model);
|
||||||
|
completer()->setCompletionMode(QCompleter::PopupCompletion);
|
||||||
|
completer()->setCaseSensitivity(Qt::CaseInsensitive);
|
||||||
|
connect(this, &VCompleterLineEdit::textEdited, this, &VCompleterLineEdit::ShowCompletion);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VCompleterLineEdit::SetCompletion(const QStringList &list)
|
||||||
|
{
|
||||||
|
m_model->setStringList(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VCompleterLineEdit::focusInEvent(QFocusEvent *e)
|
||||||
|
{
|
||||||
|
QLineEdit::focusInEvent(e);
|
||||||
|
// force completion when line edit is focued in
|
||||||
|
completer()->complete();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VCompleterLineEdit::ShowCompletion()
|
||||||
|
{
|
||||||
|
// PrepareCompletion();
|
||||||
|
|
||||||
|
// force to show all items when text is empty
|
||||||
|
completer()->setCompletionMode(text().isEmpty() ? QCompleter::UnfilteredPopupCompletion
|
||||||
|
: QCompleter::PopupCompletion);
|
||||||
|
if (text().isEmpty())
|
||||||
|
{
|
||||||
|
// completion list will be hidden now; we will show it again after a delay
|
||||||
|
QTimer::singleShot(100, this, &VCompleterLineEdit::CompletionPopup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VCompleterLineEdit::CompletionPopup()
|
||||||
|
{
|
||||||
|
// apparently, complete() works only in event handler
|
||||||
|
QApplication::postEvent(this, new QEvent(QEvent::User));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VCompleterLineEdit::customEvent(QEvent *e)
|
||||||
|
{
|
||||||
|
QLineEdit::customEvent(e);
|
||||||
|
// force completion after text is deleted
|
||||||
|
completer()->complete();
|
||||||
|
}
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
|
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
|
||||||
|
class QStringListModel;
|
||||||
|
|
||||||
class VLineEdit : public QLineEdit
|
class VLineEdit : public QLineEdit
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -47,4 +49,31 @@ private:
|
||||||
bool m_selectOnMousePress;
|
bool m_selectOnMousePress;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*! Line edit widget with auto completion based on QStringListModel.
|
||||||
|
Modified behaviour: completion list will appear even when contents of
|
||||||
|
line edit is empty. Full list of options will be showed when line edit
|
||||||
|
has focus and is empty.
|
||||||
|
*/
|
||||||
|
class VCompleterLineEdit : public VLineEdit
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit VCompleterLineEdit(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
//! Set list of options used for completion.
|
||||||
|
void SetCompletion(const QStringList &list);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void focusInEvent(QFocusEvent *e) override;
|
||||||
|
virtual void customEvent(QEvent* e) override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void ShowCompletion();
|
||||||
|
void CompletionPopup();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(VCompleterLineEdit)
|
||||||
|
QStringListModel *m_model;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // VLINEEDIT_H
|
#endif // VLINEEDIT_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user