CConfiguration::CConfiguration(QWidget* canvasWidget, const QString& configFile) : m_CanvasWidget(canvasWidget), m_DisplaySizeX(0), m_DisplaySizeY(0) { m_Nodes.setAutoDelete(true); QDomDocument doc("ScenarioSetup"); QFile file(configFile); if(!file.open(QIODevice::ReadOnly)) { throw ELoadFileException(); } QString errorMessage; int errorLine; if(!doc.setContent(&file , true , &errorMessage, &errorLine)) { file.close(); throw EXMLSyntaxException(errorMessage, errorLine); } file.close(); QDomNode currentNode = doc.documentElement().firstChild(); while(!currentNode.isNull()) { if(QDomNode::ElementNode == currentNode.nodeType()) { if(currentNode.toElement().tagName() == QString(g_RefreshTimeTag)) { m_RefreshTime = currentNode.toElement().text().toInt(); } else if(currentNode.toElement().tagName() == QString(g_ListenPortTag)) { m_ListenPort = currentNode.toElement().text().toInt(); } else if(currentNode.toElement().tagName() == QString(g_ResolutionXTag)) { m_DisplaySizeX = currentNode.toElement().text().toInt(); } else if(currentNode.toElement().tagName() == QString(g_ResolutionYTag)) { m_DisplaySizeY = currentNode.toElement().text().toInt(); } else if(currentNode.toElement().tagName() == QString(g_ProtocolColorTag)) { QDomAttr Attribute = currentNode.toElement().attributeNode(QString(g_ProtocolColorIDTag)); if(!Attribute.isNull()) { m_ColorMap[Attribute.value().toInt()] = currentNode.toElement().text(); } } else if(currentNode.toElement().tagName() == QString(g_BackgroundImageTag)) { m_BackgroundImageName = currentNode.toElement().text(); } else if(currentNode.toElement().tagName() == QString(g_CaptionTag)) { m_Caption = currentNode.toElement().text(); } else if((currentNode.toElement().tagName() == QString(g_NodeTag)) || (currentNode.toElement().tagName() == QString(g_RSPNodeTag))) { CNode* node = createNode(currentNode.toElement()); m_Nodes.append(node); m_NodesMap[node->getUniqueID()] = node; } else { QMessageBox::critical(0, "Error!", "Found unknown tag in config file: " + currentNode.toElement().tagName()); } } currentNode = currentNode.nextSibling(); } m_NetworkListener = new CNetworkListener(m_ListenPort, m_NodesMap); }