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
6d56c513
Commit
6d56c513
authored
Sep 11, 2022
by
Waqar Ahmed
Browse files
Allow closing all widgets at once
parent
9202a58b
Changes
5
Hide whitespace changes
Inline
Side-by-side
addons/filetree/katefiletree.cpp
View file @
6d56c513
...
...
@@ -325,12 +325,22 @@ void KateFileTree::mouseClicked(const QModelIndex &index)
{
const
bool
closeButtonClicked
=
m_hasCloseButton
&&
index
.
column
()
==
1
;
if
(
m_proxyModel
->
isDir
(
index
))
{
if
(
closeButtonClicked
)
{
const
QList
<
KTextEditor
::
Document
*>
list
=
m_proxyModel
->
docTreeFromIndex
(
index
);
closeDocs
(
list
);
}
if
(
m_proxyModel
->
isDir
(
index
)
&&
closeButtonClicked
)
{
const
QList
<
KTextEditor
::
Document
*>
list
=
m_proxyModel
->
docTreeFromIndex
(
index
);
closeDocs
(
list
);
return
;
}
else
if
(
m_proxyModel
->
isWidgetDir
(
index
)
&&
closeButtonClicked
)
{
const
auto
idx
=
index
.
siblingAtColumn
(
0
);
const
auto
count
=
m_proxyModel
->
rowCount
(
idx
);
QWidgetList
widgets
;
widgets
.
reserve
(
count
);
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
widgets
<<
m_proxyModel
->
index
(
i
,
0
,
idx
).
data
(
KateFileTreeModel
::
WidgetRole
).
value
<
QWidget
*>
();
}
for
(
const
auto
&
w
:
widgets
)
{
closeWidget
(
w
);
}
}
if
(
auto
*
doc
=
m_proxyModel
->
docFromIndex
(
index
))
{
...
...
addons/filetree/katefiletreemodel.cpp
View file @
6d56c513
...
...
@@ -836,18 +836,33 @@ bool KateFileTreeModel::hasChildren(const QModelIndex &parent) const
return
item
->
childCount
()
>
0
;
}
bool
KateFileTreeModel
::
i
sDir
(
const
QModelIndex
&
index
)
ProxyItem
*
KateFileTreeModel
::
i
temForIndex
(
const
QModelIndex
&
index
)
const
{
if
(
!
index
.
isValid
())
{
return
true
;
return
m_root
;
}
const
ProxyItem
*
item
=
static_cast
<
ProxyItem
*>
(
index
.
internalPointer
());
ProxyItem
*
item
=
static_cast
<
ProxyItem
*>
(
index
.
internalPointer
());
if
(
!
item
)
{
return
false
;
return
nullptr
;
}
return
item
;
}
return
item
->
flag
(
ProxyItem
::
Dir
);
bool
KateFileTreeModel
::
isDir
(
const
QModelIndex
&
index
)
const
{
if
(
auto
item
=
itemForIndex
(
index
))
{
return
item
->
flag
(
ProxyItem
::
Dir
)
&&
!
item
->
flag
(
ProxyItem
::
Widget
);
}
return
false
;
}
bool
KateFileTreeModel
::
isWidgetDir
(
const
QModelIndex
&
index
)
const
{
if
(
auto
item
=
itemForIndex
(
index
))
{
return
item
->
flag
(
ProxyItem
::
Dir
)
&&
item
->
flag
(
ProxyItem
::
Widget
);
}
return
false
;
}
bool
KateFileTreeModel
::
listMode
()
const
...
...
addons/filetree/katefiletreemodel.h
View file @
6d56c513
...
...
@@ -61,7 +61,8 @@ public:
QModelIndex
widgetIndex
(
QWidget
*
)
const
;
static
bool
isDir
(
const
QModelIndex
&
index
);
bool
isDir
(
const
QModelIndex
&
index
)
const
;
bool
isWidgetDir
(
const
QModelIndex
&
index
)
const
;
bool
listMode
()
const
;
void
setListMode
(
bool
);
...
...
@@ -113,6 +114,7 @@ private:
void
initModel
();
void
clearModel
();
void
connectDocument
(
const
KTextEditor
::
Document
*
);
ProxyItem
*
itemForIndex
(
const
QModelIndex
&
index
)
const
;
private:
ProxyItemDir
*
m_root
;
...
...
addons/filetree/katefiletreeproxymodel.cpp
View file @
6d56c513
...
...
@@ -86,3 +86,8 @@ QModelIndex KateFileTreeProxyModel::widgetIndex(QWidget *w) const
{
return
mapFromSource
(
static_cast
<
KateFileTreeModel
*>
(
sourceModel
())
->
widgetIndex
(
w
));
}
bool
KateFileTreeProxyModel
::
isWidgetDir
(
const
QModelIndex
&
i
)
const
{
return
static_cast
<
KateFileTreeModel
*>
(
sourceModel
())
->
isWidgetDir
(
mapToSource
(
i
));
}
addons/filetree/katefiletreeproxymodel.h
View file @
6d56c513
...
...
@@ -25,6 +25,7 @@ public:
QModelIndex
docIndex
(
const
KTextEditor
::
Document
*
)
const
;
QModelIndex
widgetIndex
(
QWidget
*
)
const
;
bool
isDir
(
const
QModelIndex
&
i
)
const
;
bool
isWidgetDir
(
const
QModelIndex
&
i
)
const
;
void
setSourceModel
(
QAbstractItemModel
*
model
)
override
;
KTextEditor
::
Document
*
docFromIndex
(
const
QModelIndex
&
index
);
QList
<
KTextEditor
::
Document
*>
docTreeFromIndex
(
const
QModelIndex
&
index
);
...
...
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