Skip to content

Commit

Permalink
Consistency fix; changed p_m to m_p like every other variable
Browse files Browse the repository at this point in the history
Added basic edit tracking (if edit is made, accordion title goes bold and earns a star) Still need to toggle save-status on save

Made most changes suggest by code review:
Fixed Bracket style consistency
Replaced most instances of StructArrayOf<StringBuffer> with StringArrays
Cleaned up QMLMarkup for readability purposes. Took advantage of appendf.
Combined extraneous if statements
  • Loading branch information
Dyllan To authored and Dyllan To committed Jun 29, 2015
1 parent ecb49b5 commit 0851054
Show file tree
Hide file tree
Showing 13 changed files with 186 additions and 155 deletions.
9 changes: 2 additions & 7 deletions configurator/ConfigSchemaHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,7 @@ const char* CConfigSchemaHelper::printQML(const char* comp, int nIdx) const

if (pSchema != NULL)
{
//pSchema->loadXMLFromEnvXml(CConfigSchemaHelper::getConstEnvPropertyTree());
//pSchema->getQML2(strQML, nIdx);
pSchema->getQML3(strQML, nIdx);

return strQML.str();
}
}
Expand Down Expand Up @@ -722,16 +719,14 @@ const char* CConfigSchemaHelper::getTableValue(const char* pXPath, int nRow) co
StringBuffer strXPath(pXPath);
StringBuffer strXPathOrignal(pXPath);

CConfigSchemaHelper::stripXPathIndex(strXPath);
CConfigSchemaHelper::stripXPathIndex(strXPath);

strXPath.appendf("[%d]", nRow);

char pTemp[64];
int offset = strlen(itoa(nRow, pTemp, 10)) - 1;
int offset = strXPath.length() - (strlen(itoa(nRow, pTemp, 10)) - 1);

strXPath.append((String(strXPathOrignal).substring(strXPath.length()-offset, strXPathOrignal.length())));
//strXPath.append((String(strXPathOrignal).substring(strXPath.length()-offset, strXPathOrignal.length()))->toCharArray());
strXPath.append(strXPathOrignal, strXPath.length(), strXPathOrignal.length()-offset);

pAttribute = m_pSchemaMapManager->getAttributeFromXPath(strXPath.str());

