Пример #1
0
// Read sprite size and location data from plist, and save it in a hash table.
// I really hope that the file format doesn't change, since a lot of it is hardcoded in.
void MainWindow::loadSpritePlist()
{
    QDomDocument doc("BallGameSpriteSheet");
    QFile file(PATH_SPRITE_PLIST);
    if (!file.open(QIODevice::ReadOnly))
        return;
    if (!doc.setContent(&file)) {
        file.close();
        return;
    }
    file.close();

    QString itemName = "null";
    QRect itemRect;

    // print out the element names of all elements that are direct children
    // of the outermost element.
    QDomElement docElem = doc.documentElement();

    QDomNode n = docElem.firstChild();
    n = n.firstChild().nextSibling().firstChild();
    while(!n.isNull()) {
        QDomElement e = n.toElement(); // try to convert the node to an element.
        if(!e.isNull()) {
            itemName = qPrintable(e.text()); // the node really is an element.
        }
        n = n.nextSibling();
        QDomNode m = n.firstChild();

        // 2 is the index of the Rect string in the sub-dicts.
        for(int i = 0; i < 1; i++)
            m = m.nextSibling();

        //qDebug(m.toElement().text().toAscii());

        QDomElement f = m.toElement();
        itemRect = strToRect(qPrintable(f.text()));
        n = n.nextSibling();

        spriteSheetLocations.insert(itemName, itemRect);
    }
}
Пример #2
0
/************************************************
 *
 * ***********************************************/
void PdfMergerIPCReader::mergerOutputReady()
{
    mBuf += QString::fromLocal8Bit(mProcess->readAllStandardOutput());
    QString line;
    int i;
    for (i=0; i<mBuf.length(); ++i)
    {
        QChar c = mBuf.at(i);
        if (c != '\n')
        {
            line += c;
            continue;
        }


        QStringList data = line.split(':', QString::KeepEmptyParts);

        //***************************************
        if (data.at(0) == "S")
        {
            emit progress(data.at(1).toInt(), mPageCount);
        }


        //***************************************
        else if (data.at(0) == "P")
        {
            PdfPageInfo info;
            info.objNum = data.at(3).toInt();
            info.cropBox = strToRect(data.at(4));
            info.mediaBox = strToRect(data.at(5));
            info.rotate = data.at(6).toInt();

            emit pageInfo(data.at(1).toInt(),
                          data.at(2).toInt(),
                          info);
        }


        //***************************************
        else if (data.at(0) == "A")
        {
            mPageCount = data.at(1).toInt();
            emit allPagesCount(mPageCount);
        }


        //***************************************
        else if (data.at(0) == "X")
        {
            emit xRefInfo(data.at(1).toDouble(),
                          data.at(2).toDouble());
        }


        //***************************************
        else if (data.at(0) == "E")
        {
            emit error(data.at(1));
        }

        //***************************************
        else if (data.at(0) == "W")
        {
            qWarning() << data.at(1);
        }

        //***************************************
        else if (data.at(0) == "D")
        {
            qDebug() << data.at(1);
        }

        line = "";
    }

    mBuf.remove(0, i);
}