Add type selector popup, view root switching, and new type creation

- Type selector chevron [▸] on command row opens searchable popup
- Popup lists all root structs with filter, keyboard nav, side-triangle indicator
- Selecting a type switches the editor view via setViewRootId
- "Create new type" inserts a new root struct with no name
- Command row displays the active view root's name
- Tests for chevron detection, span compatibility, view switching, undo
This commit is contained in:
batallion2
2026-02-09 12:21:03 -07:00
committed by sysadmin
parent 0e65b9997e
commit f4149faa9a
15 changed files with 1611 additions and 291 deletions

58
src/typeselectorpopup.h Normal file
View File

@@ -0,0 +1,58 @@
#pragma once
#include <QFrame>
#include <QFont>
#include <QVector>
#include <QString>
#include <cstdint>
class QLineEdit;
class QListView;
class QStringListModel;
class QLabel;
class QToolButton;
namespace rcx {
struct TypeEntry {
uint64_t id = 0;
QString displayName;
QString classKeyword; // "struct", "class", or "enum"
};
class TypeSelectorPopup : public QFrame {
Q_OBJECT
public:
explicit TypeSelectorPopup(QWidget* parent = nullptr);
void setFont(const QFont& font);
void setTypes(const QVector<TypeEntry>& types, uint64_t currentId);
void popup(const QPoint& globalPos);
signals:
void typeSelected(uint64_t structId);
void createNewTypeRequested();
void dismissed();
protected:
bool eventFilter(QObject* obj, QEvent* event) override;
void hideEvent(QHideEvent* event) override;
private:
QLabel* m_titleLabel = nullptr;
QLabel* m_escLabel = nullptr;
QToolButton* m_createBtn = nullptr;
QLineEdit* m_filterEdit = nullptr;
QListView* m_listView = nullptr;
QStringListModel* m_model = nullptr;
QVector<TypeEntry> m_allTypes;
QVector<TypeEntry> m_filteredTypes;
uint64_t m_currentId = 0;
QFont m_font;
void applyFilter(const QString& text);
void acceptCurrent();
void acceptIndex(int row);
};
} // namespace rcx