MCPcopy Create free account
hub / github.com/KDE/kdevelop / cloneProfile

Method cloneProfile

kdevplatform/shell/settings/environmentprofilelistmodel.cpp:138–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138int 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
163void EnvironmentProfileListModel::setDefaultProfile(int profileIndex)
164{

Callers 1

cloneSelectedProfileMethod · 0.80

Calls 6

profileNamesMethod · 0.80
QModelIndexClass · 0.70
isEmptyMethod · 0.45
containsMethod · 0.45
sizeMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected