Add a view id tag to project tree and tooltip

* Remove it from property editor
This commit is contained in:
Gaute Lindkvist 2019-11-04 15:26:03 +01:00
parent f222f73718
commit 03ff43237d
21 changed files with 261 additions and 35 deletions

View File

@ -191,6 +191,9 @@ RiaPreferences::RiaPreferences( void )
"",
"" );
m_appendFieldKeywordToToolTipText.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
CAF_PDM_InitField( &m_showViewIdInProjectTree, "showViewIdInTree", false, "Show View Id in Project Tree", "", "", "" );
m_showViewIdInProjectTree.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
CAF_PDM_InitField( &m_showTestToolbar, "showTestToolbar", false, "Enable Test Toolbar", "", "", "" );
m_showTestToolbar.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
CAF_PDM_InitField( &m_includeFractureDebugInfoFile,
@ -357,12 +360,12 @@ void RiaPreferences::defineEditorAttribute( const caf::PdmFieldHandle* field,
}
if ( field == &octaveShowHeaderInfoWhenExecutingScripts || field == &autocomputeDepthRelatedProperties ||
field == &loadAndShowSoil || field == &useShaders || field == &showHud ||
field == &m_appendClassNameToUiText || field == &m_appendFieldKeywordToToolTipText ||
field == &m_showTestToolbar || field == &m_includeFractureDebugInfoFile ||
field == &showLasCurveWithoutTvdWarning || field == &holoLensDisableCertificateVerification ||
field == &m_showProjectChangedDialog || field == &m_searchPlotTemplateFoldersRecursively ||
field == &showLegendBackground || field == &m_showSummaryTimeAsLongString )
field == &loadAndShowSoil || field == &useShaders || field == &showHud || field == &m_appendClassNameToUiText ||
field == &m_appendFieldKeywordToToolTipText || field == &m_showTestToolbar ||
field == &m_includeFractureDebugInfoFile || field == &showLasCurveWithoutTvdWarning ||
field == &holoLensDisableCertificateVerification || field == &m_showProjectChangedDialog ||
field == &m_searchPlotTemplateFoldersRecursively || field == &showLegendBackground ||
field == &m_showSummaryTimeAsLongString || field == &m_showViewIdInProjectTree )
{
caf::PdmUiCheckBoxEditorAttribute* myAttr = dynamic_cast<caf::PdmUiCheckBoxEditorAttribute*>( attribute );
if ( myAttr )
@ -481,6 +484,7 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
{
uiOrdering.add( &m_appendClassNameToUiText );
uiOrdering.add( &m_appendFieldKeywordToToolTipText );
uiOrdering.add( &m_showViewIdInProjectTree );
uiOrdering.add( &m_showProjectChangedDialog );
@ -653,6 +657,14 @@ bool RiaPreferences::appendFieldKeywordToToolTipText() const
return RiaApplication::enableDevelopmentFeatures() && m_appendFieldKeywordToToolTipText();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaPreferences::showViewIdInProjectTree() const
{
return RiaApplication::enableDevelopmentFeatures() && m_showViewIdInProjectTree();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -71,6 +71,7 @@ public:
// Debug settings
bool appendClassNameToUiText() const;
bool appendFieldKeywordToToolTipText() const;
bool showViewIdInProjectTree() const;
bool showTestToolbar() const;
bool includeFractureDebugInfoFile() const;
bool showProjectChangedDialog() const;
@ -163,6 +164,7 @@ private:
caf::PdmChildField<RifReaderSettings*> m_readerSettings;
caf::PdmField<bool> m_appendClassNameToUiText;
caf::PdmField<bool> m_appendFieldKeywordToToolTipText;
caf::PdmField<bool> m_showViewIdInProjectTree;
caf::PdmField<bool> m_showProjectChangedDialog;

View File

@ -366,7 +366,6 @@ QList<caf::PdmOptionItemInfo>
//--------------------------------------------------------------------------------------------------
void RimFlowCharacteristicsPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
RimViewWindow::defineUiOrdering( uiConfigName, uiOrdering );
{
// Ensure a case is selected if one is available
RimProject* proj = nullptr;

View File

@ -124,7 +124,7 @@ RimWellAllocationPlot::RimWellAllocationPlot()
m_accumulatedWellFlowPlot->setAvailableDepthUnits( {} );
m_accumulatedWellFlowPlot->setAvailableDepthTypes(
{RimWellLogPlot::CONNECTION_NUMBER, RimWellLogPlot::TRUE_VERTICAL_DEPTH, RimWellLogPlot::PSEUDO_LENGTH} );
{ RimWellLogPlot::CONNECTION_NUMBER, RimWellLogPlot::TRUE_VERTICAL_DEPTH, RimWellLogPlot::PSEUDO_LENGTH } );
m_accumulatedWellFlowPlot->setCommonDataSourceEnabled( false );
}
@ -796,8 +796,6 @@ QImage RimWellAllocationPlot::snapshotWindowContent()
//--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
RimViewWindow::defineUiOrdering( uiConfigName, uiOrdering );
uiOrdering.add( &m_userName );
uiOrdering.add( &m_showPlotTitle );

View File

@ -976,8 +976,6 @@ void RimWellPltPlot::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin
//--------------------------------------------------------------------------------------------------
void RimWellPltPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
RimViewWindow::defineUiOrdering( uiConfigName, uiOrdering );
uiOrdering.add( &m_wellPathName );
caf::PdmUiGroup* sourcesGroup = uiOrdering.addNewGroupWithKeyword( "Sources", "Sources" );

View File

@ -883,7 +883,6 @@ void RimWellRftPlot::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin
//--------------------------------------------------------------------------------------------------
void RimWellRftPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
RimViewWindow::defineUiOrdering( uiConfigName, uiOrdering );
uiOrdering.add( &m_wellPathNameOrSimWellName );
uiOrdering.add( &m_showStatisticsCurves );
uiOrdering.add( &m_showEnsembleCurves );

View File

@ -452,8 +452,6 @@ void RimGridCrossPlot::initAfterRead()
//--------------------------------------------------------------------------------------------------
void RimGridCrossPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
RimViewWindow::defineUiOrdering( uiConfigName, uiOrdering );
uiOrdering.add( &m_showInfoBox );
if ( isStandalonePlot() )

View File

@ -327,8 +327,6 @@ void Rim3dView::deleteViewWidget()
//--------------------------------------------------------------------------------------------------
void Rim3dView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
RimViewWindow::defineUiOrdering( uiConfigName, uiOrdering );
caf::PdmUiGroup* viewGroup = uiOrdering.addNewGroupWithKeyword( "Viewer", "ViewGroup" );
viewGroup->add( &m_backgroundColor );

View File

@ -62,6 +62,15 @@ public:
}
virtual void setWidthScaleFactor( WidthScaleFactor scaleFactor ) {}
virtual int rowSpan() const
{
return 1;
}
virtual int colSpan() const
{
return 1;
}
virtual bool hasCustomFontSizes( RiaDefines::FontSettingType fontSettingType, int defaultFontSize ) const = 0;
virtual bool applyFontSize( RiaDefines::FontSettingType fontSettingType,
int oldFontSize,

View File

@ -101,9 +101,9 @@ CAF_PDM_SOURCE_INIT( RimProject, "ResInsightProject" );
///
//--------------------------------------------------------------------------------------------------
RimProject::RimProject( void )
: m_nextValidCaseId( 0 )
, m_nextValidCaseGroupId( 0 )
, m_nextValidViewId( 0 )
: m_nextValidCaseId( 1 )
, m_nextValidCaseGroupId( 1 )
, m_nextValidViewId( 1 )
{
CAF_PDM_InitObject( "Project", "", "", "" );

View File

@ -19,13 +19,18 @@
#include "RimViewWindow.h"
#include "RiaApplication.h"
#include "RiaColorTables.h"
#include "RiaColorTools.h"
#include "RiaFieldHandleTools.h"
#include "RiaGuiApplication.h"
#include "RiaPreferences.h"
#include "RicfCommandObject.h"
#include "RimMdiWindowController.h"
#include "RimProject.h"
#include "cafPdmUiTreeViewEditor.h"
#include "cvfAssert.h"
#include <QDebug>
@ -54,7 +59,10 @@ RimViewWindow::RimViewWindow( void )
// Obsolete field
CAF_PDM_InitFieldNoDefault( &obsoleteField_windowGeometry, "WindowGeometry", "", "", "", "" );
RiaFieldhandleTools::disableWriteAndSetFieldHidden( &obsoleteField_windowGeometry );
RiaApplication::instance()->project()->assignViewIdToView( this );
QString viewIdTooltip = QString( "View id: %1" ).arg( m_viewId );
this->setUiToolTip( viewIdTooltip );
}
//--------------------------------------------------------------------------------------------------
@ -306,7 +314,15 @@ void RimViewWindow::initAfterRead()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimViewWindow::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
void RimViewWindow::defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
{
uiOrdering.add( &m_viewId );
caf::PdmUiTreeViewItemAttribute* treeItemAttribute = dynamic_cast<caf::PdmUiTreeViewItemAttribute*>( attribute );
if ( treeItemAttribute && RiaApplication::instance()->preferences()->showViewIdInProjectTree() )
{
treeItemAttribute->tag = QString( "%1" ).arg( m_viewId );
cvf::Color3f viewColor = RiaColorTables::contrastCategoryPaletteColors().cycledColor3f( (size_t)m_viewId );
cvf::Color3f viewTextColor = RiaColorTools::contrastColor( viewColor );
treeItemAttribute->bgColor = QColor( RiaColorTools::toQColor( viewColor ) );
treeItemAttribute->fgColor = QColor( RiaColorTools::toQColor( viewTextColor ) );
}
}

View File

@ -126,7 +126,8 @@ protected:
const QVariant& oldValue,
const QVariant& newValue ) override;
void initAfterRead() override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
private:
void setAsMdiWindow( int mainWindowID );

View File

@ -125,8 +125,6 @@ double RimWellBoreStabilityPlot::userDefinedUcs() const
//--------------------------------------------------------------------------------------------------
void RimWellBoreStabilityPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
RimViewWindow::defineUiOrdering( uiConfigName, uiOrdering );
m_commonDataSource->uiOrdering( RimWellLogCurveCommonDataSource::smoothingUiOrderinglabel(), uiOrdering );
caf::PdmUiGroup* parameterSources = uiOrdering.addNewGroup( "Parameter Sources" );

View File

@ -593,8 +593,6 @@ void RimWellLogPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
RimViewWindow::defineUiOrdering( uiConfigName, uiOrdering );
if ( m_commonDataSourceEnabled )
{
m_commonDataSource->uiOrdering( uiConfigName, uiOrdering );

View File

@ -1668,8 +1668,6 @@ void RimSummaryPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
mainOptions->add( &m_normalizeCurveYValues );
RimViewWindow::defineUiOrdering( uiConfigName, uiOrdering );
uiOrdering.skipRemainingFields( true );
}

View File

@ -627,8 +627,8 @@ RiuWidgetStyleSheet RiuQwtPlotWidget::createPlotStyleSheet() const
{
QColor backgroundColor = QColor( "white" );
QColor highlightColor = QApplication::palette().highlight().color();
QColor blendedHighlightColor = RiaColorTools::blendQColors( highlightColor, backgroundColor, 1, 10 );
QColor nearlyBackgroundColor = RiaColorTools::blendQColors( highlightColor, backgroundColor, 1, 30 );
QColor blendedHighlightColor = RiaColorTools::blendQColors( highlightColor, backgroundColor, 1, 20 );
QColor nearlyBackgroundColor = RiaColorTools::blendQColors( highlightColor, backgroundColor, 1, 40 );
RiuWidgetStyleSheet styleSheet;
styleSheet.set( "background-color", backgroundColor.name() );
@ -639,12 +639,14 @@ RiuWidgetStyleSheet RiuQwtPlotWidget::createPlotStyleSheet() const
if ( m_draggable )
{
QString backgroundGradient = QString( QString( "qlineargradient( x1 : 1, y1 : 0, x2 : 1, y2 : 1,"
"stop: 0 %1, stop: 0.015 %2, stop:1 %3 )" )
"stop: 0 %1, stop: 0.02 %2, stop:1 %3 )" )
.arg( blendedHighlightColor.name() )
.arg( nearlyBackgroundColor.name() )
.arg( backgroundColor.name() ) );
styleSheet.state( RiuWidgetStyleSheet::HOVER ).set( "background", backgroundGradient );
styleSheet.state( RiuWidgetStyleSheet::HOVER )
.set( "border", QString( "1px dashed %1" ).arg( blendedHighlightColor.name() ) );
}
styleSheet.state( RiuWidgetStyleSheet::DRAG_TARGET_BEFORE ).set( "border-left", "1px solid lime" );
styleSheet.state( RiuWidgetStyleSheet::DRAG_TARGET_AFTER ).set( "border-right", "1px solid lime" );

View File

@ -351,6 +351,7 @@ void PdmUiTreeSelectionEditor::configureAndUpdateUi(const QString& uiConfigName)
}
}
}
// If the tree doesn't have grand children we treat this as a straight list
m_treeView->setRootIsDecorated(m_model->hasGrandChildren());

