Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
KEditBookmarks
Commits
f0a1752d
Commit
f0a1752d
authored
Dec 03, 2020
by
Ahmad Samir
Browse files
Port foreach (deprecated) to range-for
Compile with -DQT_NO_FOREACH
parent
ae772c6b
Changes
4
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
f0a1752d
...
...
@@ -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
)
...
...
src/bookmarkiterator.cpp
View file @
f0a1752d
...
...
@@ -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
);
...
...
src/kbookmarkmodel/commands.cpp
View file @
f0a1752d
...
...
@@ -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
);
for
each
(
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
;
for
each
(
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
;
for
each
(
const
KBookmark
&
bk
,
items
)
{
for
(
const
KBookmark
&
bk
:
items
)
{
addresses
.
append
(
bk
.
address
());
}
mcmd
->
undo
();
for
each
(
const
QString
&
address
,
addresses
)
{
for
(
const
auto
&
address
:
qAsConst
(
addresses
)
)
{
new
DeleteCommand
(
model
,
address
,
false
,
mcmd
);
}
...
...
src/kbookmarkmodel/model.cpp
View file @
f0a1752d
...
...
@@ -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)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment