30NodeCycleWidget::NodeCycleWidget(QWidget *parent) : QWidget(parent) {
32 setWindowFlags(Qt::Popup | Qt::FramelessWindowHint);
33 setAttribute(Qt::WA_DeleteOnClose,
false);
36 infoLabel_ =
new QLabel(
this);
37 prevButton_ =
new QPushButton(
"Previous",
this);
38 nextButton_ =
new QPushButton(
"Next",
this);
39 closeButton_ =
new QPushButton(
"Close",
this);
42 QVBoxLayout *mainLayout =
new QVBoxLayout(
this);
43 mainLayout->addWidget(infoLabel_);
45 QHBoxLayout *buttonLayout =
new QHBoxLayout();
46 buttonLayout->addWidget(prevButton_);
47 buttonLayout->addWidget(nextButton_);
48 buttonLayout->addWidget(closeButton_);
49 mainLayout->addLayout(buttonLayout);
51 setLayout(mainLayout);
54 connect(prevButton_, &QPushButton::clicked,
this, &NodeCycleWidget::onPrevious);
55 connect(nextButton_, &QPushButton::clicked,
this, &NodeCycleWidget::onNext);
56 connect(closeButton_, &QPushButton::clicked,
this, &NodeCycleWidget::onClose);
62 const QPoint &clickPos) {
63 if (matches.empty()) {
73 move(clickPos + QPoint(10, 10));
82void NodeCycleWidget::onNext() {
83 if (matches_.empty()) {
87 currentIndex_ = (currentIndex_ + 1) % matches_.size();
89 emit nodeSelected(matches_[currentIndex_]);
92void NodeCycleWidget::onPrevious() {
93 if (matches_.empty()) {
97 if (currentIndex_ == 0) {
98 currentIndex_ = matches_.size() - 1;
104 emit nodeSelected(matches_[currentIndex_]);
107void NodeCycleWidget::onClose() {
112void NodeCycleWidget::updateDisplay() {
113 if (matches_.empty()) {
117 AstViewNode *node = matches_[currentIndex_];
118 const AcavJson &props = node->getProperties();
120 QString kind =
"<unknown>";
121 if (props.contains(
"kind") && props.at(
"kind").is_string()) {
122 kind = QString::fromStdString(
123 props.at(
"kind").get<InternedString>().str());
126 if (props.contains(
"name")) {
127 name = QString::fromStdString(props[
"name"].get<InternedString>().str());
130 QString info = QString(
"Match %1 of %2: %3")
131 .arg(currentIndex_ + 1)
132 .arg(matches_.size())
135 if (!name.isEmpty()) {
136 info += QString(
" (%1)").arg(name);
139 infoLabel_->setText(info);
142 prevButton_->setEnabled(matches_.size() > 1);
143 nextButton_->setEnabled(matches_.size() > 1);
AST data structures and memory management.
nlohmann::basic_json< std::map, std::vector, InternedString, bool, int64_t, uint64_t, double, std::allocator, nlohmann::adl_serializer, std::vector< uint8_t > > AcavJson
Custom JSON type using InternedString for automatic string deduplication.