| 127 | |
| 128 | |
| 129 | void CustomNodeDialog::checkValid() |
| 130 | { |
| 131 | bool valid = false; |
| 132 | auto name = ui->lineEdit->text(); |
| 133 | int pos; |
| 134 | |
| 135 | if( name.toLower() == "root" ) |
| 136 | { |
| 137 | ui->labelWarning->setText("The name 'root' is forbidden"); |
| 138 | } |
| 139 | else if( name.isEmpty() ) |
| 140 | { |
| 141 | ui->labelWarning->setText("The name cannot be empty"); |
| 142 | } |
| 143 | else if( _validator->validate(name, pos) != QValidator::Acceptable) |
| 144 | { |
| 145 | ui->labelWarning->setText("Invalid name: use only letters, digits and underscores"); |
| 146 | } |
| 147 | else if( _models.count( name ) > 0 && !_editing ) |
| 148 | { |
| 149 | ui->labelWarning->setText("Another Node has the same name"); |
| 150 | } |
| 151 | else { |
| 152 | |
| 153 | bool empty_param_name = false; |
| 154 | bool invalid_param_name = false; |
| 155 | std::set<QString> param_names; |
| 156 | for (int row=0; row < ui->tableWidget->rowCount(); row++ ) |
| 157 | { |
| 158 | auto param_name = ui->tableWidget->item(row,0)->text(); |
| 159 | if(param_name.isEmpty()) |
| 160 | { |
| 161 | empty_param_name = true; |
| 162 | } |
| 163 | else if( _validator->validate(param_name, pos) != QValidator::Acceptable) |
| 164 | { |
| 165 | invalid_param_name = true; |
| 166 | } |
| 167 | else{ |
| 168 | param_names.insert(param_name); |
| 169 | } |
| 170 | } |
| 171 | if( empty_param_name ) |
| 172 | { |
| 173 | ui->labelWarning->setText("Empty NodeParameter key"); |
| 174 | } |
| 175 | else if( invalid_param_name ) |
| 176 | { |
| 177 | ui->labelWarning->setText("Invalid key: use only letters, digits and underscores"); |
| 178 | } |
| 179 | else if( param_names.size() < ui->tableWidget->rowCount() ) |
| 180 | { |
| 181 | ui->labelWarning->setText("Duplicated NodeParameter key"); |
| 182 | } |
| 183 | else if( param_names.size() == ui->tableWidget->rowCount() ) |
| 184 | { |
| 185 | valid = true; |
| 186 | } |
nothing calls this directly
no outgoing calls
no test coverage detected