Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
listwidget_taskmenu.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3// Qt-Security score:significant reason:default
4
8#include <qdesigner_command_p.h>
9
10#include <QtDesigner/abstractformwindow.h>
11
12#include <QtWidgets/qstyle.h>
13#include <QtWidgets/qlineedit.h>
14#include <QtWidgets/qstyleoption.h>
15
16#include <QtGui/qaction.h>
17
18#include <QtCore/qcoreevent.h>
19#include <QtCore/qvariant.h>
20#include <QtCore/qdebug.h>
21
23
24namespace qdesigner_internal {
25
26ListWidgetTaskMenu::ListWidgetTaskMenu(QListWidget *button, QObject *parent)
27 : QDesignerTaskMenu(button, parent),
28 m_listWidget(button)
29{
30 m_editItemsAction = new QAction(this);
31 m_editItemsAction->setText(tr("Edit Items..."));
32 connect(m_editItemsAction, &QAction::triggered, this, &ListWidgetTaskMenu::editItems);
33 m_taskActions.append(m_editItemsAction);
34
35 QAction *sep = new QAction(this);
36 sep->setSeparator(true);
37 m_taskActions.append(sep);
38}
39
41
43{
44 return m_editItemsAction;
45}
46
48{
49 return m_taskActions + QDesignerTaskMenu::taskActions();
50}
51
52void ListWidgetTaskMenu::editItems()
53{
54 m_formWindow = QDesignerFormWindowInterface::findFormWindow(m_listWidget);
55 if (m_formWindow.isNull())
56 return;
57
58 Q_ASSERT(m_listWidget != nullptr);
59
60 ListWidgetEditor dlg(m_formWindow, m_listWidget->window());
61 ListContents oldItems = dlg.fillContentsFromListWidget(m_listWidget);
62 if (dlg.exec() == QDialog::Accepted) {
63 ListContents items = dlg.contents();
64 if (items != oldItems) {
65 ChangeListContentsCommand *cmd = new ChangeListContentsCommand(m_formWindow);
66 cmd->init(m_listWidget, oldItems, items);
67 cmd->setText(tr("Change List Contents"));
68 m_formWindow->commandHistory()->push(cmd);
69 }
70 }
71}
72
73void ListWidgetTaskMenu::updateSelection()
74{
75 if (m_editor)
76 m_editor->deleteLater();
77}
78
79} // namespace qdesigner_internal
80
81QT_END_NAMESPACE
QAction * preferredEditAction() const override
QList< QAction * > taskActions() const override
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.