View File

@ -51,7 +51,9 @@
#include <QGridLayout>
#include <QMenu>
#include <QModelIndexList>
#include <QPainter>
#include <QSortFilterProxyModel>
#include <QStyleOptionViewItem>
#include <QTreeView>
#include <QWidget>
@ -108,6 +110,7 @@ PdmUiTreeViewEditor::PdmUiTreeViewEditor()
m_layout = nullptr;
m_treeView = nullptr;
m_treeViewModel = nullptr;
m_delegate = nullptr;
}
//--------------------------------------------------------------------------------------------------
@ -133,6 +136,10 @@ QWidget* PdmUiTreeViewEditor::createWidget(QWidget* parent)
m_treeView->setModel(m_treeViewModel);
m_treeView->installEventFilter(this);
m_delegate = new PdmUiTreeViewItemDelegate(m_treeView, m_treeViewModel);
m_treeView->setItemDelegate(m_delegate);
connect(treeView()->selectionModel(), SIGNAL(selectionChanged( const QItemSelection & , const QItemSelection & )), SLOT(slotOnSelectionChanged( const QItemSelection & , const QItemSelection & )));
m_layout->addWidget(m_treeView);
@ -153,7 +160,7 @@ void PdmUiTreeViewEditor::configureAndUpdateUi(const QString& uiConfigName)
PdmUiObjectHandle* uiObjectHandle = dynamic_cast<PdmUiObjectHandle*>(this->pdmItemRoot());
if (uiObjectHandle)
{
uiObjectHandle->objectEditorAttribute(uiConfigName, &editorAttributes);
uiObjectHandle->objectEditorAttribute(uiConfigName, &editorAttributes);
}
}
@ -169,6 +176,12 @@ void PdmUiTreeViewEditor::configureAndUpdateUi(const QString& uiConfigName)
selectAsCurrentItem(uiObjectHandle);
}
}
if (m_delegate)
{
m_delegate->clearAttributes();
updateItemDelegateForSubTree();
}
}
//--------------------------------------------------------------------------------------------------
@ -213,7 +226,12 @@ void PdmUiTreeViewEditor::selectedUiItems(std::vector<PdmUiItem*>& objects)
//--------------------------------------------------------------------------------------------------
void PdmUiTreeViewEditor::updateMySubTree(PdmUiItem* uiItem)
{
if (m_treeViewModel) { m_treeViewModel->updateSubTree(uiItem); }
if (m_treeViewModel)
{
m_treeViewModel->updateSubTree(uiItem);
QModelIndex index = m_treeViewModel->findModelIndex(uiItem);
updateItemDelegateForSubTree(index);
}
}
//--------------------------------------------------------------------------------------------------
@ -422,6 +440,29 @@ void PdmUiTreeViewEditor::updateSelectionManager()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiTreeViewEditor::updateItemDelegateForSubTree(const QModelIndex& modelIndex /*= QModelIndex()*/)
{
auto allIndices = m_treeViewModel->allIndicesRecursive();
for (QModelIndex index : allIndices)
{
PdmUiItem* uiItem = m_treeViewModel->uiItemFromModelIndex(index);
PdmUiObjectHandle* uiObjectHandle = dynamic_cast<PdmUiObjectHandle*>(uiItem);
if (uiObjectHandle)
{
PdmUiTreeViewItemAttribute attribute;
uiObjectHandle->objectEditorAttribute("", &attribute);
if (!attribute.tag.isEmpty())
{
m_delegate->addAttribute(index, attribute);
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -439,4 +480,98 @@ bool PdmUiTreeViewEditor::isAppendOfClassNameToUiItemTextEnabled()
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PdmUiTreeViewItemDelegate::PdmUiTreeViewItemDelegate(QObject* parent, PdmUiTreeViewQModel* model)
: QStyledItemDelegate(parent)
, m_model(model)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiTreeViewItemDelegate::clearAttributes()
{
m_attributes.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiTreeViewItemDelegate::addAttribute(QModelIndex index, const PdmUiTreeViewItemAttribute& attribute)
{
m_attributes[index] = attribute;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiTreeViewItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QStyledItemDelegate::paint(painter, option, index);
// Save painter so we can restore it
painter->save();
auto it = m_attributes.find(index);
if (it == m_attributes.end()) return;
const int insideTopBottomMargins = 1;
const int insideleftRightMargins = 6;
const int outsideLeftRightMargins = 4;
QFont font = QApplication::font();
if (font.pixelSize() > 0)
{
font.setPixelSize(std::max(1, font.pixelSize() - 2));
}
else
{
font.setPointSize(std::max(1, font.pointSize() - 2));
}
painter->setFont(font);
QString text = it->second.tag;
QColor bgColor = it->second.bgColor;
QColor fgColor = it->second.fgColor;
QSize textSize(QFontMetrics(font).size(Qt::TextSingleLine, text));
QRect rect = option.rect;
QSize fullSize = rect.size();
int textDiff = (fullSize.height() - textSize.height());
QRect textRect;
if (it->second.position == PdmUiTreeViewItemAttribute::AT_END)
{
QPoint bottomRight = rect.bottomRight() - QPoint(outsideLeftRightMargins, 0);
QPoint textBottomRight = bottomRight - QPoint(insideleftRightMargins, textDiff / 2);
QPoint textTopLeft = textBottomRight - QPoint(textSize.width(), textSize.height());
textRect = QRect(textTopLeft, textBottomRight);
}
else
{
QPoint textTopLeft = QPoint(0, rect.topLeft().y()) + QPoint(outsideLeftRightMargins + insideleftRightMargins, + textDiff / 2);
QPoint textBottomRight = textTopLeft + QPoint(textSize.width(), textSize.height());
textRect = QRect(textTopLeft, textBottomRight);
}
QRect tagRect = textRect.marginsAdded(QMargins(insideleftRightMargins, insideTopBottomMargins, insideleftRightMargins, insideTopBottomMargins));
QBrush brush(bgColor);
painter->setBrush(brush);
painter->setPen(bgColor);
painter->setRenderHint(QPainter::Antialiasing);
const double xRoundingRadiusPercent = 50.0;
const double yRoundingRadiusPercent = 25.0;
painter->drawRoundedRect(tagRect, xRoundingRadiusPercent, yRoundingRadiusPercent, Qt::RelativeSize);
painter->setPen(fgColor);
painter->drawText(textRect, Qt::AlignCenter, text);
// Restore painter
painter->restore();
}
} // end namespace caf

View File

@ -42,9 +42,11 @@
#include "cafPdmUiTreeViewQModel.h"
#include <QAbstractItemModel>
#include <QColor>
#include <QPointer>
#include <QWidget>
#include <QItemSelectionModel>
#include <QStyledItemDelegate>
#include <QTreeView>
@ -61,9 +63,45 @@ namespace caf
class PdmChildArrayFieldHandle;
class PdmUiDragDropInterface;
class PdmUiItem;
class PdmUiTreeViewEditor;
class PdmUiTreeViewQModel;
class PdmUiTreeViewWidget;
class PdmUiTreeViewItemAttribute : public PdmUiEditorAttribute
{
public:
enum Position
{
IN_FRONT,
AT_END
};
PdmUiTreeViewItemAttribute()
: tag()
, position(AT_END)
, bgColor(Qt::red)
, fgColor(Qt::white)
{
}
QString tag;
Position position;
QColor bgColor;
QColor fgColor;
};
class PdmUiTreeViewItemDelegate : public QStyledItemDelegate
{
public:
PdmUiTreeViewItemDelegate(QObject* parent, PdmUiTreeViewQModel* model);
void clearAttributes();
void addAttribute(QModelIndex index, const PdmUiTreeViewItemAttribute& attribute);
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
private:
PdmUiTreeViewQModel* m_model;
std::map<QModelIndex, PdmUiTreeViewItemAttribute> m_attributes;
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -131,6 +169,7 @@ private:
PdmChildArrayFieldHandle* currentChildArrayFieldHandle();
void updateSelectionManager();
void updateItemDelegateForSubTree(const QModelIndex& modelIndex = QModelIndex());
bool eventFilter(QObject *obj, QEvent *event) override;
@ -139,7 +178,8 @@ private:
QVBoxLayout* m_layout;
PdmUiTreeViewWidget* m_treeView;
PdmUiTreeViewQModel* m_treeViewModel;
PdmUiTreeViewQModel* m_treeViewModel;
PdmUiTreeViewItemDelegate* m_delegate;
bool m_useDefaultContextMenu;
bool m_updateSelectionManager;

View File

@ -396,6 +396,28 @@ void PdmUiTreeViewQModel::updateEditorsForSubTree(PdmUiTreeOrdering* root)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::list<QModelIndex> PdmUiTreeViewQModel::allIndicesRecursive(const QModelIndex& current) const
{
std::list<QModelIndex> currentAndDescendants;
currentAndDescendants.push_back(current);
int rows = rowCount(current);
int cols = columnCount(current);
for (int row = 0; row < rows; ++row)
{
for (int col = 0; col < cols; ++col)
{
QModelIndex childIndex = index(row, col, current);
std::list<QModelIndex> subList = allIndicesRecursive(childIndex);
currentAndDescendants.insert(currentAndDescendants.end(), subList.begin(), subList.end());
}
}
return currentAndDescendants;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -75,6 +75,8 @@ public:
void setDragDropInterface(PdmUiDragDropInterface* dragDropInterface);
PdmUiDragDropInterface* dragDropInterface();
std::list<QModelIndex> allIndicesRecursive(const QModelIndex& current = QModelIndex()) const;
private:
void updateSubTreeRecursive(const QModelIndex& uiSubTreeRootModelIdx, PdmUiTreeOrdering* uiModelSubTreeRoot, PdmUiTreeOrdering* updatedPdmSubTreeRoot);