void Circuit::setNetClassName(NetClass& netclass, const QString& newName) throw (Exception) { // check if the netclass was added to the circuit if (mNetClasses.value(netclass.getUuid()) != &netclass) { throw LogicError(__FILE__, __LINE__); } // check if there is no netclass with the same name in the list if (getNetClassByName(newName)) { throw RuntimeError(__FILE__, __LINE__, netclass.getUuid().toStr(), QString(tr("There is already a net class with the name \"%1\"!")).arg(newName)); } // apply the new name netclass.setName(newName); // can throw }
void Circuit::addNetClass(NetClass& netclass) throw (Exception) { if (&netclass.getCircuit() != this) { throw LogicError(__FILE__, __LINE__); } // check if there is no netclass with the same uuid in the list if (getNetClassByUuid(netclass.getUuid())) { throw RuntimeError(__FILE__, __LINE__, netclass.getUuid().toStr(), QString(tr("There is already a net class with the UUID \"%1\"!")) .arg(netclass.getUuid().toStr())); } // check if there is no netclass with the same name in the list if (getNetClassByName(netclass.getName())) { throw RuntimeError(__FILE__, __LINE__, netclass.getUuid().toStr(), QString(tr("There is already a net class with the name \"%1\"!")) .arg(netclass.getName())); } // add netclass to circuit netclass.addToCircuit(); // can throw mNetClasses.insert(netclass.getUuid(), &netclass); emit netClassAdded(netclass); }
void Circuit::setNetClassName(NetClass& netclass, const QString& newName) throw (Exception) { Q_ASSERT(mNetClasses.contains(netclass.getUuid()) == true); if (newName == netclass.getName()) return; // check the validity of the new name if (newName.isEmpty()) { throw RuntimeError(__FILE__, __LINE__, netclass.getUuid().toStr(), QString(tr("The new netclass name must not be empty!"))); } // check if there is no netclass with the same name in the list if (getNetClassByName(newName)) { throw RuntimeError(__FILE__, __LINE__, netclass.getUuid().toStr(), QString(tr("There is already a netclass with the name \"%1\"!")).arg(newName)); } // apply the new name netclass.setName(newName); }