| 71 | }; |
| 72 | |
| 73 | VariableToolTip::VariableToolTip(QWidget* parent, const QPoint& position, |
| 74 | const QString& identifier) |
| 75 | : ActiveToolTip(parent, position) |
| 76 | { |
| 77 | setPalette( QApplication::palette() ); |
| 78 | |
| 79 | m_model = new TreeModel(QVector<QString>{i18n("Name"), i18n("Value"), i18n("Type")}, this); |
| 80 | |
| 81 | auto* tr = new TooltipRoot(m_model); |
| 82 | m_model->setRootItem(tr); |
| 83 | m_var = ICore::self()->debugController()->currentSession()-> |
| 84 | variableController()->createVariable( |
| 85 | m_model, tr, identifier); |
| 86 | tr->init(m_var); |
| 87 | m_var->attachMaybe(this, "variableCreated"); |
| 88 | |
| 89 | auto* l = new QVBoxLayout(this); |
| 90 | l->setContentsMargins(0, 0, 0, 0); |
| 91 | |
| 92 | m_view = new AsyncTreeView(*m_model, this); |
| 93 | m_view->setModel(m_model); |
| 94 | m_view->header()->resizeSection(0, 150); |
| 95 | m_view->header()->resizeSection(1, 90); |
| 96 | m_view->setSelectionBehavior(QAbstractItemView::SelectRows); |
| 97 | m_view->setSelectionMode(QAbstractItemView::SingleSelection); |
| 98 | m_view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
| 99 | m_view->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding); |
| 100 | l->addWidget(m_view); |
| 101 | |
| 102 | const QModelIndex varIndex = m_model->indexForItem(m_var, 0); |
| 103 | m_itemHeight = m_view->indexRowSizeHint(varIndex); |
| 104 | connect(m_view->verticalScrollBar(), |
| 105 | &QScrollBar::rangeChanged, |
| 106 | this, |
| 107 | &VariableToolTip::slotRangeChanged); |
| 108 | |
| 109 | m_selection = m_view->selectionModel(); |
| 110 | m_selection->select(varIndex, |
| 111 | QItemSelectionModel::Rows | QItemSelectionModel::ClearAndSelect); |
| 112 | |
| 113 | auto* buttonBox = new QHBoxLayout(); |
| 114 | buttonBox->setContentsMargins(11, 0, 11, 6); |
| 115 | auto* watchThisButton = new QPushButton(i18n("Watch This")); |
| 116 | buttonBox->addWidget(watchThisButton); |
| 117 | auto* stopOnChangeButton = new QPushButton(i18n("Stop on Change")); |
| 118 | buttonBox->addWidget(stopOnChangeButton); |
| 119 | |
| 120 | connect(watchThisButton, &QPushButton::clicked, |
| 121 | this, [this](){ slotLinkActivated(QStringLiteral("add_watch")); }); |
| 122 | connect(stopOnChangeButton, &QPushButton::clicked, |
| 123 | this, [this](){ slotLinkActivated(QStringLiteral("add_watchpoint")); }); |
| 124 | |
| 125 | auto* inner = new QHBoxLayout(); |
| 126 | l->addLayout(inner); |
| 127 | inner->setContentsMargins(0, 0, 0, 0); |
| 128 | inner->addLayout(buttonBox); |
| 129 | inner->addStretch(); |
| 130 |
nothing calls this directly
no test coverage detected