Merge pull request #4740 from OPM/sync-tree-selection-with-field-value

Sync tree selection with field value
This commit is contained in:
Magne Sjaastad 2019-09-20 11:19:52 +02:00 committed by GitHub
commit d4b64c58f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 1061 additions and 846 deletions

View File

@ -605,6 +605,7 @@ void RiuSummaryCurveDefSelection::setSelectedCurveDefinitions( const std::vector
{
resetAllFields();
std::set<RifEclipseSummaryAddress::SummaryVarCategory> categories;
for ( const auto& curveDef : curveDefinitions )
{
if ( !( curveDef.summaryCase() || curveDef.isEnsembleCurve() ) ) continue;
@ -664,6 +665,14 @@ void RiuSummaryCurveDefSelection::setSelectedCurveDefinitions( const std::vector
( *identifierAndField->pdmField() ) = newSelectionVector;
}
}
categories.insert( curveDef.summaryAddress().category() );
}
if ( !categories.empty() )
{
RifEclipseSummaryAddress::SummaryVarCategory cat = *( categories.begin() );
m_currentSummaryCategory.setValue( cat );
}
}
@ -1180,7 +1189,7 @@ void RiuSummaryCurveDefSelection::defineEditorAttribute( const caf::PdmFieldHand
{
if ( &m_selectedSummaryCategories == field )
{
attrib->fieldToReceiveCurrentItemValue = &m_currentSummaryCategory;
attrib->currentIndexFieldHandle = &m_currentSummaryCategory;
attrib->showTextFilter = false;
attrib->showToggleAllCheckbox = false;
attrib->setCurrentIndexWhenItemIsChecked = true;

View File

@ -43,7 +43,6 @@
#include <QFrame>
#include <QGridLayout>
//==================================================================================================
///
//==================================================================================================
@ -51,8 +50,8 @@ class WidgetCellIds
{
public:
WidgetCellIds(QWidget* w, const std::vector<int>& occupiedCellIds)
: m_customWidget(w),
m_customWidgetCellIds(occupiedCellIds)
: m_customWidget(w)
, m_customWidgetCellIds(occupiedCellIds)
{
}
@ -60,11 +59,8 @@ public:
std::vector<int> m_customWidgetCellIds;
};
namespace caf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -77,9 +73,7 @@ CustomObjectEditor::CustomObjectEditor()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
CustomObjectEditor::~CustomObjectEditor()
{
}
CustomObjectEditor::~CustomObjectEditor() {}
//--------------------------------------------------------------------------------------------------
///
@ -93,7 +87,12 @@ void CustomObjectEditor::defineGridLayout(int rowCount, int columnCount)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void CustomObjectEditor::addWidget(QWidget* widget, int row, int column, int rowSpan, int columnSpan, Qt::Alignment alignment /*= 0*/)
void CustomObjectEditor::addWidget(QWidget* widget,
int row,
int column,
int rowSpan,
int columnSpan,
Qt::Alignment alignment /*= 0*/)
{
CAF_ASSERT(isAreaAvailable(row, column, rowSpan, columnSpan));
@ -151,7 +150,8 @@ QWidget* CustomObjectEditor::createWidget(QWidget* parent)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void CustomObjectEditor::recursivelyConfigureAndUpdateTopLevelUiOrdering(const PdmUiOrdering& topLevelUiOrdering, const QString& uiConfigName)
void CustomObjectEditor::recursivelyConfigureAndUpdateTopLevelUiOrdering(const PdmUiOrdering& topLevelUiOrdering,
const QString& uiConfigName)
{
resetCellId();
@ -284,5 +284,4 @@ std::vector<int> CustomObjectEditor::cellIds(int row, int column, int rowSpan, i
return cells;
}
} // end namespace caf

View File

@ -50,11 +50,9 @@ class WidgetCellIds;
namespace caf
{
class PdmUiItem;
class PdmUiGroup;
//==================================================================================================
/// Automatically layout top level groups into a grid layout
///
@ -99,6 +97,4 @@ private:
std::vector<WidgetCellIds> m_customWidgetAreas;
};
} // end namespace caf

View File

@ -5,17 +5,15 @@
#include "CustomObjectEditor.h"
#include "ManyGroups.h"
#include "WidgetLayoutTest.h"
#include "MenuItemProducer.h"
#include "WidgetLayoutTest.h"
#include "cafAppEnum.h"
#ifdef TAP_USE_COMMAND_FRAMEWORK
#include "cafCmdExecCommandManager.h"
#include "cafCmdSelectionHelper.h"
#include "cafCmdFeatureManager.h"
#include "cafCmdSelectionHelper.h"
#endif
#include "cafFilePath.h"
@ -27,9 +25,9 @@
#include "cafPdmReferenceHelper.h"
#include "cafPdmUiComboBoxEditor.h"
#include "cafPdmUiFilePathEditor.h"
#include "cafPdmUiOrdering.h"
#include "cafPdmUiItem.h"
#include "cafPdmUiListEditor.h"
#include "cafPdmUiOrdering.h"
#include "cafPdmUiPropertyView.h"
#include "cafPdmUiPushButtonEditor.h"
#include "cafPdmUiTableView.h"
@ -39,25 +37,25 @@
#include "cafPdmUiTreeView.h"
#include "cafSelectionManager.h"
#include "cafCmdFeatureMenuBuilder.h"
#include <QAction>
#include <QDockWidget>
#include <QFileDialog>
#include <QMenuBar>
#include <QTreeView>
#include <QUndoView>
#include "cafCmdFeatureMenuBuilder.h"
class DemoPdmObjectGroup : public caf::PdmDocument
{
CAF_PDM_HEADER_INIT;
public:
public:
DemoPdmObjectGroup()
{
CAF_PDM_InitFieldNoDefault(&objects, "PdmObjects", "", "", "", "")
objects.uiCapability()->setUiHidden(true);
objects.uiCapability()
->setUiHidden(true);
}
public:
@ -69,18 +67,40 @@ CAF_PDM_SOURCE_INIT(DemoPdmObjectGroup, "DemoPdmObjectGroup");
class SmallDemoPdmObject : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
public:
SmallDemoPdmObject()
{
CAF_PDM_InitObject("Small Demo Object", ":/images/win/filenew.png", "This object is a demo of the CAF framework", "This object is a demo of the CAF framework");
CAF_PDM_InitObject("Small Demo Object",
":/images/win/filenew.png",
"This object is a demo of the CAF framework",
"This object is a demo of the CAF framework");
CAF_PDM_InitField(&m_toggleField, "Toggle", false, "Add Items To Multi Select", "", "Toggle Field tooltip", " Toggle Field whatsthis");
CAF_PDM_InitField(&m_doubleField, "BigNumber", 0.0, "Big Number", "", "Enter a big number here", "This is a place you can enter a big real value if you want" );
CAF_PDM_InitField(
&m_toggleField, "Toggle", false, "Add Items To Multi Select", "", "Toggle Field tooltip", " Toggle Field whatsthis");
CAF_PDM_InitField(&m_doubleField,
"BigNumber",
0.0,
"Big Number",
"",
"Enter a big number here",
"This is a place you can enter a big real value if you want");
m_doubleField.uiCapability()->setCustomContextMenuEnabled(true);
CAF_PDM_InitField(&m_intField, "IntNumber", 0, "Small Number", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_textField, "TextField", QString(""), "Text", "", "Text tooltip", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intField,
"IntNumber",
0,
"Small Number",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_textField,
"TextField",
QString(""),
"Text",
"",
"Text tooltip",
"This is a place you can enter a small integer value if you want");
m_proxyDoubleField.registerSetMethod(this, &SmallDemoPdmObject::setDoubleMember);
m_proxyDoubleField.registerGetMethod(this, &SmallDemoPdmObject::doubleMember);
@ -92,7 +112,10 @@ public:
m_fileNameList.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
m_proxyDoubleField = 0;
if (!(m_proxyDoubleField == 3)) { std::cout << "Double is not 3 " << std::endl; }
if (!(m_proxyDoubleField == 3))
{
std::cout << "Double is not 3 " << std::endl;
}
CAF_PDM_InitFieldNoDefault(&m_multiSelectList, "SelectedItems", "Multi Select Field", "", "", "");
m_multiSelectList.xmlCapability()->setIOReadable(false);
@ -104,7 +127,6 @@ public:
m_multiSelectList.v().push_back("Third");
}
caf::PdmField<double> m_doubleField;
caf::PdmField<int> m_intField;
caf::PdmField<QString> m_textField;
@ -115,7 +137,6 @@ public:
caf::PdmField<std::vector<QString>> m_multiSelectList;
caf::PdmField<bool> m_toggleField;
caf::PdmFieldHandle* objectToggleField() override
{
@ -130,14 +151,22 @@ public:
}
}
void setDoubleMember(const double& d) { m_doubleMember = d; std::cout << "setDoubleMember" << std::endl; }
double doubleMember() const { std::cout << "doubleMember" << std::endl; return m_doubleMember; }
void setDoubleMember(const double& d)
{
m_doubleMember = d;
std::cout << "setDoubleMember" << std::endl;
}
double doubleMember() const
{
std::cout << "doubleMember" << std::endl;
return m_doubleMember;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override
QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly) override
{
QList<caf::PdmOptionItemInfo> options;
@ -160,7 +189,8 @@ public:
{
text = "Second_b";
caf::PdmOptionItemInfo itemInfo = caf::PdmOptionItemInfo(text, text, false, caf::QIconProvider(":/images/win/filenew.png"));
caf::PdmOptionItemInfo itemInfo =
caf::PdmOptionItemInfo(text, text, false, caf::QIconProvider(":/images/win/filenew.png"));
itemInfo.setLevel(1);
options.push_back(itemInfo);
}
@ -195,16 +225,12 @@ public:
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void defineCustomContextMenu(const caf::PdmFieldHandle* fieldNeedingMenu,
QMenu* menu,
QWidget* fieldEditorWidget) override
void defineCustomContextMenu(const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget) override
{
menu->addAction("test");
menu->addAction("other test <<>>");
@ -231,54 +257,229 @@ protected:
CAF_PDM_SOURCE_INIT(SmallDemoPdmObject, "SmallDemoPdmObject");
class SmallGridDemoPdmObject : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
public:
SmallGridDemoPdmObject()
{
CAF_PDM_InitObject("Small Grid Demo Object", "", "This object is a demo of the CAF framework", "This object is a demo of the CAF framework");
CAF_PDM_InitObject("Small Grid Demo Object",
"",
"This object is a demo of the CAF framework",
"This object is a demo of the CAF framework");
CAF_PDM_InitField(&m_intFieldStandard, "Standard", 0, "Standard", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldUseFullSpace, "FullSpace", 0, "Use Full Space For Both", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldUseFullSpaceLabel, "FullSpaceLabel", 0, "Total 3, Label MAX", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldUseFullSpaceField, "FullSpaceField", 0, "Total MAX, Label 1", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldWideLabel,"WideLabel", 0, "Wide Label", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldWideField,"WideField", 0, "Wide Field", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldLeft, "LeftField", 0, "Left Field", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldRight, "RightField", 0, "Right Field With More Text", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldWideBoth, "WideBoth", 0, "Wide Both", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldStandard,
"Standard",
0,
"Standard",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldUseFullSpace,
"FullSpace",
0,
"Use Full Space For Both",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldUseFullSpaceLabel,
"FullSpaceLabel",
0,
"Total 3, Label MAX",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldUseFullSpaceField,
"FullSpaceField",
0,
"Total MAX, Label 1",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldWideLabel,
"WideLabel",
0,
"Wide Label",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldWideField,
"WideField",
0,
"Wide Field",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldLeft,
"LeftField",
0,
"Left Field",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldRight,
"RightField",
0,
"Right Field With More Text",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldWideBoth,
"WideBoth",
0,
"Wide Both",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldWideBoth2, "WideBoth2", 0, "Wide Both", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldLeft2, "LeftFieldInGrp", 0, "Left Field", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldCenter, "CenterFieldInGrp", 0, "Center Field", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldRight2, "RightFieldInGrp", 0, "Right Field", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldLabelTop, "FieldLabelTop", 0, "Field Label Top", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldWideBoth2,
"WideBoth2",
0,
"Wide Both",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldLeft2,
"LeftFieldInGrp",
0,
"Left Field",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldCenter,
"CenterFieldInGrp",
0,
"Center Field",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldRight2,
"RightFieldInGrp",
0,
"Right Field",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldLabelTop,
"FieldLabelTop",
0,
"Field Label Top",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
m_intFieldLabelTop.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP);
CAF_PDM_InitField(&m_stringFieldLabelHidden, "FieldLabelHidden", QString("Hidden Label Field"), "Field Label Hidden", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_stringFieldLabelHidden,
"FieldLabelHidden",
QString("Hidden Label Field"),
"Field Label Hidden",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
m_stringFieldLabelHidden.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
CAF_PDM_InitField(&m_intFieldWideBothAuto, "WideBothAuto", 0, "Wide ", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldLeftAuto, "LeftFieldInGrpAuto", 0, "Left Field", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldCenterAuto, "CenterFieldInGrpAuto", 0, "Center Field", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldRightAuto, "RightFieldInGrpAuto", 0, "Right Field", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldLabelTopAuto, "FieldLabelTopAuto", 0, "Field Label Top", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldWideBothAuto,
"WideBothAuto",
0,
"Wide ",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldLeftAuto,
"LeftFieldInGrpAuto",
0,
"Left Field",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldCenterAuto,
"CenterFieldInGrpAuto",
0,
"Center Field",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldRightAuto,
"RightFieldInGrpAuto",
0,
"Right Field",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldLabelTopAuto,
"FieldLabelTopAuto",
0,
"Field Label Top",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
m_intFieldLabelTopAuto.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP);
CAF_PDM_InitField(&m_stringFieldLabelHiddenAuto, "FieldLabelHiddenAuto", QString("Hidden Label Field"), "Field Label Hidden", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_stringFieldLabelHiddenAuto,
"FieldLabelHiddenAuto",
QString("Hidden Label Field"),
"Field Label Hidden",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
m_stringFieldLabelHiddenAuto.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
CAF_PDM_InitField(&m_intFieldLeftOfGroup, "FieldLeftOfGrp", 0, "Left of group", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldRightOfGroup, "FieldRightOfGrp", 0, "Right of group wide label", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldInsideGroup1, "FieldInGrp1", 0, "Inside Group", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldInsideGroup2, "FieldInGrp2", 0, "Inside Group", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldInsideGroup3, "FieldInGrp3", 0, "Inside Group", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldInsideGroup4, "FieldInGrp4", 0, "Inside Group", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldInsideGroup5, "FieldInGrp5", 0, "Inside Group", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldInsideGroup6, "FieldInGrp6", 0, "Inside Group", "", "Enter some small number here", "This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldLeftOfGroup,
"FieldLeftOfGrp",
0,
"Left of group",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldRightOfGroup,
"FieldRightOfGrp",
0,
"Right of group wide label",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldInsideGroup1,
"FieldInGrp1",
0,
"Inside Group",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldInsideGroup2,
"FieldInGrp2",
0,
"Inside Group",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldInsideGroup3,
"FieldInGrp3",
0,
"Inside Group",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldInsideGroup4,
"FieldInGrp4",
0,
"Inside Group",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldInsideGroup5,
"FieldInGrp5",
0,
"Inside Group",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_intFieldInsideGroup6,
"FieldInGrp6",
0,
"Inside Group",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
}
// Outside group
@ -327,9 +528,14 @@ protected:
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override
{
uiOrdering.add(&m_intFieldStandard);
uiOrdering.add(&m_intFieldUseFullSpace, caf::PdmUiOrdering::LayoutOptions(true, caf::PdmUiOrdering::LayoutOptions::MAX_COLUMN_SPAN, caf::PdmUiOrdering::LayoutOptions::MAX_COLUMN_SPAN));
uiOrdering.add(&m_intFieldUseFullSpaceLabel, caf::PdmUiOrdering::LayoutOptions(true, 3, caf::PdmUiOrdering::LayoutOptions::MAX_COLUMN_SPAN));
uiOrdering.add(&m_intFieldUseFullSpaceField, caf::PdmUiOrdering::LayoutOptions(true, caf::PdmUiOrdering::LayoutOptions::MAX_COLUMN_SPAN, 1));
uiOrdering.add(&m_intFieldUseFullSpace,
caf::PdmUiOrdering::LayoutOptions(true,
caf::PdmUiOrdering::LayoutOptions::MAX_COLUMN_SPAN,
caf::PdmUiOrdering::LayoutOptions::MAX_COLUMN_SPAN));
uiOrdering.add(&m_intFieldUseFullSpaceLabel,
caf::PdmUiOrdering::LayoutOptions(true, 3, caf::PdmUiOrdering::LayoutOptions::MAX_COLUMN_SPAN));
uiOrdering.add(&m_intFieldUseFullSpaceField,
caf::PdmUiOrdering::LayoutOptions(true, caf::PdmUiOrdering::LayoutOptions::MAX_COLUMN_SPAN, 1));
uiOrdering.add(&m_intFieldWideLabel, caf::PdmUiOrdering::LayoutOptions(true, 4, 3));
uiOrdering.add(&m_intFieldWideField, caf::PdmUiOrdering::LayoutOptions(true, 4, 1));
uiOrdering.add(&m_intFieldLeft, caf::PdmUiOrdering::LayoutOptions(true));
@ -346,7 +552,8 @@ protected:
group->add(&m_intFieldLabelTop, caf::PdmUiOrdering::LayoutOptions(true, 6));
group->add(&m_stringFieldLabelHidden, caf::PdmUiOrdering::LayoutOptions(true, 6));
caf::PdmUiGroup* autoGroup = uiOrdering.addNewGroup("Automatic Full Width Group", caf::PdmUiOrdering::LayoutOptions(true));
caf::PdmUiGroup* autoGroup =
uiOrdering.addNewGroup("Automatic Full Width Group", caf::PdmUiOrdering::LayoutOptions(true));
autoGroup->add(&m_intFieldWideBothAuto, caf::PdmUiOrdering::LayoutOptions(true));
autoGroup->add(&m_intFieldLeftAuto, caf::PdmUiOrdering::LayoutOptions(true));
autoGroup->add(&m_intFieldCenterAuto, false);
@ -354,7 +561,6 @@ protected:
autoGroup->add(&m_intFieldLabelTopAuto, true);
autoGroup->add(&m_stringFieldLabelHiddenAuto, true);
uiOrdering.add(&m_intFieldLeftOfGroup);
caf::PdmUiGroup* group2 = uiOrdering.addNewGroup("Right Group", caf::PdmUiOrdering::LayoutOptions(false, 2, 0));
group2->setEnableFrame(false);
@ -371,7 +577,6 @@ protected:
groupR->setEnableFrame(false);
groupR->add(&m_intFieldInsideGroup4);
groupR->add(&m_intFieldInsideGroup6);
}
};
@ -396,7 +601,6 @@ public:
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
}
// Outside group
@ -417,22 +621,38 @@ CAF_PDM_SOURCE_INIT(SingleEditorPdmObject, "SingleEditorObject");
class SmallDemoPdmObjectA : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
public:
enum TestEnumType
{
T1, T2, T3
T1,
T2,
T3
};
SmallDemoPdmObjectA()
{
CAF_PDM_InitObject("Small Demo Object A", "", "This object is a demo of the CAF framework", "This object is a demo of the CAF framework");
CAF_PDM_InitObject("Small Demo Object A",
"",
"This object is a demo of the CAF framework",
"This object is a demo of the CAF framework");
CAF_PDM_InitField(&m_toggleField, "Toggle", false, "Toggle Field", "", "Toggle Field tooltip", " Toggle Field whatsthis");
CAF_PDM_InitField(&m_pushButtonField, "Push", false, "Button Field", "", "", " ");
CAF_PDM_InitField(&m_doubleField, "BigNumber", 0.0, "Big Number", "", "Enter a big number here", "This is a place you can enter a big real value if you want");
CAF_PDM_InitField(&m_intField, "IntNumber", 0, "Small Number", "", "Enter some small number here","This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_doubleField,
"BigNumber",
0.0,
"Big Number",
"",
"Enter a big number here",
"This is a place you can enter a big real value if you want");
CAF_PDM_InitField(&m_intField,
"IntNumber",
0,
"Small Number",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_textField, "TextField", QString("Small Demo Object A"), "Name Text Field", "", "", "");
CAF_PDM_InitField(&m_testEnumField, "TestEnumValue", caf::AppEnum<TestEnumType>(T1), "EnumField", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_ptrField, "m_ptrField", "PtrField", "", "", "");
@ -445,7 +665,8 @@ public:
m_testEnumField.capability<caf::PdmUiFieldHandle>()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
CAF_PDM_InitFieldNoDefault(&m_multipleAppEnum, "MultipleAppEnumValue", "MultipleAppEnumValue", "", "", "");
m_multipleAppEnum.capability<caf::PdmUiFieldHandle>()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName());
m_multipleAppEnum.capability<caf::PdmUiFieldHandle>()->setUiEditorTypeName(
caf::PdmUiTreeSelectionEditor::uiEditorTypeName());
CAF_PDM_InitFieldNoDefault(&m_highlightedEnum, "HighlightedEnum", "HighlightedEnum", "", "", "");
m_highlightedEnum.uiCapability()->setUiHidden(true);
}
@ -457,11 +678,16 @@ public:
caf::PdmPtrField<SmallDemoPdmObjectA*> m_ptrField;
caf::PdmProxyValueField<caf::AppEnum<TestEnumType>> m_proxyEnumField;
void setEnumMember(const caf::AppEnum<TestEnumType>& val) { m_proxyEnumMember = val; }
caf::AppEnum<TestEnumType> enumMember() const { return m_proxyEnumMember; }
void setEnumMember(const caf::AppEnum<TestEnumType>& val)
{
m_proxyEnumMember = val;
}
caf::AppEnum<TestEnumType> enumMember() const
{
return m_proxyEnumMember;
}
TestEnumType m_proxyEnumMember;
// vector of app enum
caf::PdmField<std::vector<caf::AppEnum<TestEnumType>>> m_multipleAppEnum;
caf::PdmField<caf::AppEnum<TestEnumType>> m_highlightedEnum;
@ -490,7 +716,8 @@ public:
}
}
QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override
QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly) override
{
QList<caf::PdmOptionItemInfo> options;
@ -518,7 +745,9 @@ public:
}
}
options.push_back(caf::PdmOptionItemInfo(uiObject->uiName() + "(" + userDesc + ")", QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(objects[i]))));
options.push_back(
caf::PdmOptionItemInfo(uiObject->uiName() + "(" + userDesc + ")",
QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(objects[i]))));
}
}
}
@ -526,7 +755,8 @@ public:
{
for (size_t i = 0; i < caf::AppEnum<TestEnumType>::size(); ++i)
{
options.push_back(caf::PdmOptionItemInfo(caf::AppEnum<TestEnumType>::uiTextFromIndex(i), caf::AppEnum<TestEnumType>::fromIndex(i)));
options.push_back(caf::PdmOptionItemInfo(caf::AppEnum<TestEnumType>::uiTextFromIndex(i),
caf::AppEnum<TestEnumType>::fromIndex(i)));
}
}
@ -547,14 +777,16 @@ protected:
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override
void defineEditorAttribute(const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute) override
{
if (field == &m_multipleAppEnum)
{
caf::PdmUiTreeSelectionEditorAttribute* attr = dynamic_cast<caf::PdmUiTreeSelectionEditorAttribute*>(attribute);
if (attr)
{
attr->fieldToReceiveCurrentItemValue = &m_highlightedEnum;
attr->currentIndexFieldHandle = &m_highlightedEnum;
}
}
else if (field == &m_proxyEnumField)
@ -567,13 +799,13 @@ protected:
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void defineObjectEditorAttribute(QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override
{
caf::PdmUiTableViewPushButtonEditorAttribute* attr = dynamic_cast<caf::PdmUiTableViewPushButtonEditorAttribute*>(attribute);
caf::PdmUiTableViewPushButtonEditorAttribute* attr =
dynamic_cast<caf::PdmUiTableViewPushButtonEditorAttribute*>(attribute);
if (attr)
{
attr->registerPushButtonTextForFieldKeyword(m_pushButtonField.keyword(), "Edit");
@ -592,37 +824,59 @@ namespace caf
addItem(SmallDemoPdmObjectA::T2, "T2", "A B letter");
addItem(SmallDemoPdmObjectA::T3, "T3", "A B C letter");
setDefault(SmallDemoPdmObjectA::T1);
}
}
} // namespace caf
Q_DECLARE_METATYPE(caf::AppEnum<SmallDemoPdmObjectA::TestEnumType>);
class DemoPdmObject : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
public:
DemoPdmObject()
{
CAF_PDM_InitObject( "Demo Object", "", "This object is a demo of the CAF framework", "This object is a demo of the CAF framework");
CAF_PDM_InitObject(
"Demo Object", "", "This object is a demo of the CAF framework", "This object is a demo of the CAF framework");
CAF_PDM_InitField(&m_toggleField, "Toggle", false, "Toggle Field", "", "Toggle Field tooltip", " Toggle Field whatsthis");
CAF_PDM_InitField(&m_doubleField, "BigNumber", 0.0, "Big Number", "", "Enter a big number here", "This is a place you can enter a big real value if you want");
CAF_PDM_InitField(&m_intField, "IntNumber", 0, "Small Number", "", "Enter some small number here", "This is a place you can enter a small integer value if you want" );
CAF_PDM_InitField(&m_boolField, "BooleanValue", false, "Boolean:" , "", "Boolean:Enter some small number here", "Boolean:This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_doubleField,
"BigNumber",
0.0,
"Big Number",
"",
"Enter a big number here",
"This is a place you can enter a big real value if you want");
CAF_PDM_InitField(&m_intField,
"IntNumber",
0,
"Small Number",
"",
"Enter some small number here",
"This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_boolField,
"BooleanValue",
false,
"Boolean:",
"",
"Boolean:Enter some small number here",
"Boolean:This is a place you can enter a small integer value if you want");
CAF_PDM_InitField(&m_textField, "TextField", QString("Demo Object Description Field"), "Description Field", "", "", "");
CAF_PDM_InitField(&m_filePath, "FilePath", QString(""), "Filename", "", "", "");
CAF_PDM_InitField(&m_longText, "LongText", QString("Test text"), "Long Text", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_multiSelectList, "MultiSelect", "Selection List", "", "List" , "This is a multi selection list" );
CAF_PDM_InitFieldNoDefault(
&m_multiSelectList, "MultiSelect", "Selection List", "", "List", "This is a multi selection list");
CAF_PDM_InitFieldNoDefault(&m_objectList, "ObjectList", "Objects list Field", "", "List", "This is a list of PdmObjects");
CAF_PDM_InitFieldNoDefault(&m_objectListOfSameType, "m_objectListOfSameType", "Same type Objects list Field", "", "Same type List" , "Same type list of PdmObjects" );
CAF_PDM_InitFieldNoDefault(&m_objectListOfSameType,
"m_objectListOfSameType",
"Same type Objects list Field",
"",
"Same type List",
"Same type list of PdmObjects");
m_objectListOfSameType.uiCapability()->setUiEditorTypeName(caf::PdmUiTableViewEditor::uiEditorTypeName());
m_objectListOfSameType.uiCapability()->setCustomContextMenuEnabled(true);;
m_objectListOfSameType.uiCapability()->setCustomContextMenuEnabled(true);
;
CAF_PDM_InitFieldNoDefault(&m_ptrField, "m_ptrField", "PtrField", "", "Same type List", "Same type list of PdmObjects");
m_filePath.capability<caf::PdmUiFieldHandle>()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
@ -654,19 +908,18 @@ public:
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override
QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly) override
{
QList<caf::PdmOptionItemInfo> options;
if (&m_multiSelectList == fieldNeedingOptions)
{
options.push_back(caf::PdmOptionItemInfo("Choice 1", "Choice1"));
options.push_back(caf::PdmOptionItemInfo("Choice 2", "Choice2"));
options.push_back(caf::PdmOptionItemInfo("Choice 3", "Choice3"));
options.push_back(caf::PdmOptionItemInfo("Choice 4", "Choice4"));
options.push_back(caf::PdmOptionItemInfo("Choice 5", "Choice5"));
options.push_back(caf::PdmOptionItemInfo("Choice 6", "Choice6"));
}
if (&m_ptrField == fieldNeedingOptions)
@ -676,7 +929,9 @@ public:
caf::PdmUiObjectHandle* uiObject = caf::uiObj(m_objectListOfSameType[i]);
if (uiObject)
{
options.push_back(caf::PdmOptionItemInfo(uiObject->uiName(), QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(m_objectListOfSameType[i]))));
options.push_back(caf::PdmOptionItemInfo(
uiObject->uiName(),
QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(m_objectListOfSameType[i]))));
}
}
}
@ -694,8 +949,6 @@ public:
return &m_textField;
}
// Fields
caf::PdmField<bool> m_boolField;
caf::PdmField<double> m_doubleField;
@ -707,12 +960,10 @@ public:
caf::PdmField<QString> m_longText;
caf::PdmField<std::vector<QString>> m_multiSelectList;
caf::PdmChildArrayField<caf::PdmObjectHandle*> m_objectList;
caf::PdmChildArrayField<SmallDemoPdmObjectA*> m_objectListOfSameType;
caf::PdmPtrField<SmallDemoPdmObjectA*> m_ptrField;
caf::PdmField<bool> m_toggleField;
MenuItemProducer* m_menuItemProducer;
@ -730,7 +981,6 @@ public:
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -754,6 +1004,7 @@ public:
}
}
}
protected:
//--------------------------------------------------------------------------------------------------
///
@ -765,13 +1016,10 @@ protected:
caf::PdmUiTableView::addActionsToMenu(menu, &m_objectListOfSameType);
}
}
};
CAF_PDM_SOURCE_INIT(DemoPdmObject, "DemoPdmObject");
MainWindow* MainWindow::sm_mainWindowInstance = nullptr;
//--------------------------------------------------------------------------------------------------
@ -807,7 +1055,6 @@ MainWindow::MainWindow()
caf::CmdExecCommandManager::instance()->enableUndoCommandSystem(true);
undoView->setStack(caf::CmdExecCommandManager::instance()->undoStack());
#endif
}
//--------------------------------------------------------------------------------------------------
@ -846,7 +1093,6 @@ void MainWindow::createDockPanels()
addDockWidget(Qt::RightDockWidgetArea, dockWidget);
}
{
QDockWidget* dockWidget = new QDockWidget("cafPropertyView", this);
dockWidget->setObjectName("dockWidget");
@ -883,7 +1129,6 @@ void MainWindow::createDockPanels()
addDockWidget(Qt::RightDockWidgetArea, dockWidget);
}
{
QDockWidget* dockWidget = new QDockWidget("Undo stack", this);
dockWidget->setObjectName("dockWidget");
@ -894,7 +1139,6 @@ void MainWindow::createDockPanels()
addDockWidget(Qt::RightDockWidgetArea, dockWidget);
}
}
//--------------------------------------------------------------------------------------------------
@ -936,7 +1180,6 @@ void MainWindow::buildTestModel()
demoObject->m_objectListOfSameType.push_back(new SmallDemoPdmObjectA());
demoObject->m_objectListOfSameType.push_back(new SmallDemoPdmObjectA());
demoObj2->m_objectList.push_back(new SmallDemoPdmObjectA());
demoObj2->m_objectList.push_back(new SmallDemoPdmObjectA());
demoObj2->m_objectList.push_back(new SmallDemoPdmObject());
@ -944,7 +1187,6 @@ void MainWindow::buildTestModel()
delete smallObj3;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -1005,7 +1247,6 @@ void MainWindow::setPdmRoot(caf::PdmObjectHandle* pdmRoot)
m_customObjectEditor->setPdmObject(nullptr);
}
m_customObjectEditor->updateUi();
}
@ -1148,10 +1389,7 @@ void MainWindow::slotRemove()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void MainWindow::slotRemoveAll()
{
}
void MainWindow::slotRemoveAll() {}
//--------------------------------------------------------------------------------------------------
///
@ -1211,14 +1449,13 @@ void MainWindow::slotShowTableView()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void MainWindow::slotLoadProject()
{
QString fileName = QFileDialog::getOpenFileName(nullptr, tr("Open Project File"), "test.proj", "Project Files (*.proj);;All files(*.*)");
QString fileName =
QFileDialog::getOpenFileName(nullptr, tr("Open Project File"), "test.proj", "Project Files (*.proj);;All files(*.*)");
if (!fileName.isEmpty())
{
setPdmRoot(nullptr);
@ -1237,7 +1474,8 @@ void MainWindow::slotLoadProject()
//--------------------------------------------------------------------------------------------------
void MainWindow::slotSaveProject()
{
QString fileName = QFileDialog::getSaveFileName(nullptr, tr("Save Project File"), "test.proj", "Project Files (*.proj);;All files(*.*)");
QString fileName =
QFileDialog::getSaveFileName(nullptr, tr("Save Project File"), "test.proj", "Project Files (*.proj);;All files(*.*)");
if (!fileName.isEmpty())
{
m_testRoot->fileName = fileName;
@ -1270,5 +1508,4 @@ void MainWindow::slotCustomMenuRequestedForProjectTree(const QPoint&)
menu.exec(QCursor::pos());
caf::CmdFeatureManager::instance()->setCurrentContextMenuTargetWidget(nullptr);
}
}

View File

@ -1,8 +1,8 @@
#pragma once
#include <QMainWindow>
#include <QAbstractItemModel>
#include <QItemSelection>
#include <QMainWindow>
class DemoPdmObject;
class DemoPdmObjectGroup;
@ -19,7 +19,7 @@ namespace caf
class PdmUiTreeView;
class PdmUiTableView;
class CustomObjectEditor;
}
} // namespace caf
class MainWindow : public QMainWindow
{
@ -69,4 +69,3 @@ private:
QLabel* m_plotLabel;
QLabel* m_smallPlotLabel;
};

