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
KDebugSettings
Commits
6b413bfa
Commit
6b413bfa
authored
Dec 25, 2020
by
Laurent Montel
😁
Browse files
Rename group
parent
f1429b4f
Pipeline
#45301
passed with stage
in 9 minutes and 46 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/groupmanagementwidget.cpp
View file @
6b413bfa
...
...
@@ -27,6 +27,7 @@
#include <QDir>
#include <QListWidget>
#include <QVBoxLayout>
#include <QInputDialog>
GroupManagementWidget
::
GroupManagementWidget
(
QWidget
*
parent
)
:
QWidget
(
parent
)
...
...
@@ -54,6 +55,24 @@ void GroupManagementWidget::slotCustomContextMenu()
const
auto
items
=
mListWidget
->
selectedItems
();
if
(
!
items
.
isEmpty
())
{
QMenu
menu
(
this
);
if
(
mListWidget
->
selectedItems
().
count
()
==
1
)
{
const
auto
item
=
items
.
at
(
0
);
menu
.
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"edit"
)),
i18n
(
"Rename Groups"
),
this
,
[
this
,
item
]()
{
const
QString
fullPath
=
item
->
data
(
FullPathRole
).
toString
();
QFile
f
(
fullPath
);
QFileInfo
fileInfo
(
f
);
const
QString
filePath
=
fileInfo
.
path
();
const
QString
newName
=
QInputDialog
::
getText
(
this
,
i18n
(
"Rename Group"
),
i18n
(
"New Name:"
));
const
QString
newNameTrimmed
=
newName
.
trimmed
();
if
(
!
newNameTrimmed
.
isEmpty
())
{
if
(
!
f
.
rename
(
filePath
+
QLatin1Char
(
'/'
)
+
newNameTrimmed
))
{
KMessageBox
::
error
(
this
,
i18n
(
"Impossible to rename group as
\'
%1
\'
"
,
newNameTrimmed
),
i18n
(
"Rename Group"
));
}
}
});
menu
.
addSeparator
();
}
menu
.
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"edit-delete"
)),
i18n
(
"Remove Groups"
),
this
,
[
this
,
items
]()
{
for
(
auto
item
:
items
)
{
const
QString
fullPath
=
item
->
data
(
FullPathRole
).
toString
();
...
...
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