diff --git a/ChangeLog.txt b/ChangeLog.txt index 0584eaf8a..4084280d0 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -32,6 +32,7 @@ - [#180] New feature: Search field in tape app and dialog Increments. - [#514] Read only setting not working properly. - [#480] New tool: Midpoint between two points. +- [#496] Selector for selecting which pieces to print. # Version 0.4.5 - [#435] Valentina doesn't change the cursor. diff --git a/src/app/valentina/dialogs/dialogs.pri b/src/app/valentina/dialogs/dialogs.pri index c5910f074..edc6d002c 100644 --- a/src/app/valentina/dialogs/dialogs.pri +++ b/src/app/valentina/dialogs/dialogs.pri @@ -18,7 +18,8 @@ HEADERS += \ $$PWD/dialoglayoutsettings.h \ $$PWD/dialoglayoutprogress.h \ $$PWD/dialogsavelayout.h \ - $$PWD/vwidgetgroups.h + $$PWD/vwidgetgroups.h \ + $$PWD/vwidgetdetails.h SOURCES += \ $$PWD/dialogincrements.cpp \ @@ -35,7 +36,8 @@ SOURCES += \ $$PWD/dialoglayoutsettings.cpp \ $$PWD/dialoglayoutprogress.cpp \ $$PWD/dialogsavelayout.cpp \ - $$PWD/vwidgetgroups.cpp + $$PWD/vwidgetgroups.cpp \ + $$PWD/vwidgetdetails.cpp FORMS += \ $$PWD/dialogincrements.ui \ @@ -47,4 +49,5 @@ FORMS += \ $$PWD/dialoglayoutsettings.ui \ $$PWD/dialoglayoutprogress.ui \ $$PWD/dialogsavelayout.ui \ - $$PWD/vwidgetgroups.ui + $$PWD/vwidgetgroups.ui \ + $$PWD/vwidgetdetails.ui diff --git a/src/app/valentina/dialogs/vwidgetdetails.cpp b/src/app/valentina/dialogs/vwidgetdetails.cpp new file mode 100644 index 000000000..fd4ec5cb3 --- /dev/null +++ b/src/app/valentina/dialogs/vwidgetdetails.cpp @@ -0,0 +1,131 @@ +/************************************************************************ + ** + ** @file vwidgetdetails.cpp + ** @author Roman Telezhynskyi + ** @date 25 6, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2016 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "vwidgetdetails.h" +#include "ui_vwidgetdetails.h" +#include "../ifc/xml/vabstractpattern.h" +#include "../vpatterndb/vcontainer.h" +#include "../vmisc/vabstractapplication.h" +#include "../vtools/undocommands/toggledetailinlayout.h" + +#include + +//--------------------------------------------------------------------------------------------------------------------- +VWidgetDetails::VWidgetDetails(VContainer *data, VAbstractPattern *doc, QWidget *parent) + : QWidget(parent), + ui(new Ui::VWidgetDetails), + m_doc(doc), + m_data(data) +{ + ui->setupUi(this); + + FillTable(m_data->DataDetails()); + + connect(ui->tableWidget, &QTableWidget::cellClicked, this, &VWidgetDetails::InLayoutStateChanged); +} + +//--------------------------------------------------------------------------------------------------------------------- +VWidgetDetails::~VWidgetDetails() +{ + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VWidgetDetails::UpdateList() +{ + FillTable(m_data->DataDetails()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VWidgetDetails::InLayoutStateChanged(int row, int column) +{ + if (column != 0) + { + return; + } + + QTableWidgetItem *item = ui->tableWidget->item(row, column); + const quint32 id = item->data(Qt::UserRole).toUInt(); + const QHash *allDetails = m_data->DataDetails(); + const bool inLayout = not allDetails->value(id).IsInLayout(); + + ToggleDetailInLayout *togglePrint = new ToggleDetailInLayout(id, inLayout, m_data, m_doc); + connect(togglePrint, &ToggleDetailInLayout::NeedLiteParsing, m_doc, &VAbstractPattern::LiteParseTree); + qApp->getUndoStack()->push(togglePrint); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VWidgetDetails::FillTable(const QHash *details) +{ + const int selectedRow = ui->tableWidget->currentRow(); + ui->tableWidget->clear(); + + ui->tableWidget->setColumnCount(2); + ui->tableWidget->setRowCount(details->size()); + qint32 currentRow = -1; + auto i = details->constBegin(); + while (i != details->constEnd()) + { + ++currentRow; + const VDetail det = i.value(); + + QTableWidgetItem *item = new QTableWidgetItem(); + item->setTextAlignment(Qt::AlignHCenter); + if (det.IsInLayout()) + { + item->setIcon(QIcon("://icon/16x16/allow_detail.png")); + } + else + { + item->setIcon(QIcon("://icon/16x16/forbid_detail.png")); + } + item->setData(Qt::UserRole, i.key()); + ui->tableWidget->setItem(currentRow, 0, item); + + QString name = det.getName(); + if (name.isEmpty()) + { + name = tr("Unnamed"); + } + + item = new QTableWidgetItem(name); + item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); + + // set the item non-editable (view only), and non-selectable + Qt::ItemFlags flags = item->flags(); + flags &= ~(Qt::ItemIsEditable); // reset/clear the flag + item->setFlags(flags); + + ui->tableWidget->setItem(currentRow, 1, item); + ++i; + } + ui->tableWidget->resizeColumnsToContents(); + ui->tableWidget->resizeRowsToContents(); + + ui->tableWidget->setCurrentCell(selectedRow, 0); +} diff --git a/src/app/valentina/dialogs/vwidgetdetails.h b/src/app/valentina/dialogs/vwidgetdetails.h new file mode 100644 index 000000000..c59147007 --- /dev/null +++ b/src/app/valentina/dialogs/vwidgetdetails.h @@ -0,0 +1,66 @@ +/************************************************************************ + ** + ** @file vwidgetdetails.h + ** @author Roman Telezhynskyi + ** @date 25 6, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2016 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef VWIDGETDETAILS_H +#define VWIDGETDETAILS_H + +#include + +class VAbstractPattern; +class VContainer; +class VDetail; + +namespace Ui +{ + class VWidgetDetails; +} + +class VWidgetDetails : public QWidget +{ + Q_OBJECT + +public: + explicit VWidgetDetails(VContainer *data, VAbstractPattern *doc, QWidget *parent = nullptr); + virtual ~VWidgetDetails(); + +public slots: + void UpdateList(); + +private slots: + void InLayoutStateChanged(int row, int column); + +private: + Q_DISABLE_COPY(VWidgetDetails) + Ui::VWidgetDetails *ui; + VAbstractPattern *m_doc; + VContainer *m_data; + + void FillTable(const QHash *details); +}; + +#endif // VWIDGETDETAILS_H diff --git a/src/app/valentina/dialogs/vwidgetdetails.ui b/src/app/valentina/dialogs/vwidgetdetails.ui new file mode 100644 index 000000000..fb6fc341a --- /dev/null +++ b/src/app/valentina/dialogs/vwidgetdetails.ui @@ -0,0 +1,58 @@ + + + VWidgetDetails + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + false + + + false + + + 16 + + + false + + + true + + + false + + + false + + + 10 + + + + + + + + diff --git a/src/app/valentina/dialogs/vwidgetgroups.ui b/src/app/valentina/dialogs/vwidgetgroups.ui index 3bd6c417e..006e30e6c 100644 --- a/src/app/valentina/dialogs/vwidgetgroups.ui +++ b/src/app/valentina/dialogs/vwidgetgroups.ui @@ -11,7 +11,11 @@ - Form + + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png @@ -53,6 +57,8 @@ - + + + diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 4da6d58e2..cc5b835b6 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -56,6 +56,7 @@ #include "dialogs/dialogs.h" #include "dialogs/vwidgetgroups.h" #include "../vtools/undocommands/addgroup.h" +#include "dialogs/vwidgetdetails.h" #include #include @@ -122,6 +123,7 @@ MainWindow::MainWindow(QWidget *parent) gradationHeights(nullptr), gradationSizes(nullptr), gradationHeightsLabel(nullptr), gradationSizesLabel(nullptr), toolOptions(nullptr), groupsWidget(nullptr), + detailsWidget(nullptr), lock(nullptr) { for (int i = 0; i < MaxRecentFiles; ++i) @@ -137,7 +139,12 @@ MainWindow::MainWindow(QWidget *parent) connect(doc, &VPattern::patternChanged, this, &MainWindow::PatternWasModified); connect(doc, &VPattern::UndoCommand, this, &MainWindow::FullParseFile); connect(doc, &VPattern::SetEnabledGUI, this, &MainWindow::SetEnabledGUI); - connect(doc, &VPattern::CheckLayout, this, &MainWindow::Layout); + connect(doc, &VPattern::CheckLayout, [this](){ + if (pattern->DataDetails()->count() == 0) + { + ActionDraw(true); + } + }); connect(doc, &VPattern::SetCurrentPP, this, &MainWindow::GlobalChangePP); qApp->setCurrentDocument(doc); @@ -1320,7 +1327,8 @@ void MainWindow::CleanLayout() shadows.clear(); papers.clear(); ui->listWidget->clear(); - SetLayoutModeActions(false); + listDetails.clear(); + SetLayoutModeActions(); } //--------------------------------------------------------------------------------------------------------------------- @@ -1335,7 +1343,7 @@ void MainWindow::PrepareSceneList() if (not scenes.isEmpty()) { ui->listWidget->setCurrentRow(0); - SetLayoutModeActions(true); + SetLayoutModeActions(); } } @@ -2109,7 +2117,10 @@ void MainWindow::ActionDraw(bool checked) ui->dockWidgetLayoutPages->setVisible(false); ui->dockWidgetToolOptions->setVisible(isDockToolOptionsVisible); + + ui->dockWidgetGroups->setWidget(groupsWidget); ui->dockWidgetGroups->setVisible(isDockGroupsVisible); + ui->dockWidgetGroups->setToolTip(tr("Contains all visibility groups")); } else { @@ -2149,11 +2160,13 @@ void MainWindow::ActionDetails(bool checked) QMessageBox::information(this, tr("Detail mode"), tr("You can't use now the Detail mode. " "Please, create at least one workpiece."), QMessageBox::Ok, QMessageBox::Ok); - Layout(); + ActionDraw(true); return; } } + detailsWidget->UpdateList(); + qCDebug(vMainWindow, "Show details scene"); SaveCurrentScene(); @@ -2179,7 +2192,10 @@ void MainWindow::ActionDetails(bool checked) ui->dockWidgetLayoutPages->setVisible(false); ui->dockWidgetToolOptions->setVisible(isDockToolOptionsVisible); + + ui->dockWidgetGroups->setWidget(detailsWidget); ui->dockWidgetGroups->setVisible(isDockGroupsVisible); + ui->dockWidgetGroups->setToolTip(tr("Show which details will go in layout")); helpLabel->setText(""); } @@ -2214,17 +2230,39 @@ void MainWindow::ActionLayout(bool checked) ui->actionDetails->setChecked(false); ui->actionLayout->setChecked(true); - const QHash *details = pattern->DataDetails(); + QHash details; if(not qApp->getOpeningPattern()) { - if (details->count() == 0) + const QHash *allDetails = pattern->DataDetails(); + if (allDetails->count() == 0) { QMessageBox::information(this, tr("Layout mode"), tr("You can't use now the Layout mode. " "Please, create at least one workpiece."), QMessageBox::Ok, QMessageBox::Ok); - Layout(); + ActionDraw(true); return; } + else + { + QHash::const_iterator i = allDetails->constBegin(); + while (i != allDetails->constEnd()) + { + if (i.value().IsInLayout()) + { + details.insert(i.key(), i.value()); + } + ++i; + } + + if (details.count() == 0) + { + QMessageBox::information(this, tr("Layout mode"), tr("You can't use now the Layout mode. Please, " + "include at least one detail in layout."), + QMessageBox::Ok, QMessageBox::Ok); + mode == Draw::Calculation ? ActionDraw(true) : ActionDetails(true); + return; + } + } } comboBoxDraws->setCurrentIndex(-1);// Hide pattern pieces @@ -2233,7 +2271,7 @@ void MainWindow::ActionLayout(bool checked) SaveCurrentScene(); - PrepareDetailsForLayout(details); + PrepareDetailsForLayout(&details); currentScene = tempSceneLayout; ui->view->itemClicked(nullptr); @@ -2514,7 +2552,7 @@ void MainWindow::Clear() #ifndef QT_NO_CURSOR QApplication::restoreOverrideCursor(); #endif - Layout(); + CleanLayout(); #ifdef Q_OS_WIN32 qt_ntfs_permission_lookup--; // turn it off again @@ -2781,29 +2819,6 @@ void MainWindow::ClickEndVisualization() EndVisualization(true); } -//--------------------------------------------------------------------------------------------------------------------- -void MainWindow::Layout() -{ - if (pattern->DataDetails()->size() > 0) - { - SetLayoutModeActions(true); - } - else - { - listDetails.clear(); - if (not ui->actionDraw->isChecked()) - { - ActionDraw(true); - } - else - { - ui->actionDetails->setChecked(false); - ui->actionLayout->setChecked(false); - } - SetLayoutModeActions(false); - } -} - //--------------------------------------------------------------------------------------------------------------------- void MainWindow::UpdateGradation() { @@ -2973,18 +2988,6 @@ void MainWindow::ChangedHeight(const QString &text) } } -//--------------------------------------------------------------------------------------------------------------------- -void MainWindow::DockToolOptionsVisibilityChanged(bool visible) -{ - isDockToolOptionsVisible = visible; -} - -//--------------------------------------------------------------------------------------------------------------------- -void MainWindow::DockGropsVisibilityChanged(bool visible) -{ - isDockGroupsVisible = visible; -} - //--------------------------------------------------------------------------------------------------------------------- void MainWindow::SetDefaultHeight() { @@ -3166,19 +3169,16 @@ void MainWindow::SetEnableTool(bool enable) } //--------------------------------------------------------------------------------------------------------------------- -void MainWindow::SetLayoutModeActions(bool enable) +void MainWindow::SetLayoutModeActions() { - bool value = enable; - if (scenes.isEmpty()) - { - value = false; - } - ui->actionExportAs->setEnabled(value); - ui->actionPrintPreview->setEnabled(value); - ui->actionPrintPreviewTiled->setEnabled(value); - ui->actionSaveAsTiledPDF->setEnabled(value); - ui->actionPrint->setEnabled(value); - ui->actionPrintTiled->setEnabled(value); + const bool enabled = not scenes.isEmpty(); + + ui->actionExportAs->setEnabled(enabled); + ui->actionPrintPreview->setEnabled(enabled); + ui->actionPrintPreviewTiled->setEnabled(enabled); + ui->actionSaveAsTiledPDF->setEnabled(enabled); + ui->actionPrint->setEnabled(enabled); + ui->actionPrintTiled->setEnabled(enabled); } //--------------------------------------------------------------------------------------------------------------------- @@ -3610,12 +3610,15 @@ void MainWindow::AddDocks() //Add dock actionDockWidgetToolOptions = ui->dockWidgetToolOptions->toggleViewAction(); ui->menuPatternPiece->insertAction(ui->actionPattern_properties, actionDockWidgetToolOptions); - connect(ui->dockWidgetToolOptions, &QDockWidget::visibilityChanged, this, - &MainWindow::DockToolOptionsVisibilityChanged); + connect(ui->dockWidgetToolOptions, &QDockWidget::visibilityChanged, [this](bool visible){ + isDockToolOptionsVisible = visible; + }); actionDockWidgetGroups = ui->dockWidgetGroups->toggleViewAction(); ui->menuPatternPiece->insertAction(ui->actionPattern_properties, actionDockWidgetGroups); - connect(ui->dockWidgetGroups, &QDockWidget::visibilityChanged, this, &MainWindow::DockGropsVisibilityChanged); + connect(ui->dockWidgetGroups, &QDockWidget::visibilityChanged, [this](bool visible){ + isDockGroupsVisible = visible; + }); separatorAct = new QAction(this); separatorAct->setSeparator(true); @@ -3634,6 +3637,10 @@ void MainWindow::InitDocksContain() qCDebug(vMainWindow, "Initialization groups dock."); groupsWidget = new VWidgetGroups(doc, this); ui->dockWidgetGroups->setWidget(groupsWidget); + + detailsWidget = new VWidgetDetails(pattern, doc, this); + connect(doc, &VPattern::FullUpdateFromFile, detailsWidget, &VWidgetDetails::UpdateList); + detailsWidget->setVisible(false); } //--------------------------------------------------------------------------------------------------------------------- @@ -3992,12 +3999,10 @@ void MainWindow::ShowPaper(int index) if (index < 0 || index >= scenes.size()) { ui->view->setScene(tempSceneLayout); - SetLayoutModeActions(false); } else { ui->view->setScene(scenes.at(index)); - SetLayoutModeActions(true); } ui->view->fitInView(ui->view->scene()->sceneRect(), Qt::KeepAspectRatio); diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index 943245dc9..1f8b5cd91 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -49,6 +49,7 @@ class DialogIncrements; class DialogTool; class DialogHistory; class VWidgetGroups; +class VWidgetDetails; /** * @brief The MainWindow class main windows. @@ -152,7 +153,6 @@ public slots: void SetEnabledGUI(bool enabled); void ClickEndVisualization(); - void Layout(); void UpdateGradation(); void GlobalChangePP(const QString &patternPiece); void WindowsLocale(); @@ -207,9 +207,6 @@ private slots: void ChangedSize(const QString &text); void ChangedHeight(const QString & text); - void DockToolOptionsVisibilityChanged(bool visible); - void DockGropsVisibilityChanged(bool visible); - private: Q_DISABLE_COPY(MainWindow) /** @brief ui keeps information about user interface */ @@ -280,6 +277,7 @@ private: QPointer gradationSizesLabel; VToolOptionsPropertyBrowser *toolOptions; VWidgetGroups *groupsWidget; + VWidgetDetails *detailsWidget; std::shared_ptr> lock; void SetDefaultHeight(); @@ -294,7 +292,7 @@ private: void SetEnableWidgets(bool enable); void SetEnableTool(bool enable); - void SetLayoutModeActions(bool enable); + void SetLayoutModeActions(); void SaveCurrentScene(); void RestoreCurrentScene(); diff --git a/src/app/valentina/mainwindow.ui b/src/app/valentina/mainwindow.ui index f0904c225..d1e500848 100644 --- a/src/app/valentina/mainwindow.ui +++ b/src/app/valentina/mainwindow.ui @@ -1518,8 +1518,11 @@ true + + + - Groups + Group 2 diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index 436211ad1..b3e6b9e72 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -457,25 +457,25 @@ void MainWindowsNoGUI::PrintTiled() void MainWindowsNoGUI::PrepareDetailsForLayout(const QHash *details) { SCASSERT(details != nullptr) - if (details->count() == 0) + if (details->count() == 0) { listDetails.clear(); return; } listDetails.clear(); - QHashIterator idetail(*details); - while (idetail.hasNext()) + QHash::const_iterator i = details->constBegin(); + while (i != details->constEnd()) { - idetail.next(); VLayoutDetail det = VLayoutDetail(); - const VDetail &d = idetail.value(); + const VDetail d = i.value(); det.SetCountourPoints(d.ContourPoints(pattern)); det.SetSeamAllowencePoints(d.SeamAllowancePoints(pattern), d.getSeamAllowance(), d.getClosed()); det.setName(d.getName()); det.setWidth(qApp->toPixel(d.getWidth())); listDetails.append(det); + ++i; } } diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 339d2f53c..abaac899c 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -590,6 +590,7 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document detail.setSeamAllowance(GetParametrUInt(domElement, VToolDetail::AttrSupplement, "1")); detail.setWidth(GetParametrDouble(domElement, VToolDetail::AttrWidth, "10.0")); detail.setClosed(GetParametrUInt(domElement, VToolDetail::AttrClosed, "1")); + detail.SetInLayout(GetParametrBool(domElement, AttrInLayout, trueStr)); QStringList types = QStringList() << VToolDetail::NodePoint << VToolDetail::NodeArc << VToolDetail::NodeSpline << VToolDetail::NodeSplinePath; diff --git a/src/libs/ifc/ifcdef.cpp b/src/libs/ifc/ifcdef.cpp index 53b3e1587..1228e41e4 100644 --- a/src/libs/ifc/ifcdef.cpp +++ b/src/libs/ifc/ifcdef.cpp @@ -130,6 +130,7 @@ const QString AttrCRadius = QStringLiteral("cRadius"); const QString AttrArc = QStringLiteral("arc"); const QString AttrSuffix = QStringLiteral("suffix"); const QString AttrIdObject = QStringLiteral("idObject"); +const QString AttrInLayout = QStringLiteral("inLayout"); const QString TypeLineNone = QStringLiteral("none"); const QString TypeLineLine = QStringLiteral("hair"); diff --git a/src/libs/ifc/ifcdef.h b/src/libs/ifc/ifcdef.h index 93399b39d..0ce6dddd9 100644 --- a/src/libs/ifc/ifcdef.h +++ b/src/libs/ifc/ifcdef.h @@ -132,6 +132,7 @@ extern const QString AttrCRadius; extern const QString AttrArc; extern const QString AttrSuffix; extern const QString AttrIdObject; +extern const QString AttrInLayout; extern const QString TypeLineNone; extern const QString TypeLineLine; diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index 5868055e2..fe077d4dc 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -15,6 +15,7 @@ schema/pattern/v0.2.7.xsd schema/pattern/v0.3.0.xsd schema/pattern/v0.3.1.xsd + schema/pattern/v0.3.2.xsd schema/standard_measurements/v0.3.0.xsd schema/standard_measurements/v0.4.0.xsd schema/standard_measurements/v0.4.1.xsd diff --git a/src/libs/ifc/schema/pattern/v0.3.2.xsd b/src/libs/ifc/schema/pattern/v0.3.2.xsd new file mode 100644 index 000000000..c4167817b --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.3.2.xsd @@ -0,0 +1,516 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index 5068702ef..cb16a65fc 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -43,8 +43,8 @@ */ const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0"); -const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.3.1"); -const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.3.1.xsd"); +const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.3.2"); +const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.3.2.xsd"); //--------------------------------------------------------------------------------------------------------------------- VPatternConverter::VPatternConverter(const QString &fileName) @@ -115,6 +115,8 @@ QString VPatternConverter::XSDSchema(int ver) const case (0x000300): return QStringLiteral("://schema/pattern/v0.3.0.xsd"); case (0x000301): + return QStringLiteral("://schema/pattern/v0.3.1.xsd"); + case (0x000302): return CurrentSchema; default: InvalidVersion(ver); @@ -186,6 +188,10 @@ void VPatternConverter::ApplyPatches() ValidateXML(XSDSchema(0x000301), fileName); V_FALLTHROUGH case (0x000301): + ToV0_3_2(); + ValidateXML(XSDSchema(0x000302), fileName); + V_FALLTHROUGH + case (0x000302): break; default: break; @@ -322,6 +328,13 @@ void VPatternConverter::ToV0_3_1() Save(); } +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::ToV0_3_2() +{ + SetVersion(QStringLiteral("0.3.2")); + Save(); +} + //--------------------------------------------------------------------------------------------------------------------- void VPatternConverter::TagUnitToV0_2_0() { diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index 55be6f196..99f3f5638 100644 --- a/src/libs/ifc/xml/vpatternconverter.h +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -70,6 +70,7 @@ private: void ToV0_2_7(); void ToV0_3_0(); void ToV0_3_1(); + void ToV0_3_2(); void TagUnitToV0_2_0(); void TagIncrementToV0_2_0(); diff --git a/src/libs/vmisc/share/resources/icon.qrc b/src/libs/vmisc/share/resources/icon.qrc index 8abf44308..74cb170cd 100644 --- a/src/libs/vmisc/share/resources/icon.qrc +++ b/src/libs/vmisc/share/resources/icon.qrc @@ -61,5 +61,9 @@ icon/16x16/closed_eye@2x.png icon/16x16/open_eye.png icon/16x16/open_eye@2x.png + icon/16x16/allow_detail.png + icon/16x16/allow_detail@2x.png + icon/16x16/forbid_detail.png + icon/16x16/forbid_detail@2x.png diff --git a/src/libs/vmisc/share/resources/icon/16x16/allow_detail.png b/src/libs/vmisc/share/resources/icon/16x16/allow_detail.png new file mode 100644 index 000000000..6bd8724f6 Binary files /dev/null and b/src/libs/vmisc/share/resources/icon/16x16/allow_detail.png differ diff --git a/src/libs/vmisc/share/resources/icon/16x16/allow_detail@2x.png b/src/libs/vmisc/share/resources/icon/16x16/allow_detail@2x.png new file mode 100644 index 000000000..fd847a5b5 Binary files /dev/null and b/src/libs/vmisc/share/resources/icon/16x16/allow_detail@2x.png differ diff --git a/src/libs/vmisc/share/resources/icon/16x16/forbid_detail.png b/src/libs/vmisc/share/resources/icon/16x16/forbid_detail.png new file mode 100644 index 000000000..f47012319 Binary files /dev/null and b/src/libs/vmisc/share/resources/icon/16x16/forbid_detail.png differ diff --git a/src/libs/vmisc/share/resources/icon/16x16/forbid_detail@2x.png b/src/libs/vmisc/share/resources/icon/16x16/forbid_detail@2x.png new file mode 100644 index 000000000..ee46abafb Binary files /dev/null and b/src/libs/vmisc/share/resources/icon/16x16/forbid_detail@2x.png differ diff --git a/src/libs/vpatterndb/vdetail.cpp b/src/libs/vpatterndb/vdetail.cpp index d7a2e8db2..2d9d87e2f 100644 --- a/src/libs/vpatterndb/vdetail.cpp +++ b/src/libs/vpatterndb/vdetail.cpp @@ -175,6 +175,18 @@ void VDetail::setId(const quint32 &id) d->_id = id; } +//--------------------------------------------------------------------------------------------------------------------- +bool VDetail::IsInLayout() const +{ + return d->inLayout; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDetail::SetInLayout(bool inLayout) +{ + d->inLayout = inLayout; +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief OnEdge checks if two poins located on the edge. Edge is line between two points. If between two points diff --git a/src/libs/vpatterndb/vdetail.h b/src/libs/vpatterndb/vdetail.h index fb57ab56e..5ef7f34c1 100644 --- a/src/libs/vpatterndb/vdetail.h +++ b/src/libs/vpatterndb/vdetail.h @@ -67,6 +67,9 @@ public: quint32 id() const; void setId(const quint32 &id); + bool IsInLayout() const; + void SetInLayout(bool inLayout); + QVector getNodes() const; void setNodes(const QVector &value); diff --git a/src/libs/vpatterndb/vdetail_p.h b/src/libs/vpatterndb/vdetail_p.h index 72aff357a..b22d094da 100644 --- a/src/libs/vpatterndb/vdetail_p.h +++ b/src/libs/vpatterndb/vdetail_p.h @@ -42,15 +42,15 @@ class VDetailData : public QSharedData { public: VDetailData() - :_id(NULL_ID), nodes(QVector()), mx(0), my(0) + :_id(NULL_ID), nodes(QVector()), mx(0), my(0), inLayout(true) {} explicit VDetailData(const QVector &nodes) - :_id(NULL_ID), nodes(nodes), mx(0), my(0) + :_id(NULL_ID), nodes(nodes), mx(0), my(0), inLayout(true) {} VDetailData(const VDetailData &detail) - :QSharedData(detail), _id(NULL_ID), nodes(detail.nodes), mx(detail.mx), my(detail.my) + :QSharedData(detail), _id(NULL_ID), nodes(detail.nodes), mx(detail.mx), my(detail.my), inLayout(detail.inLayout) {} ~VDetailData() {} @@ -67,6 +67,8 @@ public: /** @brief my bias y axis. */ qreal my; + bool inLayout; + private: VDetailData &operator=(const VDetailData &) Q_DECL_EQ_DELETE; }; diff --git a/src/libs/vtools/undocommands/toggledetailinlayout.cpp b/src/libs/vtools/undocommands/toggledetailinlayout.cpp new file mode 100644 index 000000000..4b13fd15f --- /dev/null +++ b/src/libs/vtools/undocommands/toggledetailinlayout.cpp @@ -0,0 +1,132 @@ +/************************************************************************ + ** + ** @file toggledetailinlayout.cpp + ** @author Roman Telezhynskyi + ** @date 25 6, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2016 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "toggledetailinlayout.h" +#include "../vpatterndb/vdetail.h" +#include "../vpatterndb/vcontainer.h" + +//--------------------------------------------------------------------------------------------------------------------- +ToggleDetailInLayout::ToggleDetailInLayout(quint32 id, bool state, VContainer *data, VAbstractPattern *doc, + QUndoCommand *parent) + : VUndoCommand(QDomElement(), doc, parent), + m_id(id), + m_data(data), + m_oldState(m_data->DataDetails()->value(m_id).IsInLayout()), + m_newState(state) +{ + setText(tr("detail in layout list")); +} + +//--------------------------------------------------------------------------------------------------------------------- +ToggleDetailInLayout::~ToggleDetailInLayout() +{ +} + +//--------------------------------------------------------------------------------------------------------------------- +void ToggleDetailInLayout::undo() +{ + qCDebug(vUndo, "ToggleDetailInLayout::undo()."); + + if (m_newState != m_oldState) + { + Do(m_oldState); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void ToggleDetailInLayout::redo() +{ + qCDebug(vUndo, "ToggleDetailInLayout::redo()."); + + if (m_newState != m_oldState) + { + Do(m_newState); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +bool ToggleDetailInLayout::mergeWith(const QUndoCommand *command) +{ + const ToggleDetailInLayout *stateCommand = static_cast(command); + SCASSERT(stateCommand != nullptr); + const quint32 id = stateCommand->getDetId(); + + if (id != m_id) + { + return false; + } + + m_newState = stateCommand->getNewState(); + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +int ToggleDetailInLayout::id() const +{ + return static_cast(UndoCommand::ToggleDetailInLayout); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 ToggleDetailInLayout::getDetId() const +{ + return m_id; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool ToggleDetailInLayout::getNewState() const +{ + return m_newState; +} + +//--------------------------------------------------------------------------------------------------------------------- +void ToggleDetailInLayout::Do(bool state) +{ + QDomElement detail = doc->elementById(m_id); + if (detail.isElement()) + { + if (state == false) + { + doc->SetAttribute(detail, AttrInLayout, state); + } + else + { + detail.removeAttribute(AttrInLayout); + } + + VDetail det = m_data->DataDetails()->value(m_id); + det.SetInLayout(state); + m_data->UpdateDetail(m_id, det); + + emit NeedLiteParsing(Document::LiteParse); + } + else + { + qDebug("Can't get detail by id = %u.", m_id); + return; + } +} diff --git a/src/libs/vtools/undocommands/toggledetailinlayout.h b/src/libs/vtools/undocommands/toggledetailinlayout.h new file mode 100644 index 000000000..ca9833ce0 --- /dev/null +++ b/src/libs/vtools/undocommands/toggledetailinlayout.h @@ -0,0 +1,57 @@ +/************************************************************************ + ** + ** @file toggledetailinlayout.h + ** @author Roman Telezhynskyi + ** @date 25 6, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2016 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef TOGGLEDETAILINLAYOUT_H +#define TOGGLEDETAILINLAYOUT_H + +#include "vundocommand.h" + +class ToggleDetailInLayout : public VUndoCommand +{ + Q_OBJECT +public: + ToggleDetailInLayout(quint32 id, bool state, VContainer *data, VAbstractPattern *doc, + QUndoCommand *parent = nullptr); + virtual ~ToggleDetailInLayout(); + virtual void undo() Q_DECL_OVERRIDE; + virtual void redo() Q_DECL_OVERRIDE; + virtual bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE; + virtual int id() const Q_DECL_OVERRIDE; + quint32 getDetId() const; + bool getNewState() const; +private: + Q_DISABLE_COPY(ToggleDetailInLayout) + quint32 m_id; + VContainer *m_data; + bool m_oldState; + bool m_newState; + + void Do(bool state); +}; + +#endif // TOGGLEDETAILINLAYOUT_H diff --git a/src/libs/vtools/undocommands/undocommands.pri b/src/libs/vtools/undocommands/undocommands.pri index a20f58d15..39a455dc1 100644 --- a/src/libs/vtools/undocommands/undocommands.pri +++ b/src/libs/vtools/undocommands/undocommands.pri @@ -22,7 +22,8 @@ HEADERS += \ $$PWD/addgroup.h \ $$PWD/delgroup.h \ $$PWD/label/rotationmovelabel.h \ - undocommands/label/moveabstractlabel.h + $$PWD/label/moveabstractlabel.h \ + $$PWD/toggledetailinlayout.h SOURCES += \ $$PWD/addtocalc.cpp \ @@ -45,4 +46,5 @@ SOURCES += \ $$PWD/addgroup.cpp \ $$PWD/delgroup.cpp \ $$PWD/label/rotationmovelabel.cpp \ - undocommands/label/moveabstractlabel.cpp + $$PWD/label/moveabstractlabel.cpp \ + $$PWD/toggledetailinlayout.cpp diff --git a/src/libs/vtools/undocommands/vundocommand.h b/src/libs/vtools/undocommands/vundocommand.h index e86cfce82..241288ad2 100644 --- a/src/libs/vtools/undocommands/vundocommand.h +++ b/src/libs/vtools/undocommands/vundocommand.h @@ -50,7 +50,8 @@ enum class UndoCommand: char { AddPatternPiece, RenamePP, MoveLabel, MoveDoubleLabel, - RotationMoveLabel + RotationMoveLabel, + ToggleDetailInLayout }; class VPattern;