Ejemplo n.º 1
0
void XMLOperations::insertDownloadTrash(SDownloadTrash tmpStruct)
{
    QDomDocument domDocument;
    QFile downloadTrashFile(DOWNLOADTRASHFILE_PATH);
    if (downloadTrashFile.open(QIODevice::ReadOnly))
    {
        // 此处需做错误判断
        if (!domDocument.setContent(&downloadTrashFile))
            return;
    }
    else
        return;

    downloadTrashFile.close();

    QDomElement fileElement = domDocument.createElement("File");

    fileElement.appendChild(createChildElement("Name", tmpStruct.name));
    fileElement.appendChild(createChildElement("URL", tmpStruct.URL));
    fileElement.appendChild(createChildElement("DLToolsType", tmpStruct.dlToolsType));
    fileElement.appendChild(createChildElement("TotalSize", tmpStruct.totalSize));
    fileElement.appendChild(createChildElement("IconPath",tmpStruct.iconPath));

    QDomElement rootElement = domDocument.documentElement();
    rootElement.appendChild(fileElement);

    //写xml文件
    if (!downloadTrashFile.open(QIODevice::WriteOnly | QIODevice::Truncate))
        return;
    QTextStream textStream(&downloadTrashFile);

    domDocument.save(textStream,4);

    downloadTrashFile.close();
}
Ejemplo n.º 2
0
QDomElement XMLOperations::createThreadElement(QList<SDownloadThread> threadList)
{
    QDomDocument domDoc;
    QDomElement threadsNode = domDoc.createElement("Threads");

    for (int i = 0; i < threadList.count(); i ++)
    {
        QDomElement threadNode = domDoc.createElement("Thread");
        threadNode.appendChild(createChildElement("StartBlockIndex", threadList.at(i).startBlockIndex));
        threadNode.appendChild(createChildElement("EndBlockIndex", threadList.at(i).endBlockIndex));
        threadNode.appendChild(createChildElement("CompleteBlockCount", threadList.at(i).completedBlockCount));

        threadsNode.appendChild(threadNode);
    }

    return threadsNode;
}
Ejemplo n.º 3
0
	void COverlay::createChildPanel(const std::string& name, 
		float left, float top, float width, float height,
		const std::string& material)
	{
		assert( !_overlayManager->hasOverlayElement(name) && "Ya existe un elemento hijo con el mismo nombre" );
		
		Ogre::OverlayElement* newChild = 
			createChildElement(TChildType::PANEL, name, left, top, width, height);

		if(material.length() > 0)
			newChild->setMaterialName(material);

		_overlay->add2D( static_cast<Ogre::OverlayContainer*>(newChild) );
	} //createChildPanel
Ejemplo n.º 4
0
	void COverlay::createChildTextArea(const std::string &panelName, const std::string &name,
		float left, float top, float width, float height,
		const std::string &font, float fontSize, const std::string &text)
	{
		assert(_childElements[panelName] && "No existe un panel hijo con ese nombre en este overlay!");

		Ogre::TextAreaOverlayElement* newChild = static_cast<Ogre::TextAreaOverlayElement*>(
			createChildElement(TChildType::TEXTAREA, name, left, top, width, height)
		);									
			newChild->setFontName(font);
			newChild->setCharHeight(fontSize);
			newChild->setCaption(text);

		static_cast<Ogre::OverlayContainer*>( _childElements[panelName] )->addChild(newChild);
	} // createChildTextArea
