| 93 | } |
| 94 | |
| 95 | int EnvironmentProfileListModel::addProfile(const QString& newProfileName) |
| 96 | { |
| 97 | const auto profileNames = this->profileNames(); |
| 98 | if (newProfileName.isEmpty() || |
| 99 | profileNames.contains(newProfileName)) { |
| 100 | return -1; |
| 101 | } |
| 102 | |
| 103 | // estimate insert position by comparison as used by QMap for the keys |
| 104 | int insertPos = 0; |
| 105 | while (insertPos < profileNames.size() && |
| 106 | profileNames.at(insertPos) < newProfileName) { |
| 107 | ++insertPos; |
| 108 | } |
| 109 | beginInsertRows(QModelIndex(), insertPos, insertPos); |
| 110 | |
| 111 | // trigger creation of new profile |
| 112 | variables(newProfileName); |
| 113 | |
| 114 | endInsertRows(); |
| 115 | return insertPos; |
| 116 | } |
| 117 | |
| 118 | void EnvironmentProfileListModel::removeProfile(int profileIndex) |
| 119 | { |
nothing calls this directly
no test coverage detected