コード例 #1
0
ファイル: circuit.cpp プロジェクト: rnestler/LibrePCB
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
}
コード例 #2
0
ファイル: circuit.cpp プロジェクト: 0xB767B/LibrePCB
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);
}