bool TupCommandExecutor::removeLipSync(TupLayerResponse *response)
{
    #ifdef K_DEBUG
        QString msg = "TupCommandExecutor::removeLipSync() - Adding lipsync...";
        #ifdef Q_OS_WIN32
            qWarning() << msg;
        #else
            tWarning() << msg;
        #endif
    #endif

    int scenePos = response->sceneIndex();
    QString name = response->arg().toString();

    TupScene *scene = m_project->scene(scenePos);

    if (!scene)
        return false;

    if (scene->removeLipSync(name)) {
        emit responsed(response);
        return true;
    }

    return false;
}
bool TupCommandExecutor::updateLipSync(TupLayerResponse *response)
{
    #ifdef K_DEBUG
        QString msg = "TupCommandExecutor::updateLipSync() - Updating lipsync...";
        #ifdef Q_OS_WIN32
            qWarning() << msg;
        #else
            tWarning() << msg;
        #endif
    #endif

    int scenePos = response->sceneIndex();
    QString xml = response->arg().toString();

    TupScene *scene = m_project->scene(scenePos);

    if (!scene)
        return false;

    TupLipSync *lipsync = new TupLipSync();
    lipsync->fromXml(xml);
    if (scene->updateLipSync(lipsync)) {
        emit responsed(response);
        return true;
    }

    return false;
}
bool TupCommandExecutor::insertSymbolIntoFrame(TupLibraryResponse *response)
{
#ifdef K_DEBUG
    tFatal() << "TupCommandExecutor::insertSymbolIntoFrame() - Adding symbol to project: " << response->arg().toString();
#endif


    if (m_project->scenesTotal() > 0) {
        if (m_project->insertSymbolIntoFrame(response->spaceMode(), response->arg().toString(),
                                             response->sceneIndex(), response->layerIndex(), response->frameIndex())) {
            TupScene *scene = m_project->scene(response->sceneIndex());
            if (scene) {
                TupLayer *layer = scene->layer(response->layerIndex());
                if (layer) {
                    TupFrame *frame = layer->frame(response->frameIndex());
                    if (frame)
                        response->setFrameState(frame->isEmpty());
                }
            }
            emit responsed(response);
            return true;
        }
    } else {
#ifdef K_DEBUG
        tError() << "TupCommandExecutor::insertSymbolIntoFrame() - No scenes available!";
#endif
    }

    return false;
}
bool TupCommandExecutor::moveLayer(TupLayerResponse *response)
{
    int scenePos = response->sceneIndex();
    int position = response->layerIndex();
    int newPosition = response->arg().toInt();

    TupScene *scene = m_project->scene(scenePos);

    if (!scene)
        return false;

    if (! scene->moveLayer(position, newPosition)) {
        #ifdef K_DEBUG
            QString msg = "TupCommandExecutor::moveLayer() - Error while moving layer!";
            #ifdef Q_OS_WIN32
                qDebug() << msg;
            #else
                tError() << msg;
            #endif
        #endif	
        return false;
    } else {
        emit responsed(response);
        return true;
    }

    return false;
}
bool TupCommandExecutor::resetFrame(TupFrameResponse *response)
{
    int scenePos = response->sceneIndex();
    int layerPos = response->layerIndex();
    int position = response->frameIndex();
   
    TupScene *scene = m_project->scene(scenePos);
   
    if (scene) {
        scene->resetStoryBoardScene(position);
        TupLayer *layer = scene->layer(layerPos);
        if (layer) {
            TupFrame *frame = layer->frame(position);
            if (frame) {
                /*
                QDomDocument doc;
                doc.appendChild(frame->toXml(doc));
                response->setArg(frame->frameName());
                */
                if (layer->resetFrame(position)) {
                    //response->setState(doc.toString(0));
                    emit responsed(response);

                    return true;
                }
            }
        }
    }
   
    return false;
}
bool TupCommandExecutor::addLipSync(TupLayerResponse *response)
{
    #ifdef K_DEBUG
        QString msg = "TupCommandExecutor::addLipSync() - Adding lipsync...";
        #ifdef Q_OS_WIN32
            qWarning() << msg;
        #else
            tWarning() << msg;
        #endif
    #endif

    int scenePos = response->sceneIndex();
    int position = response->layerIndex();
    QString xml = response->arg().toString();

    TupScene *scene = m_project->scene(scenePos);

    if (!scene)
        return false;

    TupLayer *layer = scene->layer(position);

    if (layer) {
        TupLipSync *lipsync = new TupLipSync();
        lipsync->fromXml(xml);
        layer->addLipSync(lipsync);

        emit responsed(response);
        return true;
    }

    return false;
}
bool TupCommandExecutor::removeLayer(TupLayerResponse *response)
{
    #ifdef K_DEBUG
           T_FUNCINFO;
    #endif

    int scenePos = response->sceneIndex();
    int position = response->layerIndex();

    TupScene *scene = m_project->scene(scenePos);

    if (scene) {
        TupLayer *layer = scene->layer(position);
        if (layer) {
            QDomDocument document;
            document.appendChild(layer->toXml(document));
            response->setState(document.toString());
            response->setArg(layer->layerName());

            if (scene->removeLayer(position)) {
                emit responsed(response);
                return true;
            } 
        } 
    }

    return false;
}
bool KTCommandExecutor::createScene(KTSceneResponse *response)
{
    #ifdef K_DEBUG
        K_FUNCINFO;
    #endif
    
    int position = response->sceneIndex();
    QString name = response->arg().toString();
    
    if (position < 0 || position > m_project->scenes().count())
        return false;
    
    KTScene *scene = m_project->createScene(position);
    if (!scene) 
        return false;
    
    if (!name.isEmpty())
        scene->setSceneName(name);
    else
        response->setArg(scene->sceneName());
    
    emit responsed(response);
    
    QString state =  response->state();
    
    if (! state.isEmpty()) {
        scene->fromXml(state);
        response->setArg(scene->sceneName());
    }
    
    return true;
}
bool TupCommandExecutor::renameLayer(TupLayerResponse *response)
{
    int scenePos = response->sceneIndex();
    int position = response->layerIndex();
    QString newName = response->arg().toString();

    #ifdef K_DEBUG
           tWarning() << "Renamed layer: " << newName;
    #endif

    QString oldName;

    TupScene *scene = m_project->scene(scenePos);

    if (!scene)
        return false;

    TupLayer *layer = scene->layer(position);

    if (layer) {
        QString current = layer->layerName();
        layer->setLayerName(newName);

        emit responsed(response);
        response->setArg(current);

        return true;
    }

    return false;
}
bool TupCommandExecutor::createFrame(TupFrameResponse *response)
{
    #ifdef K_DEBUG
        #ifdef Q_OS_WIN32
            qDebug() << "[TupCommandExecutor::createFrame()]";
        #else
            T_FUNCINFO;
        #endif
    #endif

    int scenePosition = response->sceneIndex();
    int layerPosition = response->layerIndex();
    int position = response->frameIndex();
    QString name = response->arg().toString();

    // QString state = response->state();
    
    TupScene *scene = m_project->scene(scenePosition);
    
    if (!scene) 
        return false;

    scene->insertStoryBoardScene(position);
    
    TupLayer *layer = scene->layer(layerPosition);
    
    if (layer) {
        TupFrame *frame = layer->createFrame(name, position);
        
        if (!frame)
            return false;
       
        /* 
        if (!name.isEmpty()) {
            #ifdef K_DEBUG
                tDebug("items") << name;
            #endif
            frame->setFrameName(name);
        } else {
            response->setArg(frame->frameName());
        }
        */

        response->setArg(frame->frameName());
        response->setFrameIndex(layer->visualIndexOf(frame));

        emit responsed(response);

        /* SQA: Check if this code is really necessary
        if (!state.isEmpty()) {
            frame->fromXml(state);
            response->setArg(frame->frameName());
        }
        */

        return true;
    }
    
    return false;
}
bool TupCommandExecutor::removeSymbolFromFrame(TupLibraryResponse *response)
{
#ifdef K_DEBUG
    T_FUNCINFO;
#endif

    if (m_project->scenesTotal() > 0) {
        if (m_project->removeSymbolFromFrame(response->arg().toString(), response->symbolType())) {
            TupScene *scene = m_project->scene(response->sceneIndex());
            if (scene) {
                TupLayer *layer = scene->layer(response->layerIndex());
                if (layer) {
                    TupFrame *frame = layer->frame(response->frameIndex());
                    if (frame)
                        response->setFrameState(frame->isEmpty());
                }
            }
            emit responsed(response);
            return true;
        } else {
#ifdef K_DEBUG
            tError() << "TupCommandExecutor::removeSymbolFromFrame() - Error: Symbol can't be removed from project!";
#endif
        }
    } else {
#ifdef K_DEBUG
        tError() << "TupCommandExecutor::removeSymbolFromFrame() - No scenes available!";
#endif
    }

    return false;
}
bool TupCommandExecutor::setFrameVisibility(TupFrameResponse *response)
{
    int scenePos = response->sceneIndex();
    int layerPos = response->layerIndex();
    int position = response->frameIndex();
    bool view = response->arg().toBool();
    
    TupScene *scene = m_project->scene(scenePos);
    
    if (!scene)
        return false;
    
    TupLayer *layer = scene->layer(layerPos);
    
    if (layer) {
        TupFrame *frame = layer->frame(position);
        
        if (! frame) 
            return false;
        
        frame->setVisible(view);
        emit responsed(response);

        return true;
    }
    
    return false;
}
bool TupCommandExecutor::exchangeFrame(TupFrameResponse *response)
{
    int scenePos = response->sceneIndex();
    int layerPos = response->layerIndex();
    int position = response->frameIndex();
    int newPosition = response->arg().toInt();
    TupScene *scene = m_project->scene(scenePos);
   
    if (!scene)
        return false;
  
    scene->moveStoryBoardScene(position, newPosition);
    TupLayer *layer = scene->layer(layerPos);
   
    if (layer) {
        if (layer->exchangeFrame(position, newPosition)) {
            emit responsed(response);
            return true;
        } else {
            #ifdef K_DEBUG
                QString msg = "TupCommandExecutor::exchangeFrame() - Error while exchanging frames";
                #ifdef Q_OS_WIN32
                    qDebug() << msg;
                #else
                    tError() << msg;
                #endif
            #endif  
            return false;
        }
    }
   
    return false;
}
Exemple #14
0
void TupCommandExecutor::setBgColor(TupSceneResponse *response)
{
    QString colorName = response->arg().toString();
    m_project->setBgColor(QColor(colorName));

    emit responsed(response);
}
bool KTCommandExecutor::removeScene(KTSceneResponse *response)
{
    #ifdef K_DEBUG
        K_FUNCINFO;
    #endif    

    int position = response->sceneIndex();
    
    KTScene *toRemove = m_project->scene(position);
    
    if (toRemove) {
        QDomDocument document;
        document.appendChild(toRemove->toXml(document));
        
        response->setState(document.toString());
        response->setArg(toRemove->sceneName());
        
        if (m_project->removeScene(position)) {
            emit responsed(response);
            return true;
        }
    }
    
    return false;
}
bool KTCommandExecutor::moveScene(KTSceneResponse *response)
{
    int position = response->sceneIndex();
    int newPosition = response->arg().toInt();
    if (m_project->moveScene(position, newPosition)) {
        emit responsed(response);
        return true;
    }
    
    return false;
}
bool TupCommandExecutor::removeSymbol(TupLibraryResponse *response)
{
#ifdef K_DEBUG
    T_FUNCINFO;
#endif

    if ((response->sceneIndex() > -1) && (response->layerIndex() > -1) && (response->frameIndex() > -1)) {

        if (m_project->removeSymbol(response->arg().toString(), response->symbolType(), response->spaceMode(),
                                    response->sceneIndex(), response->layerIndex(), response->frameIndex())) {
            emit responsed(response);
            return true;
        }
    } else {
        if (m_project->removeSymbol(response->arg().toString())) {
            emit responsed(response);
            return true;
        }
    }

    return false;
}
bool TupCommandExecutor::createSymbol(TupLibraryResponse *response)
{
#ifdef K_DEBUG
    tFatal() << "TupCommandExecutor::createSymbol() - Creating object: " << response->arg().toString();
#endif

    if (m_project->createSymbol(response->symbolType(), response->arg().toString(),
                                response->data(), response->parent())) {
        emit responsed(response);

        return true;
    }

    return false;
}
Exemple #19
0
bool TupCommandExecutor::resetScene(TupSceneResponse *response)
{
    int position = response->sceneIndex();
    QString name = response->arg().toString();
    TupScene *scene = m_project->scene(position);

    if (!scene)
        return false;

    scene->reset(name);

    emit responsed(response);

    return true;
}
bool KTCommandExecutor::setSceneVisibility(KTSceneResponse *response)
{
    int position = response->sceneIndex();
    bool view = response->arg().toBool();
    
    KTScene *scene = m_project->scene(position);
    
    if (!scene)
        return false;
    
    scene->setVisible(view);
    
    emit responsed(response);
    
    return true;
}
bool KTCommandExecutor::renameScene(KTSceneResponse *response)
{
    int position = response->sceneIndex();
    QString newName = response->arg().toString();
    KTScene *scene = m_project->scene(position);
    
    if (!scene)
        return false;
    
    KTProjectRequest request = KTRequestBuilder::createSceneRequest(position, KTProjectRequest::Rename, newName);
    
    scene->setSceneName(newName);
    
    emit responsed(response);

    return true;
}
bool TupCommandExecutor::selectFrame(TupFrameResponse *response)
{
    #ifdef K_DEBUG
        #ifdef Q_OS_WIN32
            qDebug() << "[TupCommandExecutor::selectFrame()]";
        #else
            T_FUNCINFO;
        #endif
    #endif	
	
    int scenePos = response->sceneIndex();
    int layerPos = response->layerIndex();
    int position = response->frameIndex();
    // bool prioritary = response->arg().toBool();

    TupScene *scene = m_project->scene(scenePos);

    if (!scene || scenePos < 0 || position < 0)
        return false;
    
    TupLayer *layer = scene->layer(layerPos);
    
    if (layer) {
        if (position < layer->framesTotal()) {
            TupFrame *frame = layer->frame(position);
            if (! frame) 
                return false;
        
            emit responsed(response);
            return true;
        } else {
            #ifdef K_DEBUG
                QString msg = "TupCommandExecutor::selectFrame() - Invalid frame index -> " + QString::number(position);
                #ifdef Q_OS_WIN32
                    qDebug() << msg;
                #else
                    tError() << msg;
                #endif
            #endif
            return false;
        }
    } 
    
    return false;
}
bool TupCommandExecutor::createLayer(TupLayerResponse *response)
{	
    #ifdef K_DEBUG
        #ifdef Q_OS_WIN32
            qDebug() << "[TupCommandExecutor::createLayer()]";
        #else
            T_FUNCINFO;
        #endif
    #endif

    int scenePosition = response->sceneIndex();
    int position = response->layerIndex();

    QString name = response->arg().toString();
    QString state = response->state();

    TupScene *scene = m_project->scene(scenePosition);

    if (scene) {
        TupLayer *layer = scene->createLayer(name, position);

        if (! layer) 
            return false;

        /*
        if (!name.isEmpty())
            layer->setLayerName(name);
        else
            response->setArg(layer->layerName());
        */

        layer->setLayerName(name);

        // response->setArg(layer->layerName());
        // layer->fromXml(state);
        // m_project->updateScene(scenePosition, scene);

        emit responsed(response);

        return true;
    }

    return false;
}
bool TupCommandExecutor::renameFrame(TupFrameResponse *response)
{
    #ifdef K_DEBUG
        #ifdef Q_OS_WIN32
            qDebug() << "[TupCommandExecutor::renameFrame()]";
        #else
            T_FUNCINFO;
        #endif
    #endif	

    int scenePos = response->sceneIndex();
    int layerPos = response->layerIndex();
    int position = response->frameIndex();
    QString newName= response->arg().toString();

    QString oldName;
    
    TupScene *scene = m_project->scene(scenePos);
    
    if (!scene)
        return false;
    
    TupLayer *layer = scene->layer(layerPos);
    
    if (layer) {
        TupFrame *frame = layer->frame(position);
        
        if (! frame) 
            return false;
        
        oldName = frame->frameName();

        if (oldName.compare(newName) != 0)
            frame->setFrameName(newName);
        
        emit responsed(response);

        return true;
    }
    
    return false;
}
bool KTCommandExecutor::lockScene(KTSceneResponse *response)
{
    int position = response->sceneIndex();
    bool lock = response->arg().toBool();

    #ifdef K_DEBUG
        kWarning() << "Lock scene: " << lock;
    #endif    

    KTScene *scene = m_project->scene(position);
    
    if (!scene)
        return false;
    
    scene->setLocked(lock);
    
    emit responsed(response);

    return true;
}
bool TupCommandExecutor::lockLayer(TupLayerResponse *response)
{
    int scenePos = response->sceneIndex();
    int position = response->layerIndex();
    bool lock = response->arg().toBool();

    TupScene *scene = m_project->scene(scenePos);

    if (!scene)
        return false;

    TupLayer *layer = scene->layer(position);

    if (layer) {
        layer->setLocked(lock);
        emit responsed(response);
        return true;
    }

    return false;
}
bool TupCommandExecutor::pasteFrame(TupFrameResponse *response)
{
    #ifdef K_DEBUG
        #ifdef Q_OS_WIN32
            qDebug() << "[TupCommandExecutor::pasteFrame()]";
        #else
            T_FUNCINFO;
        #endif
    #endif	
	
    int scenePos = response->sceneIndex();
    int layerPos = response->layerIndex();
    int position = response->frameIndex();
    QString copyFrame = response->arg().toString();

    TupScene *scene = m_project->scene(scenePos);
    if (scene) {
        TupLayer *layer = scene->layer(layerPos);
        if (layer) {
            TupFrame *frame = layer->frame(position);
            if (frame) {
                QString name = frame->frameName();
                
                QDomDocument doc;
                doc.appendChild(frame->toXml(doc));
                response->setArg(doc.toString(0));
                frame->clear();
                frame->fromXml(copyFrame);
                frame->setFrameName(name);

                response->setFrameState(frame->isEmpty());
                emit responsed(response);

                return true;
            }
        }
    }

    return false;
}
bool TupCommandExecutor::setLayerVisibility(TupLayerResponse *response)
{
    int scenePos = response->sceneIndex();
    int position = response->layerIndex();
    bool view = response->arg().toBool();

    TupScene *scene = m_project->scene(scenePos);

    if (!scene)
        return false;

    TupLayer *layer = scene->layer(position);

    if (layer) {
        layer->setVisible(view);
        responsed(response);

        return true;
    }

    return false;
}
bool TupCommandExecutor::moveLayer(TupLayerResponse *response)
{
    int scenePos = response->sceneIndex();
    int position = response->layerIndex();
    int newPosition = response->arg().toInt();

    TupScene *scene = m_project->scene(scenePos);

    if (!scene)
        return false;

    if (! scene->moveLayer(position, newPosition)) {
        #ifdef K_DEBUG
               tWarning() << "Failed moving layer";
        #endif
        return false;
    } else {
        emit responsed(response);
        return true;
    }

    return false;
}
Exemple #30
0
bool TupCommandExecutor::removeScene(TupSceneResponse *response)
{
    #ifdef K_DEBUG
           T_FUNCINFO;
    #endif    

    int position = response->sceneIndex();
    int scenesTotal = m_project->scenesTotal();

    TupScene *toRemove = m_project->scene(position);

    if (toRemove) {
        QDomDocument document;
        document.appendChild(toRemove->toXml(document));
        
        response->setState(document.toString());
        response->setArg(toRemove->sceneName());
        
        if (m_project->removeScene(position)) {

            if (position+1 < scenesTotal) {
                for (int i = position + 1; i < scenesTotal; i++)
                     m_project->moveScene(i, i-1);
            }

            emit responsed(response);

            return true;
        } 
    } else {
        #ifdef K_DEBUG
               tError() << "TupCommandExecutor::removeScene() - Scene doesn't exist (" << position << ")";
        #endif
    }
    
    return false;
}