Adds initial intermediate qt6 porting state
This commit is contained in:
11247 files changed
+1891537
No files matched your search
+36
@@ -0,0 +1,36 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Malte Diers, SLTE, 2021-03-12
|
||||
#
|
||||
|
||||
SET(participant_selection_gui_SRCS
|
||||
participant_selection.cpp
|
||||
participant_selection.h
|
||||
#participant_selection_model.cpp
|
||||
#participant_selection_model.h
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(participant_selection_gui_SRCS
|
||||
participant_selection.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY2(WS PpmParticipantSelectionGui SHARED ${participant_selection_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(PpmParticipantSelectionGui
|
||||
nglwidgets
|
||||
NGLLogger
|
||||
PpmCommon
|
||||
advancedSymbologyGui
|
||||
# PpmGuiParticipantsPluginInterface
|
||||
PpmGuiComboboxPluginInterface
|
||||
# PpmGuiTemplatesPluginInterface
|
||||
PpmDataPluginInterface
|
||||
LtsDataView
|
||||
LtsWidgets
|
||||
LtsSession
|
||||
# LtsUtilsGuiDds
|
||||
# LtsUtilsSettings
|
||||
# svcCoreClient # Core Ftc - for TLH
|
||||
)
|
||||
|
||||
+440
@@ -0,0 +1,440 @@
|
||||
|
||||
|
||||
|
||||
#include "participant_selection.h"
|
||||
|
||||
#include "ui_participant_selection.h"
|
||||
|
||||
#include <Common/participant_edit_model.h>
|
||||
#include <Common/participant_beautify_view.h>
|
||||
#include <Common/participant_tree_edit_handler.h>
|
||||
#include <ParticipantManagement/logger.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsDataView/search_model.h>
|
||||
|
||||
#include <ParticipantManagement/ppm_operator_rights.h>
|
||||
#include <Plugins/AdvancedSymbology/asb_data_plugin_interface.h>
|
||||
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_participants_gui_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_templates_gui_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
|
||||
|
||||
#include <QTreeView>
|
||||
#include <QTableView>
|
||||
#include <QAction>
|
||||
#include <QHeaderView>
|
||||
#include <QTimer>
|
||||
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
int ParticipantSelection::s_preselectedParty = 2;
|
||||
|
||||
|
||||
ParticipantSelection::ParticipantSelection(LtsSession::LtsSession *session, QWidget *parent)
|
||||
: LtsWidgets::LtsFramelessDialog(parent, LtsWidgets::Behaviour::Modal)
|
||||
, m_dtc(nullptr)
|
||||
, m_ppmGuiCbxIfc(nullptr)
|
||||
, m_session(session)
|
||||
, m_ui(new Ui::ParticipantSelection)
|
||||
, m_logger(getLogger("ParticipantSelection"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
|
||||
|
||||
m_ui->tableViewSelection->treeView()->setIndentation(0);
|
||||
m_ui->tableViewSelection->treeView()->setItemsExpandable(false);
|
||||
|
||||
|
||||
connect(m_ui->pbTreeView, &QPushButton::clicked, this, &ParticipantSelection::onSwitchToTreeView);
|
||||
connect(m_ui->pbTableView, &QPushButton::clicked, this, &ParticipantSelection::onSwitchToTableView);
|
||||
|
||||
m_ui->treeViewSelection->treeView()->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
m_ui->tableViewSelection->treeView()->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
setStyleSheet(QStringLiteral("QToolTip { background-color: #ffffff; }"));
|
||||
}
|
||||
|
||||
ParticipantSelection::~ParticipantSelection()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
bool ParticipantSelection::init()
|
||||
{
|
||||
|
||||
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_dtc))
|
||||
return false;
|
||||
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(m_ppmGuiCbxIfc))
|
||||
return false;
|
||||
m_session->getForeignDataInterface<AdvancedSymbology::DataInterface>(m_asb);
|
||||
|
||||
connect(m_ui->ltsDialogButtonBox->getButton(LtsWidgets::DialogButton::Ok), &QPushButton::clicked, this, &ParticipantSelection::accept);
|
||||
connect(m_ui->ltsDialogButtonBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, this, &ParticipantSelection::reject);
|
||||
|
||||
|
||||
if (!m_dtc || !m_ppmGuiCbxIfc)
|
||||
return false;
|
||||
|
||||
|
||||
m_model = new ParticipantEditModel(this, m_dtc, m_asb);
|
||||
|
||||
|
||||
|
||||
m_proxyTree = new ParticipantTreeFilterProxyModel(this);
|
||||
m_proxyTree->setSourceModel(m_model);
|
||||
|
||||
m_ui->treeViewSelection->setModel(m_proxyTree);
|
||||
m_ui->treeViewSelection->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->treeViewSelection->setColumnHidden(ParticipantEditModel::ColParticipantId, true);
|
||||
#endif
|
||||
|
||||
|
||||
m_proxyTable = new ParticipantTableFilterProxyModel(this);
|
||||
m_proxyTable->setSourceModel(m_model);
|
||||
|
||||
connect(m_ui->tableViewSelection, &LtsDataView::LtsDataView::filterChanged,
|
||||
m_proxyTable, &ParticipantTableFilterProxyModel::onFilter);
|
||||
connect(m_ui->tableViewSelection, &LtsDataView::LtsDataView::sortOrderChanged,
|
||||
this, &ParticipantSelection::onSortTableView);
|
||||
connect(m_model, &ParticipantEditModel::internalDataChanged,
|
||||
m_proxyTable, &ParticipantTableFilterProxyModel::init);
|
||||
|
||||
connect(m_ui->tableViewSelection, &LtsDataView::LtsDataView::doubleClicked,
|
||||
this, &ParticipantSelection::accept);
|
||||
connect(m_ui->treeViewSelection, &LtsDataView::LtsDataView::doubleClicked,
|
||||
this, &ParticipantSelection::accept);
|
||||
m_ui->tableViewSelection->setModel(m_proxyTable);
|
||||
m_ui->tableViewSelection->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->tableViewSelection->setColumnHidden(ParticipantEditModel::ColParticipantId, true);
|
||||
#endif
|
||||
|
||||
|
||||
connect(m_ui->cbParty, static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged),
|
||||
this, &ParticipantSelection::onPartyChanged);
|
||||
|
||||
m_ppmGuiCbxIfc->fillPartyComboBox(m_ui->cbParty,
|
||||
ForeignGuiComboboxInterface::CbxPartyFilter::NormalPool);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const int idx = m_ui->cbParty->findData(s_preselectedParty);
|
||||
if (idx >= 0)
|
||||
m_ui->cbParty->setCurrentIndex(idx);
|
||||
|
||||
|
||||
|
||||
connect(m_ui->treeViewSelection, &LtsDataView::LtsDataView::filterChanged,
|
||||
this, [this](){ onFilterChanged(m_ui->treeViewSelection->searchModel(), m_ui->tableViewSelection->searchModel()); });
|
||||
connect(m_ui->tableViewSelection, &LtsDataView::LtsDataView::filterChanged,
|
||||
this, [this](){ onFilterChanged(m_ui->tableViewSelection->searchModel(), m_ui->treeViewSelection->searchModel()); });
|
||||
|
||||
|
||||
connect(m_ui->treeViewSelection, &LtsDataView::LtsDataView::selectionChanged,
|
||||
this, &ParticipantSelection::onSelectionChangedInTree);
|
||||
connect(m_ui->tableViewSelection, &LtsDataView::LtsDataView::selectionChanged,
|
||||
this, &ParticipantSelection::onSelectionChangedInTable);
|
||||
|
||||
|
||||
connect(m_ui->treeViewSelection->searchView()->header(), &QHeaderView::sectionResized,
|
||||
this, [this](int column, int oldWidth, int newWidth)
|
||||
{
|
||||
Q_UNUSED(oldWidth);
|
||||
onColumnWidthChanged(m_ui->tableViewSelection->searchView(), column, newWidth);
|
||||
});
|
||||
connect(m_ui->tableViewSelection->searchView()->header(), &QHeaderView::sectionResized,
|
||||
this, [this](int column, int oldWidth, int newWidth)
|
||||
{
|
||||
Q_UNUSED(oldWidth);
|
||||
onColumnWidthChanged(m_ui->treeViewSelection->searchView(), column, newWidth);
|
||||
});
|
||||
|
||||
|
||||
m_model->setUnitsSelectable(false);
|
||||
|
||||
onSwitchToTreeView();
|
||||
onPartyChanged();
|
||||
onEnaDisa();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ParticipantSelection::setMultiSelectionEnabled(bool enabled)
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
m_ui->treeViewSelection->setSelectionMode(QAbstractItemView::SelectionMode::MultiSelection);
|
||||
m_ui->tableViewSelection->setSelectionMode(QAbstractItemView::SelectionMode::MultiSelection);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->treeViewSelection->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);
|
||||
m_ui->tableViewSelection->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ParticipantSelection::setParticipantSelected(int partyId, int participantId)
|
||||
{
|
||||
if (participantId <= 0)
|
||||
return;
|
||||
|
||||
m_ui->cbParty->setCurrentIndex(m_ui->cbParty->findData(partyId));
|
||||
|
||||
|
||||
|
||||
const QModelIndex index = m_model->indexFromParticipantId(participantId);
|
||||
onSelectionChangedInTable(QItemSelection(index, index),{});
|
||||
onSelectionChangedInTree(QItemSelection(index, index),{});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ParticipantSelection::accept()
|
||||
{
|
||||
QModelIndexList indexList = m_ui->tableViewSelection->selectionModel()->selectedIndexes();
|
||||
if (indexList.isEmpty())
|
||||
return;
|
||||
|
||||
LtsWidgets::LtsFramelessDialog::accept();
|
||||
|
||||
m_proxyTable->resetMapping();
|
||||
m_proxyTable->init();
|
||||
|
||||
QVector<int> participantIds;
|
||||
participantIds.reserve(indexList.size());
|
||||
for (const auto &index : qAsConst(indexList))
|
||||
{
|
||||
QModelIndex sourceIndex = m_proxyTable->mapToSource(index);
|
||||
if (index.column() != 0)
|
||||
continue;
|
||||
participantIds << m_model->privateData(sourceIndex)->participant.id();
|
||||
}
|
||||
emit selectedParticipants(participantIds);
|
||||
}
|
||||
|
||||
void ParticipantSelection::onPartyChanged()
|
||||
{
|
||||
const int newPartyId = m_ui->cbParty->currentData().toInt();
|
||||
s_preselectedParty = newPartyId;
|
||||
|
||||
m_proxyTable->resetMapping();
|
||||
m_proxyTable->disableSorting();
|
||||
|
||||
if (m_model->onReinitModel(newPartyId))
|
||||
{
|
||||
m_ui->treeViewSelection->expandAll();
|
||||
m_ui->treeViewSelection->resizeHeadersByContent();
|
||||
}
|
||||
|
||||
|
||||
m_proxyTable->init();
|
||||
|
||||
|
||||
|
||||
|
||||
QTimer *timer = new QTimer(this);
|
||||
timer->singleShot(100, this, [this, timer]()
|
||||
{
|
||||
m_ui->tableViewSelection->treeView()->dataChanged
|
||||
(
|
||||
m_proxyTable->index(0, 0),
|
||||
m_proxyTable->index(std::min(50, m_proxyTable->rowCount()), 0),
|
||||
{ Qt::DecorationRole }
|
||||
);
|
||||
timer->deleteLater();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void ParticipantSelection::onChangesMade()
|
||||
{
|
||||
onEnaDisa();
|
||||
if (m_model->onReinitModel(s_preselectedParty))
|
||||
beautifyTreeView(m_ui->treeViewSelection->treeView(), m_model, true);
|
||||
}
|
||||
|
||||
void ParticipantSelection::onBeautifyTreeView()
|
||||
{
|
||||
beautifyTreeView(m_ui->treeViewSelection->treeView(), m_model, true);
|
||||
}
|
||||
|
||||
void ParticipantSelection::onEnaDisa()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ParticipantSelection::onSwitchToTreeView()
|
||||
{
|
||||
m_ui->pbTreeView->setEnabled(false);
|
||||
m_ui->pbTableView->setEnabled(true);
|
||||
m_ui->tableViewSelection->hide();
|
||||
m_ui->treeViewSelection->show();
|
||||
m_ui->treeViewSelection->expandAll();
|
||||
if (!m_ui->treeViewSelection->selectionModel()->selectedIndexes().isEmpty())
|
||||
{
|
||||
const QModelIndex &proxyIndex = m_ui->treeViewSelection->selectionModel()->selectedIndexes().first();
|
||||
m_ui->treeViewSelection->scrollTo(proxyIndex);
|
||||
}
|
||||
onEnaDisa();
|
||||
}
|
||||
|
||||
void ParticipantSelection::onSwitchToTableView()
|
||||
{
|
||||
m_ui->pbTreeView->setEnabled(true);
|
||||
m_ui->pbTableView->setEnabled(false);
|
||||
m_ui->treeViewSelection->hide();
|
||||
m_ui->tableViewSelection->show();
|
||||
if (!m_ui->tableViewSelection->selectionModel()->selectedIndexes().isEmpty())
|
||||
{
|
||||
const QModelIndex &proxyIndex = m_ui->tableViewSelection->selectionModel()->selectedIndexes().first();
|
||||
m_ui->tableViewSelection->scrollTo(proxyIndex);
|
||||
}
|
||||
onEnaDisa();
|
||||
}
|
||||
|
||||
void ParticipantSelection::onSelectionChangedInTree(const QItemSelection &selected, const QItemSelection &deselected)
|
||||
{
|
||||
m_ui->tableViewSelection->blockSignals(true);
|
||||
QModelIndexList indexes = deselected.indexes();
|
||||
for (const QModelIndex &sourceIndex : qAsConst(indexes))
|
||||
{
|
||||
QModelIndex proxyIndex = m_proxyTable->mapFromSource(sourceIndex);
|
||||
if (m_ui->tableViewSelection->selectionModel()->selectedIndexes().contains(proxyIndex))
|
||||
m_ui->tableViewSelection->selectionModel()->select(proxyIndex, { QItemSelectionModel::Deselect, QItemSelectionModel::Rows });
|
||||
}
|
||||
|
||||
indexes = selected.indexes();
|
||||
for (const QModelIndex &sourceIndex : qAsConst(indexes))
|
||||
{
|
||||
QModelIndex proxyIndex = m_proxyTable->mapFromSource(sourceIndex);
|
||||
if (!m_ui->tableViewSelection->selectionModel()->selectedIndexes().contains(proxyIndex))
|
||||
m_ui->tableViewSelection->selectionModel()->select(proxyIndex, { QItemSelectionModel::Select, QItemSelectionModel::Rows });
|
||||
}
|
||||
m_ui->tableViewSelection->blockSignals(false);
|
||||
m_ui->ltsDialogButtonBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(m_ui->treeViewSelection->selectedRows().count() > 0);
|
||||
}
|
||||
|
||||
void ParticipantSelection::onSelectionChangedInTable(const QItemSelection &selected, const QItemSelection &deselected)
|
||||
{
|
||||
m_ui->treeViewSelection->blockSignals(true);
|
||||
QModelIndexList indexes = deselected.indexes();
|
||||
for (const QModelIndex &sourceIndex : qAsConst(indexes))
|
||||
{
|
||||
QModelIndex proxyIndex = m_proxyTree->mapFromSource(sourceIndex);
|
||||
if (m_ui->treeViewSelection->selectionModel()->selectedIndexes().contains(proxyIndex))
|
||||
m_ui->treeViewSelection->selectionModel()->select(proxyIndex, { QItemSelectionModel::Deselect, QItemSelectionModel::Rows });
|
||||
}
|
||||
|
||||
indexes = selected.indexes();
|
||||
for (const QModelIndex &sourceIndex : qAsConst(indexes))
|
||||
{
|
||||
QModelIndex proxyIndex = m_proxyTree->mapFromSource(sourceIndex);
|
||||
if (!m_ui->treeViewSelection->selectionModel()->selectedIndexes().contains(proxyIndex))
|
||||
m_ui->treeViewSelection->selectionModel()->select(proxyIndex, { QItemSelectionModel::Select, QItemSelectionModel::Rows });
|
||||
}
|
||||
m_ui->treeViewSelection->blockSignals(false);
|
||||
m_ui->ltsDialogButtonBox->getButton(LtsWidgets::DialogButton::Ok)->setEnabled(m_ui->tableViewSelection->selectedRows().count() > 0);
|
||||
}
|
||||
|
||||
void ParticipantSelection::onFilterChanged(LtsDataView::SearchModel *from, LtsDataView::SearchModel *to)
|
||||
{
|
||||
for (int column = 0; column < to->columnCount(); ++column)
|
||||
{
|
||||
QModelIndex fromIndex = from->index(0, column, QModelIndex());
|
||||
QModelIndex toIndex = to->index(0, column, QModelIndex());
|
||||
QVariant columnFilter = from->data(fromIndex, Qt::EditRole);
|
||||
QVariant comboBoxData = from->data(fromIndex, LtsWidgets::LtsColumnFilterProxyModel::ComboboxFilterRole);
|
||||
|
||||
if (columnFilter != to->data(toIndex, Qt::EditRole))
|
||||
{
|
||||
to->setData(toIndex, columnFilter, Qt::EditRole);
|
||||
to->setData(toIndex, from->data(fromIndex, Qt::DisplayRole).toString(), Qt::DisplayRole);
|
||||
}
|
||||
else if (comboBoxData != to->data(toIndex, LtsWidgets::LtsColumnFilterProxyModel::ComboboxFilterRole))
|
||||
{
|
||||
to->setData(toIndex, comboBoxData, LtsWidgets::LtsColumnFilterProxyModel::ComboboxFilterRole);
|
||||
LtsWidgets::ComboboxFilterContent comboFilterContent = LtsWidgets::ComboboxFilterContent::fromVariant(
|
||||
m_model->headerData(column, Qt::Horizontal, LtsWidgets::LtsColumnFilterProxyModel::ComboboxFilterRole)
|
||||
);
|
||||
if (comboBoxData.toInt() == 0)
|
||||
{
|
||||
to->setData(toIndex, tr("<no filter>"), Qt::DisplayRole);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (const LtsWidgets::ComboboxFilterData &data : qAsConst(comboFilterContent.data))
|
||||
if (data.data == comboBoxData)
|
||||
{
|
||||
to->setData(toIndex, data.text, Qt::DisplayRole);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
m_ui->tableViewSelection->blockSignals(true);
|
||||
m_ui->tableViewSelection->selectionModel()->clearSelection();
|
||||
m_ui->tableViewSelection->blockSignals(false);
|
||||
m_ui->treeViewSelection->blockSignals(true);
|
||||
m_ui->treeViewSelection->selectionModel()->clearSelection();
|
||||
m_ui->treeViewSelection->blockSignals(false);
|
||||
}
|
||||
|
||||
void ParticipantSelection::onSortTableView(int column, Qt::SortOrder order)
|
||||
{
|
||||
QModelIndex sourceIndex;
|
||||
if (!m_ui->treeViewSelection->selectionModel()->selectedIndexes().isEmpty())
|
||||
{
|
||||
QModelIndex proxyIndex = m_ui->tableViewSelection->selectionModel()->selectedIndexes().first();
|
||||
sourceIndex = m_proxyTable->mapToSource(proxyIndex);
|
||||
m_ui->tableViewSelection->blockSignals(true);
|
||||
m_ui->tableViewSelection->selectionModel()->select(proxyIndex, { QItemSelectionModel::Deselect, QItemSelectionModel::Rows });
|
||||
m_ui->tableViewSelection->blockSignals(false);
|
||||
}
|
||||
|
||||
m_proxyTable->onSort(column, order);
|
||||
|
||||
if (sourceIndex != QModelIndex())
|
||||
{
|
||||
QModelIndex proxyIndex = m_proxyTable->mapFromSource(sourceIndex);
|
||||
m_ui->tableViewSelection->blockSignals(true);
|
||||
m_ui->tableViewSelection->selectionModel()->select(proxyIndex, { QItemSelectionModel::Select, QItemSelectionModel::Rows });
|
||||
m_ui->tableViewSelection->blockSignals(false);
|
||||
m_ui->tableViewSelection->scrollTo(proxyIndex);
|
||||
}
|
||||
}
|
||||
|
||||
void ParticipantSelection::onColumnWidthChanged(QTreeView *to, const int &column, const int &width)
|
||||
{
|
||||
if (to->columnWidth(column) != width)
|
||||
to->setColumnWidth(column, width);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Services/ParticipantManagement/ppm_dtc.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <ParticipantSelection/ppmparticipantselectiongui_export.h>
|
||||
|
||||
class QTreeView;
|
||||
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
class ForeignDataInterface;
|
||||
}
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ParticipantSelection;
|
||||
}
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
namespace LtsDataView
|
||||
{
|
||||
class SearchModel;
|
||||
}
|
||||
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
class ParticipantEditModel;
|
||||
class ParticipantSelectionItem;
|
||||
class ParticipantTreeEditHandler;
|
||||
class ParticipantTreeFilterProxyModel;
|
||||
class ParticipantTableFilterProxyModel;
|
||||
|
||||
|
||||
class PPMPARTICIPANTSELECTIONGUI_EXPORT ParticipantSelection : public LtsWidgets::LtsFramelessDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ParticipantSelection(LtsSession::LtsSession *session, QWidget *parent = nullptr);
|
||||
~ParticipantSelection();
|
||||
|
||||
bool init();
|
||||
|
||||
void setParticipantSelected(int partyId, int participantId);
|
||||
|
||||
void setMultiSelectionEnabled(bool enabled);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
protected slots:
|
||||
void onEnaDisa();
|
||||
|
||||
void onPartyChanged();
|
||||
void onChangesMade();
|
||||
void onBeautifyTreeView();
|
||||
|
||||
private slots:
|
||||
void onSwitchToTreeView();
|
||||
void onSwitchToTableView();
|
||||
void onFilterChanged(LtsDataView::SearchModel *from, LtsDataView::SearchModel *to);
|
||||
void onSortTableView(int column, Qt::SortOrder order);
|
||||
void onSelectionChangedInTree(const QItemSelection &selected, const QItemSelection &deselected);
|
||||
void onSelectionChangedInTable(const QItemSelection &selected, const QItemSelection &deselected);
|
||||
void onColumnWidthChanged(QTreeView *to, const int &column, const int &width);
|
||||
void accept() override final;
|
||||
|
||||
signals:
|
||||
void selectedParticipants(const QVector<int> &participantIds);
|
||||
|
||||
private:
|
||||
ParticipantTreeEditHandler *m_pTreehandler{nullptr};
|
||||
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> m_ppmGuiCbxIfc;
|
||||
std::shared_ptr<AdvancedSymbology::ForeignDataInterface> m_asb;
|
||||
|
||||
ParticipantSelectionItem *m_newItemDlg{nullptr};
|
||||
LtsSession::LtsSession *m_session{nullptr};
|
||||
|
||||
static int s_preselectedParty;
|
||||
|
||||
ParticipantEditModel *m_model{nullptr};
|
||||
ParticipantTreeFilterProxyModel *m_proxyTree{nullptr};
|
||||
ParticipantTableFilterProxyModel *m_proxyTable{nullptr};
|
||||
|
||||
Ui::ParticipantSelection *m_ui;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ParticipantSelection</class>
|
||||
<widget class="QWidget" name="ParticipantSelection">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>655</width>
|
||||
<height>472</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">setwindowtitle in source</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblParty">
|
||||
<property name="text">
|
||||
<string>Party:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="pbTreeView">
|
||||
<property name="text">
|
||||
<string>Tree View</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="5">
|
||||
<widget class="LtsWidgets::LtsDialogButtonBox" name="ltsDialogButtonBox"/>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="5">
|
||||
<widget class="LtsDataView::LtsDataView" name="tableViewSelection">
|
||||
<property name="showColumnCount" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QPushButton" name="pbTableView">
|
||||
<property name="text">
|
||||
<string>Table View</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbParty">
|
||||
<property name="const" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="5">
|
||||
<widget class="LtsDataView::LtsDataView" name="treeViewSelection">
|
||||
<property name="showColumnCount" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsDialogButtonBox</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsWidgets/lts_dialog_button_box.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>LtsWidgets/lts_combo_box.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>LtsDataView::LtsDataView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsDataView/lts_data_view.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
|
||||
|
||||
|
||||
#include "participant_selection_gui_plugin.h"
|
||||
#include "participant_selection.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
ParticipantManagement::ParticipantSelection *InterfaceImpl::onParticipantSelection(QWidget *parent, LtsSession::LtsSession *session)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
auto *dlg = new ParticipantSelection(session, parent);
|
||||
if (dlg->init())
|
||||
return dlg;
|
||||
return nullptr;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ParticipantManagement/logger.h>
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_participants_gui_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
|
||||
namespace AdvancedSymbology
|
||||
{
|
||||
class ForeignDataInterface;
|
||||
}
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
class ParticipantSelection;
|
||||
|
||||
class InterfaceImpl final : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
static ParticipantSelection *onParticipantSelection(QWidget *parent, LtsSession::LtsSession *session);
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
+1372
File diff suppressed because it is too large.
Load diff
+276
@@ -0,0 +1,276 @@
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Common/participant_icon_model_base.h>
|
||||
|
||||
#include <ParticipantManagement/logger.h>
|
||||
#include <Plugins/ParticipantManagement/Gui/ParticipantSelection/ppmparticipantselectiongui_export.h>
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
|
||||
#include <QSet>
|
||||
|
||||
|
||||
class QTreeView;
|
||||
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
class CheckedTreeItem;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class PPMPARTICIPANTSELECTIONGUI_EXPORT ParticipantSelectionModel : public ParticipantIconModelBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
ColDesignator,
|
||||
ColIdentifier,
|
||||
ColTypeClass,
|
||||
ColType,
|
||||
ColEquipmentNumber,
|
||||
ColParticipantId,
|
||||
ColInfo,
|
||||
ColSign
|
||||
};
|
||||
|
||||
class CheckedTreeItem final : public NGLTreeItem
|
||||
{
|
||||
public:
|
||||
using NGLTreeItem::NGLTreeItem;
|
||||
|
||||
ParticipantData participant;
|
||||
bool bIsChecked = false;
|
||||
};
|
||||
|
||||
ParticipantSelectionModel(QObject *parent,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AdvancedSymbology::ForeignDataInterface> &asbIfc);
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||
|
||||
virtual bool onReinitModel(int partyId, const QSet<int> &checkedParticipants = QSet<int>(), Qt::CheckState cs = Qt::Checked);
|
||||
|
||||
bool insertRow(int row, const QModelIndex &parent, NGLTreeItem *item);
|
||||
bool removeRow(int row, const QModelIndex &parent = QModelIndex());
|
||||
bool isRowRemovable(const CheckedTreeItem *parentItem) const;
|
||||
|
||||
bool rowsCheckable() const { return m_bRowsAreCheckable; }
|
||||
bool unitsSelectable() const { return m_bUnitsSelectable; }
|
||||
int partyId() const { return m_partyId; }
|
||||
|
||||
void dataCommitted();
|
||||
void processMissingSuperiorId();
|
||||
void selectItemByParticipantId(int participantId,
|
||||
const std::function<void(const QModelIndex &)> &selectItem,
|
||||
const QModelIndex &parent = QModelIndex());
|
||||
|
||||
QModelIndexList getIndexesByParticipantIds(const std::vector<int32_t> &participantIds,
|
||||
const QModelIndex &parent = QModelIndex()) const;
|
||||
|
||||
void setRowsCheckable(bool bCheckable);
|
||||
void setUnitsSelectable(bool bSelectable) { m_bUnitsSelectable = bSelectable; }
|
||||
bool setCheckStateForParticipants(const QSet<int> &checkedParticipants, Qt::CheckState cs);
|
||||
|
||||
ParticipantManagement::ParticipantData getParticipantData(const QModelIndex &idx) const;
|
||||
std::vector<ParticipantData> participantData(bool bOnlyModified = true) const;
|
||||
QSet<int> participantIds() const;
|
||||
QSet<int> checkStateForParticipants(Qt::CheckState cs) const;
|
||||
|
||||
CheckedTreeItem *privateData(const QModelIndex &index);
|
||||
const CheckedTreeItem *privateData(const QModelIndex &index) const;
|
||||
|
||||
QModelIndex indexFromParticipantId(int participantId) const;
|
||||
|
||||
QString getHierarchyFromIndex(const QModelIndex &index) const;
|
||||
|
||||
protected:
|
||||
void gatherParticipants(QHash<int, ParticipantData> &tmap,
|
||||
QHash<int, QSet<int>> &parentId2id) const;
|
||||
|
||||
std::vector<ParticipantData> getChildrenOf(NGLTreeItem *item,
|
||||
int parentId,
|
||||
int hierarchyNumber,
|
||||
bool bOnlyModifed,
|
||||
int &highestModId) const;
|
||||
bool updateChildrenOf(int parentId,
|
||||
NGLTreeItem *parent,
|
||||
const QHash<int, QSet<int>> &parentId2id,
|
||||
const QHash<int, ParticipantData> &tmap);
|
||||
void insertChildrenOf(int parentId,
|
||||
NGLTreeItem *parent,
|
||||
const QModelIndex &parentIdx,
|
||||
const QHash<int, QSet<int>> &parentId2id,
|
||||
const QHash<int, ParticipantData> &tmap,
|
||||
const QSet<int> &checkedParticipants,
|
||||
Qt::CheckState cs);
|
||||
|
||||
bool isParentOf(const NGLTreeItem *item, int participantId) const;
|
||||
|
||||
QSet<int> participantIds(NGLTreeItem *parentItem) const;
|
||||
QSet<int> checkState(CheckedTreeItem *parentItem, Qt::CheckState cs) const;
|
||||
|
||||
void setCheckState(CheckedTreeItem *parentItem, const QSet<int> &checkedParticipants, Qt::CheckState cs);
|
||||
|
||||
QModelIndex indexFromParticipantId(int participantId, const CheckedTreeItem *cti) const;
|
||||
int participantIdFromItem(NGLTreeItem *item) const;
|
||||
CheckedTreeItem *searchParticipant(const NGLTreeItem *parentItem, int participantId) const;
|
||||
|
||||
NGLTreeItem *createItem(const QVariant &data, const QIcon &icon) const override;
|
||||
QVariant getItemData(const NGLTreeItem *item) const override;
|
||||
|
||||
public slots:
|
||||
int insertParticipant(const QModelIndex &parent, ParticipantData participantData, bool bNewParticipant);
|
||||
int onInsertRow(const QModelIndex &parent, const ParticipantData &participantData);
|
||||
bool onUpdateRow(const QModelIndex &index, const ParticipantData &participantData);
|
||||
bool onDeleteRow(const QModelIndex &idx, bool isFirstItem = true);
|
||||
void onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType);
|
||||
|
||||
signals:
|
||||
void internalDataChanged();
|
||||
|
||||
protected:
|
||||
int m_partyId;
|
||||
bool m_bRowsAreCheckable;
|
||||
bool m_bUnitsSelectable;
|
||||
std::vector<ParticipantManagement::ParticipantData> m_dataToDelete;
|
||||
QTimer *m_missingSuperiorIdTimer;
|
||||
QSet<int> m_missingSuperiorId;
|
||||
QSet<int> m_usedTypeIds;
|
||||
QSet<TypeClass> m_usedTypeClassIds;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class PPMPARTICIPANTSELECTIONGUI_EXPORT ParticipantTreeFilterProxyModel : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
|
||||
void setAllowedTypes(const QSet<int> &allowedTypes);
|
||||
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
||||
|
||||
int partyId() const { return m_sourceModel ? m_sourceModel->partyId() : -1; }
|
||||
|
||||
protected:
|
||||
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
|
||||
bool filterTypeRecursive(const ParticipantSelectionModel::CheckedTreeItem *item) const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
QSet<int> m_allowedTypes;
|
||||
ParticipantSelectionModel *m_sourceModel{nullptr};
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class PPMPARTICIPANTSELECTIONGUI_EXPORT ParticipantTableFilterProxyModel : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
struct SortData
|
||||
{
|
||||
bool isActive{false};
|
||||
int column{-1};
|
||||
Qt::SortOrder order{Qt::DescendingOrder};
|
||||
bool ascending() const
|
||||
{
|
||||
return order == Qt::AscendingOrder;
|
||||
}
|
||||
bool descending() const
|
||||
{
|
||||
return order == Qt::DescendingOrder;
|
||||
}
|
||||
QString toString()
|
||||
{
|
||||
QString str{QStringLiteral("active=")};
|
||||
str += isActive ? QStringLiteral("true") : QStringLiteral("false");
|
||||
str += QStringLiteral(", column=") + QString::number(column) + QStringLiteral(", order=");
|
||||
str += order == Qt::DescendingOrder ? QStringLiteral("Descending") : QStringLiteral("Ascending");
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
explicit ParticipantTableFilterProxyModel(QObject *parent = nullptr);
|
||||
|
||||
void init();
|
||||
void resetMapping();
|
||||
void disableSorting() { m_sortData.isActive = false; }
|
||||
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||
|
||||
QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override;
|
||||
QModelIndex mapToSource(const QModelIndex &proxyIndex) const override;
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
||||
QModelIndex parent(const QModelIndex &child) const override;
|
||||
QModelIndex sibling(int row, int column, const QModelIndex &idx) const override;
|
||||
|
||||
bool isFilterActive() const { return m_isFilterActive; }
|
||||
bool hasChildren(const QModelIndex &parent) const override;
|
||||
|
||||
SortData sortData() const { return m_sortData; }
|
||||
|
||||
protected:
|
||||
bool lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const override;
|
||||
bool filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const override;
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
|
||||
bool filterAcceptsRowInternal(int sourceRow, const QModelIndex &sourceParent) const;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
int mapTreeToTable(const QModelIndex &parent = QModelIndex(), int row = 0);
|
||||
|
||||
public slots:
|
||||
void onFilter();
|
||||
void onSort(int column, Qt::SortOrder order);
|
||||
|
||||
private:
|
||||
QHash<int, QModelIndex> m_mapToSource;
|
||||
QHash<QModelIndex, int> m_mapFromSource;
|
||||
QHash<int, QModelIndex> m_mapToSourceInternal;
|
||||
QHash<QModelIndex, int> m_mapFromSourceInternal;
|
||||
QHash<int, QModelIndex> m_mapToSourceFiltered;
|
||||
QHash<QModelIndex, int> m_mapFromSourceFiltered;
|
||||
QVector<int> m_sortMap;
|
||||
|
||||
bool m_isFilterActive{false};
|
||||
SortData m_sortData;
|
||||
|
||||
ParticipantSelectionModel *m_sourceModel{nullptr};
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(ParticipantManagement::ParticipantData)
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
#<PresetName>:<database><,username><,password><,hostname><,port(optional)><,filename(optional)>
|
||||
:,ctc_ws,ctc11de,,PQSQL
|
||||
Reference in new issue
Block a user