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
tablewidget_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
7
8#include <QtDesigner/abstractformwindow.h>
9
10#include <QtWidgets/qtablewidget.h>
11#include <QtWidgets/qlineedit.h>
12#include <QtWidgets/qstyle.h>
13#include <QtWidgets/qstyleoption.h>
14
15#include <QtGui/qaction.h>
16
17#include <QtCore/qcoreevent.h>
18#include <QtCore/qvariant.h>
19#include <QtCore/qdebug.h>
20
22
23namespace qdesigner_internal {
24
25TableWidgetTaskMenu::TableWidgetTaskMenu(QTableWidget *button, QObject *parent)
26 : QDesignerTaskMenu(button, parent),
27 m_tableWidget(button),
28 m_editItemsAction(new QAction(tr("Edit Items..."), this))
29{
30 connect(m_editItemsAction, &QAction::triggered, this, &TableWidgetTaskMenu::editItems);
31 m_taskActions.append(m_editItemsAction);
32
33 QAction *sep = new QAction(this);
34 sep->setSeparator(true);
35 m_taskActions.append(sep);
36}
37
38
40
42{
43 return m_editItemsAction;
44}
45
47{
48 return m_taskActions + QDesignerTaskMenu::taskActions();
49}
50
51void TableWidgetTaskMenu::editItems()
52{
53 m_formWindow = QDesignerFormWindowInterface::findFormWindow(m_tableWidget);
54 if (m_formWindow.isNull())
55 return;
56
57 Q_ASSERT(m_tableWidget != nullptr);
58
59 TableWidgetEditorDialog dlg(m_formWindow, m_tableWidget->window());
60 TableWidgetContents oldCont = dlg.fillContentsFromTableWidget(m_tableWidget);
61 if (dlg.exec() == QDialog::Accepted) {
62 TableWidgetContents newCont = dlg.contents();
63 if (newCont != oldCont) {
64 ChangeTableContentsCommand *cmd = new ChangeTableContentsCommand(m_formWindow);
65 cmd->init(m_tableWidget, oldCont, newCont);
66 m_formWindow->commandHistory()->push(cmd);
67 }
68 }
69}
70
71void TableWidgetTaskMenu::updateSelection()
72{
73 if (m_editor)
74 m_editor->deleteLater();
75}
76
77} // namespace qdesigner_internal
78
79QT_END_NAMESPACE
QList< QAction * > taskActions() const override
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.