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
3e4551da
Commit
3e4551da
authored
Feb 02, 2021
by
Christoph Cullmann
🐮
Browse files
sort per directory level, this is MUCH faster
parent
73b34c0d
Changes
3
Hide whitespace changes
Inline
Side-by-side
addons/project/kateprojectitem.cpp
View file @
3e4551da
...
...
@@ -81,6 +81,19 @@ QVariant KateProjectItem::data(int role) const
return
QStandardItem
::
data
(
role
);
}
bool
KateProjectItem
::
operator
<
(
const
QStandardItem
&
other
)
const
{
// let directories stay first
const
bool
isDirectory
=
data
(
Qt
::
ToolTipRole
).
isNull
();
const
bool
otherIsDirectory
=
other
.
data
(
Qt
::
ToolTipRole
).
isNull
();
if
(
isDirectory
!=
otherIsDirectory
)
{
return
isDirectory
>
otherIsDirectory
;
}
// case-insensitive compare of the filename
return
data
(
Qt
::
DisplayRole
).
toString
().
compare
(
other
.
data
(
Qt
::
DisplayRole
).
toString
(),
Qt
::
CaseInsensitive
)
<
0
;
}
QIcon
*
KateProjectItem
::
icon
()
const
{
if
(
m_icon
)
{
...
...
addons/project/kateprojectitem.h
View file @
3e4551da
...
...
@@ -48,6 +48,13 @@ public:
*/
QVariant
data
(
int
role
=
Qt
::
UserRole
+
1
)
const
override
;
/**
* We want case-insensitive sorting and directories first!
* @param other other element to compare with
* @return is this element less than?
*/
bool
operator
<
(
const
QStandardItem
&
other
)
const
override
;
public:
void
slotModifiedChanged
(
KTextEditor
::
Document
*
);
void
slotModifiedOnDisk
(
KTextEditor
::
Document
*
document
,
bool
isModified
,
KTextEditor
::
ModificationInterface
::
ModifiedOnDiskReason
reason
);
...
...
addons/project/kateprojectworker.cpp
View file @
3e4551da
...
...
@@ -167,12 +167,13 @@ void KateProjectWorker::loadFilesEntry(QStandardItem *parent, const QVariantMap
}),
files
.
end
());
/**
* we might end up with nothing to add at all
*/
if
(
files
.
isEmpty
())
{
return
;
}
files
.
sort
(
Qt
::
CaseInsensitive
);
/**
* construct paths first in tree and items in a map
*/
...
...
@@ -213,6 +214,12 @@ void KateProjectWorker::loadFilesEntry(QStandardItem *parent, const QVariantMap
for
(
const
auto
&
item
:
qAsConst
(
item2ParentPath
))
{
item
.
second
->
appendRow
(
item
.
first
);
}
/**
* sort the stuff once recursively, this is a LOT faster than once sorting the list
* as we have normally not all stuff in on level of directory
*/
parent
->
sortChildren
(
0
);
}
QStringList
KateProjectWorker
::
findFiles
(
const
QDir
&
dir
,
const
QVariantMap
&
filesEntry
)
...
...
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