Added "All/None" menu in detail list area for easier handling of many parts.
--HG-- branch : feature
This commit is contained in:
parent
8cf52dc674
commit
a067b19d8f
|
@ -33,6 +33,7 @@
|
|||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "../vtools/undocommands/toggledetailinlayout.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QUndoStack>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -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<quint32, VDetail> *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; i<ui->tableWidget->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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ public slots:
|
|||
|
||||
private slots:
|
||||
void InLayoutStateChanged(int row, int column);
|
||||
void ShowContextMenu(const QPoint &pos);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VWidgetDetails)
|
||||
|
|
Loading…
Reference in New Issue
Block a user