Exemplo n.º 1
0
bool LOCACC::updateMessage(QStringList newMessageData, bool isAccTextSame, QTreeWidgetItem *currentItem)
{
    QString messageId = currentItem->text(0);
    QString eleId = currentItem->parent()->text(0);
    QJsonArray jArray = m_jsonMasterObj["locAccData"].toArray();
    QString parentScreen = currentItem->parent()->parent()->text(0);
    QJsonObject tempObj ;
    for(int i = 0 ; i < jArray.count() ; i++ )
    {
        tempObj = jArray.at(i).toObject();
        if(tempObj["id"] == parentScreen)
        {
            QJsonArray eleJArray = tempObj["elements"].toArray();
            QJsonObject tempEleObj;
            for(int j = 0 ; j < eleJArray.count(); j++)
            {
                tempEleObj = eleJArray.at(j).toObject();
                if(tempEleObj["id"] == eleId)
                {
                    QJsonArray msgsArray = tempEleObj["messages"].toArray();
                    QJsonObject tempMsgObj;
                    for(int k = 0; k < msgsArray.count() ; k++)
                    {
                        tempMsgObj = msgsArray.at(k).toObject();
                        if(tempMsgObj["id"] == messageId)
                        {
                            msgsArray.removeAt(k);
                            if(messageExistance(newMessageData,msgsArray))
                            {
                                return false;
                            }
                            QJsonObject newMsgObj = getMessageJson(newMessageData,isAccTextSame);
                            msgsArray.insert(k,newMsgObj);
                            tempEleObj["messages"] = msgsArray;
                            eleJArray.replace(j,tempEleObj);
                            tempObj["elements"] = eleJArray;
                            jArray.replace(i,tempObj);
                            setMessageTooltip(currentItem,newMsgObj);
                            break;
                        }
                    }
                }
            }
        }
    }
    m_jsonMasterObj["locAccData"] = jArray;
    currentItem->setText(0,newMessageData.at(0));
    writeFile();
    return true;
}
Exemplo n.º 2
0
QTreeWidgetItem* LOCACC::addElement(QStringList elementData, QTreeWidgetItem *parent)
{
    QJsonArray jArray = m_jsonMasterObj["locAccData"].toArray();
    QString parentScreen = parent->text(0);
    QJsonObject tempObj ;
    QTreeWidgetItem *newEleWidget;
    for(int i = 0 ; i < jArray.count() ; i++ )
    {
        tempObj = jArray.at(i).toObject();
        if(tempObj["id"] == parentScreen)
        {
            QJsonArray eleJArray = tempObj["elements"].toArray();
            if(messageExistance(elementData,eleJArray))
            {
                return false;
            }
            QJsonObject newEleObj = getElementJson(elementData);
            eleJArray.append(newEleObj);
            tempObj["elements"] = eleJArray;
            jArray.replace(i,tempObj);

            QStringList strList;
            strList << elementData;
            newEleWidget  = new QTreeWidgetItem(strList);
            parent->addChild(newEleWidget);
            break;
        }
    }
    m_jsonMasterObj["locAccData"] = jArray;
    writeFile();
    return newEleWidget;
}
Exemplo n.º 3
0
bool LOCACC::deleteElement(QTreeWidgetItem *currentItem)
{
    QString elementId = currentItem->text(0);
    QJsonArray jArray = m_jsonMasterObj["locAccData"].toArray();
    QString parentScreen = currentItem->parent()->text(0);
    QJsonObject tempObj ;
    for(int i = 0 ; i < jArray.count() ; i++ )
    {
        tempObj = jArray.at(i).toObject();
        if(tempObj["id"] == parentScreen)
        {
            QJsonArray eleJArray = tempObj["elements"].toArray();
            QJsonObject eleObject ;
            for(int j = 0 ; j < eleJArray.count() ; j++)
            {
                eleObject = eleJArray.at(j).toObject();
                if(eleObject["id"] == elementId)
                {
                    eleJArray.removeAt(j);
                    tempObj["elements"] = eleJArray;
                    jArray.replace(i,tempObj);
                    break;
                }
            }
        }
    }
    m_jsonMasterObj["locAccData"] = jArray;
    currentItem->parent()->removeChild(currentItem);
    emptyTreeWidget(currentItem);
    writeFile();
    return true;
}
Exemplo n.º 4
0
QTreeWidgetItem* LOCACC::addMessage(QStringList msgData, bool isAccTextSame, QTreeWidgetItem *parent)
{
    QString eleId = parent->text(0);
    QJsonArray jArray = m_jsonMasterObj["locAccData"].toArray();
    QString parentScreen = parent->parent()->text(0);
    QJsonObject tempObj ;
    QTreeWidgetItem *newMsg;
    for(int i = 0 ; i < jArray.count() ; i++ )
    {
        tempObj = jArray.at(i).toObject();
        if(tempObj["id"] == parentScreen)
        {
            QJsonArray eleJArray = tempObj["elements"].toArray();
            QJsonObject tempEleObj;
            for(int j = 0 ; j < eleJArray.count(); j++)
            {
                tempEleObj = eleJArray.at(j).toObject();
                if(tempEleObj["id"] == eleId)
                {
                    QJsonArray msgsArray = tempEleObj["messages"].toArray();
                    if(messageExistance(msgData,msgsArray))
                    {
                        return false;
                    }
                    QJsonObject newMsgJson = getMessageJson(msgData,isAccTextSame);
                    msgsArray.append(newMsgJson);
                    QStringList msgList;
                    msgList << msgData.at(0);
                    newMsg  = new QTreeWidgetItem(msgList);
                    setMessageTooltip(newMsg,newMsgJson);
                    parent->addChild(newMsg);
                    tempEleObj["messages"] = msgsArray;
                    eleJArray.replace(j,tempEleObj);
                    tempObj["elements"] = eleJArray;
                    jArray.replace(i,tempObj);
                    break;
                }
            }
        }
    }
    m_jsonMasterObj["locAccData"] = jArray;
    writeFile();
    return newMsg;
}
Exemplo n.º 5
0
void ContactDetails::writeDetailsToDocument()
{
    QJsonArray detailGroupArray;

    foreach(ContactDetailGroupBox* detailGroup, contactDetailList)
    {
        if(!detailGroup->toJsonObject().isEmpty())
            detailGroupArray.append(detailGroup->toJsonObject());
    }

    QJsonObject contactObject;
    contactObject.insert("name", ui->nameLineEdit->text());
    contactObject.insert("detailGroups", detailGroupArray);

    QJsonArray currentArray = document->array();
    currentArray.replace(rowIndex, contactObject);

    document->setArray(currentArray);
}
Exemplo n.º 6
0
void AccessControlPage::editAccessControlRule()
{
	QJsonArray accessControlRules = VeyonCore::config().accessControlRules();

	int row = ui->accessControlRulesView->currentIndex().row();

	if( row >= accessControlRules.count() )
	{
		return;
	}

	AccessControlRule rule( accessControlRules[row] );

	if( AccessControlRuleEditDialog( rule, this ).exec() )
	{
		accessControlRules.replace( row, rule.toJson() );

		modifyAccessControlRules( accessControlRules, row );
	}
}
Exemplo n.º 7
0
bool LOCACC::updateElement(QStringList newElementData, QTreeWidgetItem *currentItem)
{
    QString elementId = currentItem->text(0);
    QJsonArray jArray = m_jsonMasterObj["locAccData"].toArray();
    QString parentScreen = currentItem->parent()->text(0);
    QJsonObject tempObj ;
    for(int i = 0 ; i < jArray.count() ; i++ )
    {
        tempObj = jArray.at(i).toObject();
        if(tempObj["id"] == parentScreen)
        {
            QJsonArray eleJArray = tempObj["elements"].toArray();
            QJsonObject eleObject ;
            for(int j = 0 ; j < eleJArray.count() ; j++)
            {
                eleObject = eleJArray.at(j).toObject();
                if(eleObject["id"] == elementId)
                {
                    eleJArray.removeAt(j);
                    if(elementExistance(newElementData,eleJArray))
                    {
                        return false;
                    }
                    QJsonObject newEleJson = getElementJson(newElementData);
                    newEleJson["messages"] = eleObject["messages"];
                    eleJArray.insert(j,newEleJson);
                    tempObj["elements"] = eleJArray;
                    jArray.replace(i,tempObj);
                    break;
                }
            }
        }
    }
    m_jsonMasterObj["locAccData"] = jArray;
    currentItem->setText(0,newElementData.at(0));
    writeFile();
    return true;
}
Exemplo n.º 8
0
bool LOCACC::replaceAll(QString commonLocAccFilePath)
{        
    QFile file(commonLocAccFilePath);
    if(!file.exists())
    {
        qDebug() << "Replacement file is not found";
        return false;
    }
    file.open(QIODevice::ReadOnly | QIODevice::Text);
    QByteArray rawData = file.readAll();
    QJsonDocument doc(QJsonDocument::fromJson(rawData));
    QJsonObject replacementJSON = doc.object();
    QJsonArray replacementArray = replacementJSON["locAccData"].toArray();
    file.close();

    QJsonObject jsonObj_currentScreen;
    for(int i = 0 ; i < replacementArray.count() ; i++)
    {
        jsonObj_currentScreen = replacementArray.at(i).toObject();
        if(jsonObj_currentScreen["id"] == STR_MISCCEL_SCREEN)
        {
            replacementArray = jsonObj_currentScreen["elements"].toArray();
            break;
        }
    }

    QJsonArray jsonLog;
    QJsonArray scrnJArray = m_jsonMasterObj["locAccData"].toArray();
    QJsonObject tempScrnObj ;
    for(int i = 0 ; i < scrnJArray.count() ; i++ )
    {
        tempScrnObj = scrnJArray.at(i).toObject();
        QJsonArray eleJArray = tempScrnObj["elements"].toArray();
        QJsonObject tempEleObj;
        for(int j = 0 ; j < eleJArray.count(); j++)
        {
            tempEleObj = eleJArray.at(j).toObject();
            QJsonArray msgsArray = tempEleObj["messages"].toArray();
            QJsonObject tempMsgObj;
            for(int k = 0; k < msgsArray.count() ; k++)
            {
                tempMsgObj = msgsArray.at(k).toObject();
                QJsonObject tempLocAccObj = tempMsgObj["message"].toObject();
                QJsonObject tempReplaceObj;
                for(int l = 0 ; l < replacementArray.count() ; l++ )
                {
                    tempReplaceObj = replacementArray.at(l).toObject();
                    QJsonArray messageArray = tempReplaceObj["messages"].toArray();
                    for(int m = 0 ; m < messageArray.count() ; m++)
                    {
                        QJsonObject messageObject = messageArray.at(m).toObject();
                        QString str_locText = tempLocAccObj["loc"].toString();
                        bool b_compareResult = str_locText.compare(messageObject["message"].toObject()["loc"].toString());
                       /* qDebug() << b_compareResult << " " << str_locText
                                 << "  " << messageObject["message"].toObject()["loc"].toString();*/
                        if(b_compareResult == 0)
                        {
                            // Generate Log Object
                            QJsonObject logObject ;
                            logObject["screenId"] = tempScrnObj["id"];
                            logObject["elementId"] = tempEleObj["id"];
                            logObject["messageId"] = tempMsgObj["id"];
                            logObject["originalText"] = tempLocAccObj["loc"];
                            logObject["commonId"] = tempReplaceObj["id"];
                            jsonLog.append(logObject);                            

                            // Actual Change
                            tempLocAccObj["loc"] = QString("");
                            tempLocAccObj["acc"] = QString("");
                            tempLocAccObj["commonId"] = tempReplaceObj["id"];

                            tempMsgObj["message"] = tempLocAccObj;
                            msgsArray.replace(k,tempMsgObj);
                        }
                    }
                }               
            }
            tempEleObj["messages"] = msgsArray;
            eleJArray.replace(j,tempEleObj);
        }
        tempScrnObj["elements"] = eleJArray;
        scrnJArray.replace(i,tempScrnObj);
    }

    m_jsonMasterObj["locAccData"] = scrnJArray;
    writeFile();
    writeLogFile(jsonLog);
    writeHtmlLogFile(jsonLog);
    return true;
}