Unified type popup: explicit TypeEntry model, modifier toggles, section headers

- Replace sentinel-id scheme (kPrimBase) with TypeEntry::Kind discriminant
- Merge showTypeSelectorPopup + showTypePickerPopup into single showTypePopup
- Merge applyTypePickerResult into applyTypePopupResult matching on entryKind
- Add modifier toggle buttons (plain, *, **, [n]) with array count input
- Add section headers (primitives / project types) with dim centered styling
- Root mode shows project types first; non-Root sorts same-size primitives first
- Remove popup outside border, flat "Create new type" button
- Add parseTypeSpec parser, update tests with new TypeEntry API
This commit is contained in:
IChooseYou
2026-02-11 13:39:43 -07:00
committed by sysadmin
parent 33a093ae7d
commit db5d3ae311
6 changed files with 889 additions and 241 deletions

View File

@@ -4,21 +4,47 @@
#include <QVector>
#include <QString>
#include <cstdint>
#include "core.h"
class QLineEdit;
class QListView;
class QStringListModel;
class QLabel;
class QToolButton;
class QButtonGroup;
class QWidget;
namespace rcx {
// ── Popup mode ──
enum class TypePopupMode { Root, FieldType, ArrayElement, PointerTarget };
// ── Type entry (explicit discriminant — no sentinel IDs) ──
struct TypeEntry {
uint64_t id = 0;
QString displayName;
QString classKeyword; // "struct", "class", or "enum"
enum Kind { Primitive, Composite, Section };
Kind entryKind = Primitive;
NodeKind primitiveKind = NodeKind::Hex8; // valid when entryKind==Primitive
uint64_t structId = 0; // valid when entryKind==Composite
QString displayName;
QString classKeyword; // "struct", "class", "enum" (Composite only)
bool enabled = true; // false = grayed out (visible but not selectable)
};
// ── Parsed type spec (shared between popup filter and inline edit) ──
struct TypeSpec {
QString baseName;
bool isPointer = false;
int arrayCount = 0; // 0 = not array
};
TypeSpec parseTypeSpec(const QString& text);
// ── Popup widget ──
class TypeSelectorPopup : public QFrame {
Q_OBJECT
public:
@@ -26,11 +52,16 @@ public:
void setFont(const QFont& font);
void setTitle(const QString& title);
void setTypes(const QVector<TypeEntry>& types, uint64_t currentId);
void setMode(TypePopupMode mode);
void setCurrentNodeSize(int bytes);
void setTypes(const QVector<TypeEntry>& types, const TypeEntry* current = nullptr);
void popup(const QPoint& globalPos);
/// Force native window creation to avoid cold-start delay.
void warmUp();
signals:
void typeSelected(uint64_t id, const QString& displayName);
void typeSelected(const TypeEntry& entry, const QString& fullText);
void createNewTypeRequested();
void dismissed();
@@ -43,17 +74,32 @@ private:
QToolButton* m_escLabel = nullptr;
QToolButton* m_createBtn = nullptr;
QLineEdit* m_filterEdit = nullptr;
QLabel* m_previewLabel = nullptr;
QListView* m_listView = nullptr;
QStringListModel* m_model = nullptr;
// Modifier toggles
QWidget* m_modRow = nullptr;
QToolButton* m_btnPlain = nullptr;
QToolButton* m_btnPtr = nullptr;
QToolButton* m_btnDblPtr = nullptr;
QToolButton* m_btnArray = nullptr;
QLineEdit* m_arrayCountEdit = nullptr;
QButtonGroup* m_modGroup = nullptr;
QVector<TypeEntry> m_allTypes;
QVector<TypeEntry> m_filteredTypes;
uint64_t m_currentId = 0;
TypeEntry m_currentEntry;
bool m_hasCurrent = false;
TypePopupMode m_mode = TypePopupMode::FieldType;
int m_currentNodeSize = 0;
QFont m_font;
void applyFilter(const QString& text);
void updateModifierPreview();
void acceptCurrent();
void acceptIndex(int row);
int nextSelectableRow(int from, int direction) const;
};
} // namespace rcx