Commit f0a1752d authored by Ahmad Samir's avatar Ahmad Samir
Browse files

Port foreach (deprecated) to range-for

Compile with -DQT_NO_FOREACH
parent ae772c6b
......@@ -37,7 +37,7 @@ endif()
remove_definitions(-DQT_NO_CAST_FROM_ASCII)
add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
add_definitions(-DQT_NO_FOREACH)
add_subdirectory(src)
add_subdirectory(doc)
......
......@@ -93,7 +93,8 @@ void BookmarkIteratorHolder::removeIterator(BookmarkIterator *itr)
void BookmarkIteratorHolder::cancelAllItrs()
{
Q_FOREACH(BookmarkIterator* iterator, m_iterators) {
const auto iterList = m_iterators;
for (BookmarkIterator* iterator : iterList) {
iterator->cancel();
}
qDeleteAll(m_iterators);
......
......@@ -504,8 +504,8 @@ KEBMacroCommand* CmdGen::insertMimeSource(KBookmarkModel* model, const QString &
KEBMacroCommand *mcmd = new KEBMacroCommand(cmdName);
QString currentAddress = addr;
QDomDocument doc;
const KBookmark::List bookmarks = KBookmark::List::fromMimeData(data, doc);
foreach (const KBookmark &bk, bookmarks) {
const auto bookmarks = KBookmark::List::fromMimeData(data, doc);
for (const KBookmark &bk : bookmarks) {
new CreateCommand(model, currentAddress, bk, QString(), mcmd);
currentAddress = KBookmark::nextAddress(currentAddress);
}
......@@ -522,7 +522,7 @@ KEBMacroCommand* CmdGen::itemsMoved(KBookmarkModel* model, const QList<KBookmark
KEBMacroCommand *mcmd = new KEBMacroCommand(copy ? i18nc("(qtundo-format)", "Copy Items")
: i18nc("(qtundo-format)", "Move Items"));
QString bkInsertAddr = newAddress;
foreach (const KBookmark &bk, items) {
for (const KBookmark &bk : items) {
new CreateCommand(model, bkInsertAddr,
KBookmark(bk.internalElement().cloneNode(true).toElement()),
bk.text(), mcmd);
......@@ -532,12 +532,12 @@ KEBMacroCommand* CmdGen::itemsMoved(KBookmarkModel* model, const QList<KBookmark
// Do the copying, and get the updated addresses of the bookmarks to remove.
mcmd->redo();
QStringList addresses;
foreach (const KBookmark &bk, items) {
for (const KBookmark &bk : items) {
addresses.append(bk.address());
}
mcmd->undo();
foreach (const QString &address, addresses) {
for (const auto &address : qAsConst(addresses)) {
new DeleteCommand(model, address, false, mcmd);
}
......
......@@ -310,11 +310,12 @@ QMimeData * KBookmarkModel::mimeData(const QModelIndexList & indexes) const
KBookmark::List bookmarks;
QByteArray addresses;
Q_FOREACH(const QModelIndex& it, indexes) {
for (const auto &it : indexes) {
if (it.column() == NameColumnId) {
bookmarks.push_back(bookmarkForIndex(it));
if (!addresses.isEmpty())
if (!addresses.isEmpty()) {
addresses.append(';');
}
addresses.append(bookmarkForIndex(it).address().toLatin1());
qCDebug(KEDITBOOKMARKS_LOG) << "appended" << bookmarkForIndex(it).address();
}
......@@ -374,7 +375,7 @@ bool KBookmarkModel::dropMimeData(const QMimeData * data, Qt::DropAction action,
KBookmark::List bookmarks;
QList<QByteArray> addresses = data->data(s_mime_bookmark_addresses).split(';');
std::sort(addresses.begin(), addresses.end());
Q_FOREACH(const QByteArray& address, addresses) {
for (const auto &address : qAsConst(addresses)) {
KBookmark bk = bookmarkManager()->findByAddress(QString::fromLatin1(address));
qCDebug(KEDITBOOKMARKS_LOG) << "Extracted bookmark:" << bk.address();
bookmarks.prepend(bk); // reverse order, so that we don't invalidate addresses (#287038)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment