diff examples/layouts/dynamiclayouts/dialog.d @ 368:185df9220ea7

Fixed startsWith. Implemented meta-object members as ranges. Freed QMetaObject from stuff that belongs to MetaClass
author Max Samukha <maxter@maxter.com>
date Mon, 28 Jun 2010 21:29:32 +0300
parents 5896535a03cd
children 778ef7374fb5
line wrap: on
line diff
--- a/examples/layouts/dynamiclayouts/dialog.d	Thu Jun 24 13:47:30 2010 +0300
+++ b/examples/layouts/dynamiclayouts/dialog.d	Mon Jun 28 21:29:32 2010 +0300
@@ -58,151 +58,153 @@
 {
 public:
 
-	this(QWidget parent = null)
-	{
-		super(parent);
-		createRotableGroupBox();
-		createOptionsGroupBox();
-		createButtonBox();
+    this(QWidget parent = null)
+    {
+        super(parent);
+
+        createRotableGroupBox();
+        createOptionsGroupBox();
+        createButtonBox();
 
-		mainLayout = new QGridLayout;
-		mainLayout.addWidget(rotableGroupBox, 0, 0);
-		mainLayout.addWidget(optionsGroupBox, 1, 0);
-		mainLayout.addWidget(buttonBox, 2, 0);
-		setLayout(mainLayout);
+        mainLayout = new QGridLayout;
+        mainLayout.addWidget(rotableGroupBox, 0, 0);
+        mainLayout.addWidget(optionsGroupBox, 1, 0);
+        mainLayout.addWidget(buttonBox, 2, 0);
+        setLayout(mainLayout);
 
-		mainLayout.setSizeConstraint(QLayout.SetMinimumSize);
+        mainLayout.setSizeConstraint(QLayout.SetMinimumSize);
 
-		setWindowTitle(tr("Dynamic Layouts"));
-	}
+        setWindowTitle(tr("Dynamic Layouts"));
+    }
 
 private: // slots
 
-	void slot_buttonsOrientationChanged(int index)
-	{
-		mainLayout.setSizeConstraint(QLayout.SetNoConstraint);
-		setMinimumSize(0, 0);
+    void slot_buttonsOrientationChanged(int index)
+    {
+        mainLayout.setSizeConstraint(QLayout.SetNoConstraint);
+        setMinimumSize(0, 0);
 
-		Qt.Orientation orientation = cast(Qt.Orientation) buttonsOrientationComboBox.itemData(index).toInt();
+        Qt.Orientation orientation = cast(Qt.Orientation) buttonsOrientationComboBox.itemData(index).toInt();
 
-		if (orientation == buttonBox.orientation())
-			return;
+        if (orientation == buttonBox.orientation())
+            return;
 
-		mainLayout.removeWidget(buttonBox);
+        mainLayout.removeWidget(buttonBox);
 
-		int spacing = mainLayout.spacing();
+        int spacing = mainLayout.spacing();
 
-		QSize oldSizeHint = buttonBox.sizeHint() + QSize(spacing, spacing);
-		buttonBox.setOrientation(orientation);
-		QSize newSizeHint = buttonBox.sizeHint() + QSize(spacing, spacing);
+        QSize oldSizeHint = buttonBox.sizeHint() + QSize(spacing, spacing);
+        buttonBox.setOrientation(orientation);
+        QSize newSizeHint = buttonBox.sizeHint() + QSize(spacing, spacing);
 
-		if (orientation == Qt.Orientation.Horizontal) {
-			mainLayout.addWidget(buttonBox, 2, 0);
-			resize(size() + QSize(-1 * oldSizeHint.width(), newSizeHint.height()));
-		} else {
-			mainLayout.addWidget(buttonBox, 0, 3, 2, 1);
-			resize(size() + QSize(newSizeHint.width(), -1 * oldSizeHint.height()));
-		}
+        if (orientation == Qt.Orientation.Horizontal) {
+            mainLayout.addWidget(buttonBox, 2, 0);
+            resize(size() + QSize(-1 * oldSizeHint.width(), newSizeHint.height()));
+        } else {
+            mainLayout.addWidget(buttonBox, 0, 3, 2, 1);
+            resize(size() + QSize(newSizeHint.width(), -1 * oldSizeHint.height()));
+        }
 
-		mainLayout.setSizeConstraint(QLayout.SetDefaultConstraint);
-	}
+        mainLayout.setSizeConstraint(QLayout.SetDefaultConstraint);
+    }
 
-	void slot_rotateWidgets()
-	{
-		assert(rotableWidgets.length % 2 == 0);
+    void slot_rotateWidgets()
+    {
+        assert(rotableWidgets.length % 2 == 0);
 
-		foreach (QWidget widget; rotableWidgets)
-			rotableLayout.removeWidget(widget);
+        foreach (QWidget widget; rotableWidgets)
+            rotableLayout.removeWidget(widget);
+
+        rotableWidgets = rotableWidgets[1..$] ~ rotableWidgets[0];
 
-		rotableWidgets = rotableWidgets[1..$] ~ rotableWidgets[0];
-		
-		int n = rotableWidgets.length;
-		for (int i = 0; i < n / 2; ++i) {
-			rotableLayout.addWidget(rotableWidgets[n - i - 1], 0, i);
-			rotableLayout.addWidget(rotableWidgets[i], 1, i);
-		}
-	}
+        int n = rotableWidgets.length;
+        for (int i = 0; i < n / 2; ++i) {
+            rotableLayout.addWidget(rotableWidgets[n - i - 1], 0, i);
+            rotableLayout.addWidget(rotableWidgets[i], 1, i);
+        }
+    }
 
-	void slot_help()
-	{
-		QMessageBox.information(this, tr("Dynamic Layouts Help"),
-			tr("This example shows how to change layouts dynamically."));
-	}
+    void slot_help()
+    {
+        QMessageBox.information(this, tr("Dynamic Layouts Help"),
+            tr("This example shows how to change layouts dynamically."));
+    }
 
 private:
-	
-	void createRotableGroupBox()
-	{
-		rotableGroupBox = new QGroupBox(tr("Rotable Widgets"));
+
+    void createRotableGroupBox()
+    {
+        rotableGroupBox = new QGroupBox(tr("Rotable Widgets"));
 
-		auto a0 = new QSpinBox;
-		auto a1 = new QSlider;
-		auto a2 = new QDial;
-		auto a3 = new QProgressBar;
-		
-		rotableWidgets ~= a0;
-		rotableWidgets ~= a1;
-		rotableWidgets ~= a2;
-		rotableWidgets ~= a3;
+        auto a0 = new QSpinBox;
+        auto a1 = new QSlider;
+        auto a2 = new QDial;
+        auto a3 = new QProgressBar;
+
+        rotableWidgets ~= a0;
+        rotableWidgets ~= a1;
+        rotableWidgets ~= a2;
+        rotableWidgets ~= a3;
+
+        int n = rotableWidgets.length;
 
-		int n = rotableWidgets.length;
-		for (int i = 0; i < n; ++i)
-			connect(rotableWidgets[i], "valueChanged", rotableWidgets[(i + 1) % n], "setValue");
+        for (int i = 0; i < n; ++i)
+            connect(rotableWidgets[i], "valueChanged", rotableWidgets[(i + 1) % n], "setValue");
 
-       
-		rotableLayout = new QGridLayout;
-		rotableGroupBox.setLayout(rotableLayout);
+        rotableLayout = new QGridLayout;
+        rotableGroupBox.setLayout(rotableLayout);
+
+        rotateWidgets();
+
+    }
 
-		rotateWidgets();
-	}
+    void createOptionsGroupBox()
+    {
+        optionsGroupBox = new QGroupBox(tr("Options"));
 
-	void createOptionsGroupBox()
-	{
-		optionsGroupBox = new QGroupBox(tr("Options"));
+        buttonsOrientationLabel = new QLabel(tr("Orientation of buttons:"));
 
-		buttonsOrientationLabel = new QLabel(tr("Orientation of buttons:"));
-
-		buttonsOrientationComboBox = new QComboBox;
-		buttonsOrientationComboBox.addItem(tr("Horizontal"), new QVariant(cast(ulong) Qt.Horizontal));
-		buttonsOrientationComboBox.addItem(tr("Vertical"), new QVariant(cast(ulong) Qt.Vertical));
+        buttonsOrientationComboBox = new QComboBox;
+        buttonsOrientationComboBox.addItem(tr("Horizontal"), new QVariant(cast(ulong) Qt.Horizontal));
+        buttonsOrientationComboBox.addItem(tr("Vertical"), new QVariant(cast(ulong) Qt.Vertical));
 
-		connect(buttonsOrientationComboBox, "currentIndexChanged", this, "buttonsOrientationChanged");
-      
-		optionsLayout = new QGridLayout;
-		optionsLayout.addWidget(buttonsOrientationLabel, 0, 0);
-		optionsLayout.addWidget(buttonsOrientationComboBox, 0, 1);
-		optionsLayout.setColumnStretch(2, 1);
-		optionsGroupBox.setLayout(optionsLayout);
-	}
+        connect(buttonsOrientationComboBox, "currentIndexChanged", this, "buttonsOrientationChanged");
 
-	void createButtonBox()
-	{
-		buttonBox = new QDialogButtonBox;
+        optionsLayout = new QGridLayout;
+        optionsLayout.addWidget(buttonsOrientationLabel, 0, 0);
+        optionsLayout.addWidget(buttonsOrientationComboBox, 0, 1);
+        optionsLayout.setColumnStretch(2, 1);
+        optionsGroupBox.setLayout(optionsLayout);
+    }
 
-		closeButton = buttonBox.addButton(QDialogButtonBox.Close);
-		helpButton = buttonBox.addButton(QDialogButtonBox.Help);
-		rotateWidgetsButton = buttonBox.addButton(tr("Rotate &Widgets"), QDialogButtonBox.ActionRole);
+    void createButtonBox()
+    {
+        buttonBox = new QDialogButtonBox;
+
+        closeButton = buttonBox.addButton(QDialogButtonBox.Close);
+        helpButton = buttonBox.addButton(QDialogButtonBox.Help);
+        rotateWidgetsButton = buttonBox.addButton(tr("Rotate &Widgets"), QDialogButtonBox.ActionRole);
 
-		connect(rotateWidgetsButton, "clicked", this, "rotateWidgets");
-		connect(closeButton, "clicked", this, "close");
-		connect(helpButton, "clicked", this, "help");
-	}
+        connect(rotateWidgetsButton, "clicked", this, "rotateWidgets");
+        connect(closeButton, "clicked", this, "close");
+        connect(helpButton, "clicked", this, "help");
+    }
+
+    QGroupBox rotableGroupBox;
+    QWidget[] rotableWidgets;
 
-	QGroupBox rotableGroupBox;
-	QWidget[] rotableWidgets;
-    
-	QGroupBox optionsGroupBox;
-	QLabel buttonsOrientationLabel;
-	QComboBox buttonsOrientationComboBox;
+    QGroupBox optionsGroupBox;
+    QLabel buttonsOrientationLabel;
+    QComboBox buttonsOrientationComboBox;
 
-	QDialogButtonBox buttonBox;
-	QPushButton closeButton;
-	QPushButton helpButton;
-	QPushButton rotateWidgetsButton;
+    QDialogButtonBox buttonBox;
+    QPushButton closeButton;
+    QPushButton helpButton;
+    QPushButton rotateWidgetsButton;
 
-	QGridLayout mainLayout;
-	QGridLayout rotableLayout;
-	QGridLayout optionsLayout;
+    QGridLayout mainLayout;
+    QGridLayout rotableLayout;
+    QGridLayout optionsLayout;
 
     mixin Q_OBJECT;
 }