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