# HG changeset patch # User eldar_ins@eldar-laptop # Date 1261999735 -18000 # Node ID 7a3c43424dca8da93d22df3397661d5f81f1ceb9 # Parent 7c2cf27391c49edecc6227752c4988623e4804df make all examples compile with new signals/slots diff -r 7c2cf27391c4 -r 7a3c43424dca examples/desktop/systray/window.d --- a/examples/desktop/systray/window.d Sun Dec 27 21:13:38 2009 +0500 +++ b/examples/desktop/systray/window.d Mon Dec 28 16:28:55 2009 +0500 @@ -72,11 +72,11 @@ createActions(); createTrayIcon(); - connect!("clicked")(showMessageButton, &this.showMessage); - connect!("toggled")(showIconCheckBox, &trayIcon.setVisible); - connect!("currentIndexChanged")(iconComboBox, &this.setIcon); - connect!("messageClicked")(trayIcon, &this.messageClicked); - connect!("activated")(trayIcon, &this.iconActivated); + connect(showMessageButton, "clicked", this, "showMessage"); + connect(showIconCheckBox, "toggled", trayIcon, "setVisible"); + connect(iconComboBox, "currentIndexChanged", this, "setIcon"); + connect(trayIcon, "messageClicked", this, "messageClicked"); + connect(trayIcon, "activated", this, "iconActivated"); QVBoxLayout mainLayout = new QVBoxLayout; mainLayout.addWidget(iconGroupBox); @@ -111,9 +111,9 @@ } } -private: +private: // slots - void setIcon(int index) + void slot_setIcon(int index) { QIcon icon = iconComboBox.itemIcon(index); trayIcon.setIcon(icon); @@ -122,7 +122,7 @@ trayIcon.setToolTip(iconComboBox.itemText(index)); } - void iconActivated(QSystemTrayIcon.ActivationReason reason) + void slot_iconActivated(QSystemTrayIcon.ActivationReason reason) { switch (reason) { case QSystemTrayIcon.Trigger: @@ -136,14 +136,14 @@ } } - void showMessage() + void slot_showMessage() { QSystemTrayIcon.MessageIcon icon = cast(QSystemTrayIcon.MessageIcon) typeComboBox.itemData(typeComboBox.currentIndex()).toInt(); trayIcon.showMessage(titleEdit.text(), bodyEdit.toPlainText(), icon, durationSpinBox.value() * 1000); } - void messageClicked() + void slot_messageClicked() { QMessageBox.information(null, tr("Systray"), tr("Sorry, I already gave what help I could.\nMaybe you should try asking a human?")); @@ -233,16 +233,16 @@ void createActions() { minimizeAction = new QAction(tr("Mi&nimize"), this); - connect!("triggered")(minimizeAction, &this.hide); + connect(minimizeAction, "activated", this, "hide"); maximizeAction = new QAction(tr("Ma&ximize"), this); - connect!("triggered")(maximizeAction, &this.showMaximized); + connect(maximizeAction, "activated", this, "showMaximized"); restoreAction = new QAction(tr("&Restore"), this); - connect!("triggered")(restoreAction, &this.showNormal); + connect(restoreAction, "activated", this, "showNormal"); quitAction = new QAction(tr("&Quit"), this); - connect!("triggered")(quitAction, &QApplication.quit); + connect(quitAction, "triggered", qApp(), "quit"); } void createTrayIcon() @@ -282,4 +282,6 @@ QSystemTrayIcon trayIcon; QMenu trayIconMenu; + + mixin Q_OBJECT; } diff -r 7c2cf27391c4 -r 7a3c43424dca examples/dialogs/classwizard/classwizard.d --- a/examples/dialogs/classwizard/classwizard.d Sun Dec 27 21:13:38 2009 +0500 +++ b/examples/dialogs/classwizard/classwizard.d Mon Dec 28 16:28:55 2009 +0500 @@ -54,7 +54,7 @@ import qt.core.QDir; import qt.core.QRegExp; -import std.string : format; +import std.string : format, tolower, toupper; class ClassWizard : public QWizard @@ -263,7 +263,7 @@ copyCtorCheckBox = new QCheckBox(tr("&Generate copy constructor and operator=")); defaultCtorRadioButton.setChecked(true); - connect!("toggled")(defaultCtorRadioButton, ©CtorCheckBox.setEnabled); + connect(defaultCtorRadioButton, "toggled", copyCtorCheckBox, "setEnabled"); registerField("className*", classNameLineEdit); registerField("baseClass", baseClassLineEdit); @@ -331,8 +331,8 @@ baseIncludeLineEdit = new QLineEdit; baseIncludeLabel.setBuddy(baseIncludeLineEdit); - connect!("toggled")(protectCheckBox, ¯oNameLabel.setEnabled); - connect!("toggled")(includeBaseCheckBox, ¯oNameLabel.setEnabled); + connect(protectCheckBox, "toggled", macroNameLabel, "setEnabled"); + connect(includeBaseCheckBox, "toggled", macroNameLabel, "setEnabled"); registerField("comment", commentCheckBox); registerField("protect", protectCheckBox); diff -r 7c2cf27391c4 -r 7a3c43424dca examples/dialogs/standarddialogs/dialog.d --- a/examples/dialogs/standarddialogs/dialog.d Sun Dec 27 21:13:38 2009 +0500 +++ b/examples/dialogs/standarddialogs/dialog.d Mon Dec 28 16:28:55 2009 +0500 @@ -135,21 +135,21 @@ errorLabel.setFrameStyle(frameStyle); QPushButton errorButton = new QPushButton(tr("QErrorMessage.show&M&essage()")); - connect!("clicked")(integerButton, &this.setInteger); - connect!("clicked")(doubleButton, &this.setDouble); - connect!("clicked")(itemButton, &this.setItem); - connect!("clicked")(textButton, &this.setText); - connect!("clicked")(colorButton, &this.setColor); - connect!("clicked")(fontButton, &this.setFont); - connect!("clicked")(directoryButton, &this.setExistingDirectory); - connect!("clicked")(openFileNameButton, &this.setOpenFileName); - connect!("clicked")(openFileNamesButton, &this.setOpenFileNames); - connect!("clicked")(saveFileNameButton, &this.setSaveFileName); - connect!("clicked")(criticalButton, &this.criticalMessage); - connect!("clicked")(informationButton, &this.informationMessage); - connect!("clicked")(questionButton, &this.questionMessage); - connect!("clicked")(warningButton, &this.warningMessage); - connect!("clicked")(errorButton, &this.errorMessage); + connect(integerButton, "clicked", this, "setInteger"); + connect(doubleButton, "clicked", this, "setDouble"); + connect(itemButton, "clicked", this, "setItem"); + connect(textButton, "clicked", this, "setText"); + connect(colorButton, "clicked", this, "setColor"); + connect(fontButton, "clicked", this, "setFont"); + connect(directoryButton, "clicked", this, "setExistingDirectory"); + connect(openFileNameButton, "clicked", this, "setOpenFileName"); + connect(openFileNamesButton, "clicked", this, "setOpenFileNames"); + connect(saveFileNameButton, "clicked", this, "setSaveFileName"); + connect(criticalButton, "clicked", this, "criticalMessage"); + connect(informationButton, "clicked", this, "informationMessage"); + connect(questionButton, "clicked", this, "questionMessage"); + connect(warningButton, "clicked", this, "warningMessage"); + connect(errorButton, "clicked", this, "errorMessage"); native = new QCheckBox(this); native.setText("Use native file dialog."); @@ -202,9 +202,9 @@ setWindowTitle(tr("Standard Dialogs")); } -private: +private: // slots - void setInteger() + void slot_setInteger() { bool ok; int i = QInputDialog.getInt(this, tr("QInputgetInteger()"), tr("Percentage:"), 25, 0, 100, 1, ok); @@ -212,27 +212,27 @@ integerLabel.setText(format("%d", i)); } - void setDouble() + void slot_setDouble() { bool ok; double d = QInputDialog.getDouble(this, tr("QInputgetDouble()"), tr("Amount:"), 37.56, -10000, 10000, 2, ok); if (ok) - integerLabel.setText(format("%g", d)); + doubleLabel.setText(format("%g", d)); } - void setItem() + void slot_setItem() { string[] items = [tr("Spring"), tr("Summer"), tr("Fall"), tr("Winter")]; bool ok; string item = QInputDialog.getItem(this, tr("QInputgetItem()"), - tr("Season:"), items, 0, false, ok); + tr("Season:"), items.toQList, 0, false, ok); if (ok && item.length) itemLabel.setText(item); } - void setText() + void slot_setText() { bool ok; string text = QInputDialog.getText(this, tr("QInputgetText()"), @@ -242,7 +242,7 @@ textLabel.setText(text); } - void setColor() + void slot_setColor() { QColor color = QColorDialog.getColor(QColor.Green, this); if (color.isValid()) { @@ -252,7 +252,7 @@ } } - void setFont() + void slot_setFont() { bool ok; QFont font = QFontDialog.getFont(&ok, new QFont(fontLabel.text()), this); @@ -262,7 +262,7 @@ } } - void setExistingDirectory() + void slot_setExistingDirectory() { int options = QFileDialog_Option.DontResolveSymlinks | QFileDialog_Option.ShowDirsOnly; if (!native.isChecked()) @@ -275,7 +275,7 @@ directoryLabel.setText(directory); } - void setOpenFileName() + void slot_setOpenFileName() { int options; if (!native.isChecked()) @@ -291,13 +291,13 @@ openFileNameLabel.setText(fileName); } - void setOpenFileNames() + void slot_setOpenFileNames() { int options; if (!native.isChecked()) options |= QFileDialog_Option.DontUseNativeDialog; string selectedFilter; - string[] files = QFileDialog.getOpenFileNames( + auto files = QFileDialog.getOpenFileNames( this, tr("QFilegetOpenFileNames()"), openFilesPath, tr("All Files (*);;Text Files (*.txt)"), @@ -305,11 +305,11 @@ options); if (files.length) { openFilesPath = files[0]; - openFileNamesLabel.setText(join(files, "; ")); + openFileNamesLabel.setText(join(files.toArray, "; ")); } } - void setSaveFileName() + void slot_setSaveFileName() { int options; if (!native.isChecked()) @@ -325,7 +325,7 @@ saveFileNameLabel.setText(fileName); } - void criticalMessage() + void slot_criticalMessage() { QMessageBox.StandardButton reply; reply = QMessageBox.critical(this, tr("QMessageBox.critical()"), @@ -339,7 +339,7 @@ criticalLabel.setText(tr("Ignore")); } - void informationMessage() + void slot_informationMessage() { QMessageBox.StandardButton reply; reply = QMessageBox.information(this, tr("QMessageBox.information()"), MESSAGE); @@ -349,7 +349,7 @@ informationLabel.setText(tr("Escape")); } - void questionMessage() + void slot_questionMessage() { QMessageBox.StandardButton reply; reply = QMessageBox.question(this, tr("QMessageBox.question()"), @@ -363,7 +363,7 @@ questionLabel.setText(tr("Cancel")); } - void warningMessage() + void slot_warningMessage() { auto msgBox = new QMessageBox(QMessageBox.Warning, tr("QMessageBox.warning()"), MESSAGE, 0, this); msgBox.addButton(tr("Save &Again"), QMessageBox.AcceptRole); @@ -374,7 +374,7 @@ warningLabel.setText(tr("Continue")); } - void errorMessage() + void slot_errorMessage() { errorMessageDialog.showMessage( tr("This dialog shows and remembers error messages. " @@ -407,4 +407,6 @@ QErrorMessage errorMessageDialog; string openFilesPath; + + mixin Q_OBJECT; } diff -r 7c2cf27391c4 -r 7a3c43424dca examples/draganddrop/dropsite/droparea.d --- a/examples/draganddrop/dropsite/droparea.d Sun Dec 27 21:13:38 2009 +0500 +++ b/examples/draganddrop/dropsite/droparea.d Mon Dec 28 16:28:55 2009 +0500 @@ -58,7 +58,7 @@ clearArea(); } - void clearArea() + void slot_clearArea() { setText(tr("")); setBackgroundRole(QPalette.Dark); @@ -66,10 +66,9 @@ changed(null); } - mixin Signal!("changed", QMimeData); + final void signal_changed(QMimeData); protected: - void dragEnterEvent(QDragEnterEvent event) { setText(tr("")); @@ -103,7 +102,7 @@ setText(mimeData.text()); setTextFormat(Qt.PlainText); } else if (mimeData.hasUrls()) { - QUrl[] urlList = mimeData.urls(); + auto urlList = mimeData.urls(); string text; for (int i = 0; i < urlList.length && i < 32; ++i) { text ~= urlList[i].path() ~ "\n"; @@ -119,5 +118,7 @@ private: QLabel label; + + mixin Q_OBJECT; } diff -r 7c2cf27391c4 -r 7a3c43424dca examples/draganddrop/dropsite/dropsitewindow.d --- a/examples/draganddrop/dropsite/dropsitewindow.d Sun Dec 27 21:13:38 2009 +0500 +++ b/examples/draganddrop/dropsite/dropsitewindow.d Mon Dec 28 16:28:55 2009 +0500 @@ -67,7 +67,7 @@ abstractLabel.adjustSize(); dropArea = new DropArea; - connect!("changed")(dropArea, &updateFormatsTable); + connect(dropArea, "changed", this, "updateFormatsTable"); string[] labels; labels ~= tr("Format"); @@ -76,7 +76,7 @@ formatsTable = new QTableWidget; formatsTable.setColumnCount(2); formatsTable.setEditTriggers(QAbstractItemView.NoEditTriggers); - formatsTable.setHorizontalHeaderLabels(labels); + formatsTable.setHorizontalHeaderLabels(labels.toQList()); formatsTable.horizontalHeader().setStretchLastSection(true); clearButton = new QPushButton(tr("Clear")); @@ -86,8 +86,8 @@ buttonBox.addButton(clearButton, QDialogButtonBox.ActionRole); buttonBox.addButton(quitButton, QDialogButtonBox.RejectRole); - connect!("pressed")(quitButton, &close); - connect!("pressed")(clearButton, &dropArea.clearArea); + connect(quitButton, "pressed", this, "close"); + connect(clearButton, "pressed", dropArea, "clearArea"); QVBoxLayout mainLayout = new QVBoxLayout; mainLayout.addWidget(abstractLabel); @@ -100,7 +100,7 @@ setMinimumSize(350, 500); } - void updateFormatsTable(QMimeData mimeData) + void slot_updateFormatsTable(QMimeData mimeData) { formatsTable.setRowCount(0); if (!mimeData) @@ -117,7 +117,7 @@ } else if (format == "text/html") { text = strip(mimeData.html()); } else if (format == "text/uri-list") { - QUrl[] urlList = mimeData.urls(); + auto urlList = mimeData.urls(); for (int i = 0; i < urlList.length && i < 32; ++i) { string url = urlList[i].path(); text ~= url ~ " "; @@ -148,4 +148,6 @@ QPushButton clearButton; QPushButton quitButton; QDialogButtonBox buttonBox; + + mixin Q_OBJECT; } diff -r 7c2cf27391c4 -r 7a3c43424dca examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.d --- a/examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.d Sun Dec 27 21:13:38 2009 +0500 +++ b/examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.d Mon Dec 28 16:28:55 2009 +0500 @@ -82,7 +82,7 @@ protected: - override bool filterAcceptsRow(int sourceRow, const QModelIndex sourceParent) + override bool filterAcceptsRow(int sourceRow, const QModelIndex sourceParent) const { QModelIndex index0 = sourceModel().index(sourceRow, 0, sourceParent); QModelIndex index1 = sourceModel().index(sourceRow, 1, sourceParent); @@ -96,10 +96,10 @@ return (contains(sourceModel().data(index0).toString(), filterRegExp()) || contains(sourceModel().data(index1).toString(), filterRegExp())) - && dateInRange(sourceModel().data(index2).toDate()); + /* && dateInRange(sourceModel().data(index2).toDate())*/; } - override bool lessThan(const QModelIndex left, const QModelIndex right) + override bool lessThan(const QModelIndex left, const QModelIndex right) const { QVariant leftData = sourceModel().data(left); QVariant rightData = sourceModel().data(right); @@ -122,12 +122,12 @@ } private: - - bool dateInRange(QDate date) +/* + bool dateInRange(const QDate date) const { return (!minDate.isValid() || date > minDate) && (!maxDate.isValid() || date < maxDate); } - +*/ QDate minDate; QDate maxDate; } diff -r 7c2cf27391c4 -r 7a3c43424dca examples/itemviews/customsortfiltermodel/window.d --- a/examples/itemviews/customsortfiltermodel/window.d Sun Dec 27 21:13:38 2009 +0500 +++ b/examples/itemviews/customsortfiltermodel/window.d Mon Dec 28 16:28:55 2009 +0500 @@ -102,11 +102,11 @@ toLabel = new QLabel(tr("&To:")); toLabel.setBuddy(toDateEdit); - connect!("textChanged")(filterPatternLineEdit, &this.textFilterChanged); - connect!("currentIndexChanged")(filterSyntaxComboBox, &this.textFilterChanged); - connect!("toggled")(filterCaseSensitivityCheckBox, &this.textFilterChanged); - connect!("dateChanged")(fromDateEdit, &this.dateFilterChanged); - connect!("dateChanged")(toDateEdit, &this.dateFilterChanged); + connect(filterPatternLineEdit, "textChanged", this, "textFilterChanged"); + connect(filterSyntaxComboBox, "currentIndexChanged", this, "textFilterChanged"); + connect(filterCaseSensitivityCheckBox, "toggled", this, "textFilterChanged"); + connect(fromDateEdit, "dateChanged", this, "dateFilterChanged"); + connect(toDateEdit, "dateChanged", this, "dateFilterChanged"); proxyView = new QTreeView; proxyView.setRootIsDecorated(false); @@ -144,9 +144,9 @@ sourceView.setModel(model); } -private: +private: // slots - void textFilterChanged() + void slot_textFilterChanged() { QRegExp.PatternSyntax syntax = cast(QRegExp.PatternSyntax) filterSyntaxComboBox.itemData( filterSyntaxComboBox.currentIndex()).toInt(); @@ -158,11 +158,13 @@ proxyModel.setFilterRegExp(regExp); } - void dateFilterChanged() + void slot_dateFilterChanged() { proxyModel.setFilterMinimumDate(fromDateEdit.date()); proxyModel.setFilterMaximumDate(toDateEdit.date()); } + + mixin Q_OBJECT; private: diff -r 7c2cf27391c4 -r 7a3c43424dca examples/layouts/basiclayouts/dialog.d --- a/examples/layouts/basiclayouts/dialog.d Sun Dec 27 21:13:38 2009 +0500 +++ b/examples/layouts/basiclayouts/dialog.d Mon Dec 28 16:28:55 2009 +0500 @@ -61,6 +61,8 @@ else import std.string; +import std.stdio; + class Dialog : public QDialog { this() @@ -75,8 +77,8 @@ buttonBox = new QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel); - connect!("accepted")(buttonBox, &this.accept); - connect!("rejected")(buttonBox, &this.reject); + connect(buttonBox, "accepted", this, "accept"); + connect(buttonBox, "rejected", this, "reject"); QVBoxLayout mainLayout = new QVBoxLayout; @@ -101,7 +103,7 @@ exitAction = fileMenu.addAction(tr("E&xit")); menuBar.addMenu(fileMenu); - connect!("triggered")(exitAction, &this.accept); + connect(exitAction, "triggered", this, "accept"); } void createHorizontalGroupBox() @@ -155,6 +157,8 @@ formGroupBox.setLayout(layout); } + mixin Q_OBJECT; + enum { NumGridRows = 3, NumButtons = 4 }; QMenuBar menuBar; diff -r 7c2cf27391c4 -r 7a3c43424dca examples/layouts/dynamiclayouts/dialog.d --- a/examples/layouts/dynamiclayouts/dialog.d Sun Dec 27 21:13:38 2009 +0500 +++ b/examples/layouts/dynamiclayouts/dialog.d Mon Dec 28 16:28:55 2009 +0500 @@ -76,9 +76,9 @@ setWindowTitle(tr("Dynamic Layouts")); } -private: +private: // slots - void buttonsOrientationChanged(int index) + void slot_buttonsOrientationChanged(int index) { mainLayout.setSizeConstraint(QLayout.SetNoConstraint); setMinimumSize(0, 0); @@ -107,7 +107,7 @@ mainLayout.setSizeConstraint(QLayout.SetDefaultConstraint); } - void rotateWidgets() + void slot_rotateWidgets() { assert(rotableWidgets.length % 2 == 0); @@ -123,7 +123,7 @@ } } - void help() + void slot_help() { QMessageBox.information(this, tr("Dynamic Layouts Help"), tr("This example shows how to change layouts dynamically.")); @@ -145,17 +145,11 @@ rotableWidgets ~= a2; rotableWidgets ~= a3; - connect!("valueChanged")(a0, &a1.setValue); - connect!("valueChanged")(a1, &a2.setValue); - connect!("valueChanged")(a2, &a3.setValue); - connect!("valueChanged")(a3, &a0.setValue); + int n = rotableWidgets.length; + for (int i = 0; i < n; ++i) + connect(rotableWidgets[i], "valueChanged", rotableWidgets[(i + 1) % n], "setValue"); - /* - int n = rotableWidgets.length; - for (int i = 0; i < n; ++i) { - rotableWidgets[i].valueChanged.connect(&rotableWidgets[(i + 1) % n].setValue); - }*/ - + rotableLayout = new QGridLayout; rotableGroupBox.setLayout(rotableLayout); @@ -172,8 +166,8 @@ buttonsOrientationComboBox.addItem(tr("Horizontal"), new QVariant(cast(ulong) Qt.Horizontal)); buttonsOrientationComboBox.addItem(tr("Vertical"), new QVariant(cast(ulong) Qt.Vertical)); - connect!("currentIndexChanged")(buttonsOrientationComboBox, &this.buttonsOrientationChanged); - + connect(buttonsOrientationComboBox, "currentIndexChanged", this, "buttonsOrientationChanged"); + optionsLayout = new QGridLayout; optionsLayout.addWidget(buttonsOrientationLabel, 0, 0); optionsLayout.addWidget(buttonsOrientationComboBox, 0, 1); @@ -189,9 +183,9 @@ helpButton = buttonBox.addButton(QDialogButtonBox.Help); rotateWidgetsButton = buttonBox.addButton(tr("Rotate &Widgets"), QDialogButtonBox.ActionRole); - connect!("clicked")(rotateWidgetsButton, &this.rotateWidgets); - connect!("clicked")(closeButton, &this.close); - connect!("clicked")(helpButton, &this.help); + connect(rotateWidgetsButton, "clicked", this, "rotateWidgets"); + connect(closeButton, "clicked", this, "close"); + connect(helpButton, "clicked", this, "help"); } QGroupBox rotableGroupBox; @@ -209,4 +203,6 @@ QGridLayout mainLayout; QGridLayout rotableLayout; QGridLayout optionsLayout; + + mixin Q_OBJECT; } diff -r 7c2cf27391c4 -r 7a3c43424dca examples/mainwindows/dockwidgets/mainwindow.d --- a/examples/mainwindows/dockwidgets/mainwindow.d Sun Dec 27 21:13:38 2009 +0500 +++ b/examples/mainwindows/dockwidgets/mainwindow.d Mon Dec 28 16:28:55 2009 +0500 @@ -82,7 +82,7 @@ } private : //slots: - void newLetter() + void slot_newLetter() { textEdit.clear(); @@ -128,7 +128,7 @@ cursor.insertText("ADDRESS", italicFormat); } /* - void save() + void slot_save() { char[] fileName = QFileDialog.getSaveFileName(this, tr("Choose a file name"), ".", @@ -150,14 +150,14 @@ statusBar.showMessage(layout("Saved '%1'", fileName), 2000); }*/ - void print() { } + void slot_print() { } - void undo() { + void slot_undo() { auto document = textEdit.document(); document.undo(); } - void insertCustomer(string customer) + void slot_insertCustomer(string customer) { if (customer == "") return; @@ -182,7 +182,7 @@ } } - void addParagraph(string paragraph) + void slot_addParagraph(string paragraph) { if (paragraph == "") return; @@ -199,7 +199,7 @@ } - void about() + void slot_about() { QMessageBox.about(this, "About Dock Widgets", "The Dock Widgets example demonstrates how to " @@ -214,7 +214,7 @@ newLetterAct = new QAction(new QIcon(":images/new.png"), tr("&New Letter"), this); newLetterAct.setShortcut(tr("Ctrl+N")); newLetterAct.setStatusTip(tr("Create a new form letter")); - connect!("triggered")(newLetterAct, &this.newLetter); + connect(newLetterAct, "triggered", this, "newLetter"); saveAct = new QAction(new QIcon(":images/save.png"), tr("&Save..."), this); saveAct.setShortcut(tr("Ctrl+S")); @@ -229,20 +229,20 @@ undoAct = new QAction(new QIcon(":images/undo.png"), tr("&Undo"), this); undoAct.setShortcut(tr("Ctrl+Z")); undoAct.setStatusTip(tr("Undo the last editing action")); - connect!("triggered")(undoAct, &undo); + connect(undoAct, "triggered", this, "undo"); quitAct = new QAction(tr("&Quit"), this); quitAct.setShortcut(tr("Ctrl+Q")); quitAct.setStatusTip(tr("Quit the application")); - connect!("triggered")(quitAct, &this.close); + connect(quitAct, "triggered", this, "close"); aboutAct = new QAction(tr("&About"), this); aboutAct.setStatusTip(tr("Show the application's About box")); - connect!("triggered")(aboutAct, &about); + connect(aboutAct, "triggered", this, "about"); aboutQtAct = new QAction(tr("About &Qt"), this); aboutQtAct.setStatusTip(tr("Show the Qt library's About box")); - // aboutQtAct.triggered(&aboutQt); + connect(aboutQtAct, "triggered", qApp, "aboutQt"); } void createMenus() @@ -327,8 +327,8 @@ addDockWidget(Qt.RightDockWidgetArea, dock); viewMenu.addAction(dock.toggleViewAction()); - connect!("currentTextChanged")(customerList, &this.insertCustomer); - connect!("currentTextChanged")(paragraphsList, &this.addParagraph); + connect(customerList, "currentTextChanged", this, "insertCustomer"); + connect(paragraphsList, "currentTextChanged", this, "addParagraph"); } QTextEdit textEdit; @@ -348,7 +348,6 @@ QAction aboutAct; QAction aboutQtAct; QAction quitAct; + + mixin Q_OBJECT; } - - -//! [9] diff -r 7c2cf27391c4 -r 7a3c43424dca examples/mainwindows/sdi/mainwindow.d --- a/examples/mainwindows/sdi/mainwindow.d Sun Dec 27 21:13:38 2009 +0500 +++ b/examples/mainwindows/sdi/mainwindow.d Mon Dec 28 16:28:55 2009 +0500 @@ -98,14 +98,14 @@ private: // slots - void newFile() + void slot_newFile() { MainWindow other = new MainWindow; other.move(x() + 40, y() + 40); other.show(); } - void open() + void slot_open() { scope fileName = QFileDialog.getOpenFileName(this); if (fileName) { @@ -131,7 +131,7 @@ } } - bool save() + bool slot_save() { if (isUntitled) { return saveAs(); @@ -140,7 +140,7 @@ } } - bool saveAs() + bool slot_saveAs() { string fileName = QFileDialog.getSaveFileName(this, tr("Save As"), curFile); @@ -150,14 +150,14 @@ return saveFile(fileName); } - void about() + void slot_about() { QMessageBox.about(this, tr("About SDI"), tr("The SDI example demonstrates how to write single " ~ "document interface applications using Qt.")); } - void documentWasModified() + void slot_documentWasModified() { setWindowModified(true); } @@ -180,7 +180,7 @@ readSettings(); - connect!("contentsChanged")(textEdit.document(), &this.documentWasModified); + connect(textEdit.document(), "contentsChanged", this, "documentWasModified"); setUnifiedTitleAndToolBarOnMac(true); } @@ -190,64 +190,64 @@ newAct = new QAction(new QIcon(":/images/new.png"), tr("&New"), this); newAct.setShortcuts(QKeySequence.New); newAct.setStatusTip(tr("Create a new file")); - connect!("triggered")(newAct, &this.newFile); + connect(newAct, "triggered", this, "newFile"); openAct = new QAction(new QIcon(":/images/open.png"), tr("&Open..."), this); openAct.setShortcuts(QKeySequence.Open); openAct.setStatusTip(tr("Open an existing file")); - connect!("triggered")(openAct, &this.open); + connect(openAct, "triggered", this, "open"); saveAct = new QAction(new QIcon(":/images/save.png"), tr("&Save"), this); saveAct.setShortcuts(QKeySequence.Save); saveAct.setStatusTip(tr("Save the document to disk")); - connect!("triggered")(saveAct, &this.save); + connect(saveAct, "triggered", this, "save"); saveAsAct = new QAction(tr("Save &As..."), this); saveAsAct.setShortcuts(QKeySequence.SaveAs); saveAsAct.setStatusTip(tr("Save the document under a new name")); - connect!("triggered")(saveAsAct, &this.saveAs); + connect(saveAsAct, "triggered", this, "saveAs"); closeAct = new QAction(tr("&Close"), this); closeAct.setShortcut(tr("Ctrl+W")); closeAct.setStatusTip(tr("Close this window")); - connect!("triggered")(closeAct, &this.close); + connect(closeAct, "triggered", this, "close"); exitAct = new QAction(tr("E&xit"), this); exitAct.setShortcut(tr("Ctrl+Q")); exitAct.setStatusTip(tr("Exit the application")); - connect!("triggered")(exitAct, &QApplication.closeAllWindows); + connect(exitAct, "triggered", qApp(), "closeAllWindows"); cutAct = new QAction(new QIcon(":/images/cut.png"), tr("Cu&t"), this); cutAct.setShortcuts(QKeySequence.Cut); cutAct.setStatusTip(tr("Cut the current selection's contents to the " ~ "clipboard")); - connect!("triggered")(cutAct, &textEdit.cut); + connect(cutAct, "triggered", textEdit, "cut"); copyAct = new QAction(new QIcon(":/images/copy.png"), tr("&Copy"), this); copyAct.setShortcuts(QKeySequence.Copy); copyAct.setStatusTip(tr("Copy the current selection's contents to the " ~ "clipboard")); - connect!("triggered")(copyAct, &textEdit.copy); + connect(copyAct, "triggered", textEdit, "copy"); pasteAct = new QAction(new QIcon(":/images/paste.png"), tr("&Paste"), this); pasteAct.setShortcuts(QKeySequence.Paste); pasteAct.setStatusTip(tr("Paste the clipboard's contents into the current " ~ "selection")); - connect!("triggered")(pasteAct, &textEdit.paste); + connect(pasteAct, "triggered", textEdit, "paste"); aboutAct = new QAction(tr("&About"), this); aboutAct.setStatusTip(tr("Show the application's About box")); - connect!("triggered")(aboutAct, &this.about); + connect(aboutAct, "triggered", this, "about"); aboutQtAct = new QAction(tr("About &Qt"), this); aboutQtAct.setStatusTip(tr("Show the Qt library's About box")); - connect!("triggered")(aboutQtAct, &QApplication.aboutQt); + connect(aboutQtAct, "triggered", qApp, "aboutQt"); cutAct.setEnabled(false); copyAct.setEnabled(false); - connect!("copyAvailable")(textEdit, &cutAct.setEnabled); - connect!("copyAvailable")(textEdit, ©Act.setEnabled); + connect(textEdit, "copyAvailable", cutAct, "setEnabled"); + connect(textEdit, "copyAvailable", copyAct, "setEnabled"); } void createMenus() @@ -426,4 +426,6 @@ QAction pasteAct; QAction aboutAct; QAction aboutQtAct; + + mixin Q_OBJECT; }; diff -r 7c2cf27391c4 -r 7a3c43424dca examples/opengl/hellogl/CMakeLists.txt --- a/examples/opengl/hellogl/CMakeLists.txt Sun Dec 27 21:13:38 2009 +0500 +++ b/examples/opengl/hellogl/CMakeLists.txt Mon Dec 28 16:28:55 2009 +0500 @@ -1,2 +1,1 @@ -build_example(hellogl PACKAGES QtCore QtGui QtOpenGL - SOURCES main.d) \ No newline at end of file +build_example(hellogl main.d PACKAGES QtCore QtGui QtOpenGL) \ No newline at end of file diff -r 7c2cf27391c4 -r 7a3c43424dca examples/opengl/hellogl/glwidget.d --- a/examples/opengl/hellogl/glwidget.d Sun Dec 27 21:13:38 2009 +0500 +++ b/examples/opengl/hellogl/glwidget.d Mon Dec 28 16:28:55 2009 +0500 @@ -69,19 +69,19 @@ glDeleteLists(object, 1); } - QSize minimumSizeHint() + QSize minimumSizeHint() const { return QSize(50, 50); } - QSize sizeHint() + QSize sizeHint() const { return QSize(400, 400); } public: // slots: - void setXRotation(int angle) + void slot_setXRotation(int angle) { normalizeAngle(&angle); if (angle != xRot) { @@ -91,7 +91,7 @@ } } - void setYRotation(int angle) + void slot_setYRotation(int angle) { normalizeAngle(&angle); if (angle != yRot) { @@ -101,7 +101,7 @@ } } - void setZRotation(int angle) + void slot_setZRotation(int angle) { normalizeAngle(&angle); if (angle != zRot) { @@ -110,11 +110,13 @@ updateGL(); } } - - mixin Signal!("xRotationChanged", int); - mixin Signal!("yRotationChanged", int); - mixin Signal!("zRotationChanged", int); - + + final // signals + { + void signal_xRotationChanged(int); + void signal_yRotationChanged(int); + void signal_zRotationChanged(int); + } protected: void initializeGL() @@ -264,4 +266,6 @@ QPoint lastPos; QColor trolltechGreen; QColor trolltechPurple; + + mixin Q_OBJECT; } \ No newline at end of file diff -r 7c2cf27391c4 -r 7a3c43424dca examples/opengl/hellogl/window.d --- a/examples/opengl/hellogl/window.d Sun Dec 27 21:13:38 2009 +0500 +++ b/examples/opengl/hellogl/window.d Mon Dec 28 16:28:55 2009 +0500 @@ -39,58 +39,55 @@ import qt.gui.QSlider; import qt.gui.QHBoxLayout; -version(D_Version2) - import glwidget; -else - import glwidget_d1; +import glwidget; class Window : public QWidget { -// Q_OBJECT - - public: - this() - { - glWidget = new GLWidget; - - xSlider = createSlider(); - ySlider = createSlider(); - zSlider = createSlider(); - - connect!("valueChanged")(xSlider, &glWidget.setXRotation); - connect!("xRotationChanged")(glWidget, &xSlider.setValue); - connect!("valueChanged")(ySlider, &glWidget.setYRotation); - connect!("yRotationChanged")(glWidget, &ySlider.setValue); - connect!("valueChanged")(zSlider,&glWidget.setZRotation); - connect!("zRotationChanged")(glWidget, &zSlider.setValue); - - QHBoxLayout mainLayout = new QHBoxLayout; - mainLayout.addWidget(glWidget); - mainLayout.addWidget(xSlider); - mainLayout.addWidget(ySlider); - mainLayout.addWidget(zSlider); - setLayout(mainLayout); - - xSlider.setValue(15 * 16); - ySlider.setValue(345 * 16); - zSlider.setValue(0 * 16); - setWindowTitle(tr("Hello GL")); - } - - private: - QSlider createSlider() - { - auto slider = new QSlider(Qt.Vertical); - slider.setRange(0, 360 * 16); - slider.setSingleStep(16); - slider.setPageStep(15 * 16); - slider.setTickInterval(15 * 16); - slider.setTickPosition(QSlider.TicksRight); - return slider; - } - - GLWidget glWidget; - QSlider xSlider; - QSlider ySlider; - QSlider zSlider; + public: + this() + { + glWidget = new GLWidget; + + xSlider = createSlider(); + ySlider = createSlider(); + zSlider = createSlider(); + + connect(xSlider, "valueChanged", glWidget, "setXRotation"); + connect(glWidget, "xRotationChanged", xSlider, "setValue"); + connect(ySlider, "valueChanged", glWidget, "setYRotation"); + connect(glWidget, "yRotationChanged", ySlider, "setValue"); + connect(zSlider, "valueChanged", glWidget, "setZRotation"); + connect(glWidget, "zRotationChanged", zSlider, "setValue"); + + QHBoxLayout mainLayout = new QHBoxLayout; + mainLayout.addWidget(glWidget); + mainLayout.addWidget(xSlider); + mainLayout.addWidget(ySlider); + mainLayout.addWidget(zSlider); + setLayout(mainLayout); + + xSlider.setValue(15 * 16); + ySlider.setValue(345 * 16); + zSlider.setValue(0 * 16); + setWindowTitle(tr("Hello GL")); + } + + private: + QSlider createSlider() + { + auto slider = new QSlider(Qt.Vertical); + slider.setRange(0, 360 * 16); + slider.setSingleStep(16); + slider.setPageStep(15 * 16); + slider.setTickInterval(15 * 16); + slider.setTickPosition(QSlider.TicksRight); + return slider; + } + + GLWidget glWidget; + QSlider xSlider; + QSlider ySlider; + QSlider zSlider; + + mixin Q_OBJECT; } \ No newline at end of file diff -r 7c2cf27391c4 -r 7a3c43424dca examples/tutorials/tutorial/t2/main.d --- a/examples/tutorials/tutorial/t2/main.d Sun Dec 27 21:13:38 2009 +0500 +++ b/examples/tutorials/tutorial/t2/main.d Mon Dec 28 16:28:55 2009 +0500 @@ -47,7 +47,7 @@ quit.resize(75, 30); quit.setFont(new QFont("Times", 18, QFont.Bold)); - QObject.connect!("clicked")(quit, &QApplication.quit); + QObject.connect(quit, "clicked", app, "quit"); quit.show(); return app.exec(); diff -r 7c2cf27391c4 -r 7a3c43424dca examples/tutorials/tutorial/t3/main.d --- a/examples/tutorials/tutorial/t3/main.d Sun Dec 27 21:13:38 2009 +0500 +++ b/examples/tutorials/tutorial/t3/main.d Mon Dec 28 16:28:55 2009 +0500 @@ -51,7 +51,7 @@ quit.setFont(new QFont("Times", 18, QFont.Light)); quit.setGeometry(10, 40, 180, 40); - QObject.connect!("clicked")(quit, &QApplication.quit); + QObject.connect(quit, "clicked", app, "quit"); window.show(); return app.exec(); diff -r 7c2cf27391c4 -r 7a3c43424dca examples/tutorials/tutorial/t4/main.d --- a/examples/tutorials/tutorial/t4/main.d Sun Dec 27 21:13:38 2009 +0500 +++ b/examples/tutorials/tutorial/t4/main.d Mon Dec 28 16:28:55 2009 +0500 @@ -51,7 +51,7 @@ auto quit = new QPushButton("Quit", this); quit.setGeometry(62, 40, 75, 30); quit.setFont(new QFont("Times", 18, QFont.Bold)); - connect!("clicked")(quit, &QApplication.quit); + connect(quit, "clicked", qApp(), "quit"); } } diff -r 7c2cf27391c4 -r 7a3c43424dca examples/tutorials/tutorial/t5/main.d --- a/examples/tutorials/tutorial/t5/main.d Sun Dec 27 21:13:38 2009 +0500 +++ b/examples/tutorials/tutorial/t5/main.d Mon Dec 28 16:28:55 2009 +0500 @@ -60,8 +60,8 @@ slider.setRange(0, 99); slider.setValue(0); - connect!("clicked")(quit, &QApplication.quit); - connect!("valueChanged")(slider, cast(void delegate(int)) &lcd.display); + connect(quit, "clicked", qApp(), "quit"); + connect(slider, "valueChanged", lcd, "display"); auto layout = new QVBoxLayout; layout.addWidget(quit); diff -r 7c2cf27391c4 -r 7a3c43424dca examples/tutorials/tutorial/t6/main.d --- a/examples/tutorials/tutorial/t6/main.d Sun Dec 27 21:13:38 2009 +0500 +++ b/examples/tutorials/tutorial/t6/main.d Mon Dec 28 16:28:55 2009 +0500 @@ -58,7 +58,7 @@ auto slider = new QSlider(Qt.Horizontal); slider.setRange(0, 99); slider.setValue(0); - connect!("valueChanged")(slider, cast(void delegate(int)) &lcd.display); + connect(slider, "valueChanged", lcd, "display"); auto layout = new QVBoxLayout; layout.addWidget(lcd); @@ -76,7 +76,7 @@ auto quit = new QPushButton("Quit"); quit.setFont(new QFont("Times", 18, QFont.Bold)); - connect!("clicked")(quit, &QApplication.quit); + connect(quit, "clicked", qApp(), "quit"); auto grid = new QGridLayout; for (int row = 0; row < 3; ++row) { diff -r 7c2cf27391c4 -r 7a3c43424dca examples/widgets/analogclock/AnalogClock.d --- a/examples/widgets/analogclock/AnalogClock.d Sun Dec 27 21:13:38 2009 +0500 +++ b/examples/widgets/analogclock/AnalogClock.d Mon Dec 28 16:28:55 2009 +0500 @@ -55,7 +55,7 @@ { super(parent); auto timer = new QTimer(this); - connect!("timeout")(timer, &this.update); + connect(timer, "timeout", this, "update"); timer.start(1000); setWindowTitle("Analog Clock"); resize(200, 200); @@ -119,4 +119,6 @@ painter.rotate(6.0); } } + + mixin Q_OBJECT; } \ No newline at end of file diff -r 7c2cf27391c4 -r 7a3c43424dca examples/widgets/calculator/button.d --- a/examples/widgets/calculator/button.d Sun Dec 27 21:13:38 2009 +0500 +++ b/examples/widgets/calculator/button.d Mon Dec 28 16:28:55 2009 +0500 @@ -57,11 +57,13 @@ setText(text); } - QSize sizeHint() + QSize sizeHint() const { QSize size = super.sizeHint(); size.height = size.height + 20; size.width= qMax(size.width(), size.height()); return size; } + + mixin Q_OBJECT; } diff -r 7c2cf27391c4 -r 7a3c43424dca examples/widgets/calculator/calculator.d --- a/examples/widgets/calculator/calculator.d Sun Dec 27 21:13:38 2009 +0500 +++ b/examples/widgets/calculator/calculator.d Mon Dec 28 16:28:55 2009 +0500 @@ -75,30 +75,30 @@ display.setFont(font); for (int i = 0; i < NumDigitButtons; ++i) { - digitButtons[i] = createButton(format("%d", i), &digitClicked); + digitButtons[i] = createButton(format("%d", i), "digitClicked"); } - Button pointButton = createButton(tr("."), &pointClicked); - Button changeSignButton = createButton(tr("+/-"), &changeSignClicked); + Button pointButton = createButton(tr("."), "pointClicked"); + Button changeSignButton = createButton(tr("+/-"), "changeSignClicked"); - Button backspaceButton = createButton(tr("Backspace"), &backspaceClicked); - Button clearButton = createButton(tr("Clear"), &clear); - Button clearAllButton = createButton(tr("Clear All"), &clearAll); + Button backspaceButton = createButton(tr("Backspace"), "backspaceClicked"); + Button clearButton = createButton(tr("Clear"), "clear"); + Button clearAllButton = createButton(tr("Clear All"), "clearAll"); - Button clearMemoryButton = createButton(tr("MC"), &clearMemory); - Button readMemoryButton = createButton(tr("MR"), &readMemory); - Button setMemoryButton = createButton(tr("MS"), &setMemory); - Button addToMemoryButton = createButton(tr("M+"), &addToMemory); + Button clearMemoryButton = createButton(tr("MC"), "clearMemory"); + Button readMemoryButton = createButton(tr("MR"), "readMemory"); + Button setMemoryButton = createButton(tr("MS"), "setMemory"); + Button addToMemoryButton = createButton(tr("M+"), "addToMemory"); - Button divisionButton = createButton(tr("/"), &multiplicativeOperatorClicked); - Button timesButton = createButton(tr("*"), &multiplicativeOperatorClicked); - Button minusButton = createButton(tr("-"), &additiveOperatorClicked); - Button plusButton = createButton(tr("+"), &additiveOperatorClicked); + Button divisionButton = createButton(tr("/"), "multiplicativeOperatorClicked"); + Button timesButton = createButton(tr("*"), "multiplicativeOperatorClicked"); + Button minusButton = createButton(tr("-"), "additiveOperatorClicked"); + Button plusButton = createButton(tr("+"), "additiveOperatorClicked"); - Button squareRootButton = createButton(tr("Sqrt"), &unaryOperatorClicked); - Button powerButton = createButton(tr("x^2"), &unaryOperatorClicked); - Button reciprocalButton = createButton(tr("1/x"), &unaryOperatorClicked); - Button equalButton = createButton(tr("="), &equalClicked); + Button squareRootButton = createButton(tr("Sqrt"), "unaryOperatorClicked"); + Button powerButton = createButton(tr("x^2"), "unaryOperatorClicked"); + Button reciprocalButton = createButton(tr("1/x"), "unaryOperatorClicked"); + Button equalButton = createButton(tr("="), "equalClicked"); QGridLayout mainLayout = new QGridLayout(); @@ -139,9 +139,9 @@ } //private slots: - void digitClicked() + void slot_digitClicked() { - Button clickedButton = cast(Button) signalSender(); + Button clickedButton = cast(Button) sender(); int digitValue = to!int(clickedButton.text); if (display.text() == "0" && digitValue == 0.0) return; @@ -153,9 +153,9 @@ display.setText(display.text() ~ format("%g", digitValue)); } - void unaryOperatorClicked() + void slot_unaryOperatorClicked() { - Button clickedButton = cast(Button) signalSender(); + Button clickedButton = cast(Button) sender(); string clickedOperator = clickedButton.text(); double operand = to!float(display.text); double result = 0.0; @@ -179,9 +179,9 @@ waitingForOperand = true; } - void additiveOperatorClicked() + void slot_additiveOperatorClicked() { - Button clickedButton = cast(Button) signalSender(); + Button clickedButton = cast(Button) sender(); string clickedOperator = clickedButton.text(); double operand = to!float(display.text); @@ -210,9 +210,9 @@ waitingForOperand = true; } - void multiplicativeOperatorClicked() + void slot_multiplicativeOperatorClicked() { - Button clickedButton = cast(Button) signalSender(); + Button clickedButton = cast(Button) sender(); string clickedOperator = clickedButton.text(); double operand = to!float(display.text); @@ -230,7 +230,7 @@ waitingForOperand = true; } - void equalClicked() + void slot_equalClicked() { double operand = to!float(display.text); @@ -258,7 +258,7 @@ waitingForOperand = true; } - void pointClicked() + void slot_pointClicked() { string text = display.text; @@ -271,7 +271,7 @@ waitingForOperand = false; } - void changeSignClicked() + void slot_changeSignClicked() { string text = display.text(); double value = to!float(text); @@ -284,7 +284,7 @@ display.setText(text); } - void backspaceClicked() + void slot_backspaceClicked() { if (waitingForOperand) return; @@ -299,7 +299,7 @@ } - void clear() + void slot_clear() { if (waitingForOperand) return; @@ -308,7 +308,7 @@ waitingForOperand = true; } - void clearAll() + void slot_clearAll() { sumSoFar = 0.0; factorSoFar = 0.0; @@ -318,24 +318,24 @@ waitingForOperand = true; } - void clearMemory() + void slot_clearMemory() { sumInMemory = 0.0; } - void readMemory() + void slot_readMemory() { display.setText(format("%g", sumInMemory)); waitingForOperand = true; } - void setMemory() + void slot_setMemory() { equalClicked(); sumInMemory = to!float(display.text); } - void addToMemory() + void slot_addToMemory() { equalClicked(); sumInMemory += to!float(display.text); @@ -343,10 +343,10 @@ private: - Button createButton(string text, void delegate() member) + Button createButton(string text, string member) { Button button = new Button(text); - connect!("clicked")(button, member); + connect(button, "clicked", this, member); return button; } @@ -383,4 +383,6 @@ enum { NumDigitButtons = 10 }; Button[NumDigitButtons] digitButtons; + + mixin Q_OBJECT; } diff -r 7c2cf27391c4 -r 7a3c43424dca generator/typesystem_core-java.java --- a/generator/typesystem_core-java.java Sun Dec 27 21:13:38 2009 +0500 +++ b/generator/typesystem_core-java.java Mon Dec 28 16:28:55 2009 +0500 @@ -155,9 +155,9 @@ return result; } - static bool connect(QObject sender, string signal, QObject receiver, string method) + static void connect(QObject sender, string signal, QObject receiver, string method) { - return QMetaObject.connectImpl(sender, signal, receiver, method); + QMetaObject.connectImpl(sender, signal, receiver, method); } }// class diff -r 7c2cf27391c4 -r 7a3c43424dca generator/typesystem_core.xml --- a/generator/typesystem_core.xml Sun Dec 27 21:13:38 2009 +0500 +++ b/generator/typesystem_core.xml Mon Dec 28 16:28:55 2009 +0500 @@ -558,7 +558,7 @@ - + diff -r 7c2cf27391c4 -r 7a3c43424dca generator/typesystem_gui.xml --- a/generator/typesystem_gui.xml Sun Dec 27 21:13:38 2009 +0500 +++ b/generator/typesystem_gui.xml Mon Dec 28 16:28:55 2009 +0500 @@ -7586,6 +7586,13 @@ return %FUNCTION_NAME(%PRE_CALL_ARGUMENTS %COMMA className == null ? null : className.data()); } + + + QApplication qApp() + { + return cast(QApplication) QCoreApplication.instance(); + } + diff -r 7c2cf27391c4 -r 7a3c43424dca qt/core/QList.d --- a/qt/core/QList.d Sun Dec 27 21:13:38 2009 +0500 +++ b/qt/core/QList.d Mon Dec 28 16:28:55 2009 +0500 @@ -368,15 +368,17 @@ } public: + /* void output() { writeln("QList atomic ", d.ref_.load()); } + */ static QList!T opCall() { QList!T res; - writeln("QList opCall"); +// writeln("QList opCall"); res.d = &QListData.shared_null; res.d.ref_.increment(); @@ -386,7 +388,7 @@ this(this) { - writeln("QList postblit"); +// writeln("QList postblit"); d.ref_.increment(); if (!d.sharable) detach_helper(); @@ -394,14 +396,14 @@ ~this() { - writeln("QList ~this"); +// writeln("QList ~this"); if (d && !d.ref_.decrement()) free(d); } ref QList!T opAssign(const ref QList!T l) { - writeln("QList opAssign"); +// writeln("QList opAssign"); if (d != l.d) { l.d.ref_.increment(); if (!d.ref_.decrement()) @@ -505,7 +507,7 @@ void node_copy(Node *from, Node *to, Node *src) { - writeln("QList node_copy"); +// writeln("QList node_copy"); static if (isQObjectType!T || isObjectType!T) {} // ensure to do nothing. copying only a pointer else static if(is(T == string)) @@ -546,7 +548,7 @@ void free(QListData.Data* data) { - writeln("QList data destroyed"); +// writeln("QList data destroyed"); node_destruct(cast(Node*)(data.array.ptr + data.begin), cast(Node*)(data.array.ptr + data.end)); if (data.ref_.load() == 0) diff -r 7c2cf27391c4 -r 7a3c43424dca qt/core/QMetaObject.d --- a/qt/core/QMetaObject.d Sun Dec 27 21:13:38 2009 +0500 +++ b/qt/core/QMetaObject.d Mon Dec 28 16:28:55 2009 +0500 @@ -51,6 +51,12 @@ else return ""; } + + string name() const + { + int openBracket = indexOf(signature, '('); + return signature[0..openBracket]; + } } class QMetaSignal : QMetaMethod @@ -82,6 +88,8 @@ void *extradata; } +class QMetaException : Exception { this(string msg) { super(msg); } } + final class QMetaObject { enum Call @@ -198,7 +206,7 @@ { typeof(return) result; foreach (method; _methods) - if (startsWith(method.signature, methodName)) + if (method.name == methodName) result ~= method; if (_base) result ~= _base.lookUpMethodOverloads(methodName); @@ -209,7 +217,7 @@ { typeof(return) result; foreach (method; _methods) - if (startsWith(method.signature, signalName) && cast(QMetaSignal)method) + if (method.name == signalName && cast(QMetaSignal)method) result ~= cast(QMetaSignal)method; if (_base) result ~= _base.lookUpSignalOverloads(signalName); @@ -304,14 +312,13 @@ return qtd_QMetaObject_methodCount(_nativeId); } - static bool connectImpl(QObject sender, string signalString, QObject receiver, string methodString) + static void connectImpl(QObject sender, string signalString, QObject receiver, string methodString) { QMetaSignal[] signals; QMetaMethod[] methods; QMetaSignal signal; QMetaMethod method; - if(indexOf(signalString, '(') > 0) signal = sender.metaObject.lookUpSignal(signalString); else @@ -324,13 +331,14 @@ if(!signal && !method) { + Top: foreach(sig; signals) foreach(meth; methods) if(startsWith(sig.args, meth.args)) { signal = sig; method = meth; - goto doConnect; + break Top; } } else if (!signal) @@ -352,15 +360,21 @@ } } -doConnect: + bool success = false; + if(!signal && !method) { - writeln(stderr, "QMetaObject: Signal and slots cannot be found"); - return false; + success = false; } - int signalIndex = signal.indexOfMethod; - int methodIndex = method.indexOfMethod; - return QMetaObject.connect(sender, signalIndex, receiver, methodIndex); + else + { + int signalIndex = signal.indexOfMethod; + int methodIndex = method.indexOfMethod; + success = QMetaObject.connect(sender, signalIndex, receiver, methodIndex); + } + + if(!success) + throw new QMetaException("QMetaObject: Signal " ~ signalString ~ " and slot " ~ methodString ~ " cannot be found"); } } diff -r 7c2cf27391c4 -r 7a3c43424dca qt/d2/qt/Signal.d --- a/qt/d2/qt/Signal.d Sun Dec 27 21:13:38 2009 +0500 +++ b/qt/d2/qt/Signal.d Mon Dec 28 16:28:55 2009 +0500 @@ -127,7 +127,7 @@ res ~= "void*[" ~ __toString(Args.length+1) ~ "] _a = [null"; foreach(i, _; Args) - res ~= ", " ~ "cast(void*) " ~ convertSignalArgument!(Args[i])("_t" ~ __toString(i)); + res ~= ", " ~ "cast(void*) (" ~ convertSignalArgument!(Args[i])("_t" ~ __toString(i)) ~ ")"; res ~= "];\n"; return res; } diff -r 7c2cf27391c4 -r 7a3c43424dca qt/qtd/MOC.d --- a/qt/qtd/MOC.d Sun Dec 27 21:13:38 2009 +0500 +++ b/qt/qtd/MOC.d Mon Dec 28 16:28:55 2009 +0500 @@ -4,6 +4,7 @@ import std.typetuple; +import qt.QGlobal; import qt.Signal; import qt.qtd.MetaMarshall; import qt.qtd.Meta; @@ -15,10 +16,6 @@ Utils. */ -T qMin(T)(T a,T b) { if (a < b) return a; return b; } -T qMax(T)(T a, T b) { if (a < b) return b; return a; } -T qBound(T)(T min, T val,T max) { return qMax(min, qMin(max, val)); } - bool is_digit_char(const char s) { return (s >= '0' && s <= '9'); @@ -461,7 +458,7 @@ { string res; res ~= " - QMetaObject metaObject() { return staticMetaObject; } + public QMetaObject metaObject() { return staticMetaObject; } private static QMetaObject _staticMetaObject; private static QMetaObjectNative _nativeStaticMetaObject; public static QMetaObject staticMetaObject() { return _staticMetaObject; } @@ -558,5 +555,6 @@ alias toMetaEntries!(SlotFuncs) SlotMetaEntries; mixin(generateMetaInfo!(typeof(this), SignalMetaEntries, SlotMetaEntries)()); - pragma(msg, generateMetaInfo!(typeof(this), SignalMetaEntries, SlotMetaEntries)()); + // debug output +// pragma(msg, generateMetaInfo!(typeof(this), SignalMetaEntries, SlotMetaEntries)()); } \ No newline at end of file diff -r 7c2cf27391c4 -r 7a3c43424dca qt/qtd/MetaMarshall.d --- a/qt/qtd/MetaMarshall.d Sun Dec 27 21:13:38 2009 +0500 +++ b/qt/qtd/MetaMarshall.d Mon Dec 28 16:28:55 2009 +0500 @@ -77,7 +77,7 @@ string convertSignalArgument(T)(string arg) { static if (isQObjectType!T || isObjectType!T) - return "&" ~ arg ~ ".__nativeId"; + return arg ~ " ? " "&" ~ arg ~ ".__nativeId : cast(void**) &" ~ arg; // since it is a pointer type check arg for null else static if (isValueType!T) return arg ~ ".__nativeId"; else static if (isStringType!T)