View File

@ -1,15 +1,14 @@
#pragma once
#include "cafPdmObject.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmProxyValueField.h"
class ManyGroups : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
public:
ManyGroups();
caf::PdmField<double> m_doubleField;
@ -25,14 +24,22 @@ public:
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
void setDoubleMember(const double& d) { m_doubleMember = d; std::cout << "setDoubleMember" << std::endl; }
double doubleMember() const { std::cout << "doubleMember" << std::endl; return m_doubleMember; }
void setDoubleMember(const double& d)
{
m_doubleMember = d;
std::cout << "setDoubleMember" << std::endl;
}
double doubleMember() const
{
std::cout << "doubleMember" << std::endl;
return m_doubleMember;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly) override;
private:
double m_doubleMember;
@ -43,7 +50,7 @@ protected:
//--------------------------------------------------------------------------------------------------
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;
void defineEditorAttribute(const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute) override;
};

View File

@ -43,14 +43,10 @@
#include <QTextCursor>
#include <QTextEdit>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
MenuItemProducer::MenuItemProducer()
{
}
MenuItemProducer::MenuItemProducer() {}
//--------------------------------------------------------------------------------------------------
///

View File

@ -36,7 +36,6 @@
#pragma once
#include <QObject>
#include <QPoint>
#include <QPointer>
@ -65,6 +64,3 @@ private:
QPointer<QTextEdit> m_textEdit;
int m_textPosition;
};

