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
treewidget_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/qstyle.h>
10#include <QtWidgets/qlineedit.h>
11#include <QtWidgets/qstyleoption.h>
12
13#include <QtGui/qaction.h>
14
15#include <QtCore/qcoreevent.h>
16#include <QtCore/qvariant.h>
17#include <QtCore/qdebug.h>
18
20
21namespace qdesigner_internal {
22
23TreeWidgetTaskMenu::TreeWidgetTaskMenu(QTreeWidget *button, QObject *parent)
24 : QDesignerTaskMenu(button, parent),
25 m_treeWidget(button),
26 m_editItemsAction(new QAction(tr("Edit Items..."), this))
27{
28 connect(m_editItemsAction, &QAction::triggered, this, &TreeWidgetTaskMenu::editItems);
29 m_taskActions.append(m_editItemsAction);
30
31 QAction *sep = new QAction(this);
32 sep->setSeparator(true);
33 m_taskActions.append(sep);
34}
35
36
38
40{
41 return m_editItemsAction;
42}
43
45{
46 return m_taskActions + QDesignerTaskMenu::taskActions();
47}
48
49void TreeWidgetTaskMenu::editItems()
50{
51 m_formWindow = QDesignerFormWindowInterface::findFormWindow(m_treeWidget);
52 if (m_formWindow.isNull())
53 return;
54
55 Q_ASSERT(m_treeWidget != nullptr);
56
57 TreeWidgetEditorDialog dlg(m_formWindow, m_treeWidget->window());
58 TreeWidgetContents oldCont = dlg.fillContentsFromTreeWidget(m_treeWidget);
59 if (dlg.exec() == QDialog::Accepted) {
60 TreeWidgetContents newCont = dlg.contents();
61 if (newCont != oldCont) {
62 ChangeTreeContentsCommand *cmd = new ChangeTreeContentsCommand(m_formWindow);
63 cmd->init(m_treeWidget, oldCont, newCont);
64 m_formWindow->commandHistory()->push(cmd);
65 }
66 }
67}
68
69void TreeWidgetTaskMenu::updateSelection()
70{
71 if (m_editor)
72 m_editor->deleteLater();
73}
74
75} // namespace qdesigner_internal
76
77QT_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.