Ejemplo n.º 5
0
void XMLOperations::touchMainConfigFile()
{
    QFile mainConfigFile(MAINCONFIGFILE_PATH);
    if (!mainConfigFile.exists())
    {
        if (!mainConfigFile.open(QIODevice::WriteOnly | QIODevice::Truncate))
        {
            return;
        }

        QDomDocument domDocument;

        QDomProcessingInstruction instruction;
        instruction=domDocument.createProcessingInstruction("xml","version=\'1.0\' encoding=\'UTF-8\'");

        domDocument.appendChild(instruction);

        //创建MainConfig根节点
        QDomElement mainConfigNode = domDocument.createElement("MainConfig");

        //将各个子节点添加到@mainConfigNode节点上
#ifdef Q_OS_LINUX
        mainConfigNode.appendChild(createChildElement("OperatingSystem", "Linux"));
#elif Q_OS_WIN
        mainConfigNode.appendChild(createChildElement("OperatingSystem", "Windows"));
#else
        mainConfigNode.appendChild(createChildElement("OperatingSystem", "UnSupport"));
#endif
        mainConfigNode.appendChild(createChildElement("Version", "1.0.0"));
        mainConfigNode.appendChild(createChildElement("DownloadSpeed", "2000"));
        mainConfigNode.appendChild(createChildElement("UploadSpeed", "500"));
        mainConfigNode.appendChild(createChildElement("WindowsSavePath",
                                                      QStandardPaths::standardLocations(QStandardPaths::DownloadLocation).at(0) + "/PointDownload"));
        mainConfigNode.appendChild(createChildElement("LinuxSavePath",
                                                      QStandardPaths::standardLocations(QStandardPaths::DownloadLocation).at(0) + "/PointDownload"));
        mainConfigNode.appendChild(createChildElement("Beep", "true"));
        mainConfigNode.appendChild(createChildElement("EnableUpload", "true"));
        mainConfigNode.appendChild(createChildElement("ThreadCount", "5"));
        mainConfigNode.appendChild(createChildElement("VideoDetectType", "mov;mkv;swf;flv;mp4;avi;rmvb;rm;3gp"));
        mainConfigNode.appendChild(createChildElement("AudioDetectType", "mp3;wma;flac;ape;wav;acc"));
        mainConfigNode.appendChild(createChildElement("MaxJobCount", "10"));
        mainConfigNode.appendChild(createChildElement("clipboard", "true"));
        mainConfigNode.appendChild(createChildElement("exitOnClose", "false"));
        mainConfigNode.appendChild(createChildElement("aria2Path", ""));
        mainConfigNode.appendChild(createChildElement("yougetPath", ""));

        //添加元素节点到父节点
        domDocument.appendChild(mainConfigNode);

        //写xml文件
        QTextStream textStream(&mainConfigFile);

        domDocument.save(textStream,4);

        mainConfigFile.close();
    }
}
Ejemplo n.º 6
0
void XMLOperations::insertDownloadingNode(SDownloading tmpStruct)
{
    QDomDocument domDocument;
    QFile downloadingFile(DOWNLOADINGFILE_PATH);
    if (downloadingFile.open(QIODevice::ReadOnly))
    {
        // 此处需做错误判断
        if (!domDocument.setContent(&downloadingFile))
        {
             return;
        }
    }
    else
        return;

    downloadingFile.close();

    QDomElement fileElement = domDocument.createElement("File");

    fileElement.appendChild(createChildElement("Name", tmpStruct.name));
    fileElement.appendChild(createChildElement("JobMaxSpeed", tmpStruct.jobMaxSpeed));
    fileElement.appendChild(createChildElement("SavePath", tmpStruct.savePath));
    fileElement.appendChild(createChildElement("EnableUpload", tmpStruct.enableUpload));
    fileElement.appendChild(createChildElement("URL", tmpStruct.URL));
    fileElement.appendChild(createChildElement("RedirectURL", tmpStruct.redirectRUL));
    fileElement.appendChild(createChildElement("DLToolsType", tmpStruct.dlToolsType));
    fileElement.appendChild(createChildElement("BlockCount", tmpStruct.blockCount));
    fileElement.appendChild(createChildElement("BlockSize", tmpStruct.blockSize));
    fileElement.appendChild(createChildElement("TotalSize", tmpStruct.totalSize));
    fileElement.appendChild(createChildElement("ReadySize", tmpStruct.readySize));
    fileElement.appendChild(createChildElement("State", tmpStruct.state));//2014.4.7add
    fileElement.appendChild(createChildElement("AverageSpeed", tmpStruct.averageSpeed));//2014.4.7add
    fileElement.appendChild(createChildElement("LastModifyTime", tmpStruct.lastModifyTime));//2014.4.7add
    fileElement.appendChild(createChildElement("AutoOpenFolder", tmpStruct.autoOpenFolder));
    fileElement.appendChild(createChildElement("IconPath",tmpStruct.iconPath));
    fileElement.appendChild(createThreadElement(tmpStruct.threadList));

    QDomElement rootElement = domDocument.documentElement();
    rootElement.appendChild(fileElement);

    //写xml文件
    if (!downloadingFile.open(QIODevice::WriteOnly | QIODevice::Truncate))
        return;
    QTextStream textStream(&downloadingFile);

    domDocument.save(textStream,4);

    downloadingFile.close();
}