View File

@ -2,13 +2,10 @@
#include "WidgetLayoutTest.h"
#include <QGridLayout>
#include <QLineEdit>
#include <QPushButton>
#include <QGroupBox>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
//--------------------------------------------------------------------------------------------------
///
@ -61,10 +58,7 @@ WidgetLayoutTest::WidgetLayoutTest(QWidget* parent /*= 0*/, Qt::WindowFlags f /*
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
WidgetLayoutTest::~WidgetLayoutTest()
{
}
WidgetLayoutTest::~WidgetLayoutTest() {}
//--------------------------------------------------------------------------------------------------
///

View File

@ -2,12 +2,9 @@
#include <QWidget>
class QGridLayout;
class QGroupBox;
class WidgetLayoutTest : public QWidget
{
Q_OBJECT
@ -36,6 +33,4 @@ private slots:
void setUpInitialConfigurationA();
void setUpInitialConfigurationB();
};

View File

@ -25,12 +25,11 @@
#ifdef TAP_USE_COMMAND_FRAMEWORK
#include "cafCmdExecCommandManager.h"
#include "cafCmdSelectionHelper.h"
#include "cafCmdFeatureManager.h"
#include "cafCmdSelectionHelper.h"
#endif
#include "TapProject.h"
MainWindow* MainWindow::sm_mainWindowInstance = NULL;
//--------------------------------------------------------------------------------------------------
@ -55,7 +54,6 @@ MainWindow::MainWindow()
caf::CmdExecCommandManager::instance()->enableUndoCommandSystem(true);
undoView->setStack(caf::CmdExecCommandManager::instance()->undoStack());
#endif
}
//--------------------------------------------------------------------------------------------------
@ -112,7 +110,6 @@ void MainWindow::createDockPanels()
addDockWidget(Qt::RightDockWidgetArea, dockWidget);
}
{
QDockWidget* dockWidget = new QDockWidget("Undo stack", this);
dockWidget->setObjectName("dockWidget");
@ -123,7 +120,6 @@ void MainWindow::createDockPanels()
addDockWidget(Qt::RightDockWidgetArea, dockWidget);
}
}
//--------------------------------------------------------------------------------------------------
@ -134,7 +130,6 @@ void MainWindow::buildTestModel()
m_project = new TapProject;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -216,7 +211,6 @@ void MainWindow::createActions()
connect(editRemove, SIGNAL(triggered()), SLOT(slotRemove()));
connect(editRemoveAll, SIGNAL(triggered()), SLOT(slotRemoveAll()));
// Create menus
QMenu* editMenu = menuBar()->addMenu("&Edit");
editMenu->addAction(editInsert);
@ -295,10 +289,7 @@ void MainWindow::slotRemove()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void MainWindow::slotRemoveAll()
{
}
void MainWindow::slotRemoveAll() {}
//--------------------------------------------------------------------------------------------------
///

View File

@ -1,15 +1,14 @@
#pragma once
#include <QMainWindow>
#include <QAbstractItemModel>
#include <QItemSelection>
#include <QMainWindow>
class QTreeView;
class QUndoView;
class TapProject;
namespace caf
{
class PdmObjectCollection;
@ -18,7 +17,7 @@ namespace caf
class PdmUiPropertyView;
class PdmUiTreeView;
class PdmUiTableView;
}
} // namespace caf
class MainWindow : public QMainWindow
{
@ -37,7 +36,6 @@ private:
void createToolBars();
void createDockPanels();
void buildTestModel();
void releaseTestData();
@ -49,7 +47,6 @@ private slots:
void slotSimpleSelectionChanged();
void slotShowTableView();
private:
static MainWindow* sm_mainWindowInstance;
@ -63,4 +60,3 @@ private:
TapProject* m_project;
};

View File

@ -2,11 +2,8 @@
#include "cafPdmUiListEditor.h"
CAF_PDM_SOURCE_INIT(TapCvfSpecialization, "TapCvfSpecialization");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -26,7 +23,9 @@ TapCvfSpecialization::TapCvfSpecialization()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void TapCvfSpecialization::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
void TapCvfSpecialization::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue)
{
if (changedField == &m_colorField)
{
@ -37,7 +36,9 @@ void TapCvfSpecialization::fieldChangedByUi(const caf::PdmFieldHandle* changedFi
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void TapCvfSpecialization::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
void TapCvfSpecialization::defineEditorAttribute(const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute)
{
if (field == &m_vecArrayField)
{
@ -48,4 +49,3 @@ void TapCvfSpecialization::defineEditorAttribute(const caf::PdmFieldHandle* fiel
}
}
}

View File

@ -1,30 +1,26 @@
#pragma once
#include "cvfBase.h"
#include "cvfColor3.h"
#include "cvfVector3.h"
#include "cvfMatrix4.h"
#include "cvfVector3.h"
#include "cafPdmFieldCvfColor.h"
#include "cafPdmFieldCvfVec3d.h"
#include "cafPdmFieldCvfMat4d.h"
#include "cafPdmFieldCvfVec3d.h"
#include "cafPdmObject.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include <vector>
class TapCvfSpecialization : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
TapCvfSpecialization();
caf::PdmField<QString> m_testField;
caf::PdmField<cvf::Color3f> m_colorField;
@ -37,6 +33,6 @@ public:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
protected:
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute);
virtual void
defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute);
};

View File

@ -17,7 +17,4 @@ TapProject::TapProject(void)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TapProject::~TapProject(void)
{
}
TapProject::~TapProject(void) {}

View File

@ -1,13 +1,11 @@
#pragma once
#include "cafPdmDocument.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmChildField.h"
#include "cafPdmDocument.h"
class TapCvfSpecialization;
class TapProject : public caf::PdmDocument
{
CAF_PDM_HEADER_INIT;

View File

@ -2,13 +2,10 @@
#include "WidgetLayoutTest.h"
#include <QGridLayout>
#include <QLineEdit>
#include <QPushButton>
#include <QGroupBox>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
//--------------------------------------------------------------------------------------------------
///
@ -61,10 +58,7 @@ WidgetLayoutTest::WidgetLayoutTest(QWidget* parent /*= 0*/, Qt::WindowFlags f /*
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
WidgetLayoutTest::~WidgetLayoutTest()
{
}
WidgetLayoutTest::~WidgetLayoutTest() {}
//--------------------------------------------------------------------------------------------------
///

View File

@ -2,12 +2,9 @@
#include <QWidget>
class QGridLayout;
class QGroupBox;
class WidgetLayoutTest : public QWidget
{
Q_OBJECT
@ -36,6 +33,4 @@ private slots:
void setUpInitialConfigurationA();
void setUpInitialConfigurationB();
};

View File

@ -354,6 +354,26 @@ void PdmUiTreeSelectionEditor::configureAndUpdateUi(const QString& uiConfigName)
m_treeView->setRootIsDecorated(m_model->hasGrandChildren());
m_model->resetUiValueCache();
if (m_attributes.currentIndexFieldHandle)
{
PdmUiFieldHandle* uiFieldHandle = m_attributes.currentIndexFieldHandle->uiCapability();
if (uiFieldHandle)
{
QModelIndexList indices = allVisibleSourceModelIndices();
QVariant currentItemValue = uiFieldHandle->uiValue();
for (const auto& mi : indices)
{
QVariant itemValue = m_model->data(mi, PdmUiTreeSelectionQModel::optionItemValueRole());
if (currentItemValue == itemValue)
{
QModelIndex treeViewIndex = m_proxyModel->mapFromSource(mi);
m_treeView->setCurrentIndex(treeViewIndex);
}
}
}
}
}
//--------------------------------------------------------------------------------------------------
@ -637,9 +657,9 @@ void PdmUiTreeSelectionEditor::currentChanged(const QModelIndex& current)
m_proxyModel->setData(current, true, Qt::CheckStateRole);
}
if (m_attributes.fieldToReceiveCurrentItemValue)
if (m_attributes.currentIndexFieldHandle)
{
PdmUiFieldHandle* uiFieldHandle = m_attributes.fieldToReceiveCurrentItemValue->uiCapability();
PdmUiFieldHandle* uiFieldHandle = m_attributes.currentIndexFieldHandle->uiCapability();
if (uiFieldHandle)
{
QVariant v = m_proxyModel->data(current, PdmUiTreeSelectionQModel::optionItemValueRole());

View File

@ -64,11 +64,11 @@ public:
bool singleSelectionMode;
bool setCurrentIndexWhenItemIsChecked;
/// fieldToReceiveCurrentFieldValue is used to communicate the value of current item in the tree view
/// currentIndexFieldHandle is used to communicate the value of current item in the tree view
/// This is useful when displaying a list of appEnums, and a dependent view is displaying content based on
/// the current item in the tree view
/// Make sure the type of the receiving field is of the same type as the field used in PdmUiTreeSelectionEditor
caf::PdmFieldHandle* fieldToReceiveCurrentItemValue;
caf::PdmFieldHandle* currentIndexFieldHandle;
public:
PdmUiTreeSelectionEditorAttribute()
@ -78,7 +78,7 @@ public:
singleSelectionMode = false;
setCurrentIndexWhenItemIsChecked = false;
fieldToReceiveCurrentItemValue = nullptr;
currentIndexFieldHandle = nullptr;
}
};