- // Currently the items are sorted by the selection order, resort
- // them by the filename. This assures that the new sort order is similar to
- // the current filename sort order.
- qSort(m_items.begin(), m_items.end(), lessThan);
-
- // Iterate through all items and rename them...
- int index = m_spinBox->value();
- foreach (const KFileItem& item, m_items) {
- QString newName = indexedName(m_newName, index, QLatin1Char('#'));
- ++index;
-
- const KUrl oldUrl = item.url();
- const QString extension = KMimeType::extractKnownExtension(oldUrl.prettyUrl().toLower());
- if (!extension.isEmpty()) {
- newName.append(QLatin1Char('.'));
- newName.append(extension);
- }
-
- if (oldUrl.fileName() != newName) {
- KUrl newUrl = oldUrl;
- newUrl.setFileName(KIO::encodeFileName(newName));
- KonqOperations::rename(this, oldUrl, newUrl);
- }
- }