KWidgetsAddons

kselectaction.cpp
1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 1999 Reginald Stadlbauer <reggie@kde.org>
4 SPDX-FileCopyrightText: 1999 Simon Hausmann <hausmann@kde.org>
5 SPDX-FileCopyrightText: 2000 Nicolas Hadacek <haadcek@kde.org>
6 SPDX-FileCopyrightText: 2000 Kurt Granroth <granroth@kde.org>
7 SPDX-FileCopyrightText: 2000 Michael Koch <koch@kde.org>
8 SPDX-FileCopyrightText: 2001 Holger Freyther <freyther@kde.org>
9 SPDX-FileCopyrightText: 2002 Ellis Whitehead <ellis@kde.org>
10 SPDX-FileCopyrightText: 2002 Joseph Wenninger <jowenn@kde.org>
11 SPDX-FileCopyrightText: 2003 Andras Mantia <amantia@kde.org>
12 SPDX-FileCopyrightText: 2005-2006 Hamish Rodda <rodda@kde.org>
13 SPDX-FileCopyrightText: 2006 Albert Astals Cid <aacid@kde.org>
14 SPDX-FileCopyrightText: 2006 Clarence Dang <dang@kde.org>
15 SPDX-FileCopyrightText: 2006 Michel Hermier <michel.hermier@gmail.com>
16 SPDX-FileCopyrightText: 2007 Nick Shaforostoff <shafff@ukr.net>
17
18 SPDX-License-Identifier: LGPL-2.0-only
19*/
20
21#include "kselectaction.h"
22#include "kselectaction_p.h"
23
24#include "loggingcategory.h"
25
26#include <QActionEvent>
27#include <QEvent>
28#include <QMenu>
29#include <QStandardItem>
30#include <QToolBar>
31
32// QAction::setText("Hi") and then KPopupAccelManager exec'ing, causes
33// QAction::text() to return "&Hi" :( Comboboxes don't have accels and
34// display ampersands literally.
35static QString DropAmpersands(const QString &text)
36{
37 QString label = text;
38
39 int p = label.indexOf(QLatin1Char('&'));
40 while (p >= 0 && p < label.length() - 1) {
41 if (label[p + 1].isLetterOrNumber() // Valid accelerator.
42 || label[p + 1] == QLatin1Char('&')) { // Escaped accelerator marker.
43 label.remove(p, 1);
44 }
45
46 p = label.indexOf(QLatin1Char('&'), p + 1);
47 }
48
49 return label;
50}
51
53 : KSelectAction(*new KSelectActionPrivate(this), parent)
54{
55}
56
58 : KSelectAction(*new KSelectActionPrivate(this), parent)
59{
61}
62
63KSelectAction::KSelectAction(const QIcon &icon, const QString &text, QObject *parent)
64 : KSelectAction(*new KSelectActionPrivate(this), parent)
65{
68}
69
70KSelectAction::KSelectAction(KSelectActionPrivate &dd, QObject *parent)
71 : QWidgetAction(parent)
72 , d_ptr(&dd)
73{
75 d->init();
76}
77
82
83void KSelectActionPrivate::init()
84{
85 QObject::connect(q_ptr->selectableActionGroup(), &QActionGroup::triggered, q_ptr, &KSelectAction::slotActionTriggered);
87 q_ptr->setMenu(new QMenu());
88 q_ptr->setEnabled(false);
89}
90
92{
93 Q_D(const KSelectAction);
94 return d->m_actionGroup;
95}
96
101
102QAction *KSelectAction::currentAction() const
103{
105}
106
107int KSelectAction::currentItem() const
108{
109 return selectableActionGroup()->actions().indexOf(currentAction());
110}
111
112QString KSelectAction::currentText() const
113{
114 if (QAction *a = currentAction()) {
115 return ::DropAmpersands(a->text());
116 }
117
118 return QString();
119}
120
122{
123 // qCDebug(KWidgetsAddonsLog) << "KSelectAction::setCurrentAction(" << action << ")";
124 if (action) {
125 if (actions().contains(action)) {
126 if (action->isVisible() && action->isEnabled() && action->isCheckable()) {
127 action->setChecked(true);
128 if (isCheckable()) {
129 setChecked(true);
130 }
131 return true;
132 } else {
133 qCWarning(KWidgetsAddonsLog) << "Action does not have the correct properties to be current:" << action->text();
134 }
135 } else {
136 qCWarning(KWidgetsAddonsLog) << "Action does not belong to group:" << action->text();
137 }
138 return false;
139 }
140
141 if (currentAction()) {
142 currentAction()->setChecked(false);
143 }
144
145 return false;
146}
147
149{
150 // qCDebug(KWidgetsAddonsLog) << "KSelectAction::setCurrentIndex(" << index << ")";
151 return setCurrentAction(action(index));
152}
153
155{
156 if (index >= 0 && index < selectableActionGroup()->actions().count()) {
157 return selectableActionGroup()->actions().at(index);
158 }
159
160 return nullptr;
161}
162
164{
165 QString compare;
166 if (cs == Qt::CaseSensitive) {
167 compare = text;
168 } else {
169 compare = text.toLower();
170 }
171
172 const auto selectableActions = selectableActionGroup()->actions();
173 for (QAction *action : selectableActions) {
174 const QString text = ::DropAmpersands(action->text());
175 if (cs == Qt::CaseSensitive) {
176 if (text == compare) {
177 return action;
178 }
179
180 } else if (cs == Qt::CaseInsensitive) {
181 if (text.toLower() == compare) {
182 return action;
183 }
184 }
185 }
186
187 return nullptr;
188}
189
191{
192 // qCDebug(KWidgetsAddonsLog) << "KSelectAction::setCurrentAction(" << text << ",cs=" << cs << ")";
193 return setCurrentAction(action(text, cs));
194}
195
197{
199 if (width < 0) {
200 return;
201 }
202
203 d->m_comboWidth = width;
204
205 for (QComboBox *box : std::as_const(d->m_comboBoxes)) {
206 box->setMaximumWidth(d->m_comboWidth);
207 }
208
209 Q_EMIT changed();
210}
211
213{
215 d->m_maxComboViewCount = n;
216
217 for (QComboBox *box : std::as_const(d->m_comboBoxes)) {
218 if (d->m_maxComboViewCount != -1) {
219 box->setMaxVisibleItems(d->m_maxComboViewCount);
220 } else
221 // hardcoded qt default
222 {
223 box->setMaxVisibleItems(10);
224 }
225 }
226
227 Q_EMIT changed();
228}
229
231{
232 insertAction(nullptr, action);
233}
234
236{
238 QAction *newAction = new QAction(parent());
239 newAction->setText(text);
240 newAction->setCheckable(true);
241 newAction->setProperty("isShortcutConfigurable", false);
242
243 if (!d->m_menuAccelsEnabled) {
244 newAction->setText(text);
245 newAction->setShortcut(QKeySequence());
246 }
247
248 addAction(newAction);
249 return newAction;
250}
251
253{
254 QAction *newAction = addAction(text);
255 newAction->setIcon(icon);
256 return newAction;
257}
258
260{
262 // qCDebug(KWidgetsAddonsLog) << "KSelectAction::removeAction(" << action << ")";
263 // int index = selectableActionGroup()->actions().indexOf(action);
264 // qCDebug(KWidgetsAddonsLog) << "\tindex=" << index;
265
266 // Removes the action from the group and sets its parent to null.
267 d->m_actionGroup->removeAction(action);
268
269 // Disable when no action is in the group
270 bool hasActions = selectableActionGroup()->actions().isEmpty();
271 setEnabled(!hasActions);
272
273 for (QToolButton *button : std::as_const(d->m_buttons)) {
274 button->setEnabled(!hasActions);
275 button->removeAction(action);
276 }
277
278 for (QComboBox *comboBox : std::as_const(d->m_comboBoxes)) {
279 comboBox->setEnabled(!hasActions);
280 comboBox->removeAction(action);
281 }
282
284
285 return action;
286}
287
289{
292
293 // Re-Enable when an action is added
294 setEnabled(true);
295
296 // Keep in sync with createToolBarWidget()
297 for (QToolButton *button : std::as_const(d->m_buttons)) {
298 button->setEnabled(true);
299 button->insertAction(before, action);
300 }
301
302 for (QComboBox *comboBox : std::as_const(d->m_comboBoxes)) {
303 comboBox->setEnabled(true);
304 comboBox->insertAction(before, action);
305 }
306
307 menu()->insertAction(before, action);
308}
309
311{
312 // cache values so we don't need access to members in the action
313 // after we've done an emit()
314 const QString text = ::DropAmpersands(action->text());
315 const int index = selectableActionGroup()->actions().indexOf(action);
316 // qCDebug(KWidgetsAddonsLog) << "KSelectAction::slotActionTriggered(" << action << ") text=" << text
317 // << " index=" << index << " emitting triggered()" << endl;
318
319 if (isCheckable()) { // if this is subsidiary of other KSelectAction-derived class
320 trigger(); // then imitate usual QAction behaviour so that other submenus (and their items) become unchecked
321 }
322
324 Q_EMIT indexTriggered(index);
326}
327
328QStringList KSelectAction::items() const
329{
330 Q_D(const KSelectAction);
331 QStringList ret;
332
333 const auto actions = d->m_actionGroup->actions();
334 ret.reserve(actions.size());
335 for (QAction *action : actions) {
336 ret << ::DropAmpersands(action->text());
337 }
338
339 return ret;
340}
341
342void KSelectAction::changeItem(int index, const QString &text)
343{
345 if (index < 0 || index >= actions().count()) {
346 qCWarning(KWidgetsAddonsLog) << "KSelectAction::changeItem Index out of scope";
347 return;
348 }
349
350 actions()[index]->setText(d->makeMenuText(text));
351}
352
354{
356 // qCDebug(KWidgetsAddonsLog) << "KSelectAction::setItems(" << lst << ")";
357
358 clear();
359
360 for (const QString &string : lst) {
361 if (!string.isEmpty()) {
362 addAction(string);
363 } else {
364 QAction *action = new QAction(this);
365 action->setSeparator(true);
367 }
368 }
369
370 // Disable if empty and not editable
371 setEnabled(lst.count() > 0 || d->m_edit);
372}
373
374int KSelectAction::comboWidth() const
375{
376 Q_D(const KSelectAction);
377 return d->m_comboWidth;
378}
379
381{
383 // qCDebug(KWidgetsAddonsLog) << "KSelectAction::clear()";
384
385 // we need to delete the actions later since we may get a call to clear()
386 // from a method called due to a triggered(...) signal
387 const QList<QAction *> actions = d->m_actionGroup->actions();
388 for (int i = 0; i < actions.count(); ++i) {
389 // deleteLater() only removes us from the actions() list (among
390 // other things) on the next entry into the event loop. Until then,
391 // e.g. action() and setCurrentItem() will be working on items
392 // that are supposed to have been deleted. So detach the action to
393 // prevent this from happening.
395
396 actions[i]->deleteLater();
397 }
398}
399
401{
403 while (d->m_actionGroup->actions().count()) {
404 removeAction(d->m_actionGroup->actions().first());
405 }
406}
407
409{
411 d->m_edit = edit;
412
413 for (QComboBox *comboBox : std::as_const(d->m_comboBoxes)) {
414 comboBox->setEditable(edit);
415 }
416
417 Q_EMIT changed();
418}
419
421{
422 Q_D(const KSelectAction);
423 return d->m_edit;
424}
425
427{
428 // if (checked && selectableActionGroup()->checkedAction())
429 if (!checked && currentAction()) { // other's submenu item has been selected
430 currentAction()->setChecked(false);
431 }
432}
433
434KSelectAction::ToolBarMode KSelectAction::toolBarMode() const
435{
436 Q_D(const KSelectAction);
437 return d->m_toolBarMode;
438}
439
441{
443 d->m_toolBarMode = mode;
444}
445
446QToolButton::ToolButtonPopupMode KSelectAction::toolButtonPopupMode() const
447{
448 Q_D(const KSelectAction);
449 return d->m_toolButtonPopupMode;
450}
451
453{
455 d->m_toolButtonPopupMode = mode;
456}
457
458void KSelectActionPrivate::comboBoxDeleted(QComboBox *combo)
459{
460 m_comboBoxes.removeAll(combo);
461}
462
463void KSelectActionPrivate::comboBoxCurrentIndexChanged(int index)
464{
465 Q_Q(KSelectAction);
466 // qCDebug(KWidgetsAddonsLog) << "KSelectActionPrivate::comboBoxCurrentIndexChanged(" << index << ")";
467
468 QComboBox *triggeringCombo = qobject_cast<QComboBox *>(q->sender());
469
470 QAction *a = q->action(index);
471 // qCDebug(KWidgetsAddonsLog) << "\ta=" << a;
472 if (a) {
473 // qCDebug(KWidgetsAddonsLog) << "\t\tsetting as current action";
474 a->trigger();
475
476 } else if (q->isEditable() && triggeringCombo && triggeringCombo->count() > 0 && index == triggeringCombo->count() - 1) {
477 // User must have added a new item by typing and pressing enter.
478 const QString newItemText = triggeringCombo->currentText();
479 // qCDebug(KWidgetsAddonsLog) << "\t\tuser typed new item '" << newItemText << "'";
480
481 // Only 1 combobox contains this and it's not a proper action.
482 bool blocked = triggeringCombo->blockSignals(true);
483 triggeringCombo->removeItem(index);
484 triggeringCombo->blockSignals(blocked);
485
486 QAction *newAction = q->addAction(newItemText);
487
488 newAction->trigger();
489 } else {
490 if (q->selectableActionGroup()->checkedAction()) {
491 q->selectableActionGroup()->checkedAction()->setChecked(false);
492 }
493 }
494}
495
496// TODO: DropAmpersands() certainly makes sure this doesn't work. But I don't
497// think it did anyway esp. in the presence KCheckAccelerator - Clarence.
499{
501 d->m_menuAccelsEnabled = b;
502}
503
505{
506 Q_D(const KSelectAction);
507 return d->m_menuAccelsEnabled;
508}
509
511{
514 if (menu) { // If used in a menu want to return 0 and use only the text, not a widget
515 return nullptr;
516 }
517 ToolBarMode mode = toolBarMode();
519 if (!toolBar && mode != ComboBoxMode) { // we can return a combobox just fine.
520 return nullptr;
521 }
522 switch (mode) {
523 case MenuMode: {
524 QToolButton *button = new QToolButton(toolBar);
525 button->setToolTip(toolTip());
526 button->setWhatsThis(whatsThis());
527 button->setStatusTip(statusTip());
528 button->setAutoRaise(true);
530 button->setIconSize(toolBar->iconSize());
531 button->setToolButtonStyle(toolBar->toolButtonStyle());
534 button->setDefaultAction(this);
536
537 button->setPopupMode(toolButtonPopupMode());
538
540
541 d->m_buttons.append(button);
542 return button;
543 }
544
545 case ComboBoxMode: {
546 QComboBox *comboBox = new QComboBox(parent);
547 comboBox->installEventFilter(this);
548
549 if (d->m_maxComboViewCount != -1) {
550 comboBox->setMaxVisibleItems(d->m_maxComboViewCount);
551 }
552
553 if (d->m_comboWidth > 0) {
554 comboBox->setMaximumWidth(d->m_comboWidth);
555 }
556
557 comboBox->setEditable(isEditable());
558 comboBox->setToolTip(toolTip());
559 comboBox->setWhatsThis(whatsThis());
560 comboBox->setStatusTip(statusTip());
561
562 const auto selectableActions = selectableActionGroup()->actions();
563 for (QAction *action : selectableActions) {
564 comboBox->addAction(action);
565 }
566
567 if (selectableActions.isEmpty()) {
568 comboBox->setEnabled(false);
569 }
570
571 connect(comboBox, &QComboBox::destroyed, this, [d, comboBox]() {
572 d->comboBoxDeleted(comboBox);
573 });
574
575 connect(comboBox, &QComboBox::currentIndexChanged, this, [d](int value) {
576 d->comboBoxCurrentIndexChanged(value);
577 });
578
579 d->m_comboBoxes.append(comboBox);
580
581 return comboBox;
582 }
583 }
584
585 return nullptr;
586}
587
589{
591 if (QToolButton *toolButton = qobject_cast<QToolButton *>(widget)) {
592 d->m_buttons.removeAll(toolButton);
593 } else if (QComboBox *comboBox = qobject_cast<QComboBox *>(widget)) {
594 d->m_comboBoxes.removeAll(comboBox);
595 }
597}
598
599bool KSelectAction::event(QEvent *event)
600{
602 if (event->type() == QEvent::ActionChanged) {
603 for (QComboBox *comboBox : std::as_const(d->m_comboBoxes)) {
604 comboBox->setToolTip(toolTip());
605 comboBox->setWhatsThis(whatsThis());
606 comboBox->setStatusTip(statusTip());
607 }
608 for (QToolButton *toolButton : std::as_const(d->m_buttons)) {
609 toolButton->setToolTip(toolTip());
610 toolButton->setWhatsThis(whatsThis());
611 toolButton->setStatusTip(statusTip());
612 }
613 }
614 return QWidgetAction::event(event);
615}
616
617// KSelectAction::eventFilter() is called before action->setChecked()
618// invokes the signal to update QActionGroup so KSelectAction::currentItem()
619// returns an old value. There are 3 possibilities, where n actions will
620// report QAction::isChecked() where n is:
621//
622// 0: the checked action was unchecked
623// 1: the checked action did not change
624// 2: another action was checked but QActionGroup has not been invoked yet
625// to uncheck the one that was checked before
626//
627// TODO: we might want to cache this since QEvent::ActionChanged is fired
628// often.
629static int TrueCurrentItem(KSelectAction *sa)
630{
631 QAction *curAction = sa->currentAction();
632 // qCDebug(KWidgetsAddonsLog) << "\tTrueCurrentItem(" << sa << ") curAction=" << curAction;
633
634 const auto actions = sa->actions();
635 int i = 0;
636 for (QAction *action : actions) {
637 if (action->isChecked()) {
638 // qCDebug(KWidgetsAddonsLog) << "\t\taction " << action << " (text=" << action->text () << ") isChecked";
639
640 // 2 actions checked case?
641 if (action != curAction) {
642 // qCDebug(KWidgetsAddonsLog) << "\t\t\tmust be newly selected one";
643 return i;
644 }
645 }
646 ++i;
647 }
648
649 // qCDebug(KWidgetsAddonsLog) << "\t\tcurrent action still selected? " << (curAction && curAction->isChecked ());
650 // 1 or 0 actions checked case (in that order)?
651 return (curAction && curAction->isChecked()) ? sa->actions().indexOf(curAction) : -1;
652}
653
654bool KSelectAction::eventFilter(QObject *watched, QEvent *event)
655{
656 QComboBox *comboBox = qobject_cast<QComboBox *>(watched);
657 if (!comboBox) {
658 return false /*propagate event*/;
659 }
660
661 // If focus is lost, replace any edited text with the currently selected
662 // item.
663 if (event->type() == QEvent::FocusOut) {
664 QFocusEvent *const e = static_cast<QFocusEvent *>(event);
665 // qCDebug(KWidgetsAddonsLog) << "KSelectAction::eventFilter(FocusOut)"
666 // << " comboBox: ptr=" << comboBox
667 // << " reason=" << e->reason ()
668 // << endl;
669
670 if (e->reason() != Qt::ActiveWindowFocusReason // switch window
671 && e->reason() != Qt::PopupFocusReason // menu
672 && e->reason() != Qt::OtherFocusReason // inconsistently reproduceable actions...
673 ) {
674 // qCDebug(KWidgetsAddonsLog) << "\tkilling text";
675 comboBox->setEditText(comboBox->itemText(comboBox->currentIndex()));
676 }
677
678 return false /*propagate event*/;
679 }
680
681 bool blocked = comboBox->blockSignals(true);
682
683 if (event->type() == QEvent::ActionAdded) {
684 QActionEvent *const e = static_cast<QActionEvent *>(event);
685
686 const int index = e->before() ? comboBox->findData(QVariant::fromValue(e->before())) : comboBox->count();
687 const int newItem = ::TrueCurrentItem(this);
688 // qCDebug(KWidgetsAddonsLog) << "KSelectAction::eventFilter(ActionAdded)"
689 // << " comboBox: ptr=" << comboBox
690 // << " currentItem=" << comboBox->currentIndex ()
691 // << " add index=" << index
692 // << " action new: e->before=" << e->before ()
693 // << " ptr=" << e->action ()
694 // << " icon=" << e->action ()->icon ()
695 // << " text=" << e->action ()->text ()
696 // << " currentItem=" << newItem
697 // << endl;
698 comboBox->insertItem(index, e->action()->icon(), ::DropAmpersands(e->action()->text()), QVariant::fromValue(e->action()));
700 QStandardItem *item = model->item(index);
701 item->setEnabled(e->action()->isEnabled());
702 }
703
704 // Inserting an item into a combobox can change the current item so
705 // make sure the item corresponding to the checked action is selected.
706 comboBox->setCurrentIndex(newItem);
707 } else if (event->type() == QEvent::ActionChanged) {
708 QActionEvent *const e = static_cast<QActionEvent *>(event);
709
710 const int index = comboBox->findData(QVariant::fromValue(e->action()));
711 const int newItem = ::TrueCurrentItem(this);
712 // qCDebug(KWidgetsAddonsLog) << "KSelectAction::eventFilter(ActionChanged)"
713 // << " comboBox: ptr=" << comboBox
714 // << " currentItem=" << comboBox->currentIndex ()
715 // << " changed action's index=" << index
716 // << " action new: ptr=" << e->action ()
717 // << " icon=" << e->action ()->icon ()
718 // << " text=" << e->action ()->text ()
719 // << " currentItem=" << newItem
720 // << endl;
721 comboBox->setItemIcon(index, e->action()->icon());
722 comboBox->setItemText(index, ::DropAmpersands(e->action()->text()));
724 QStandardItem *item = model->item(index);
725 item->setEnabled(e->action()->isEnabled());
726 }
727
728 // The checked action may have become unchecked so
729 // make sure the item corresponding to the checked action is selected.
730 comboBox->setCurrentIndex(newItem);
731 } else if (event->type() == QEvent::ActionRemoved) {
732 QActionEvent *const e = static_cast<QActionEvent *>(event);
733
734 const int index = comboBox->findData(QVariant::fromValue(e->action()));
735 const int newItem = ::TrueCurrentItem(this);
736 // qCDebug(KWidgetsAddonsLog) << "KSelectAction::eventFilter(ActionRemoved)"
737 // << " comboBox: ptr=" << comboBox
738 // << " currentItem=" << comboBox->currentIndex ()
739 // << " delete action index=" << index
740 // << " new: currentItem=" << newItem
741 // << endl;
742 comboBox->removeItem(index);
743
744 // Removing an item from a combobox can change the current item so
745 // make sure the item corresponding to the checked action is selected.
746 comboBox->setCurrentIndex(newItem);
747 }
748
749 comboBox->blockSignals(blocked);
750
751 return false /*propagate event*/;
752}
753
754// END
755
756#include "moc_kselectaction.cpp"
Action for selecting one of several items.
bool isEditable() const
When this action is plugged into a toolbar, it creates a combobox.
bool setCurrentAction(QAction *action)
Sets the currently checked item.
KSelectAction(QObject *parent)
Constructs a selection action with the specified parent.
void setItems(const QStringList &lst)
Convenience function to create the list of selectable items.
void setToolButtonPopupMode(QToolButton::ToolButtonPopupMode mode)
Set how this list of actions should behave when in popup mode and plugged into a toolbar.
void deleteWidget(QWidget *widget) override
Reimplemented from QWidgetAction.
bool menuAccelsEnabled() const
Returns whether ampersands passed to methods using QStrings are interpreted as keyboard accelerator i...
virtual QAction * removeAction(QAction *action)
Remove the specified action from this action selector.
void slotToggled(bool)
For structured menu building.
void setComboWidth(int width)
When this action is plugged into a toolbar, it creates a combobox.
void changeItem(int index, const QString &text)
Changes the text of item.
virtual void slotActionTriggered(QAction *action)
This function is called whenever an action from the selections is triggered.
void clear()
Remove and delete all the items in this action.
@ MenuMode
Creates a button which pops up a menu when interacted with, as defined by toolButtonPopupMode().
@ ComboBoxMode
Creates a combo box which contains the actions.
QList< QAction * > actions() const
Returns the list of selectable actions.
void setToolBarMode(ToolBarMode mode)
Set the type of widget to be inserted in a toolbar to mode.
QActionGroup * selectableActionGroup() const
The action group used to create exclusivity between the actions associated with this action.
void setMaxComboViewCount(int n)
Sets the maximum items that are visible at once if the action is a combobox, that is the number of it...
virtual void insertAction(QAction *before, QAction *action)
Inserts the action action to this widget's list of actions, before the action before.
void indexTriggered(int index)
This signal is emitted when an item is selected.
void textTriggered(const QString &text)
This signal is emitted when an item is selected.
QAction * action(const QString &text, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Searches for an action with the specified text, using a search whose case sensitivity is defined by c...
void actionTriggered(QAction *action)
This signal is emitted when an item is selected.
void addAction(QAction *action)
Add action to the list of selectable actions.
void setMenuAccelsEnabled(bool b)
Sets whether any occurrence of the ampersand character ( & ) in items should be interpreted as keyboa...
void removeAllActions()
Remove all the items in this action.
~KSelectAction() override
Destructor.
QAction * action(int index) const
Returns the action at index, if one exists.
QWidget * createWidget(QWidget *parent) override
Reimplemented from QWidgetAction.
void setEditable(bool)
When this action is plugged into a toolbar, it creates a combobox.
bool setCurrentItem(int index)
Convenience function to set the currently checked action to be the action at index index.
AKONADI_CALENDAR_EXPORT KCalendarCore::Event::Ptr event(const Akonadi::Item &item)
QString label(StandardShortcut id)
void setIconSize(const QSize &size)
QAction(QObject *parent)
void changed()
bool isCheckable() const const
void setChecked(bool)
bool isEnabled() const const
void setIcon(const QIcon &icon)
QMenu * menu() const const
void setActionGroup(QActionGroup *group)
void setSeparator(bool b)
void setShortcut(const QKeySequence &shortcut)
void setText(const QString &text)
void toggled(bool checked)
void trigger()
bool isVisible() const const
QAction * action() const const
QAction * before() const const
QList< QAction * > actions() const const
QAction * checkedAction() const const
void currentIndexChanged(int index)
void setEditable(bool editable)
int findData(const QVariant &data, int role, Qt::MatchFlags flags) const const
void insertItem(int index, const QIcon &icon, const QString &text, const QVariant &userData)
QString itemText(int index) const const
void setMaxVisibleItems(int maxItems)
QAbstractItemModel * model() const const
void removeItem(int index)
void setEditText(const QString &text)
void setItemIcon(int index, const QIcon &icon)
void setItemText(int index, const QString &text)
Qt::FocusReason reason() const const
const_reference at(qsizetype i) const const
qsizetype count() const const
qsizetype indexOf(const AT &value, qsizetype from) const const
bool isEmpty() const const
void reserve(qsizetype size)
qsizetype size() const const
Q_EMITQ_EMIT
bool blockSignals(bool block)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void deleteLater()
void destroyed(QObject *obj)
void installEventFilter(QObject *filterObj)
QObject * parent() const const
T qobject_cast(QObject *object)
bool setProperty(const char *name, QVariant &&value)
void setEnabled(bool enabled)
qsizetype indexOf(QChar ch, qsizetype from, Qt::CaseSensitivity cs) const const
qsizetype length() const const
QString & remove(QChar ch, Qt::CaseSensitivity cs)
QString toLower() const const
CaseSensitivity
ActiveWindowFocusReason
void actionTriggered(QAction *action)
void iconSizeChanged(const QSize &iconSize)
void toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle)
void setAutoRaise(bool enable)
void setPopupMode(ToolButtonPopupMode mode)
void setDefaultAction(QAction *action)
void setToolButtonStyle(Qt::ToolButtonStyle style)
void triggered(QAction *action)
QVariant fromValue(T &&value)
QAction * addAction(const QIcon &icon, const QString &text)
void addActions(const QList< QAction * > &actions)
void setEnabled(bool)
void setFocusPolicy(Qt::FocusPolicy policy)
void insertAction(QAction *before, QAction *action)
void setMaximumWidth(int maxw)
void removeAction(QAction *action)
void setStatusTip(const QString &)
void setToolTip(const QString &)
void setWhatsThis(const QString &)
virtual void deleteWidget(QWidget *widget)
virtual bool event(QEvent *event) override
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:52 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.