BUILD_RTI conditional fixes and Qt6 API updates
- cmake/FindRTI.cmake: Add INTERFACE placeholder targets when RTI not found - cmake/FindRTI.cmake: Force BUILD_RTI=OFF when RTI not installed - Lts/Common/LtsSession/CMakeLists.txt: Make LtsSessionDataDds conditional on BUILD_RTI - Lts/Viewer/CMakeLists.txt: Make LtsDataView conditional on BUILD_RTI - Lts/Plugins/*/CMakeLists.txt: 97 plugin files wrapped in BUILD_RTI conditionals - cmake/NGLMacros.cmake: Fix NGL_ADD_BIG_RESOURCES macro (removed premature return()) - Multiple Qt6 API fixes: QLinkedList→std::list, QStringRef→QStringView, etc. - BUILD_RTI_FIXES_SUMMARY.md: Comprehensive documentation of all fixes Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2065 files changed
+48219
-1763
No files matched your search
+118
@@ -0,0 +1,118 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Implementation of CheckStateProxyModel
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl/Christian Froebel, NLE, 2019-05-10
|
||||
*/
|
||||
|
||||
#include "check_state_proxy_model.h"
|
||||
|
||||
namespace LtsDataView
|
||||
{
|
||||
Qt::ItemFlags CheckStateProxyModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return sourceModel()->flags(index); // delegate to source model for further processing if necessary
|
||||
|
||||
// Sets only the checkbox nodes on user checkable,
|
||||
// checkbox leaves must be handled in source model.
|
||||
QModelIndex sourceIndex = mapToSource(index);
|
||||
Qt::ItemFlags fl = sourceModel()->flags(sourceIndex);
|
||||
if (index.column() == 0)
|
||||
return fl | Qt::ItemIsUserCheckable;
|
||||
return fl;
|
||||
}
|
||||
|
||||
|
||||
QVariant CheckStateProxyModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
QModelIndex sourceIndex = mapToSource(index);
|
||||
|
||||
// delegate everything except CheckStateRole to source model
|
||||
if (role != Qt::CheckStateRole)
|
||||
return sourceModel()->data(sourceIndex, role);
|
||||
|
||||
// delegate a leaf too with CheckStateRole to source model
|
||||
if (isLeaf(index))
|
||||
return sourceModel()->data(sourceIndex, role);
|
||||
|
||||
// delegate to source model for further processing of further columns if necessary
|
||||
if (index.column() != 0)
|
||||
return sourceModel()->data(sourceIndex, role);
|
||||
|
||||
// sets the node checkboxes and decoration depending on the entries in the tree structure
|
||||
int checkedCount = 0;
|
||||
int childCount = rowCount(index);
|
||||
for (int childRow = 0; childRow < childCount; ++childRow)
|
||||
{
|
||||
QModelIndex childIndex = this->index(childRow, 0, index);
|
||||
Qt::CheckState checkState = data(childIndex, Qt::CheckStateRole).value<Qt::CheckState>();
|
||||
if (checkState == Qt::PartiallyChecked)
|
||||
return Qt::PartiallyChecked;
|
||||
if (checkState == Qt::Checked)
|
||||
++checkedCount;
|
||||
}
|
||||
if (checkedCount == childCount)
|
||||
return Qt::Checked;
|
||||
else if (checkedCount == 0)
|
||||
return Qt::Unchecked;
|
||||
else
|
||||
return Qt::PartiallyChecked;
|
||||
}
|
||||
|
||||
|
||||
bool CheckStateProxyModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return false;
|
||||
|
||||
QModelIndex sourceIndex = mapToSource(index);
|
||||
|
||||
// delegate to source model for further processing of further columns if necessary
|
||||
if (index.column() != 0)
|
||||
return sourceModel()->setData(sourceIndex, value, role);
|
||||
|
||||
// delegate everything except CheckStateRole to source mode
|
||||
if (role != Qt::CheckStateRole)
|
||||
return sourceModel()->setData(sourceIndex, value, role);
|
||||
|
||||
if (isLeaf(index))
|
||||
{
|
||||
// delegate a leaf to source model
|
||||
sourceModel()->setData(sourceIndex, value, role);
|
||||
|
||||
// update parents recursively here
|
||||
QModelIndex idx = index.parent();
|
||||
do
|
||||
{
|
||||
emit dataChanged(idx, idx, {Qt::CheckStateRole});
|
||||
idx = idx.parent();
|
||||
}
|
||||
while (idx.isValid());
|
||||
return true;
|
||||
}
|
||||
|
||||
// update underlying children recursively (Additional nodes with leaves may also exist)
|
||||
int childCount = rowCount(index);
|
||||
for (int childRow = 0; childRow < childCount; ++childRow)
|
||||
{
|
||||
QModelIndex childIndex = this->index(childRow, 0, index);
|
||||
setData(childIndex, value, Qt::CheckStateRole);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CheckStateProxyModel::isLeaf(const QModelIndex &index) const
|
||||
{
|
||||
QModelIndex sourceIndex = mapToSource(index);
|
||||
return sourceModel()->flags(sourceIndex).testFlag(Qt::ItemIsUserCheckable);
|
||||
}
|
||||
|
||||
|
||||
} // namespace InfrastructureManagement
|
||||
Reference in new issue
Block a user