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
523f74ab
Commit
523f74ab
authored
Jan 29, 2021
by
Waqar Ahmed
Browse files
Use reserve to minimize temporary allocations
parent
c95c9f12
Changes
3
Hide whitespace changes
Inline
Side-by-side
kate/katecommandbar.cpp
View file @
523f74ab
...
...
@@ -171,6 +171,7 @@ public:
// collect rects for each word
QVector
<
QPair
<
QRect
,
QString
>>
btns
;
const
auto
list
=
shortcutString
.
split
(
QLatin1Char
(
'+'
));
btns
.
reserve
(
list
.
size
());
for
(
const
QString
&
text
:
list
)
{
QRect
r
=
option
.
fontMetrics
.
boundingRect
(
text
);
r
.
setWidth
(
r
.
width
()
+
8
);
...
...
@@ -274,16 +275,19 @@ KateCommandBar::KateCommandBar(QWidget *parent)
setHidden
(
true
);
}
void
KateCommandBar
::
updateBar
(
const
QList
<
KActionCollection
*>
&
actionCollections
)
void
KateCommandBar
::
updateBar
(
const
QList
<
KActionCollection
*>
&
actionCollections
,
int
totalActions
)
{
QVector
<
QPair
<
QString
,
QAction
*>>
actionList
;
actionList
.
reserve
(
totalActions
);
for
(
const
auto
collection
:
actionCollections
)
{
const
QList
<
QAction
*>
collectionActions
=
collection
->
actions
();
const
QString
componentName
=
collection
->
componentDisplayName
();
for
(
const
auto
action
:
collectionActions
)
{
// sanity + empty check ensures displayable actions and removes ourself
// from the action list
if
(
action
&&
!
action
->
text
().
isEmpty
())
{
actionList
.
append
({
co
llection
->
componentDisplay
Name
()
,
action
});
actionList
.
append
({
co
mponent
Name
,
action
});
}
}
}
...
...
@@ -352,7 +356,7 @@ void KateCommandBar::slotReturnPressed()
menuActions
=
menu
->
actions
();
}
for
(
auto
menuAction
:
menuActions
)
{
for
(
auto
menuAction
:
qAsConst
(
menuActions
)
)
{
if
(
menuAction
)
{
list
.
append
({
KLocalizedString
::
removeAcceleratorMarker
(
act
->
text
()),
menuAction
});
}
...
...
kate/katecommandbar.h
View file @
523f74ab
...
...
@@ -19,7 +19,7 @@ class KateCommandBar : public QMenu
public:
KateCommandBar
(
QWidget
*
parent
=
nullptr
);
void
updateBar
(
const
QList
<
KActionCollection
*>&
actions
);
void
updateBar
(
const
QList
<
KActionCollection
*>&
actions
,
int
totalActions
);
void
updateViewGeometry
();
...
...
kate/katemainwindow.cpp
View file @
523f74ab
...
...
@@ -1221,17 +1221,18 @@ void KateMainWindow::slotCommandBarOpen()
QList
<
KActionCollection
*>
actionCollections
;
auto
clients
=
guiFactory
()
->
clients
();
int
actionsCount
=
0
;
for
(
const
KXMLGUIClient
*
c
:
clients
)
{
if
(
!
c
)
{
continue
;
}
if
(
!
c
->
actionCollection
())
{
continue
;
if
(
auto
collection
=
c
->
actionCollection
())
{
actionCollections
.
append
(
collection
);
actionsCount
+=
collection
->
count
();
}
actionCollections
.
append
(
c
->
actionCollection
());
}
m_commandBar
->
updateBar
(
actionCollections
);
m_commandBar
->
updateBar
(
actionCollections
,
actionsCount
);
centralWidget
()
->
setFocusProxy
(
m_commandBar
);
}
...
...
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