@@ -54,7 +54,7 @@ void AdapterSettings::buildSection(const QJsonObject& propSchema, const QJsonVal
5454 auto * form = new SchemaFormWidget (_pItemTabs);
5555 form->setSchema (_itemSchema, itemsArray.at (i).toObject ());
5656 pages.append (form);
57- names.append (QString ( " %1 %2 " ). arg (_propertyKey[ 0 ]. toUpper () + _propertyKey. mid ( 1 )). arg (i + 1 ));
57+ names.append (formatTabName (i + 1 ));
5858 }
5959
6060 if (!pages.isEmpty ())
@@ -77,19 +77,26 @@ void AdapterSettings::buildSection(const QJsonObject& propSchema, const QJsonVal
7777 }
7878}
7979
80+ QString AdapterSettings::formatTabName (int index) const
81+ {
82+ if (_propertyKey.isEmpty ())
83+ {
84+ return QString (" Item %1" ).arg (index);
85+ }
86+ return QString (" %1 %2" ).arg (_propertyKey[0 ].toUpper () + _propertyKey.mid (1 )).arg (index);
87+ }
88+
8089void AdapterSettings::addItemTab ()
8190{
8291 auto * form = new SchemaFormWidget (_pItemTabs);
8392 QJsonObject defaultValues;
84- const QJsonArray defaultItems =
85- _pSettingsModel->adapterData (_adapterId)->defaults ().value (_propertyKey).toArray ();
93+ const QJsonArray defaultItems = _pSettingsModel->adapterData (_adapterId)->defaults ().value (_propertyKey).toArray ();
8694 if (!defaultItems.isEmpty ())
8795 {
8896 defaultValues = defaultItems.first ().toObject ();
8997 }
9098 form->setSchema (_itemSchema, defaultValues);
91- const QString name =
92- QString (" %1 %2" ).arg (_propertyKey[0 ].toUpper () + _propertyKey.mid (1 )).arg (_nextItemTabIndex);
99+ const QString name = formatTabName (_nextItemTabIndex);
93100 _nextItemTabIndex++;
94101 _pItemTabs->addNewTab (name, form);
95102}
0 commit comments