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
Kate
Commits
608b186f
Commit
608b186f
authored
Feb 06, 2021
by
Waqar Ahmed
Committed by
Christoph Cullmann
Feb 07, 2021
Browse files
Remove sorting in quickopenmodel::refresh
parent
edd799c2
Changes
1
Show whitespace changes
Inline
Side-by-side
kate/quickopen/katequickopenmodel.cpp
View file @
608b186f
...
...
@@ -73,7 +73,6 @@ void KateQuickOpenModel::refresh()
{
QObject
*
projectView
=
m_mainWindow
->
pluginView
(
QStringLiteral
(
"kateprojectplugin"
));
const
QList
<
KTextEditor
::
View
*>
sortedViews
=
m_mainWindow
->
viewManager
()
->
sortedViews
();
const
QList
<
KTextEditor
::
Document
*>
openDocs
=
KateApp
::
self
()
->
documentManager
()
->
documentList
();
const
QStringList
projectDocs
=
projectView
?
(
m_listMode
==
CurrentProject
?
projectView
->
property
(
"projectFiles"
)
:
projectView
->
property
(
"allProjectsFiles"
)).
toStringList
()
:
QStringList
();
...
...
@@ -94,55 +93,30 @@ void KateQuickOpenModel::refresh()
}();
QVector
<
ModelEntry
>
allDocuments
;
allDocuments
.
reserve
(
sortedViews
.
size
()
+
openDocs
.
size
()
+
projectDocs
.
size
());
allDocuments
.
reserve
(
sortedViews
.
size
()
+
projectDocs
.
size
());
QVector
<
QUrl
>
openedDocUrls
;
openedDocUrls
.
reserve
(
sortedViews
.
size
());
size_t
sort_id
=
static_cast
<
size_t
>
(
-
1
);
for
(
auto
*
view
:
qAsConst
(
sortedViews
))
{
auto
doc
=
view
->
document
();
allDocuments
.
push_back
({
doc
->
url
(),
doc
->
documentName
(),
doc
->
url
().
toDisplayString
(
QUrl
::
NormalizePathSegments
|
QUrl
::
PreferLocalFile
).
remove
(
projectBase
),
true
,
sort_id
--
,
-
1
});
}
for
(
auto
*
doc
:
qAsConst
(
openDocs
))
{
const
auto
normalizedUrl
=
doc
->
url
().
toString
(
QUrl
::
NormalizePathSegments
|
QUrl
::
PreferLocalFile
).
remove
(
projectBase
);
allDocuments
.
push_back
({
doc
->
url
(),
doc
->
documentName
(),
normalizedUrl
,
true
,
0
,
-
1
});
const
auto
url
=
doc
->
url
();
allDocuments
.
push_back
(
{
url
,
doc
->
documentName
(),
url
.
toDisplayString
(
QUrl
::
NormalizePathSegments
|
QUrl
::
PreferLocalFile
).
remove
(
projectBase
),
true
,
sort_id
--
,
-
1
});
openedDocUrls
.
push_back
(
url
);
}
for
(
const
auto
&
file
:
qAsConst
(
projectDocs
))
{
QFileInfo
fi
(
file
);
const
auto
localFile
=
QUrl
::
fromLocalFile
(
fi
.
absoluteFilePath
());
allDocuments
.
push_back
({
localFile
,
fi
.
fileName
(),
fi
.
filePath
().
remove
(
projectBase
),
false
,
0
,
-
1
});
if
(
openedDocUrls
.
contains
(
localFile
))
{
continue
;
}
/** Sort the arrays by filePath. */
std
::
stable_sort
(
std
::
begin
(
allDocuments
),
std
::
end
(
allDocuments
),
[](
const
ModelEntry
&
a
,
const
ModelEntry
&
b
)
{
return
a
.
filePath
<
b
.
filePath
;
});
/** remove Duplicates.
* Note that the stable_sort above guarantees that the items that the
* bold/sort_id fields of the items added first are correctly preserved.
*/
allDocuments
.
erase
(
std
::
unique
(
allDocuments
.
begin
(),
allDocuments
.
end
(),
[](
const
ModelEntry
&
a
,
const
ModelEntry
&
b
)
{
return
a
.
url
==
b
.
url
;
}),
std
::
end
(
allDocuments
));
/** sort the arrays via boldness (open or not */
std
::
stable_sort
(
std
::
begin
(
allDocuments
),
std
::
end
(
allDocuments
),
[](
const
ModelEntry
&
a
,
const
ModelEntry
&
b
)
{
if
(
a
.
bold
==
b
.
bold
)
{
return
a
.
sort_id
>
b
.
sort_id
;
allDocuments
.
push_back
({
localFile
,
fi
.
fileName
(),
fi
.
filePath
().
remove
(
projectBase
),
false
,
0
,
-
1
});
}
return
a
.
bold
>
b
.
bold
;
});
beginResetModel
();
m_modelEntries
=
allDocuments
;
m_modelEntries
=
std
::
move
(
allDocuments
)
;
endResetModel
();
}
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