bool Picture::setSyncCommandsContent(int commandsCount , string &commandsContent) { Json::Reader reader; Json::Value rootNode; if (!reader.parse(commandsContent, rootNode, false)) { return false; } for (int i = 0; i < rootNode.size(); ++i) { Json::Value tempValue = rootNode[i]; if (SessionManager::getSharedInstance()->mSessionMode == ServerMode) { CCPoint fromPoint = ccp(tempValue["fromX"].asDouble(), tempValue["fromY"].asDouble()); CCPoint toPoint = ccp(tempValue["toX"].asDouble(), tempValue["toY"].asDouble()); addNewCommand((DrawCommandType)tempValue["type"].asInt(), fromPoint, toPoint); } else { DrawCommand *drawCommand = DrawCommand::create(); drawCommand->mCommandId = tempValue["id"].asInt(); drawCommand->mFromPoint.x = tempValue["fromX"].asDouble(); drawCommand->mFromPoint.y = tempValue["fromY"].asDouble(); drawCommand->mToPoint.x = tempValue["toX"].asDouble(); drawCommand->mToPoint.y = tempValue["toY"].asDouble() ; drawCommand->mCommandType = (DrawCommandType)tempValue["type"].asInt(); mCommandList->addObject(drawCommand); } } return true; }
RemoteCommandConfigWidget::RemoteCommandConfigWidget(Transport* t, QWidget *parent) : QWidget(parent), ui(new Ui::RemoteCommandConfigWidget) { Q_ASSERT(t); qDebug() << "RemoteCommandConfigWidget::RemoteCommandConfigWidget for" << t->getDescription(); current = NULL; transport = t; ui->setupUi(this); connect(ui->commandTable, SIGNAL(clicked(QModelIndex)), this, SLOT(commandTableClicked(QModelIndex))); connect(ui->saveCommandButton, SIGNAL(clicked()), this, SLOT(saveCurrent())); connect(ui->addCommandButton, SIGNAL(clicked()), this, SLOT(addNewCommand())); connect(ui->removeCommandButton, SIGNAL(clicked()), this, SLOT(deleteCurrent())); connect(ui->testCommandButton, SIGNAL(clicked()), this, SLOT(testCurrent())); connect(ui->commandEdit, SIGNAL(textEdited(QString)), this, SLOT(madeUpdate())); connect(ui->timeoutSpin, SIGNAL(valueChanged(int)), this, SLOT(madeUpdate())); connect(ui->reconnectCheck, SIGNAL(toggled(bool)), this, SLOT(madeUpdate())); connect(ui->retiesSpin, SIGNAL(valueChanged(int)), this, SLOT(madeUpdate())); model.setHorizontalHeaderLabels(QStringList() << "Section" << "Remote Command Description"); ui->commandTable->setModel(&model); ui->commandTable->horizontalHeader()->setStretchLastSection(true); populateTable(); if (model.rowCount()>0) { ui->commandTable->selectRow(0); commandTableClicked(ui->commandTable->currentIndex()); } }
void examplemaincommandsadd() { addNewCommand(examplemain,"startexamplemain",NULL); }