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
Unmaintained
KDE Pim
Commits
10007538
Commit
10007538
authored
Jan 28, 2013
by
Laurent Montel
😁
Browse files
Fix Bug 310808 - Add context menus for list entries
Added menu when make sense. FIXED-IN: 4.10 BUG: 310808
parent
374f7966
Changes
2
Hide whitespace changes
Inline
Side-by-side
kmail/simplestringlisteditor.cpp
View file @
10007538
...
...
@@ -37,6 +37,7 @@
#include <kdebug.h>
#include <kpushbutton.h>
#include <kdialog.h>
#include <KMenu>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QListWidget>
...
...
@@ -62,6 +63,12 @@ SimpleStringListEditor::SimpleStringListEditor( QWidget * parent,
hlay
->
setMargin
(
0
);
mListBox
=
new
QListWidget
(
this
);
mListBox
->
setContextMenuPolicy
(
Qt
::
CustomContextMenu
);
connect
(
mListBox
,
SIGNAL
(
customContextMenuRequested
(
QPoint
)),
SLOT
(
slotContextMenu
(
QPoint
))
);
mListBox
->
setSelectionMode
(
QAbstractItemView
::
ExtendedSelection
);
hlay
->
addWidget
(
mListBox
,
1
);
...
...
@@ -347,6 +354,24 @@ void SimpleStringListEditor::slotSelectionChanged() {
}
}
void
SimpleStringListEditor
::
slotContextMenu
(
const
QPoint
&
pos
)
{
QList
<
QListWidgetItem
*>
lstSelectedItems
=
mListBox
->
selectedItems
();
const
bool
hasItemsSelected
=
!
lstSelectedItems
.
isEmpty
();
KMenu
*
menu
=
new
KMenu
(
this
);
if
(
mAddButton
)
{
menu
->
addAction
(
mAddButton
->
text
(),
this
,
SLOT
(
slotAdd
()));
}
if
(
mModifyButton
&&
(
lstSelectedItems
.
count
()
==
1
))
{
menu
->
addAction
(
mModifyButton
->
text
(),
this
,
SLOT
(
slotModify
()));
}
if
(
mRemoveButton
&&
hasItemsSelected
)
{
menu
->
addAction
(
mRemoveButton
->
text
(),
this
,
SLOT
(
slotRemove
()));
}
menu
->
exec
(
mListBox
->
mapToGlobal
(
pos
)
);
delete
menu
;
}
#include "simplestringlisteditor.moc"
kmail/simplestringlisteditor.h
View file @
10007538
...
...
@@ -90,7 +90,8 @@ protected slots:
void
slotDown
();
void
slotSelectionChanged
();
private
Q_SLOTS
:
void
slotContextMenu
(
const
QPoint
&
);
protected:
bool
containsString
(
const
QString
&
str
);
QList
<
QListWidgetItem
*>
selectedItems
()
const
;
...
...
Write
Preview
Markdown
is supported
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