Expand Down
10 changes: 3 additions & 7 deletions configurator/ConfiguratorAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,19 +217,15 @@ const char* getTableValue(const char *pXPath, int nRow)
else
{
StringBuffer strXPath(pXPath);
const StringBuffer strXPathOrignal(pXPath);
const StringBuffer strXPathOriginal(pXPath);


int offset = CConfigSchemaHelper::stripXPathIndex(strXPath);
int offset = strXPathOriginal.length() - (CConfigSchemaHelper::stripXPathIndex(strXPath) + 1) ;
CConfigSchemaHelper::stripXPathIndex(strXPath);

strXPath.appendf("[%d]", nRow);

//char pTemp[64];
//int offset = strlen(itoa(nRow, pTemp, 10)) - 1;

//strXPath.append((String(strXPathOrignal).substring(strXPath.length()-offset, strXPathOrignal.length()))->toCharArray());
strXPath.append((String(strXPathOrignal).substring(strXPathOrignal.length()-offset-1, strXPathOrignal.length())));
strXPath.append(strXPathOriginal, offset, strXPathOriginal.length() - offset);

pAttribute = CConfigSchemaHelper::getInstance()->getSchemaMapManager()->getAttributeFromXPath(strXPath.str());

Expand Down
69 changes: 45 additions & 24 deletions configurator/QMLMarkup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

int CQMLMarkupHelper::glImplicitHeight = -1;


void CQMLMarkupHelper::getTabQML(StringBuffer &strQML, const char *pName)
{
assert(pName != NULL);
Expand Down Expand Up @@ -163,49 +162,71 @@ bool CQMLMarkupHelper::isTableRequired(const CAttribute *pAttrib)

void CQMLMarkupHelper::buildAccordionStart(StringBuffer &strQML, const char * title, const char * altTitle, int idx)
{
StringBuffer result;
assert(title != NULL);
strQML.append("AccordionItem {\n\
title: \"").append(title).append("\"\n");
result.append("AccordionItem {\n");
result.append(CQMLMarkupHelper::printProperty("title",title));
if(strlen(altTitle)){
strQML.append("altTitle: \"").append(altTitle).append("\"\n");
result.append(CQMLMarkupHelper::printProperty("altTitle",altTitle));
}
strQML.append("index: ").append(idx).append("\n\
contentModel: VisualItemModel {\n");
char * index = NULL;
/*numtostr(index,idx);
result.append(CQMLMarkupHelper::printProperty("index",index));*/
result.append("contentModel: VisualItemModel {\n");

strQML.append(result);
}
void CQMLMarkupHelper::buildColumns(StringBuffer &strQML, StructArrayOf<StringBuffer> &roles, StructArrayOf<StringBuffer> &titles)
void CQMLMarkupHelper::buildColumns(StringBuffer &strQML, StringArray &roles, StringArray &titles)
{
/*
Sample QML for Column Instance
columnNames: [{role:"key",title:"key"}, {role:"value",title:"value"},{role:"alphabet",title:"Alpha"}]
*/
StringBuffer result;
assert(roles.length() == titles.length());
strQML.append("columnNames: [");
result.append("columnNames: [");
for(int i = 0; i < roles.length(); i++){
strQML.append("{ role:\"").append(roles[i]).append("\", title:\"").append(titles[i]).append("\" }");
const StringBuffer temprole = CQMLMarkupHelper::printProperty("role", roles[i], false);
const StringBuffer temptitle = CQMLMarkupHelper::printProperty("title", titles[i], false);
result.appendf("{%s,%s}", temprole.toCharArray(), temptitle.toCharArray());
if(i != roles.length() - 1)
strQML.append(",");
result.append(",");
}
strQML.append("]\n");
result.append("]\n");

strQML.append(result);
}

void CQMLMarkupHelper::buildRole(StringBuffer &strQML, const char * role, StructArrayOf<StringBuffer> &values, const char * type, const char * tooltip, const char * placeholder)
void CQMLMarkupHelper::buildRole(StringBuffer &strQML, const char * role, StringArray &values, const char * type, const char * tooltip, const char * placeholder)
{
StringBuffer result;
StringBuffer escapedToolTip = tooltip;
escapedToolTip.replaceString("\"","\\\"");
StringBuffer escapedPlaceholder = placeholder;
escapedPlaceholder.replaceString("\"","\\\"");
strQML.append(role);
strQML.append(": ListElement { \n");
strQML.append("value:[");
for(int i = 0; i < values.length(); i++){
strQML.append("ListElement {value: \"");
strQML.append(values[i]);
strQML.append("\"}");
result.append(role);
result.append(": ListElement { \n");
result.append("value:[");
for(int i = 0; i < values.length(); i++)
{ result.append("ListElement {value: \"");
result.append(values[i]);
result.append("\"}");
if(i != values.length()-1)
strQML.append(",");
result.append(",");
}
strQML.append("]\n");
strQML.append("type: \"").append(type).append("\"\n");
strQML.append("tooltip: \"").append(escapedToolTip).append("\"\n");
strQML.append("placeholder: \"").append(escapedPlaceholder).append("\"}\n");
result.append("]\n");
result.append(CQMLMarkupHelper::printProperty("type",type));
result.append(CQMLMarkupHelper::printProperty("tooltip",escapedToolTip));
result.append(CQMLMarkupHelper::printProperty("placeholder",escapedPlaceholder));
result.append("}");
strQML.append(result);
}

const StringBuffer CQMLMarkupHelper::printProperty(const char * property, const char * value, const bool newline)
{
StringBuffer result;
result.appendf("%s: \"%s\"",property,value);
if(newline)
result.append("\n");
return result;
}
12 changes: 7 additions & 5 deletions configurator/QMLMarkup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
//#include "jarray.hpp"
class StringBuffer;
class CAttribute;
template <typename CLASS>
class StructArrayOf;
class StringArray;
class String;


static const char* QML_TABLE_DATA_MODEL(" tableDataModel\n");
Expand Down Expand Up @@ -520,11 +520,13 @@ class CQMLMarkupHelper
{
public:
// New Helper Functions
static void buildAccordionStart(StringBuffer &strQML, const char * title, const char * altTitle = "", int idx = -5);
static void buildAccordionStart(StringBuffer &strQML, const char * title, const char * altTitle = "", int idx = -1);
// End Accordion with QML_DOUBLE_END_BRACKET

static void buildColumns(StringBuffer &strQML, StructArrayOf<StringBuffer> &roles, StructArrayOf<StringBuffer> &titles);
static void buildRole(StringBuffer &strQML, const char * role, StructArrayOf<StringBuffer> &values, const char * type = "text", const char * tooltip = "", const char * placeholder = "");
static void buildColumns(StringBuffer &strQML, StringArray &roles, StringArray &titles);
static void buildRole(StringBuffer &strQML, const char * role, StringArray &values, const char * type = "text", const char * tooltip = "", const char * placeholder = "");

static const StringBuffer printProperty(const char * property, const char * value, const bool newline = true);
// NewHelperFunctions end;

static void getTabQML(StringBuffer &strQML, const char *pName);
Expand Down
21 changes: 9 additions & 12 deletions configurator/SchemaAttributeGroup.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "SchemaAttributeGroup.hpp"
#include "SchemaAttributeGroup.hpp"
#include "DocumentationMarkup.hpp"
#include "ConfigSchemaHelper.hpp"
#include "jptree.hpp"
Expand Down Expand Up @@ -120,16 +120,13 @@ void CAttributeGroup::getQML(StringBuffer &strQML, int idx) const
void CAttributeGroup::getQML3(StringBuffer &strQML, int idx) const
{
DEBUG_MARK_QML;
if (this->getRef() != NULL && this->getRef()[0] != 0 && m_pRefAttributeGroup != NULL)
if (this->getRef() != NULL && this->getRef()[0] != 0 && m_pRefAttributeGroup != NULL && m_pRefAttributeGroup->getConstAttributeArray() != NULL)
{
if (m_pRefAttributeGroup->getConstAttributeArray() != NULL)
{
DEBUG_MARK_QML;
CQMLMarkupHelper::buildAccordionStart(strQML, this->getRef(), "");
m_pRefAttributeGroup->getConstAttributeArray()->getQML3(strQML);
strQML.append(QML_DOUBLE_END_BRACKET);
DEBUG_MARK_QML;
}
DEBUG_MARK_QML;
CQMLMarkupHelper::buildAccordionStart(strQML, this->getRef(), "");
m_pRefAttributeGroup->getConstAttributeArray()->getQML3(strQML);
strQML.append(QML_DOUBLE_END_BRACKET);
DEBUG_MARK_QML;
}
DEBUG_MARK_QML;
}
Expand Down Expand Up @@ -399,12 +396,12 @@ void CAttributeGroupArray::getQML2(StringBuffer &strQML, int idx) const

void CAttributeGroupArray::getQML3(StringBuffer &strQML, int idx) const
{
DEBUG_MARK_QML;
for (int idx=0; idx < this->length(); idx++)
{
DEBUG_MARK_QML;
(this->item(idx)).getQML3(strQML);
DEBUG_MARK_QML;
}
DEBUG_MARK_QML;
}

void CAttributeGroupArray::populateEnvXPath(StringBuffer strXPath, unsigned int index)
Expand Down
52 changes: 31 additions & 21 deletions configurator/SchemaAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ CAttribute::~CAttribute()
//CConfigSchemaHelper::getInstance()->getSchemaMapManager()->removeMapOfXPathToAttribute(this->getEnvXPath());
}

bool CAttribute::isHidden(){
if(this->getAnnotation()->getAppInfo() != NULL){
if(!stricmp(this->getAnnotation()->getAppInfo()->getViewType(),"hidden")){
return true;
}
bool CAttribute::isHidden()
{
if(this->getAnnotation()->getAppInfo() != NULL && !stricmp(this->getAnnotation()->getAppInfo()->getViewType(),"hidden"))
{
return true;
}

return false;
}

Expand Down Expand Up @@ -447,19 +446,22 @@ void CAttribute::getQML3(StringBuffer &strQML, const char * role, int idx) const
}
*/
DEBUG_MARK_QML;
StringBuffer name(role == NULL ? this->getName() : role);
StructArrayOf<StringBuffer> values;
StringBuffer name(role == NULL || role[0] == '\0' ? this->getName() : role);
StringArray values;
values.append(this->getEnvXPath());
if(this->getAnnotation()->getAppInfo() != NULL){
if(this->getAnnotation()->getAppInfo() != NULL)
{
const char * viewType = this->getAnnotation()->getAppInfo()->getViewType();
if( viewType != NULL){
if( viewType != NULL)
{
if(!stricmp(viewType,"readonly"))
viewType = "text";
else
viewType = "field";
} else viewType = "field";
CQMLMarkupHelper::buildRole(strQML, name, values, viewType, this->getAnnotation()->getAppInfo()->getToolTip(), this->getDefault());
} else {
} else
{
CQMLMarkupHelper::buildRole(strQML, name, values, "field");
}
DEBUG_MARK_QML
Expand Down Expand Up @@ -1250,16 +1252,20 @@ void CAttributeArray::getQML3(StringBuffer &strQML, int idx) const
*/
DEBUG_MARK_QML;
// If UI is LIST, each AttributeArray.getQML3() call needs to effectively return a row
if(this->getUIType() == QML_UI_TABLE_LIST){
if(this->getUIType() == QML_UI_TABLE_LIST)
{
strQML.append(QML_TABLE_ROW_START);
for(int i = 0; i < this->length(); i++){
for(int i = 0; i < this->length(); i++)
{
(this->item(i)).getQML3(strQML);
}
strQML.append(QML_TABLE_ROW_END);
// Otherwise, assume Key/Val and generate your own table
} else {
StructArrayOf<StringBuffer> roles;
StructArrayOf<StringBuffer> titles;
}
else
{
StringArray roles;
StringArray titles;
strQML.append(QML_TABLE_START);

// Builds Columns
Expand All @@ -1272,9 +1278,10 @@ void CAttributeArray::getQML3(StringBuffer &strQML, int idx) const
// build Rows
for (int i = 0; i < this->length(); i++)
{
if((this->item(i)).isHidden()) continue;
if((this->item(i)).isHidden())
continue;
strQML.append(QML_TABLE_ROW_START);
StructArrayOf<StringBuffer> key;
StringArray key;
key.append(this->item(i).getTitle());
CQMLMarkupHelper::buildRole(strQML, "key", key);
(this->item(i)).getQML3(strQML, "value");
Expand Down Expand Up @@ -1352,9 +1359,12 @@ const CAttribute* CAttributeArray::findAttributeWithName(const char *pName, bool

return NULL;
}
const void CAttributeArray::getAttributeNames(StructArrayOf<StringBuffer> &names, StructArrayOf<StringBuffer> &titles) const{
for(int i = 0; i < this->length(); i++){
if(!this->item(i).isHidden()){
const void CAttributeArray::getAttributeNames(StringArray &names, StringArray &titles) const
{
for(int i = 0; i < this->length(); i++)
{
if(!this->item(i).isHidden())
{
names.append(this->item(i).getName());
titles.append(this->item(i).getTitle());
}
Expand Down
2 changes: 1 addition & 1 deletion configurator/SchemaAttributes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class CAttributeArray : public CIArrayOf<CAttribute>, public InterfaceImpl, publ
virtual const char* getXML(const char* /*pComponent*/);

const CAttribute* findAttributeWithName(const char *pName, bool bCaseInsensitive = true) const;
const void getAttributeNames(StructArrayOf<StringBuffer> &names, StructArrayOf<StringBuffer> &titles) const;
const void getAttributeNames(StringArray &names, StringArray &titles) const;

static CAttributeArray* load(const char* pSchemaFile);
static CAttributeArray* load(CXSDNodeBase* pParentNode, const IPropertyTree *pSchemaRoot, const char* xpath);
Expand Down
Loading

0 comments on commit 0851054

Please sign in to comment.