Used QUndoStack::beginMacro and QUndoStack::endMacro.
--HG-- branch : feature
This commit is contained in:
parent
d13bf23bf7
commit
4283cc8ef2
|
@ -143,16 +143,42 @@ void VWidgetDetails::ShowContextMenu(const QPoint &pos)
|
||||||
QMenu *menu = new QMenu;
|
QMenu *menu = new QMenu;
|
||||||
QAction *actionSelectAll = menu->addAction(tr("Select all"));
|
QAction *actionSelectAll = menu->addAction(tr("Select all"));
|
||||||
QAction *actionSelectNone = menu->addAction(tr("Select none"));
|
QAction *actionSelectNone = menu->addAction(tr("Select none"));
|
||||||
|
|
||||||
|
const QHash<quint32, VDetail> *allDetails = m_data->DataDetails();
|
||||||
|
if (not allDetails->count() == 0)
|
||||||
|
{
|
||||||
|
int selectedDetails = 0;
|
||||||
|
|
||||||
|
QHash<quint32, VDetail>::const_iterator iter = allDetails->constBegin();
|
||||||
|
while (iter != allDetails->constEnd())
|
||||||
|
{
|
||||||
|
if(iter.value().IsInLayout())
|
||||||
|
{
|
||||||
|
selectedDetails++;
|
||||||
|
}
|
||||||
|
++iter;
|
||||||
|
}
|
||||||
|
if (selectedDetails == 0)
|
||||||
|
{
|
||||||
|
actionSelectNone->setDisabled(true);
|
||||||
|
}
|
||||||
|
else if (selectedDetails == allDetails->size())
|
||||||
|
{
|
||||||
|
actionSelectAll->setDisabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
QAction *selectedAction = menu->exec(ui->tableWidget->viewport()->mapToGlobal(pos));
|
QAction *selectedAction = menu->exec(ui->tableWidget->viewport()->mapToGlobal(pos));
|
||||||
|
|
||||||
bool select;
|
bool select;
|
||||||
if (selectedAction == actionSelectAll)
|
if (selectedAction == actionSelectAll)
|
||||||
{
|
{
|
||||||
select = true;
|
select = true;
|
||||||
|
qApp->getUndoStack()->beginMacro(tr("select all details"));
|
||||||
}
|
}
|
||||||
else if (selectedAction == actionSelectNone)
|
else if (selectedAction == actionSelectNone)
|
||||||
{
|
{
|
||||||
select = false;
|
select = false;
|
||||||
|
qApp->getUndoStack()->beginMacro(tr("select none details"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -163,8 +189,17 @@ void VWidgetDetails::ShowContextMenu(const QPoint &pos)
|
||||||
{
|
{
|
||||||
QTableWidgetItem *item = ui->tableWidget->item(i, 0);
|
QTableWidgetItem *item = ui->tableWidget->item(i, 0);
|
||||||
const quint32 id = item->data(Qt::UserRole).toUInt();
|
const quint32 id = item->data(Qt::UserRole).toUInt();
|
||||||
|
if (not select == m_data->DataDetails()->value(id).IsInLayout())
|
||||||
|
{
|
||||||
ToggleDetailInLayout *togglePrint = new ToggleDetailInLayout(id, select, m_data, m_doc);
|
ToggleDetailInLayout *togglePrint = new ToggleDetailInLayout(id, select, m_data, m_doc);
|
||||||
connect(togglePrint, &ToggleDetailInLayout::NeedLiteParsing, m_doc, &VAbstractPattern::LiteParseTree);
|
connect(togglePrint, &ToggleDetailInLayout::NeedLiteParsing, m_doc, &VAbstractPattern::LiteParseTree);
|
||||||
qApp->getUndoStack()->push(togglePrint);
|
qApp->getUndoStack()->push(togglePrint);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
qApp->getUndoStack()->endMacro();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user