class ClassWizard
Attributes
firstPage[RW]
secondPage[RW]
thirdPage[RW]
Public Class Methods
new(parent = nil)
click to toggle source
Calls superclass method
SimpleWizard.new
# File examples/dialogs/simplewizard/classwizard.rb, line 32 def initialize(parent = nil) super(parent) setNumPages(3) end
Public Instance Methods
accept()
click to toggle source
Calls superclass method
# File examples/dialogs/simplewizard/classwizard.rb, line 52 def accept() className = @firstPage.classNameLineEdit.text baseClass = @firstPage.baseClassLineEdit.text qobjectMacro = @firstPage.qobjectMacroCheckBox.checked? qobjectCtor = @firstPage.qobjectCtorRadioButton.checked? qwidgetCtor = @firstPage.qwidgetCtorRadioButton.checked? defaultCtor = @firstPage.defaultCtorRadioButton.checked? copyCtor = @firstPage.copyCtorCheckBox.checked? comment = @secondPage.commentCheckBox.checked? protect = @secondPage.protectCheckBox.checked? macroName = @secondPage.macroNameLineEdit.text includeBase = @secondPage.includeBaseCheckBox.checked? baseInclude = @secondPage.baseIncludeLineEdit.text outputDir = @thirdPage.outputDirLineEdit.text header = @thirdPage.headerLineEdit.text implementation = @thirdPage.implementationLineEdit.text block = Qt::ByteArray.new if comment block += "/*\n" block += " " + header + "\n" block += "*/\n" block += "\n" end if protect block += "#ifndef " + macroName + "\n" block += "#define " + macroName + "\n" block += "\n" end if includeBase block += "#include " + baseInclude + "\n" block += "\n" end block += "class " + className if !baseClass.empty? block += " : public " + baseClass end block += "\n" block += "{\n" # qmake ignore Q_OBJECT if qobjectMacro block += " Q_OBJECT\n" block += "\n" end block += "public:\n" if qobjectCtor block += " " + className + "(QObject *parent);\n" elsif qwidgetCtor block += " " + className + "(QWidget *parent);\n" elsif defaultCtor block += " " + className + "();\n" if copyCtor block += " " + className + "(const " + className + " &other);\n" block += "\n" block += " " + className + " &operator=" + "(const " + className + " &other);\n" end end block += "};\n" if protect block += "\n" block += "#endif\n" end headerFile = Qt::File.new(outputDir + "/" + header) if !headerFile.open(Qt::File::WriteOnly | Qt::File::Text) Qt::MessageBox.warning(self, tr("Simple Wizard"), tr( "Cannot write file %s:\n%s" % [ headerFile.fileName(), headerFile.errorString()] ) ) return end headerFile.write(block) block = Qt::ByteArray.new if comment block += "/*\n" block += " " + implementation + "\n" block += "*/\n" block += "\n" end block += "#include \"" + header + "\"\n" block += "\n" if qobjectCtor block += className + "::" + className + "(QObject *parent)\n" block += " : " + baseClass + "(parent)\n" block += "{\n" block += "}\n" elsif qwidgetCtor block += className + "::" + className + "(QWidget *parent)\n" block += " : " + baseClass + "(parent)\n" block += "{\n" block += "}\n" elsif defaultCtor block += className + "::" + className + "()\n" block += "{\n" block += " // missing code\n" block += "}\n" if copyCtor block += "\n" block += className + "::" + className + "(const " + className + " &other)\n" block += "{\n" block += " *this = other;\n" block += "}\n" block += "\n" block += className + " &" + className + "::operator=(const " + className + " &other)\n" block += "{\n" if !baseClass.empty? block += " " + baseClass + "::operator=(other);\n" end block += " // missing code\n" block += " return *this;\n" block += "}\n" end end implementationFile = Qt::File.new(outputDir + "/" + implementation) if !implementationFile.open(Qt::File::WriteOnly | Qt::File::Text) Qt::MessageBox.warning(self, tr("Simple Wizard"), tr("Cannot write file %s:\n%s" % [ implementationFile.fileName(), implementationFile.errorString() ] ) ) return end implementationFile.write(block) super end
createPage(index)
click to toggle source
# File examples/dialogs/simplewizard/classwizard.rb, line 37 def createPage(index) case index when 0 @firstPage = FirstPage.new(self) return @firstPage when 1 @secondPage = SecondPage.new(self) return @secondPage when 2 @thirdPage = ThirdPage.new(self) return @thirdPage end return nil end