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::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; }
TupLayer *TupScene::createLayer(QString name, int position, bool loaded) { // Q_CHECK_PTR(k->layers); if (position < 0 || position > k->layers.count()) { #ifdef K_DEBUG tError() << "TupScene::createLayer() - Invalid index -> " << position; #endif return 0; } k->layerCount++; TupLayer *layer = new TupLayer(this, k->layerCount); layer->setLayerName(name); k->layers.insert(position, layer); if (loaded) TupProjectLoader::createLayer(project()->visualIndexOf(this), position, layer->layerName(), project()); return layer; }