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
b6adb596
Commit
b6adb596
authored
Mar 02, 2021
by
Méven Car
Committed by
Christoph Cullmann
Mar 05, 2021
Browse files
Allow to clear stash dir for session when removing a session.
parent
15085b8a
Changes
3
Hide whitespace changes
Inline
Side-by-side
kate/katestashmanager.cpp
View file @
b6adb596
...
...
@@ -26,6 +26,20 @@ KateStashManager::KateStashManager(QObject *parent)
{
}
void
KateStashManager
::
clearStashForSession
(
const
KateSession
::
Ptr
session
)
{
const
QString
appDataPath
=
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppDataLocation
);
QDir
dir
(
appDataPath
);
if
(
dir
.
exists
(
QStringLiteral
(
"stash"
)))
{
dir
.
cd
(
QStringLiteral
(
"stash"
));
const
QString
sessionName
=
session
->
name
();
if
(
dir
.
exists
(
sessionName
))
{
dir
.
cd
(
sessionName
);
dir
.
removeRecursively
();
}
}
}
void
KateStashManager
::
stashDocuments
(
KConfig
*
config
,
const
QList
<
KTextEditor
::
Document
*>
&
documents
)
{
// prepare stash directory
...
...
@@ -35,12 +49,15 @@ void KateStashManager::stashDocuments(KConfig *config, const QList<KTextEditor::
dir
.
cd
(
QStringLiteral
(
"stash"
));
const
auto
session
=
KateApp
::
self
()
->
sessionManager
()
->
activeSession
();
if
(
session
)
{
const
QString
sessionName
=
session
->
name
();
dir
.
mkdir
(
sessionName
);
dir
.
cd
(
sessionName
);
if
(
!
session
)
{
qDebug
(
LOG_KATE
)
<<
"Could not stash files without a session"
;
return
;
}
const
QString
sessionName
=
session
->
name
();
dir
.
mkdir
(
sessionName
);
dir
.
cd
(
sessionName
);
int
i
=
0
;
for
(
KTextEditor
::
Document
*
doc
:
qAsConst
(
documents
))
{
const
QString
entryName
=
QStringLiteral
(
"Document %1"
).
arg
(
i
);
...
...
kate/katestashmanager.h
View file @
b6adb596
...
...
@@ -7,6 +7,7 @@
#ifndef KATESTASHMANAGER_H
#define KATESTASHMANAGER_H
#include "katesession.h"
#include "kconfiggroup.h"
namespace
KTextEditor
...
...
@@ -39,6 +40,8 @@ public:
void
stashDocument
(
KTextEditor
::
Document
*
doc
,
const
QString
&
stashfileName
,
KConfigGroup
&
kconfig
,
const
QString
&
path
);
bool
popDocument
(
KTextEditor
::
Document
*
doc
,
const
KConfigGroup
&
kconfig
);
void
clearStashForSession
(
const
KateSession
::
Ptr
session
);
private:
/**
* Stash unsave changes setting
...
...
kate/session/katesessionmanagedialog.cpp
View file @
b6adb596
...
...
@@ -98,6 +98,7 @@ void KateSessionManageDialog::done(int result)
{
for
(
const
auto
&
session
:
qAsConst
(
m_deleteList
))
{
KateApp
::
self
()
->
sessionManager
()
->
deleteSession
(
session
);
KateApp
::
self
()
->
stashManager
()
->
clearStashForSession
(
session
);
}
m_deleteList
.
clear
();
// May not needed, but anyway
...
...
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