Q_ASSERT(newName.contains('#'));
// iterate through all selected items and rename them...
- const int replaceIndex = newName.indexOf('#');
- Q_ASSERT(replaceIndex >= 0);
int index = 1;
-
- KFileItemList::const_iterator it = items.begin();
- const KFileItemList::const_iterator end = items.end();
- while (it != end) {
- const KUrl& oldUrl = (*it).url();
+ foreach (KFileItem item, items) {
+ const KUrl& oldUrl = item.url();
QString number;
number.setNum(index++);
- QString name(newName);
- name.replace(replaceIndex, 1, number);
+ QString name = newName;
+ name.replace('#', number);
if (oldUrl.fileName() != name) {
KUrl newUrl = oldUrl;
KonqOperations::rename(this, oldUrl, newUrl);
emit doingOperation(KonqFileUndoManager::RENAME);
}
- ++it;
}
}
} else {
if (m_newName.isEmpty()) {
m_errorString = i18nc("@info:status",
"The new name is empty. A name with at least one character must be entered.");
- } else if (!m_renameOneItem && m_newName.count('#') != 1) {
+ } else if (!m_renameOneItem && (m_newName.count('#') == 0)) {
m_newName.truncate(0);
- m_errorString = i18nc("@info:status", "The name must contain exactly one # character.");
+ m_errorString = i18nc("@info:status", "The name must contain at least one # character.");
}
}