Whitespace

This commit is contained in:
Magne Sjaastad 2019-02-22 07:55:57 +01:00
parent 24bda0fda2
commit 735bd5a4b1
3 changed files with 144 additions and 110 deletions

View File

@ -1,29 +1,53 @@
#include "ManyGroups.h" #include "ManyGroups.h"
#include "cafPdmUiTreeSelectionEditor.h"
#include "cafPdmUiListEditor.h" #include "cafPdmUiListEditor.h"
#include "cafPdmUiTreeSelectionEditor.h"
CAF_PDM_SOURCE_INIT(ManyGroups, "LargeObject"); CAF_PDM_SOURCE_INIT(ManyGroups, "LargeObject");
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
ManyGroups::ManyGroups() ManyGroups::ManyGroups()
{ {
CAF_PDM_InitObject("Many Groups", ":/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("Many Groups",
":/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(
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_toggleField, "Toggle", false, "Add Items To Multi Select", "", "Toggle Field tooltip", " Toggle Field whatsthis");
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,
CAF_PDM_InitField(&m_textField, "TextField", QString(""), "Text", "", "Text tooltip", "This is a place you can enter a small integer value if you want"); "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(""),
"Text",
"",
"Text tooltip",
"This is a place you can enter a small integer value if you want");
m_proxyDoubleField.registerSetMethod(this, &ManyGroups::setDoubleMember); m_proxyDoubleField.registerSetMethod(this, &ManyGroups::setDoubleMember);
m_proxyDoubleField.registerGetMethod(this, &ManyGroups::doubleMember); m_proxyDoubleField.registerGetMethod(this, &ManyGroups::doubleMember);
CAF_PDM_InitFieldNoDefault(&m_proxyDoubleField, "ProxyDouble", "Proxy Double", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_proxyDoubleField, "ProxyDouble", "Proxy Double", "", "", "");
m_proxyDoubleField = 0; 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", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_multiSelectList, "SelectedItems", "Multi Select Field", "", "", "");
m_multiSelectList.uiCapability()->setAutoAddingOptionFromValue(false); m_multiSelectList.uiCapability()->setAutoAddingOptionFromValue(false);
@ -36,8 +60,9 @@ ManyGroups::ManyGroups()
m_multiSelectList.v().push_back("Second"); m_multiSelectList.v().push_back("Second");
m_multiSelectList.v().push_back("Third"); m_multiSelectList.v().push_back("Third");
CAF_PDM_InitField(&m_singleStringWithManySelectableItems, "m_singleStringWithManySelectableItems", QString(""), "Text with many items", "", "Text tooltip", ""); CAF_PDM_InitField(
m_singleStringWithManySelectableItems.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); &m_stringWithMultipleOptions, "m_stringWithMultipleOptions", QString(""), "Text with many items", "", "", "");
m_stringWithMultipleOptions.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -62,12 +87,13 @@ void ManyGroups::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> ManyGroups::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) QList<caf::PdmOptionItemInfo> ManyGroups::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly)
{ {
QList<caf::PdmOptionItemInfo> options; QList<caf::PdmOptionItemInfo> options;
// Test code used to switch between two lists with different content, but same item count // Test code used to switch between two lists with different content, but same item count
if (fieldNeedingOptions == &m_singleStringWithManySelectableItems) if (fieldNeedingOptions == &m_stringWithMultipleOptions)
{ {
for (int i = 0; i < 100; i++) for (int i = 0; i < 100; i++)
{ {
@ -120,7 +146,8 @@ QList<caf::PdmOptionItemInfo> ManyGroups::calculateValueOptions(const caf::PdmFi
{ {
text = "Second_b"; text = "Second_b";
caf::PdmOptionItemInfo itemInfo = caf::PdmOptionItemInfo(text, text, false, QIcon(QString(":/images/win/filenew.png"))); caf::PdmOptionItemInfo itemInfo =
caf::PdmOptionItemInfo(text, text, false, QIcon(QString(":/images/win/filenew.png")));
itemInfo.setLevel(1); itemInfo.setLevel(1);
options.push_back(itemInfo); options.push_back(itemInfo);
} }
@ -165,7 +192,7 @@ void ManyGroups::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOr
uiOrdering.add(&m_toggleField); uiOrdering.add(&m_toggleField);
uiOrdering.add(&m_multiSelectList); uiOrdering.add(&m_multiSelectList);
/* /*
{ {
caf::PdmUiGroup* group = uiOrdering.addNewGroup("First"); caf::PdmUiGroup* group = uiOrdering.addNewGroup("First");
@ -201,21 +228,23 @@ void ManyGroups::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOr
subGroup->add(&m_proxyDoubleField); subGroup->add(&m_proxyDoubleField);
} }
*/ */
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void ManyGroups::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) void ManyGroups::defineEditorAttribute(const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute)
{ {
if (field == &m_multiSelectList) if (field == &m_multiSelectList)
{ {
caf::PdmUiTreeSelectionEditorAttribute* myAttr = dynamic_cast<caf::PdmUiTreeSelectionEditorAttribute*>(attribute); caf::PdmUiTreeSelectionEditorAttribute* myAttr = dynamic_cast<caf::PdmUiTreeSelectionEditorAttribute*>(attribute);
if (myAttr) if (myAttr)
{ {
//myAttr->showTextFilter = false; // myAttr->showTextFilter = false;
//myAttr->showToggleAllCheckbox = false; // myAttr->showToggleAllCheckbox = false;
} }
} }
} }

View File

@ -18,7 +18,7 @@ public:
caf::PdmProxyValueField<double> m_proxyDoubleField; caf::PdmProxyValueField<double> m_proxyDoubleField;
caf::PdmField<std::vector<QString> > m_multiSelectList; caf::PdmField<std::vector<QString> > m_multiSelectList;
caf::PdmField<QString> m_singleStringWithManySelectableItems; caf::PdmField<QString> m_stringWithMultipleOptions;
caf::PdmField<bool> m_toggleField; caf::PdmField<bool> m_toggleField;
caf::PdmFieldHandle* objectToggleField() override; caf::PdmFieldHandle* objectToggleField() override;

View File

@ -34,7 +34,6 @@
// //
//################################################################################################## //##################################################################################################
#include "cafPdmUiFormLayoutObjectEditor.h" #include "cafPdmUiFormLayoutObjectEditor.h"
#include "cafPdmObjectHandle.h" #include "cafPdmObjectHandle.h"
@ -57,10 +56,7 @@
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
caf::PdmUiFormLayoutObjectEditor::PdmUiFormLayoutObjectEditor() caf::PdmUiFormLayoutObjectEditor::PdmUiFormLayoutObjectEditor() {}
{
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
@ -103,7 +99,7 @@ void caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingIn
int nrOfExpandingItemsInRow = uiOrdering.nrOfExpandingItemsInRow(uiItemsInRow); int nrOfExpandingItemsInRow = uiOrdering.nrOfExpandingItemsInRow(uiItemsInRow);
int spareColumnsInRow = totalColumns - columnsRequiredForCurrentRow; int spareColumnsInRow = totalColumns - columnsRequiredForCurrentRow;
std::div_t columnsDiv = { 0, 0 }; std::div_t columnsDiv = {0, 0};
if (spareColumnsInRow && nrOfExpandingItemsInRow) if (spareColumnsInRow && nrOfExpandingItemsInRow)
{ {
columnsDiv = std::div(spareColumnsInRow, nrOfExpandingItemsInRow); columnsDiv = std::div(spareColumnsInRow, nrOfExpandingItemsInRow);
@ -115,7 +111,8 @@ void caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingIn
PdmUiOrdering::LayoutOptions currentLayout = uiItemsInRow[i].second; PdmUiOrdering::LayoutOptions currentLayout = uiItemsInRow[i].second;
int minimumItemColumnSpan = 0, minimumLabelColumnSpan = 0, minimumFieldColumnSpan = 0; int minimumItemColumnSpan = 0, minimumLabelColumnSpan = 0, minimumFieldColumnSpan = 0;
uiOrdering.nrOfColumnsRequiredForItem(uiItemsInRow[i], &minimumItemColumnSpan, &minimumLabelColumnSpan, &minimumFieldColumnSpan); uiOrdering.nrOfColumnsRequiredForItem(
uiItemsInRow[i], &minimumItemColumnSpan, &minimumLabelColumnSpan, &minimumFieldColumnSpan);
bool isExpandingItem = currentLayout.totalColumnSpan == PdmUiOrdering::LayoutOptions::MAX_COLUMN_SPAN; bool isExpandingItem = currentLayout.totalColumnSpan == PdmUiOrdering::LayoutOptions::MAX_COLUMN_SPAN;
int spareColumnsToAssign = 0; int spareColumnsToAssign = 0;
@ -129,9 +126,13 @@ void caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingIn
if (currentItem->isUiGroup()) if (currentItem->isUiGroup())
{ {
recursivelyAddGroupToGridLayout(currentItem, containerWidgetWithGridLayout, recursivelyAddGroupToGridLayout(currentItem,
uiConfigName, parentLayout, currentRowIndex, containerWidgetWithGridLayout,
currentColumn, itemColumnSpan); uiConfigName,
parentLayout,
currentRowIndex,
currentColumn,
itemColumnSpan);
currentColumn += itemColumnSpan; currentColumn += itemColumnSpan;
} }
else else
@ -199,7 +200,8 @@ void caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingIn
spareColumnsToAssign -= spareColumnsToAssign / 2; spareColumnsToAssign -= spareColumnsToAssign / 2;
} }
parentLayout->addWidget(fieldLabelWidget, currentRowIndex, currentColumn, 1, leftLabelColumnSpan, Qt::AlignTop); parentLayout->addWidget(
fieldLabelWidget, currentRowIndex, currentColumn, 1, leftLabelColumnSpan, Qt::AlignTop);
currentColumn += leftLabelColumnSpan; currentColumn += leftLabelColumnSpan;
// Apply margins determined by the editor type // Apply margins determined by the editor type
@ -214,7 +216,8 @@ void caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingIn
CAF_ASSERT(fieldColumnSpan >= 1 && "Need at least one column for the field"); CAF_ASSERT(fieldColumnSpan >= 1 && "Need at least one column for the field");
fieldColumnSpan = std::max(1, fieldColumnSpan); fieldColumnSpan = std::max(1, fieldColumnSpan);
parentLayout->addWidget(fieldEditorWidget, currentRowIndex, currentColumn, 1, fieldColumnSpan, Qt::AlignTop); parentLayout->addWidget(
fieldEditorWidget, currentRowIndex, currentColumn, 1, fieldColumnSpan, Qt::AlignTop);
currentColumn += fieldColumnSpan; currentColumn += fieldColumnSpan;
} }
@ -279,14 +282,15 @@ bool caf::PdmUiFormLayoutObjectEditor::isUiGroupExpanded(const PdmUiGroup* uiGro
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QMinimizePanel* caf::PdmUiFormLayoutObjectEditor::findOrCreateGroupBox(QWidget* parent, PdmUiGroup* group, const QString& uiConfigName) QMinimizePanel*
caf::PdmUiFormLayoutObjectEditor::findOrCreateGroupBox(QWidget* parent, PdmUiGroup* group, const QString& uiConfigName)
{ {
QString groupBoxKey = group->keyword(); QString groupBoxKey = group->keyword();
QMinimizePanel* groupBox = nullptr; QMinimizePanel* groupBox = nullptr;
QGridLayout* groupBoxLayout = nullptr; QGridLayout* groupBoxLayout = nullptr;
// Find or create groupBox // Find or create groupBox
std::map<QString, QPointer<QMinimizePanel> >::iterator it; std::map<QString, QPointer<QMinimizePanel>>::iterator it;
it = m_groupBoxes.find(groupBoxKey); it = m_groupBoxes.find(groupBoxKey);
if (it == m_groupBoxes.end()) if (it == m_groupBoxes.end())
@ -327,7 +331,9 @@ QMinimizePanel* caf::PdmUiFormLayoutObjectEditor::findOrCreateGroupBox(QWidget*
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
caf::PdmUiFieldEditorHandle* caf::PdmUiFormLayoutObjectEditor::findOrCreateFieldEditor(QWidget* parent, PdmUiFieldHandle* field, const QString& uiConfigName) caf::PdmUiFieldEditorHandle* caf::PdmUiFormLayoutObjectEditor::findOrCreateFieldEditor(QWidget* parent,
PdmUiFieldHandle* field,
const QString& uiConfigName)
{ {
caf::PdmUiFieldEditorHandle* fieldEditor = nullptr; caf::PdmUiFieldEditorHandle* fieldEditor = nullptr;
@ -353,7 +359,7 @@ caf::PdmUiFieldEditorHandle* caf::PdmUiFormLayoutObjectEditor::findOrCreateField
// This assert will trigger for PdmChildArrayField and PdmChildField // This assert will trigger for PdmChildArrayField and PdmChildField
// Consider to exclude assert or add editors for these types if the assert is reintroduced // Consider to exclude assert or add editors for these types if the assert is reintroduced
//CAF_ASSERT(false); // CAF_ASSERT(false);
} }
} }
else else
@ -394,7 +400,7 @@ void caf::PdmUiFormLayoutObjectEditor::cleanupBeforeSettingPdmObject()
m_newGroupBoxes.clear(); m_newGroupBoxes.clear();
std::map<QString, QPointer<QMinimizePanel> >::iterator groupIt; std::map<QString, QPointer<QMinimizePanel>>::iterator groupIt;
for (groupIt = m_groupBoxes.begin(); groupIt != m_groupBoxes.end(); ++groupIt) for (groupIt = m_groupBoxes.begin(); groupIt != m_groupBoxes.end(); ++groupIt)
{ {
if (!groupIt->second.isNull()) groupIt->second->deleteLater(); if (!groupIt->second.isNull()) groupIt->second->deleteLater();
@ -432,7 +438,7 @@ void caf::PdmUiFormLayoutObjectEditor::configureAndUpdateUi(const QString& uiCon
// Remove all fieldViews not mentioned by the configuration from the layout // Remove all fieldViews not mentioned by the configuration from the layout
std::vector< PdmFieldHandle* > fvhToRemoveFromMap; std::vector<PdmFieldHandle*> fvhToRemoveFromMap;
for (it = m_fieldViews.begin(); it != m_fieldViews.end(); ++it) for (it = m_fieldViews.begin(); it != m_fieldViews.end(); ++it)
{ {
if (it->second->uiField() == nullptr) if (it->second->uiField() == nullptr)
@ -450,8 +456,8 @@ void caf::PdmUiFormLayoutObjectEditor::configureAndUpdateUi(const QString& uiCon
// Remove all unmentioned group boxes // Remove all unmentioned group boxes
std::map<QString, QPointer<QMinimizePanel> >::iterator itOld; std::map<QString, QPointer<QMinimizePanel>>::iterator itOld;
std::map<QString, QPointer<QMinimizePanel> >::iterator itNew; std::map<QString, QPointer<QMinimizePanel>>::iterator itNew;
for (itOld = m_groupBoxes.begin(); itOld != m_groupBoxes.end(); ++itOld) for (itOld = m_groupBoxes.begin(); itOld != m_groupBoxes.end(); ++itOld)
{ {
@ -531,4 +537,3 @@ void caf::PdmUiFormLayoutObjectEditor::recursiveVerifyUniqueNames(const std::vec
} }
} }
} }