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
112ad001
Commit
112ad001
authored
Feb 07, 2021
by
Christoph Cullmann
🐮
Browse files
simplify project tree construction
parent
e0bcc697
Changes
3
Hide whitespace changes
Inline
Side-by-side
addons/project/kateproject.cpp
View file @
112ad001
...
...
@@ -378,7 +378,6 @@ void KateProject::registerUntrackedDocument(KTextEditor::Document *document)
// create document item
QFileInfo
fileInfo
(
document
->
url
().
toLocalFile
());
KateProjectItem
*
fileItem
=
new
KateProjectItem
(
KateProjectItem
::
File
,
fileInfo
.
fileName
());
fileItem
->
setData
(
document
->
url
().
toLocalFile
(),
Qt
::
ToolTipRole
);
fileItem
->
slotModifiedChanged
(
document
);
connect
(
document
,
&
KTextEditor
::
Document
::
modifiedChanged
,
this
,
&
KateProject
::
slotModifiedChanged
);
// clang-format off
...
...
addons/project/kateprojectitem.cpp
View file @
112ad001
...
...
@@ -89,7 +89,7 @@ bool KateProjectItem::operator<(const QStandardItem &other) const
{
// let directories stay first
const
auto
thisType
=
data
(
TypeRole
).
toInt
();
const
bool
otherType
=
other
.
data
(
TypeRole
).
toInt
();
const
auto
otherType
=
other
.
data
(
TypeRole
).
toInt
();
if
(
thisType
!=
otherType
)
{
return
thisType
<
otherType
;
}
...
...
addons/project/kateprojectworker.cpp
View file @
112ad001
...
...
@@ -264,7 +264,6 @@ void KateProjectWorker::loadFilesEntry(QStandardItem *parent, const QVariantMap
*/
QHash
<
QString
,
QStandardItem
*>
dir2Item
;
dir2Item
[
QString
()]
=
parent
;
QVector
<
QPair
<
QStandardItem
*
,
QStandardItem
*>>
item2ParentPath
;
for
(
const
QString
&
filePath
:
files
)
{
/**
* cheap file name computation
...
...
@@ -279,7 +278,8 @@ void KateProjectWorker::loadFilesEntry(QStandardItem *parent, const QVariantMap
* already hang in directories in tree
*/
KateProjectItem
*
fileItem
=
new
KateProjectItem
(
KateProjectItem
::
File
,
fileName
);
fileItem
->
setData
(
filePath
,
Qt
::
ToolTipRole
);
fileItem
->
setData
(
filePath
,
Qt
::
UserRole
);
(
*
file2Item
)[
filePath
]
=
fileItem
;
// get the directory's relative path to the base directory
QString
dirRelPath
=
dir
.
relativeFilePath
(
filePathName
);
...
...
@@ -288,16 +288,8 @@ void KateProjectWorker::loadFilesEntry(QStandardItem *parent, const QVariantMap
dirRelPath
=
QString
();
}
item2ParentPath
.
append
(
QPair
<
QStandardItem
*
,
QStandardItem
*>
(
fileItem
,
directoryParent
(
dir2Item
,
dirRelPath
)));
fileItem
->
setData
(
filePath
,
Qt
::
UserRole
);
(
*
file2Item
)[
filePath
]
=
fileItem
;
}
/**
* plug in the file items to the tree
*/
for
(
const
auto
&
item
:
qAsConst
(
item2ParentPath
))
{
item
.
second
->
appendRow
(
item
.
first
);
// put in our item to the right directory parent
directoryParent
(
dir2Item
,
dirRelPath
)
->
appendRow
(
fileItem
);
}
}
...
...
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