diff --git a/src/app/valentina/dialogs/vwidgetdetails.cpp b/src/app/valentina/dialogs/vwidgetdetails.cpp index 315d84997..d03c363a0 100644 --- a/src/app/valentina/dialogs/vwidgetdetails.cpp +++ b/src/app/valentina/dialogs/vwidgetdetails.cpp @@ -33,6 +33,7 @@ #include "../vmisc/vabstractapplication.h" #include "../vtools/undocommands/toggledetailinlayout.h" +#include #include //--------------------------------------------------------------------------------------------------------------------- @@ -46,7 +47,10 @@ VWidgetDetails::VWidgetDetails(VContainer *data, VAbstractPattern *doc, QWidget FillTable(m_data->DataDetails()); + ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu); + connect(ui->tableWidget, &QTableWidget::cellClicked, this, &VWidgetDetails::InLayoutStateChanged); + connect(ui->tableWidget, &QTableWidget::customContextMenuRequested, this, &VWidgetDetails::ShowContextMenu); } //--------------------------------------------------------------------------------------------------------------------- @@ -132,3 +136,35 @@ void VWidgetDetails::FillTable(const QHash *details) ui->tableWidget->setCurrentCell(selectedRow, 0); } + +//--------------------------------------------------------------------------------------------------------------------- +void VWidgetDetails::ShowContextMenu(const QPoint &pos) +{ + QMenu *menu = new QMenu; + QAction *actionSelectAll = menu->addAction(tr("Select all")); + QAction *actionSelectNone = menu->addAction(tr("Select none")); + QAction *selectedAction = menu->exec(ui->tableWidget->viewport()->mapToGlobal(pos)); + + bool select; + if (selectedAction == actionSelectAll) + { + select = true; + } + else if (selectedAction == actionSelectNone) + { + select = false; + } + else + { + return; + } + + for (int i = 0; itableWidget->rowCount(); ++i) + { + QTableWidgetItem *item = ui->tableWidget->item(i, 0); + const quint32 id = item->data(Qt::UserRole).toUInt(); + ToggleDetailInLayout *togglePrint = new ToggleDetailInLayout(id, select, m_data, m_doc); + connect(togglePrint, &ToggleDetailInLayout::NeedLiteParsing, m_doc, &VAbstractPattern::LiteParseTree); + qApp->getUndoStack()->push(togglePrint); + } +} diff --git a/src/app/valentina/dialogs/vwidgetdetails.h b/src/app/valentina/dialogs/vwidgetdetails.h index c59147007..431cbd0ac 100644 --- a/src/app/valentina/dialogs/vwidgetdetails.h +++ b/src/app/valentina/dialogs/vwidgetdetails.h @@ -53,6 +53,7 @@ public slots: private slots: void InLayoutStateChanged(int row, int column); + void ShowContextMenu(const QPoint &pos); private: Q_DISABLE_COPY(VWidgetDetails)