Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Discover
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Plasma
Discover
Commits
18082f4c
Commit
18082f4c
authored
Dec 19, 2017
by
Aleix Pol Gonzalez
🐧
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce comparisons as category vectors are sorted
parent
cd06be7b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
28 deletions
+25
-28
libdiscover/Category/Category.cpp
libdiscover/Category/Category.cpp
+25
-27
libdiscover/Category/CategoryModel.cpp
libdiscover/Category/CategoryModel.cpp
+0
-1
No files found.
libdiscover/Category/Category.cpp
View file @
18082f4c
...
...
@@ -151,39 +151,37 @@ bool Category::categoryLessThan(Category *c1, const Category *c2)
return
(
!
c1
->
isAddons
()
&&
c2
->
isAddons
())
||
(
c1
->
isAddons
()
==
c2
->
isAddons
()
&&
QString
::
localeAwareCompare
(
c1
->
name
(),
c2
->
name
())
<
0
);
}
//TODO: maybe it would be interesting to apply some rules to a said backend...
void
Category
::
addSubcategory
(
QVector
<
Category
*
>&
list
,
Category
*
newcat
)
{
Q_FOREACH
(
Category
*
c
,
list
)
{
if
(
c
->
name
()
==
newcat
->
name
())
{
if
(
c
->
icon
()
!=
newcat
->
icon
()
||
c
->
m_andFilters
!=
newcat
->
m_andFilters
||
c
->
m_isAddons
!=
newcat
->
m_isAddons
)
{
qWarning
()
<<
"the following categories seem to be the same but they're not entirely"
<<
c
->
name
()
<<
newcat
->
name
()
<<
"--"
<<
c
->
andFilters
()
<<
newcat
->
andFilters
()
<<
"--"
<<
c
->
isAddons
()
<<
newcat
->
isAddons
();
break
;
}
else
{
c
->
m_orFilters
+=
newcat
->
orFilters
();
c
->
m_notFilters
+=
newcat
->
notFilters
();
c
->
m_plugins
.
unite
(
newcat
->
m_plugins
);
Q_FOREACH
(
Category
*
nc
,
newcat
->
subCategories
())
{
addSubcategory
(
c
->
m_subCategories
,
nc
);
}
return
;
}
}
auto
it
=
std
::
lower_bound
(
list
.
begin
(),
list
.
end
(),
newcat
,
&
categoryLessThan
);
if
(
it
==
list
.
end
())
{
list
<<
newcat
;
return
;
}
for
(
auto
it
=
list
.
begin
(),
itEnd
=
list
.
end
();
it
!=
itEnd
;
++
it
)
{
if
(
!
categoryLessThan
(
*
it
,
newcat
))
{
list
.
insert
(
it
,
newcat
);
auto
c
=
*
it
;
if
(
c
->
name
()
==
newcat
->
name
())
{
if
(
c
->
icon
()
!=
newcat
->
icon
()
||
c
->
m_andFilters
!=
newcat
->
m_andFilters
||
c
->
m_isAddons
!=
newcat
->
m_isAddons
)
{
qWarning
()
<<
"the following categories seem to be the same but they're not entirely"
<<
c
->
name
()
<<
newcat
->
name
()
<<
"--"
<<
c
->
andFilters
()
<<
newcat
->
andFilters
()
<<
"--"
<<
c
->
isAddons
()
<<
newcat
->
isAddons
();
}
else
{
c
->
m_orFilters
+=
newcat
->
orFilters
();
c
->
m_notFilters
+=
newcat
->
notFilters
();
c
->
m_plugins
.
unite
(
newcat
->
m_plugins
);
Q_FOREACH
(
Category
*
nc
,
newcat
->
subCategories
())
{
addSubcategory
(
c
->
m_subCategories
,
nc
);
}
return
;
}
}
list
<<
newcat
;
list
.
insert
(
it
,
newcat
);
}
bool
Category
::
blacklistPluginsInVector
(
const
QSet
<
QString
>&
pluginNames
,
QVector
<
Category
*>&
subCategories
)
...
...
libdiscover/Category/CategoryModel.cpp
View file @
18082f4c
...
...
@@ -58,7 +58,6 @@ void CategoryModel::populateCategories()
Category
::
addSubcategory
(
ret
,
c
);
}
}
qSort
(
ret
.
begin
(),
ret
.
end
(),
Category
::
categoryLessThan
);
if
(
m_rootCategories
!=
ret
)
{
m_rootCategories
=
ret
;
Q_EMIT
rootCategoriesChanged
();
...
...
Write
Preview
Markdown
is supported
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