| 136 | } |
| 137 | |
| 138 | int EnvironmentProfileListModel::cloneProfile(const QString& newProfileName, const QString& sourceProfileName) |
| 139 | { |
| 140 | const auto profileNames = this->profileNames(); |
| 141 | if (newProfileName.isEmpty() || |
| 142 | profileNames.contains(newProfileName) || |
| 143 | !profileNames.contains(sourceProfileName)) { |
| 144 | return -1; |
| 145 | } |
| 146 | |
| 147 | // estimate insert position by comparison as used by QMap for the keys |
| 148 | int insertPos = 0; |
| 149 | while (insertPos < profileNames.size() && |
| 150 | profileNames.at(insertPos) < newProfileName) { |
| 151 | ++insertPos; |
| 152 | } |
| 153 | |
| 154 | beginInsertRows(QModelIndex(), insertPos, insertPos); |
| 155 | |
| 156 | variables(newProfileName) = variables(sourceProfileName); |
| 157 | |
| 158 | endInsertRows(); |
| 159 | |
| 160 | return insertPos; |
| 161 | } |
| 162 | |
| 163 | void EnvironmentProfileListModel::setDefaultProfile(int profileIndex) |
| 164 | { |
no test coverage detected