From 6ffd9457c50752a6f4b954421be48c91d48cb327 Mon Sep 17 00:00:00 2001 From: mappu Date: Sat, 26 Oct 2024 14:18:28 +1300 Subject: [PATCH] uic: always assume NewFoo is the correct constructor --- cmd/miqt-uic/constructors.go | 169 ----------------------------------- cmd/miqt-uic/ui2go.go | 4 +- 2 files changed, 2 insertions(+), 171 deletions(-) delete mode 100644 cmd/miqt-uic/constructors.go diff --git a/cmd/miqt-uic/constructors.go b/cmd/miqt-uic/constructors.go deleted file mode 100644 index 14ffcbf4..00000000 --- a/cmd/miqt-uic/constructors.go +++ /dev/null @@ -1,169 +0,0 @@ -package main - -func constructorFunctionFor(className string) string { - - // Rebuild this list via: - // grep -PRoh 'func New.+\(parent \*QWidget\)' ~/dev/miqt/qt/ | sed -re 's~^func New([^0-9]+)([0-9]*)\(.*~case "\1": return "New\1\2"~' - - switch className { - - // CODEGENERATED LIST START - - case "QListWidget": - return "NewQListWidget2" - case "QAbstractSpinBox": - return "NewQAbstractSpinBox2" - case "QStackedLayout": - return "NewQStackedLayout2" - case "QColumnView": - return "NewQColumnView2" - case "QProgressDialog": - return "NewQProgressDialog3" - case "QTabWidget": - return "NewQTabWidget2" - case "QLabel": - return "NewQLabel3" - case "QKeySequenceEdit": - return "NewQKeySequenceEdit3" - case "QDockWidget": - return "NewQDockWidget5" - case "QFontComboBox": - return "NewQFontComboBox2" - case "QTreeView": - return "NewQTreeView2" - case "QCalendarWidget": - return "NewQCalendarWidget2" - case "QLineEdit": - return "NewQLineEdit3" - case "QMenuBar": - return "NewQMenuBar2" - case "QFrame": - return "NewQFrame2" - case "QAbstractScrollArea": - return "NewQAbstractScrollArea2" - case "QSplitter": - return "NewQSplitter3" - case "QStackedWidget": - return "NewQStackedWidget2" - case "QWizard": - return "NewQWizard2" - case "QWizardPage": - return "NewQWizardPage2" - case "QMdiSubWindow": - return "NewQMdiSubWindow2" - case "QStatusBar": - return "NewQStatusBar2" - case "QToolButton": - return "NewQToolButton2" - case "QShortcut": - return "NewQShortcut" - case "QSlider": - return "NewQSlider3" - case "QComboBox": - return "NewQComboBox2" - case "QScrollBar": - return "NewQScrollBar3" - case "QTabBar": - return "NewQTabBar2" - case "QTextBrowser": - return "NewQTextBrowser2" - case "QTreeWidget": - return "NewQTreeWidget2" - case "QDialog": - return "NewQDialog2" - case "QFormLayout": - return "NewQFormLayout2" - case "QToolBar": - return "NewQToolBar4" - case "QWidget": - return "NewQWidget2" - case "QRadioButton": - return "NewQRadioButton3" - case "QCheckBox": - return "NewQCheckBox3" - case "QSizeGrip": - return "NewQSizeGrip" - case "QLCDNumber": - return "NewQLCDNumber3" - case "QFileDialog": - return "NewQFileDialog3" - case "QUndoView": - return "NewQUndoView4" - case "QGraphicsView": - return "NewQGraphicsView3" - case "QPushButton": - return "NewQPushButton4" - case "QColorDialog": - return "NewQColorDialog3" - case "QMessageBox": - return "NewQMessageBox4" - case "QSplashScreen": - return "NewQSplashScreen3" - case "QErrorMessage": - return "NewQErrorMessage2" - case "QListView": - return "NewQListView2" - case "QDateTimeEdit": - return "NewQDateTimeEdit5" - case "QTimeEdit": - return "NewQTimeEdit3" - case "QDateEdit": - return "NewQDateEdit3" - case "QMenu": - return "NewQMenu3" - case "QToolBox": - return "NewQToolBox2" - case "QTableWidget": - return "NewQTableWidget3" - case "QFocusFrame": - return "NewQFocusFrame2" - case "QHBoxLayout": - return "NewQHBoxLayout2" - case "QVBoxLayout": - return "NewQVBoxLayout2" - case "QInputDialog": - return "NewQInputDialog2" - case "QTableView": - return "NewQTableView2" - case "QMdiArea": - return "NewQMdiArea2" - case "QSpinBox": - return "NewQSpinBox2" - case "QDoubleSpinBox": - return "NewQDoubleSpinBox2" - case "QProgressBar": - return "NewQProgressBar2" - case "QTextEdit": - return "NewQTextEdit3" - case "QAbstractSlider": - return "NewQAbstractSlider2" - case "QDialogButtonBox": - return "NewQDialogButtonBox5" - case "QFontDialog": - return "NewQFontDialog3" - case "QMainWindow": - return "NewQMainWindow2" - case "QCommandLinkButton": - return "NewQCommandLinkButton4" - case "QDial": - return "NewQDial2" - case "QGridLayout": - return "NewQGridLayout" - case "QPlainTextEdit": - return "NewQPlainTextEdit3" - case "QScrollArea": - return "NewQScrollArea2" - case "QGroupBox": - return "NewQGroupBox3" - - // CODEGENERATED LIST END - - default: - // This class is not known to miqt-uic - // Assume it's a user promoted type from Qt Designer with a matching ctor - // of the form New{Class}(parent *QWidget) - return "New" + className - - } - -} diff --git a/cmd/miqt-uic/ui2go.go b/cmd/miqt-uic/ui2go.go index bcfe6a01..1473b451 100644 --- a/cmd/miqt-uic/ui2go.go +++ b/cmd/miqt-uic/ui2go.go @@ -203,7 +203,7 @@ func renderProperties(properties []UiProperty, ret *strings.Builder, targetName, func generateWidget(w UiWidget, parentName string, parentClass string) (string, error) { ret := strings.Builder{} - ctor := constructorFunctionFor(w.Class) + ctor := "New" + w.Class ret.WriteString(` ui.` + w.Name + ` = qt.` + ctor + `(` + qwidgetName(parentName, parentClass) + `) @@ -244,7 +244,7 @@ func generateWidget(w UiWidget, parentName string, parentClass string) (string, // Layout if w.Layout != nil { - ctor := constructorFunctionFor(w.Layout.Class) + ctor := "New" + w.Layout.Class ret.WriteString(` ui.` + w.Layout.Name + ` = qt.` + ctor + `(` + qwidgetName("ui."+w.Name, w.Class) + `)