void ProgressThread::run()
{
    int timeElapsed, timeRemaining, percentageDone;
    percentageDone = timeElapsed = timeRemaining = 0;

    // main progress loop: update GUI, then sleep for a bit
    while (true)
    {
        // get the current status
        Status currentStatus = model->getStatus();
        emit statusMessageUpdate(currentStatus.getMessage());

        // see if there is a new image to be displayed
        if (currentStatus.hasNewImage())
        {
            emit imageUpdate(model->getImage());
            // TODO: if they are not looking at the most recent image,
            //       maybe don't update the current image...
        }

        // check if the model is still running
        if (currentStatus.getState() == Status::RUNNING)
        {
            percentageDone = (int)(100*currentStatus.getProgress());
            timeElapsed = currentStatus.getTimeElapsed();
            timeRemaining = currentStatus.getTimeRemaining();
            emitProgress(percentageDone, timeElapsed, timeRemaining);
        }

        // check if model is finished
        else if (currentStatus.getState() == Status::COMPLETE)
        {
            break;
        }

        // sleep for now so it doesn't spend too much time in this thread
        msleep(sleepTimeMilliseconds);
    }

    // fix the values for the progress
    if (model->getStatus().getState() == Status::COMPLETE)
    {
        emitProgress(100, timeElapsed, 0);
        emit imageUpdate(model->getImage());
    }

    // tell GUI that it is finished
    emit finished();
}
Ejemplo n.º 2
0
PlayThread::PlayThread(QLabel* iLabel, QLabel* dLabel, QList<QImage>* iBuf, QList<QImage>* gBuf, QList<QImage>* dBuf, QList<QImage>* bBuf, int* fps)
{
    imgLabel    = iLabel;
    dbgLabel    = dLabel;
    imgBuffer   = iBuf;
    gryBuffer   = gBuf;
    dbgBuffer   = dBuf;
    backBuffer  = bBuf;
    this->fps   = fps;
    frame_pos   = 0;
    played_frame_cnt    = 0;
    state_t     = INIT;
    label_t     = GREYSCALE;
    status      = QString::fromStdString("No Input Video");
    timer_ptr   = new QTimer(0);
    connect(timer_ptr, SIGNAL(timeout()), this, SLOT(imageUpdate()));
}
Ejemplo n.º 3
0
void
SmugMug::WebService::_parseImage (QDomElement &root) {

    if (!root.isNull () && root.hasAttribute (QLatin1String ("id"))) {

        QString imageId = root.attribute (QLatin1String ("id"));
        if (!imageId.isEmpty ()) {

            SmugMug::Attributes attr;

            attr.insert ("Id", imageId);
            attr.insert ("FileName", root.attribute ("FileName"));
            attr.insert ("Caption", root.attribute ("Caption"));
            attr.insert ("Keywords", root.attribute ("Keywords"));
            attr.insert ("Date", root.attribute ("Date"));
            attr.insert ("Format", root.attribute ("Format"));
            attr.insert ("Size", root.attribute ("Size"));
            attr.insert ("Width", root.attribute ("Width"));
            attr.insert ("Height", root.attribute ("Height"));
            attr.insert ("MD5Sum", root.attribute ("MD5Sum"));
            attr.insert ("LastUpdated", root.attribute ("LastUpdated"));
            attr.insert ("OriginalUrl", root.attribute ("OriginalURL"));
            attr.insert ("LargeUrl", root.attribute ("LargeURL"));
            attr.insert ("MediumUrl", root.attribute ("MediumURL"));
            attr.insert ("SmallUrl", root.attribute ("SmallURL"));
            attr.insert ("ThumbUrl", root.attribute ("ThumbURL"));
            attr.insert ("AlbumUrl", root.attribute ("AlbumURL"));

            QDomElement albumElem = root.firstChildElement ("Album");
            if (!albumElem.isNull ()) {

                attr.insert ("AlbumId", albumElem.attribute ("id"));
            }

            emit imageUpdate (imageId, attr);
        }
    }
}