Skip to content
GitLab
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
11eb4631
Commit
11eb4631
authored
Sep 11, 2022
by
Waqar Ahmed
Browse files
use anon namespace and rename for better readability
parent
33a4a42a
Pipeline
#230571
passed with stage
in 6 minutes and 8 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
addons/filetree/katefiletree.cpp
View file @
11eb4631
...
...
@@ -45,25 +45,27 @@
#include
<QStyledItemDelegate>
// END Includes
static
KTextEditor
::
Document
*
docFromIndex
(
const
QModelIndex
&
index
)
namespace
{
KTextEditor
::
Document
*
docFromIndex
(
const
QModelIndex
&
index
)
{
return
index
.
data
(
KateFileTreeModel
::
DocumentRole
).
value
<
KTextEditor
::
Document
*>
();
}
static
QList
<
KTextEditor
::
Document
*>
docTreeFromIndex
(
const
QModelIndex
&
index
)
QList
<
KTextEditor
::
Document
*>
docTreeFromIndex
(
const
QModelIndex
&
index
)
{
return
index
.
data
(
KateFileTreeModel
::
DocumentTreeRole
).
value
<
QList
<
KTextEditor
::
Document
*>>
();
}
static
bool
closeDocs
(
const
QList
<
KTextEditor
::
Document
*>
&
docs
)
bool
closeDocs
(
const
QList
<
KTextEditor
::
Document
*>
&
docs
)
{
return
KTextEditor
::
Editor
::
instance
()
->
application
()
->
closeDocuments
(
docs
);
}
class
StyleDelegate
:
public
QStyledItemDelegate
class
CloseIcon
StyleDelegate
:
public
QStyledItemDelegate
{
public:
StyleDelegate
(
QObject
*
parent
=
nullptr
)
CloseIcon
StyleDelegate
(
QObject
*
parent
=
nullptr
)
:
QStyledItemDelegate
(
parent
)
{
}
...
...
@@ -72,7 +74,7 @@ public:
{
QStyledItemDelegate
::
paint
(
painter
,
option
,
index
);
if
(
!
m_
c
loseBtn
)
{
if
(
!
m_
showC
loseBtn
)
{
return
;
}
...
...
@@ -86,12 +88,13 @@ public:
void
setShowCloseButton
(
bool
s
)
{
m_
c
loseBtn
=
s
;
m_
showC
loseBtn
=
s
;
}
private:
bool
m_
c
loseBtn
=
false
;
bool
m_
showC
loseBtn
=
false
;
};
}
// namespace
// BEGIN KateFileTree
...
...
@@ -114,7 +117,7 @@ KateFileTree::KateFileTree(QWidget *parent)
setDragEnabled
(
true
);
setUniformRowHeights
(
true
);
setItemDelegate
(
new
StyleDelegate
(
this
));
setItemDelegate
(
new
CloseIcon
StyleDelegate
(
this
));
// handle activated (e.g. for pressing enter) + clicked (to avoid to need to do double-click e.g. on Windows)
connect
(
this
,
&
KateFileTree
::
activated
,
this
,
&
KateFileTree
::
mouseClicked
);
...
...
@@ -213,7 +216,7 @@ void KateFileTree::onRowsMoved(const QModelIndex &, int, int, const QModelIndex
void
KateFileTree
::
setShowCloseButton
(
bool
show
)
{
m_hasCloseButton
=
show
;
static_cast
<
StyleDelegate
*>
(
itemDelegate
())
->
setShowCloseButton
(
show
);
static_cast
<
CloseIcon
StyleDelegate
*>
(
itemDelegate
())
->
setShowCloseButton
(
show
);
if
(
!
header
())
return
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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