| 
									
										
										
										
											2009-02-25 09:15:00 +01:00
										 |  |  | /**************************************************************************
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | ** | 
					
						
							|  |  |  | ** This file is part of Qt Creator | 
					
						
							|  |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-02-25 09:15:00 +01:00
										 |  |  | ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-06-17 00:01:27 +10:00
										 |  |  | ** Contact: Nokia Corporation (qt-info@nokia.com) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-02-25 09:15:00 +01:00
										 |  |  | ** Commercial Usage | 
					
						
							| 
									
										
										
										
											2008-12-02 14:17:16 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-02-25 09:15:00 +01:00
										 |  |  | ** Licensees holding valid Qt Commercial licenses may use this file in | 
					
						
							|  |  |  | ** accordance with the Qt Commercial License Agreement provided with the | 
					
						
							|  |  |  | ** Software or, alternatively, in accordance with the terms contained in | 
					
						
							|  |  |  | ** a written agreement between you and Nokia. | 
					
						
							| 
									
										
										
										
											2008-12-02 14:17:16 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-02-25 09:15:00 +01:00
										 |  |  | ** GNU Lesser General Public License Usage | 
					
						
							| 
									
										
										
										
											2008-12-02 14:17:16 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-02-25 09:15:00 +01:00
										 |  |  | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
					
						
							|  |  |  | ** General Public License version 2.1 as published by the Free Software | 
					
						
							|  |  |  | ** Foundation and appearing in the file LICENSE.LGPL included in the | 
					
						
							|  |  |  | ** packaging of this file.  Please review the following information to | 
					
						
							|  |  |  | ** ensure the GNU Lesser General Public License version 2.1 requirements | 
					
						
							|  |  |  | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 | 
					
						
							| 
									
										
										
										
											2008-12-02 14:17:16 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-02-25 09:15:00 +01:00
										 |  |  | ** If you are unsure which license is appropriate for your use, please | 
					
						
							| 
									
										
										
										
											2009-06-17 00:01:27 +10:00
										 |  |  | ** contact the sales department at http://www.qtsoftware.com/contact.
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-02-25 09:15:00 +01:00
										 |  |  | **************************************************************************/ | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <QtCore/QDebug>
 | 
					
						
							|  |  |  | #include <QtCore/QDir>
 | 
					
						
							|  |  |  | #include <QtCore/QHash>
 | 
					
						
							|  |  |  | #include <QtCore/QLibrary>
 | 
					
						
							| 
									
										
										
										
											2009-01-08 11:02:04 +01:00
										 |  |  | #include <QtCore/QLinkedList>
 | 
					
						
							|  |  |  | #include <QtCore/QList>
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #include <QtCore/QMap>
 | 
					
						
							|  |  |  | #include <QtCore/QPointer>
 | 
					
						
							|  |  |  | #include <QtCore/QString>
 | 
					
						
							|  |  |  | #include <QtCore/QThread>
 | 
					
						
							|  |  |  | #include <QtCore/QVariant>
 | 
					
						
							|  |  |  | #include <QtCore/QVector>
 | 
					
						
							| 
									
										
										
										
											2009-06-25 15:00:57 +02:00
										 |  |  | #if QT_VERSION >= 0x040500
 | 
					
						
							| 
									
										
										
										
											2009-04-07 13:50:21 +02:00
										 |  |  | #include <QtCore/QSharedPointer>
 | 
					
						
							| 
									
										
										
										
											2009-06-25 15:00:57 +02:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <QtGui/QApplication>
 | 
					
						
							|  |  |  | #include <QtGui/QAction>
 | 
					
						
							|  |  |  | #include <QtGui/QColor>
 | 
					
						
							|  |  |  | #include <QtGui/QFont>
 | 
					
						
							|  |  |  | #include <QtGui/QLabel>
 | 
					
						
							|  |  |  | #include <QtGui/QPainter>
 | 
					
						
							|  |  |  | #include <QtGui/QPainterPath>
 | 
					
						
							| 
									
										
										
										
											2009-06-03 12:46:55 +02:00
										 |  |  | #include <QtGui/QStandardItemModel>
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <QtNetwork/QHostAddress>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-16 11:17:00 +01:00
										 |  |  | #include <deque>
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #include <iostream>
 | 
					
						
							| 
									
										
										
										
											2008-12-11 16:10:47 +01:00
										 |  |  | #include <map>
 | 
					
						
							| 
									
										
										
										
											2008-12-10 14:37:15 +01:00
										 |  |  | #include <list>
 | 
					
						
							| 
									
										
										
										
											2009-03-11 13:31:38 +01:00
										 |  |  | #include <set>
 | 
					
						
							| 
									
										
										
										
											2008-12-10 14:37:15 +01:00
										 |  |  | #include <stack>
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #include <string>
 | 
					
						
							|  |  |  | #include <vector>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef Q_OS_WIN
 | 
					
						
							|  |  |  | #include <windows.h>
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | uint qHash(const QMap<int, int> &) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | uint qHash(const double & f) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return int(f); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 16:48:12 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-05 08:46:24 +02:00
										 |  |  | class Foo | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2009-05-05 08:46:24 +02:00
										 |  |  |     Foo(int i = 0) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         : a(i), b(2) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         int s = 1; | 
					
						
							|  |  |  |         int t = 2; | 
					
						
							|  |  |  |         b = 2 + s + t; | 
					
						
							|  |  |  |         a += 1; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-04-16 12:17:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ~Foo() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         a = 5; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     void doit() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         static QObject ob; | 
					
						
							|  |  |  |         m["1"] = "2"; | 
					
						
							|  |  |  |         h[&ob] = m.begin(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         a += 1; | 
					
						
							|  |  |  |         --b; | 
					
						
							|  |  |  |         //s += 'x';
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     struct Bar { | 
					
						
							|  |  |  |         Bar() : ob(0) {} | 
					
						
							|  |  |  |         QObject *ob; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     int a, b; | 
					
						
							|  |  |  |     char x[6]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     //QString s;
 | 
					
						
							|  |  |  |     typedef QMap<QString, QString> Map; | 
					
						
							|  |  |  |     Map m; | 
					
						
							|  |  |  |     QHash<QObject *, Map::iterator> h; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-17 16:00:03 +02:00
										 |  |  | class X : virtual public Foo | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     X() { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Y : virtual public Foo | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     Y() { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | void testArray() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-06-17 16:00:03 +02:00
										 |  |  |     X xxx; | 
					
						
							| 
									
										
										
										
											2009-04-03 13:39:14 +02:00
										 |  |  |     char c[20]; | 
					
						
							|  |  |  |     c[0] = 'a'; | 
					
						
							|  |  |  |     c[1] = 'b'; | 
					
						
							|  |  |  |     c[2] = 'c'; | 
					
						
							|  |  |  |     c[3] = 'd'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-17 17:43:01 +01:00
										 |  |  |     QString x[20]; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     x[0] = "a"; | 
					
						
							|  |  |  |     x[1] = "b"; | 
					
						
							|  |  |  |     x[2] = "c"; | 
					
						
							|  |  |  |     x[3] = "d"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Foo foo[10]; | 
					
						
							|  |  |  |     //for (int i = 0; i != sizeof(foo)/sizeof(foo[0]); ++i) {
 | 
					
						
							|  |  |  |     for (int i = 0; i < 5; ++i) { | 
					
						
							|  |  |  |         foo[i].a = i; | 
					
						
							|  |  |  |         foo[i].doit(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 16:31:50 +01:00
										 |  |  | void testQByteArray() | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     QByteArray ba = "Hello"; | 
					
						
							|  |  |  |     ba += '"'; | 
					
						
							|  |  |  |     ba += "World"; | 
					
						
							| 
									
										
										
										
											2009-04-03 11:54:29 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const char *str1 = "\356"; | 
					
						
							|  |  |  |     const char *str2 = "\xee"; | 
					
						
							|  |  |  |     const char *str3 = "\\ee"; | 
					
						
							|  |  |  |     QByteArray buf1( str1 ); | 
					
						
							|  |  |  |     QByteArray buf2( str2 ); | 
					
						
							|  |  |  |     QByteArray buf3( str3 ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     ba += char(0); | 
					
						
							|  |  |  |     ba += 1; | 
					
						
							|  |  |  |     ba += 2; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 16:31:50 +01:00
										 |  |  | void testQHash() | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-01-27 17:41:31 +01:00
										 |  |  | #if 1
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     QHash<int, float> hgg0; | 
					
						
							|  |  |  |     hgg0[11] = 11.0; | 
					
						
							|  |  |  |     hgg0[22] = 22.0; | 
					
						
							| 
									
										
										
										
											2009-01-27 17:15:51 +01:00
										 |  |  |     hgg0[22] = 22.0; | 
					
						
							|  |  |  |     hgg0[22] = 22.0; | 
					
						
							|  |  |  |     hgg0[22] = 22.0; | 
					
						
							|  |  |  |     hgg0[22] = 22.0; | 
					
						
							|  |  |  |     hgg0[22] = 22.0; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-27 17:15:51 +01:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if 1
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-28 16:55:09 +01:00
										 |  |  |     QHash<QString, int> hgg1; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     hgg1["22.0"] = 22.0; | 
					
						
							| 
									
										
										
										
											2009-01-28 16:55:09 +01:00
										 |  |  |     hgg1["123.0"] = 22.0; | 
					
						
							|  |  |  |     hgg1["111111ss111128.0"] = 28.0; | 
					
						
							|  |  |  |     hgg1["11124.0"] = 22.0; | 
					
						
							|  |  |  |     hgg1["1111125.0"] = 22.0; | 
					
						
							|  |  |  |     hgg1["11111126.0"] = 22.0; | 
					
						
							|  |  |  |     hgg1["111111127.0"] = 27.0; | 
					
						
							|  |  |  |     hgg1["111111111128.0"] = 28.0; | 
					
						
							|  |  |  |     hgg1["111111111111111111129.0"] = 29.0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QHash<QByteArray, float> hgx1; | 
					
						
							|  |  |  |     hgx1["22.0"] = 22.0; | 
					
						
							|  |  |  |     hgx1["123.0"] = 22.0; | 
					
						
							|  |  |  |     hgx1["111111ss111128.0"] = 28.0; | 
					
						
							|  |  |  |     hgx1["11124.0"] = 22.0; | 
					
						
							|  |  |  |     hgx1["1111125.0"] = 22.0; | 
					
						
							|  |  |  |     hgx1["11111126.0"] = 22.0; | 
					
						
							|  |  |  |     hgx1["111111127.0"] = 27.0; | 
					
						
							|  |  |  |     hgx1["111111111128.0"] = 28.0; | 
					
						
							|  |  |  |     hgx1["111111111111111111129.0"] = 29.0; | 
					
						
							| 
									
										
										
										
											2009-01-27 17:15:51 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-05 11:06:25 +01:00
										 |  |  | #if 1
 | 
					
						
							| 
									
										
										
										
											2009-03-05 13:52:52 +01:00
										 |  |  |     QHash<int, QString> hgg2; | 
					
						
							|  |  |  |     hgg2[22] = "22.0"; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     QHash<QString, Foo> hgg3; | 
					
						
							|  |  |  |     hgg3["22.0"] = Foo(22); | 
					
						
							|  |  |  |     hgg3["33.0"] = Foo(33); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QObject ob; | 
					
						
							|  |  |  |     QHash<QString, QPointer<QObject> > hash; | 
					
						
							|  |  |  |     hash.insert("Hallo", QPointer<QObject>(&ob)); | 
					
						
							|  |  |  |     hash.insert("Welt", QPointer<QObject>(&ob)); | 
					
						
							|  |  |  |     hash.insert(".", QPointer<QObject>(&ob)); | 
					
						
							| 
									
										
										
										
											2009-01-27 17:15:51 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 16:31:50 +01:00
										 |  |  | void testQImage() | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     QImage im(QSize(200, 200), QImage::Format_RGB32); | 
					
						
							|  |  |  |     im.fill(QColor(200, 100, 130).rgba()); | 
					
						
							|  |  |  |     QPainter pain; | 
					
						
							|  |  |  |     pain.begin(&im); | 
					
						
							|  |  |  |     pain.drawLine(2, 2, 130, 130); | 
					
						
							|  |  |  |     pain.drawLine(4, 2, 130, 140); | 
					
						
							|  |  |  |     pain.drawRect(30, 30, 80, 80); | 
					
						
							|  |  |  |     pain.end(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void testIO() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     qDebug() << "qDebug() 1"; | 
					
						
							|  |  |  |     qDebug() << "qDebug() 2"; | 
					
						
							|  |  |  |     qDebug() << "qDebug() 3"; | 
					
						
							| 
									
										
										
										
											2009-02-23 21:15:32 +01:00
										 |  |  |     qDebug() << "qDebug <foo & bar>"; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     std::cout << "std::cout @@ 1" << std::endl; | 
					
						
							|  |  |  |     std::cout << "std::cout @@ 2\n"; | 
					
						
							|  |  |  |     std::cout << "std::cout @@ 3" << std::endl; | 
					
						
							| 
									
										
										
										
											2009-02-23 21:15:32 +01:00
										 |  |  |     std::cout << "std::cout <foo & bar>\n"; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     std::cerr << "std::cerr 1\n"; | 
					
						
							|  |  |  |     std::cerr << "std::cerr 2\n"; | 
					
						
							|  |  |  |     std::cerr << "std::cerr 3\n"; | 
					
						
							| 
									
										
										
										
											2009-02-23 21:15:32 +01:00
										 |  |  |     std::cerr << "std::cerr <foo & bar>\n"; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-08 11:02:04 +01:00
										 |  |  | void testQLinkedList() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | #if 1
 | 
					
						
							|  |  |  |     QLinkedList<int> li; | 
					
						
							|  |  |  |     QLinkedList<uint> lu; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (int i = 0; i != 3; ++i) | 
					
						
							|  |  |  |         li.append(i); | 
					
						
							|  |  |  |     li.append(102); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     lu.append(102); | 
					
						
							|  |  |  |     lu.append(102); | 
					
						
							|  |  |  |     lu.append(102); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-08 11:50:20 +01:00
										 |  |  |     QLinkedList<Foo *> lpi; | 
					
						
							|  |  |  |     lpi.append(new Foo(1)); | 
					
						
							|  |  |  |     lpi.append(0); | 
					
						
							|  |  |  |     lpi.append(new Foo(3)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-08 11:02:04 +01:00
										 |  |  |     QLinkedList<qulonglong> l; | 
					
						
							|  |  |  |     l.append(42); | 
					
						
							|  |  |  |     l.append(43); | 
					
						
							|  |  |  |     l.append(44); | 
					
						
							|  |  |  |     l.append(45); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QLinkedList<Foo> f; | 
					
						
							|  |  |  |     f.append(Foo(1)); | 
					
						
							|  |  |  |     f.append(Foo(2)); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  |     QLinkedList<std::string> v; | 
					
						
							|  |  |  |     v.push_back("aa"); | 
					
						
							|  |  |  |     v.push_back("bb"); | 
					
						
							|  |  |  |     v.push_back("cc"); | 
					
						
							|  |  |  |     v.push_back("dd"); | 
					
						
							|  |  |  |  } | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 16:31:50 +01:00
										 |  |  | void testQList() | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  | #if 1
 | 
					
						
							|  |  |  |     QList<int> li; | 
					
						
							|  |  |  |     QList<uint> lu; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-28 12:15:40 +01:00
										 |  |  |     for (int i = 0; i != 30; ++i) { | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         li.append(i); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     li.append(101); | 
					
						
							|  |  |  |     li.append(102); | 
					
						
							|  |  |  |     li.append(102); | 
					
						
							|  |  |  |     li.append(102); | 
					
						
							|  |  |  |     li.append(102); | 
					
						
							|  |  |  |     li.append(102); | 
					
						
							|  |  |  |     li.append(102); | 
					
						
							|  |  |  |     li.append(102); | 
					
						
							|  |  |  |     li.append(102); | 
					
						
							|  |  |  |     li.append(102); | 
					
						
							|  |  |  |     li.append(102); | 
					
						
							|  |  |  |     li.append(102); | 
					
						
							|  |  |  |     li.append(102); | 
					
						
							|  |  |  |     li.append(102); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-11 15:09:33 +01:00
										 |  |  |     QList<int *> lpi; | 
					
						
							|  |  |  |     lpi.append(new int(1)); | 
					
						
							|  |  |  |     lpi.append(new int(2)); | 
					
						
							|  |  |  |     lpi.append(new int(3)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     for (int i = 0; i != 3; ++i) { | 
					
						
							|  |  |  |         lu.append(i); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     lu.append(101); | 
					
						
							|  |  |  |     lu.append(102); | 
					
						
							|  |  |  |     lu.append(102); | 
					
						
							|  |  |  |     lu.append(102); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QList<uint> i; | 
					
						
							|  |  |  |     i.append(42); | 
					
						
							|  |  |  |     i.append(43); | 
					
						
							|  |  |  |     i.append(44); | 
					
						
							|  |  |  |     i.append(45); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-24 12:31:09 +02:00
										 |  |  |     QList<ushort> ls; | 
					
						
							|  |  |  |     ls.append(42); | 
					
						
							|  |  |  |     ls.append(43); | 
					
						
							|  |  |  |     ls.append(44); | 
					
						
							|  |  |  |     ls.append(45); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QList<QChar> lc; | 
					
						
							|  |  |  |     lc.append(QChar('a')); | 
					
						
							|  |  |  |     lc.append(QChar('b')); | 
					
						
							|  |  |  |     lc.append(QChar('c')); | 
					
						
							|  |  |  |     lc.append(QChar('d')); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     QList<qulonglong> l; | 
					
						
							|  |  |  |     l.append(42); | 
					
						
							|  |  |  |     l.append(43); | 
					
						
							|  |  |  |     l.append(44); | 
					
						
							|  |  |  |     l.append(45); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QList<Foo> f; | 
					
						
							|  |  |  |     f.append(Foo(1)); | 
					
						
							|  |  |  |     f.append(Foo(2)); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  |     QList<std::string> v; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     v.push_back("aa"); | 
					
						
							|  |  |  |     v.push_back("bb"); | 
					
						
							|  |  |  |     v.push_back("cc"); | 
					
						
							|  |  |  |     v.push_back("dd"); | 
					
						
							|  |  |  |  } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 16:31:50 +01:00
										 |  |  | void testQMap() | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     QMap<uint, QStringList> ggl; | 
					
						
							|  |  |  |     ggl[11] = QStringList() << "11"; | 
					
						
							|  |  |  |     ggl[22] = QStringList() << "22"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     typedef QMap<uint, QStringList> T; | 
					
						
							|  |  |  |     T ggt; | 
					
						
							|  |  |  |     ggt[11] = QStringList() << "11"; | 
					
						
							|  |  |  |     ggt[22] = QStringList() << "22"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-12 12:55:05 +01:00
										 |  |  | #if 1
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     QMap<uint, float> gg0; | 
					
						
							|  |  |  |     gg0[11] = 11.0; | 
					
						
							|  |  |  |     gg0[22] = 22.0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QMap<QString, float> gg1; | 
					
						
							|  |  |  |     gg1["22.0"] = 22.0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QMap<int, QString> gg2; | 
					
						
							|  |  |  |     gg2[22] = "22.0"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QMap<QString, Foo> gg3; | 
					
						
							|  |  |  |     gg3["22.0"] = Foo(22); | 
					
						
							|  |  |  |     gg3["33.0"] = Foo(33); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QObject ob; | 
					
						
							|  |  |  |     QMap<QString, QPointer<QObject> > map; | 
					
						
							|  |  |  |     map.insert("Hallo", QPointer<QObject>(&ob)); | 
					
						
							|  |  |  |     map.insert("Welt", QPointer<QObject>(&ob)); | 
					
						
							|  |  |  |     map.insert(".", QPointer<QObject>(&ob)); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-07 15:31:58 +01:00
										 |  |  | void testQMultiMap() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QMultiMap<uint, float> gg0; | 
					
						
							|  |  |  |     gg0.insert(11, 11.0); | 
					
						
							|  |  |  |     gg0.insert(22, 22.0); | 
					
						
							|  |  |  |     gg0.insert(22, 33.0); | 
					
						
							| 
									
										
										
										
											2009-01-07 16:29:14 +01:00
										 |  |  |     gg0.insert(22, 34.0); | 
					
						
							|  |  |  |     gg0.insert(22, 35.0); | 
					
						
							|  |  |  |     gg0.insert(22, 36.0); | 
					
						
							|  |  |  | #if 1
 | 
					
						
							| 
									
										
										
										
											2009-01-07 15:31:58 +01:00
										 |  |  |     QMultiMap<QString, float> gg1; | 
					
						
							|  |  |  |     gg1.insert("22.0", 22.0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QMultiMap<int, QString> gg2; | 
					
						
							|  |  |  |     gg2.insert(22, "22.0"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QMultiMap<QString, Foo> gg3; | 
					
						
							|  |  |  |     gg3.insert("22.0", Foo(22)); | 
					
						
							|  |  |  |     gg3.insert("33.0", Foo(33)); | 
					
						
							|  |  |  |     gg3.insert("22.0", Foo(22)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QObject ob; | 
					
						
							|  |  |  |     QMultiMap<QString, QPointer<QObject> > map; | 
					
						
							|  |  |  |     map.insert("Hallo", QPointer<QObject>(&ob)); | 
					
						
							|  |  |  |     map.insert("Welt", QPointer<QObject>(&ob)); | 
					
						
							|  |  |  |     map.insert(".", QPointer<QObject>(&ob)); | 
					
						
							|  |  |  |     map.insert(".", QPointer<QObject>(&ob)); | 
					
						
							| 
									
										
										
										
											2009-01-07 16:29:14 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-01-07 15:31:58 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 16:31:50 +01:00
										 |  |  | void testQObject(int &argc, char *argv[]) | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     QApplication app(argc, argv); | 
					
						
							|  |  |  |     QAction act("xxx", &app); | 
					
						
							|  |  |  |     QString t = act.text(); | 
					
						
							|  |  |  |     t += "y"; | 
					
						
							| 
									
										
										
										
											2009-04-03 13:39:14 +02:00
										 |  |  |     t += "y"; | 
					
						
							|  |  |  |     t += "y"; | 
					
						
							|  |  |  |     t += "y"; | 
					
						
							|  |  |  |     t += "y"; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-08 16:27:15 +02:00
										 |  |  | #if 1
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     QObject ob(&app); | 
					
						
							|  |  |  |     ob.setObjectName("An Object"); | 
					
						
							|  |  |  |     QObject ob1; | 
					
						
							|  |  |  |     ob1.setObjectName("Another Object"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QObject::connect(&ob, SIGNAL(destroyed()), &ob1, SLOT(deleteLater())); | 
					
						
							|  |  |  |     QObject::connect(&app, SIGNAL(lastWindowClosed()), &ob, SLOT(deleteLater())); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QList<QObject *> obs; | 
					
						
							|  |  |  |     obs.append(&ob); | 
					
						
							|  |  |  |     obs.append(&ob1); | 
					
						
							|  |  |  |     obs.append(0); | 
					
						
							|  |  |  |     obs.append(&app); | 
					
						
							|  |  |  |     ob1.setObjectName("A Subobject"); | 
					
						
							| 
									
										
										
										
											2009-04-08 16:27:15 +02:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-04-02 10:54:22 +02:00
										 |  |  |     QString str = QString::fromUtf8("XXXXXXXXXXXXXXyyXXX ö"); | 
					
						
							|  |  |  |     QLabel l(str); | 
					
						
							| 
									
										
										
										
											2009-07-01 14:15:10 +02:00
										 |  |  |     l.setObjectName("Some Label"); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     l.show(); | 
					
						
							|  |  |  |     app.exec(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 16:31:50 +01:00
										 |  |  | void testQPixmap() | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     QImage im(QSize(200, 200), QImage::Format_RGB32); | 
					
						
							|  |  |  |     im.fill(QColor(200, 100, 130).rgba()); | 
					
						
							|  |  |  |     QPainter pain; | 
					
						
							|  |  |  |     pain.begin(&im); | 
					
						
							|  |  |  |     pain.drawLine(2, 2, 130, 130); | 
					
						
							|  |  |  |     pain.end(); | 
					
						
							|  |  |  |     QPixmap pm = QPixmap::fromImage(im); | 
					
						
							|  |  |  |     int i = 1; | 
					
						
							|  |  |  |     Q_UNUSED(i); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void testPlugin() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QString dir = QDir::currentPath(); | 
					
						
							|  |  |  | #ifdef Q_OS_LINUX
 | 
					
						
							|  |  |  |     QLibrary lib(dir + "/libplugin.so"); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | #ifdef Q_OS_MAC
 | 
					
						
							|  |  |  |     dir = QFileInfo(dir + "/../..").canonicalPath(); | 
					
						
							|  |  |  |     QLibrary lib(dir + "/libplugin.dylib"); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | #ifdef Q_OS_WIN
 | 
					
						
							|  |  |  |     QLibrary lib(dir + "/plugin.dll"); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  |     int (*foo)() = (int(*)()) lib.resolve("pluginTest"); | 
					
						
							|  |  |  |     qDebug() << "library resolve: " << foo; | 
					
						
							|  |  |  |     if (foo) { | 
					
						
							|  |  |  |         int res = foo(); | 
					
						
							|  |  |  |         res += 1; | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         qDebug() << lib.errorString(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 16:31:50 +01:00
										 |  |  | void testQSet() | 
					
						
							| 
									
										
										
										
											2008-12-05 18:44:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     QSet<int> hgg0; | 
					
						
							|  |  |  |     hgg0.insert(11); | 
					
						
							|  |  |  |     hgg0.insert(22); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QSet<QString> hgg1; | 
					
						
							|  |  |  |     hgg1.insert("22.0"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QObject ob; | 
					
						
							|  |  |  |     QSet<QPointer<QObject> > hash; | 
					
						
							|  |  |  |     QPointer<QObject> ptr(&ob); | 
					
						
							|  |  |  |     //hash.insert(ptr);
 | 
					
						
							|  |  |  |     //hash.insert(ptr);
 | 
					
						
							|  |  |  |     //hash.insert(ptr);
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-25 15:00:57 +02:00
										 |  |  | #if QT_VERSION >= 0x040500
 | 
					
						
							| 
									
										
										
										
											2009-04-17 15:34:46 +02:00
										 |  |  | class EmployeeData : public QSharedData | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     EmployeeData() : id(-1) { name.clear(); } | 
					
						
							|  |  |  |     EmployeeData(const EmployeeData &other) | 
					
						
							|  |  |  |         : QSharedData(other), id(other.id), name(other.name) { } | 
					
						
							|  |  |  |     ~EmployeeData() { } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     int id; | 
					
						
							|  |  |  |     QString name; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Employee | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     Employee() { d = new EmployeeData; } | 
					
						
							|  |  |  |     Employee(int id, QString name) { | 
					
						
							|  |  |  |         d = new EmployeeData; | 
					
						
							|  |  |  |         setId(id); | 
					
						
							|  |  |  |         setName(name); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     Employee(const Employee &other) | 
					
						
							|  |  |  |           : d (other.d) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     void setId(int id) { d->id = id; } | 
					
						
							|  |  |  |     void setName(QString name) { d->name = name; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     int id() const { return d->id; } | 
					
						
							|  |  |  |     QString name() const { return d->name; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    private: | 
					
						
							|  |  |  |      QSharedDataPointer<EmployeeData> d; | 
					
						
							|  |  |  |  }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-07 13:50:21 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void testQSharedPointer() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-04-28 10:58:55 +02:00
										 |  |  |     //Employee e1(1, "Herbert");
 | 
					
						
							|  |  |  |     //Employee e2 = e1;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QSharedPointer<int> iptr(new int(43)); | 
					
						
							|  |  |  |     QSharedPointer<int> iptr2 = iptr; | 
					
						
							|  |  |  |     QSharedPointer<int> iptr3 = iptr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QSharedPointer<QString> ptr(new QString("hallo")); | 
					
						
							|  |  |  |     QSharedPointer<QString> ptr2 = ptr; | 
					
						
							|  |  |  |     QSharedPointer<QString> ptr3 = ptr; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-29 17:46:37 +02:00
										 |  |  |     QWeakPointer<int> wiptr(iptr); | 
					
						
							|  |  |  |     QWeakPointer<int> wiptr2 = wiptr; | 
					
						
							|  |  |  |     QWeakPointer<int> wiptr3 = wiptr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QWeakPointer<QString> wptr(ptr); | 
					
						
							|  |  |  |     QWeakPointer<QString> wptr2 = wptr; | 
					
						
							|  |  |  |     QWeakPointer<QString> wptr3 = wptr; | 
					
						
							| 
									
										
										
										
											2009-04-07 13:50:21 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2009-06-25 15:00:57 +02:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-04-07 13:50:21 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | void stringRefTest(const QString &refstring) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     Q_UNUSED(refstring); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-16 11:17:00 +01:00
										 |  |  | void testStdDeque() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     std::deque<int *> plist1; | 
					
						
							|  |  |  |     plist1.push_back(new int(1)); | 
					
						
							|  |  |  |     plist1.push_back(0); | 
					
						
							|  |  |  |     plist1.push_back(new int(2)); | 
					
						
							|  |  |  |     plist1.pop_back(); | 
					
						
							|  |  |  |     plist1.pop_front(); | 
					
						
							|  |  |  |     plist1.pop_front(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::deque<int> flist2; | 
					
						
							|  |  |  |     flist2.push_back(1); | 
					
						
							|  |  |  |     flist2.push_back(2); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::deque<Foo *> plist; | 
					
						
							|  |  |  |     plist.push_back(new Foo(1)); | 
					
						
							|  |  |  |     plist.push_back(new Foo(2)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::deque<Foo> flist; | 
					
						
							|  |  |  |     flist.push_back(1); | 
					
						
							|  |  |  |     flist.push_front(2); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 14:37:15 +01:00
										 |  |  | void testStdList() | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-07-10 09:48:51 +02:00
										 |  |  |     std::list<int> big; | 
					
						
							|  |  |  |     for (int i = 0; i < 10000; ++i) | 
					
						
							|  |  |  |         big.push_back(i); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 14:37:15 +01:00
										 |  |  |     std::list<int *> plist1; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     plist1.push_back(new int(1)); | 
					
						
							|  |  |  |     plist1.push_back(0); | 
					
						
							|  |  |  |     plist1.push_back(new int(2)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 14:37:15 +01:00
										 |  |  |     std::list<int> flist2; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     flist2.push_back(1); | 
					
						
							|  |  |  |     flist2.push_back(2); | 
					
						
							|  |  |  |     flist2.push_back(3); | 
					
						
							|  |  |  |     flist2.push_back(4); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     flist2.push_back(1); | 
					
						
							|  |  |  |     flist2.push_back(2); | 
					
						
							|  |  |  |     flist2.push_back(3); | 
					
						
							|  |  |  |     flist2.push_back(4); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 14:37:15 +01:00
										 |  |  |     std::list<Foo *> plist; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     plist.push_back(new Foo(1)); | 
					
						
							|  |  |  |     plist.push_back(0); | 
					
						
							|  |  |  |     plist.push_back(new Foo(2)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 14:37:15 +01:00
										 |  |  |     std::list<Foo> flist; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     flist.push_back(1); | 
					
						
							|  |  |  |     flist.push_back(2); | 
					
						
							|  |  |  |     flist.push_back(3); | 
					
						
							|  |  |  |     flist.push_back(4); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 14:47:45 +02:00
										 |  |  |     foreach (Foo f, flist) | 
					
						
							|  |  |  |     {} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 14:37:15 +01:00
										 |  |  |     std::list<bool> vec; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     vec.push_back(true); | 
					
						
							|  |  |  |     vec.push_back(false); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-11 16:10:47 +01:00
										 |  |  | void testStdMap() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2008-12-12 12:55:05 +01:00
										 |  |  |     std::map<QString, Foo> gg3; | 
					
						
							|  |  |  |     gg3["22.0"] = Foo(22); | 
					
						
							|  |  |  |     gg3["33.0"] = Foo(33); | 
					
						
							|  |  |  |     gg3["44.0"] = Foo(44); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-17 15:46:27 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     std::map<const char *, Foo> m1; | 
					
						
							|  |  |  |     m1["22.0"] = Foo(22); | 
					
						
							|  |  |  |     m1["33.0"] = Foo(33); | 
					
						
							|  |  |  |     m1["44.0"] = Foo(44); | 
					
						
							| 
									
										
										
										
											2008-12-12 12:55:05 +01:00
										 |  |  | #if 1
 | 
					
						
							|  |  |  |     std::map<uint, uint> gg; | 
					
						
							|  |  |  |     gg[11] = 1; | 
					
						
							|  |  |  |     gg[22] = 2; | 
					
						
							|  |  |  |     gg[33] = 3; | 
					
						
							|  |  |  |     gg[44] = 4; | 
					
						
							|  |  |  |     gg[55] = 5; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-12 14:26:54 +02:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if 0
 | 
					
						
							| 
									
										
										
										
											2008-12-11 16:10:47 +01:00
										 |  |  |     std::map<uint, QStringList> ggl; | 
					
						
							|  |  |  |     ggl[11] = QStringList() << "11"; | 
					
						
							|  |  |  |     ggl[22] = QStringList() << "22"; | 
					
						
							| 
									
										
										
										
											2008-12-12 12:55:05 +01:00
										 |  |  |     ggl[33] = QStringList() << "33"; | 
					
						
							|  |  |  |     ggl[44] = QStringList() << "44"; | 
					
						
							|  |  |  |     ggl[55] = QStringList() << "55"; | 
					
						
							| 
									
										
										
										
											2008-12-11 16:10:47 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     typedef std::map<uint, QStringList> T; | 
					
						
							|  |  |  |     T ggt; | 
					
						
							|  |  |  |     ggt[11] = QStringList() << "11"; | 
					
						
							|  |  |  |     ggt[22] = QStringList() << "22"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::map<uint, float> gg0; | 
					
						
							|  |  |  |     gg0[11] = 11.0; | 
					
						
							|  |  |  |     gg0[22] = 22.0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::map<QString, float> gg1; | 
					
						
							|  |  |  |     gg1["22.0"] = 22.0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::map<int, QString> gg2; | 
					
						
							|  |  |  |     gg2[22] = "22.0"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QObject ob; | 
					
						
							|  |  |  |     std::map<QString, QPointer<QObject> > map; | 
					
						
							| 
									
										
										
										
											2008-12-12 12:55:05 +01:00
										 |  |  |     map["Hallo"] = QPointer<QObject>(&ob); | 
					
						
							|  |  |  |     map["Welt"] = QPointer<QObject>(&ob); | 
					
						
							|  |  |  |     map["."] = QPointer<QObject>(&ob); | 
					
						
							| 
									
										
										
										
											2008-12-11 16:10:47 +01:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-11 13:31:38 +01:00
										 |  |  | void testStdSet() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     std::set<int> hgg0; | 
					
						
							|  |  |  |     hgg0.insert(11); | 
					
						
							|  |  |  |     hgg0.insert(22); | 
					
						
							|  |  |  |     hgg0.insert(33); | 
					
						
							|  |  |  | #if 1
 | 
					
						
							|  |  |  |     std::set<QString> hgg1; | 
					
						
							|  |  |  |     hgg1.insert("22.0"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QObject ob; | 
					
						
							|  |  |  |     std::set<QPointer<QObject> > hash; | 
					
						
							|  |  |  |     QPointer<QObject> ptr(&ob); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 14:37:15 +01:00
										 |  |  | void testStdStack() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     std::stack<int *> plist1; | 
					
						
							|  |  |  |     plist1.push(new int(1)); | 
					
						
							|  |  |  |     plist1.push(0); | 
					
						
							|  |  |  |     plist1.push(new int(2)); | 
					
						
							|  |  |  |     plist1.pop(); | 
					
						
							|  |  |  |     plist1.pop(); | 
					
						
							|  |  |  |     plist1.pop(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::stack<int> flist2; | 
					
						
							|  |  |  |     flist2.push(1); | 
					
						
							|  |  |  |     flist2.push(2); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::stack<Foo *> plist; | 
					
						
							|  |  |  |     plist.push(new Foo(1)); | 
					
						
							|  |  |  |     plist.push(new Foo(2)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::stack<Foo> flist; | 
					
						
							|  |  |  |     flist.push(1); | 
					
						
							|  |  |  |     flist.push(2); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | void testStdString() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QString foo; | 
					
						
							|  |  |  |     std::string str; | 
					
						
							|  |  |  |     std::wstring wstr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::vector<std::string> v; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     foo += "a"; | 
					
						
							|  |  |  |     str += "b"; | 
					
						
							|  |  |  |     wstr += wchar_t('e'); | 
					
						
							|  |  |  |     foo += "c"; | 
					
						
							|  |  |  |     str += "d"; | 
					
						
							|  |  |  |     foo += "e"; | 
					
						
							|  |  |  |     wstr += wchar_t('e'); | 
					
						
							|  |  |  |     str += "e"; | 
					
						
							|  |  |  |     foo += "a"; | 
					
						
							|  |  |  |     str += "b"; | 
					
						
							|  |  |  |     foo += "c"; | 
					
						
							|  |  |  |     str += "d"; | 
					
						
							|  |  |  |     str += "e"; | 
					
						
							|  |  |  |     wstr += wchar_t('e'); | 
					
						
							|  |  |  |     wstr += wchar_t('e'); | 
					
						
							|  |  |  |     str += "e"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QList<std::string> l; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     l.push_back(str); | 
					
						
							|  |  |  |     l.push_back(str); | 
					
						
							|  |  |  |     l.push_back(str); | 
					
						
							|  |  |  |     l.push_back(str); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     v.push_back(str); | 
					
						
							|  |  |  |     v.push_back(str); | 
					
						
							|  |  |  |     v.push_back(str); | 
					
						
							|  |  |  |     v.push_back(str); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 14:37:15 +01:00
										 |  |  | void testStdVector() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     std::vector<int *> plist1; | 
					
						
							|  |  |  |     plist1.push_back(new int(1)); | 
					
						
							|  |  |  |     plist1.push_back(0); | 
					
						
							|  |  |  |     plist1.push_back(new int(2)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::vector<int> flist2; | 
					
						
							|  |  |  |     flist2.push_back(1); | 
					
						
							|  |  |  |     flist2.push_back(2); | 
					
						
							|  |  |  |     flist2.push_back(3); | 
					
						
							|  |  |  |     flist2.push_back(4); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     flist2.push_back(1); | 
					
						
							|  |  |  |     flist2.push_back(2); | 
					
						
							|  |  |  |     flist2.push_back(3); | 
					
						
							|  |  |  |     flist2.push_back(4); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::vector<Foo *> plist; | 
					
						
							|  |  |  |     plist.push_back(new Foo(1)); | 
					
						
							|  |  |  |     plist.push_back(0); | 
					
						
							|  |  |  |     plist.push_back(new Foo(2)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::vector<Foo> flist; | 
					
						
							|  |  |  |     flist.push_back(1); | 
					
						
							|  |  |  |     flist.push_back(2); | 
					
						
							|  |  |  |     flist.push_back(3); | 
					
						
							|  |  |  |     flist.push_back(4); | 
					
						
							|  |  |  |     //flist.takeFirst();
 | 
					
						
							|  |  |  |     //flist.takeFirst();
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::vector<bool> vec; | 
					
						
							|  |  |  |     vec.push_back(true); | 
					
						
							|  |  |  |     vec.push_back(false); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-03 12:46:55 +02:00
										 |  |  | void testQStandardItemModel() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QStandardItemModel m; | 
					
						
							|  |  |  |     QStandardItem *i1, *i2, *i11; | 
					
						
							|  |  |  |     m.appendRow(QList<QStandardItem *>() | 
					
						
							|  |  |  |          << (i1 = new QStandardItem("1")) << (new QStandardItem("a"))); | 
					
						
							|  |  |  |     m.appendRow(QList<QStandardItem *>() | 
					
						
							|  |  |  |          << (i2 = new QStandardItem("2")) << (new QStandardItem("b"))); | 
					
						
							|  |  |  |     i1->appendRow(QList<QStandardItem *>() | 
					
						
							|  |  |  |          << (i11 = new QStandardItem("11")) << (new QStandardItem("aa"))); | 
					
						
							|  |  |  |     int i = 1; | 
					
						
							|  |  |  |     ++i; | 
					
						
							| 
									
										
										
										
											2009-06-23 10:24:25 +02:00
										 |  |  |     +i; | 
					
						
							| 
									
										
										
										
											2009-06-03 12:46:55 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 16:31:50 +01:00
										 |  |  | void testQString() | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     QString str = "Hello "; | 
					
						
							|  |  |  |     str += " big, "; | 
					
						
							|  |  |  |     str += " fat "; | 
					
						
							|  |  |  |     str += " World "; | 
					
						
							|  |  |  |     str += " World "; | 
					
						
							|  |  |  |     str += " World "; | 
					
						
							|  |  |  |     str += " World "; | 
					
						
							|  |  |  |     str += " World "; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 16:31:50 +01:00
										 |  |  | void testQString3() | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     QString str = "Hello "; | 
					
						
							|  |  |  |     str += " big, "; | 
					
						
							|  |  |  |     str += " fat "; | 
					
						
							|  |  |  |     str += " World "; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QString string("String Test"); | 
					
						
							|  |  |  |     QString *pstring = new QString("Pointer String Test"); | 
					
						
							|  |  |  |     stringRefTest(QString("Ref String Test")); | 
					
						
							|  |  |  |     string = "Hi"; | 
					
						
							|  |  |  |     string += "Du"; | 
					
						
							|  |  |  |     qDebug() << string; | 
					
						
							|  |  |  |     delete pstring; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 16:31:50 +01:00
										 |  |  | void testQStringList() | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     QStringList l; | 
					
						
							|  |  |  |     l << "Hello "; | 
					
						
							|  |  |  |     l << " big, "; | 
					
						
							|  |  |  |     l << " fat "; | 
					
						
							|  |  |  |     l << " World "; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void testStruct() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     Foo f(2); | 
					
						
							|  |  |  |     f.doit(); | 
					
						
							|  |  |  |     f.doit(); | 
					
						
							|  |  |  |     f.doit(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Thread : public QThread | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     Thread(int id) : m_id(id) {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     void run() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         for (int i = 0; i != 100000; ++i) { | 
					
						
							|  |  |  |             //sleep(1);
 | 
					
						
							|  |  |  |             std::cerr << m_id; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     int m_id; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 16:31:50 +01:00
										 |  |  | void testQThread() | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     Thread thread1(1); | 
					
						
							|  |  |  |     Thread thread2(2); | 
					
						
							|  |  |  |     thread1.start(); | 
					
						
							|  |  |  |     thread2.start(); | 
					
						
							|  |  |  |     thread1.wait(); | 
					
						
							|  |  |  |     thread2.wait(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 16:31:50 +01:00
										 |  |  | void testQVariant1() | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     QVariant v; | 
					
						
							|  |  |  |     v = 1; | 
					
						
							|  |  |  |     v = 1.0; | 
					
						
							|  |  |  |     v = "string"; | 
					
						
							|  |  |  |     v = 1; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 16:31:50 +01:00
										 |  |  | void testQVariant2() | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-07-01 14:15:10 +02:00
										 |  |  |     QVariant value; | 
					
						
							|  |  |  |     QVariant::Type t = QVariant::String; | 
					
						
							|  |  |  |     value = QVariant(t, (void*)0); | 
					
						
							|  |  |  |     *(QString*)value.data() = QString("XXX"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-26 10:58:56 +01:00
										 |  |  |     int i = 1; | 
					
						
							| 
									
										
										
										
											2009-07-01 14:15:10 +02:00
										 |  |  | #if 0
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     QVariant var; | 
					
						
							| 
									
										
										
										
											2009-03-26 10:58:56 +01:00
										 |  |  |     var.setValue(1); | 
					
						
							|  |  |  |     var.setValue(2); | 
					
						
							|  |  |  |     var.setValue(3); | 
					
						
							|  |  |  |     var.setValue(QString("Hello")); | 
					
						
							|  |  |  |     var.setValue(QString("World")); | 
					
						
							|  |  |  |     var.setValue(QString("Hello")); | 
					
						
							| 
									
										
										
										
											2009-03-26 10:39:20 +01:00
										 |  |  |     var.setValue(QStringList() << "World"); | 
					
						
							| 
									
										
										
										
											2009-03-26 10:58:56 +01:00
										 |  |  |     var.setValue(QStringList() << "World" << "Hello"); | 
					
						
							|  |  |  |     var.setValue(QStringList() << "Hello" << "Hello"); | 
					
						
							|  |  |  |     var.setValue(QStringList() << "World" << "Hello" << "Hello"); | 
					
						
							| 
									
										
										
										
											2009-07-01 14:15:10 +02:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #if 0
 | 
					
						
							|  |  |  |     QVariant var3; | 
					
						
							|  |  |  |     QHostAddress ha("127.0.0.1"); | 
					
						
							|  |  |  |     qVariantSetValue(var, ha); | 
					
						
							|  |  |  |     var3 = var; | 
					
						
							|  |  |  |     var3 = var; | 
					
						
							|  |  |  |     var3 = var; | 
					
						
							|  |  |  |     var3 = var; | 
					
						
							|  |  |  |     QHostAddress ha1 = var.value<QHostAddress>(); | 
					
						
							|  |  |  |     typedef QMap<uint, QStringList> MyType; | 
					
						
							|  |  |  |     MyType my; | 
					
						
							|  |  |  |     my[1] = (QStringList() << "Hello"); | 
					
						
							|  |  |  |     my[3] = (QStringList() << "World"); | 
					
						
							|  |  |  |     var.setValue(my); | 
					
						
							|  |  |  |     QString type = var.typeName(); | 
					
						
							|  |  |  |     var.setValue(my); | 
					
						
							|  |  |  |     var.setValue(my); | 
					
						
							|  |  |  |     var.setValue(my); | 
					
						
							|  |  |  |     var.setValue(my); | 
					
						
							| 
									
										
										
										
											2009-03-26 10:39:20 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 16:31:50 +01:00
										 |  |  | void testQVariant3() | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     QList<int> list; | 
					
						
							|  |  |  |     list << 1 << 2 << 3; | 
					
						
							|  |  |  |     QVariant variant = qVariantFromValue(list); | 
					
						
							|  |  |  |     list.clear(); | 
					
						
							|  |  |  |     list = qVariantValue<QList<int> >(variant); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 16:31:50 +01:00
										 |  |  | void testQVector() | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2008-12-10 16:48:12 +01:00
										 |  |  |     QVector<int> big(10000); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     QVector<Foo *> plist; | 
					
						
							|  |  |  |     plist.append(new Foo(1)); | 
					
						
							|  |  |  |     plist.append(0); | 
					
						
							|  |  |  |     plist.append(new Foo(2)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QVector<Foo> flist; | 
					
						
							|  |  |  |     flist.append(1); | 
					
						
							|  |  |  |     flist.append(2); | 
					
						
							|  |  |  |     flist.append(3); | 
					
						
							|  |  |  |     flist.append(4); | 
					
						
							|  |  |  |     //flist.takeFirst();
 | 
					
						
							|  |  |  |     //flist.takeFirst();
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QVector<bool> vec; | 
					
						
							|  |  |  |     vec.append(true); | 
					
						
							|  |  |  |     vec.append(false); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 16:31:50 +01:00
										 |  |  | void testQVectorOfQList() | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     QVector<QList<int> > v; | 
					
						
							|  |  |  |     QVector<QList<int> > *pv = &v; | 
					
						
							|  |  |  |     v.append(QList<int>() << 1); | 
					
						
							|  |  |  |     v.append(QList<int>() << 2 << 3); | 
					
						
							|  |  |  |     Q_UNUSED(pv); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-25 17:19:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-08 17:27:45 +02:00
										 |  |  | class Goo | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |    Goo(const QString& str, const int n) : | 
					
						
							|  |  |  |            str_(str), n_(n) | 
					
						
							|  |  |  |    { | 
					
						
							|  |  |  |    } | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |    QString str_; | 
					
						
							|  |  |  |    int n_; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef QList<Goo> GooList; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-25 17:19:42 +02:00
										 |  |  | void testNoArgumentName(int i, int, int k) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-07-08 17:27:45 +02:00
										 |  |  |     GooList list; | 
					
						
							|  |  |  |     list.append(Goo("Hello", 1)); | 
					
						
							|  |  |  |     list.append(Goo("World", 2)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QList<Goo> list2; | 
					
						
							|  |  |  |     list2.append(Goo("Hello", 1)); | 
					
						
							|  |  |  |     list2.append(Goo("World", 2)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-03 11:22:18 +02:00
										 |  |  |     i = 1000; | 
					
						
							|  |  |  |     k = 2000; | 
					
						
							|  |  |  |     ++k; | 
					
						
							|  |  |  |     ++k; | 
					
						
							| 
									
										
										
										
											2009-07-08 17:27:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-25 17:19:42 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | void foo() {} | 
					
						
							|  |  |  | void foo(int) {} | 
					
						
							|  |  |  | void foo(QList<int>) {} | 
					
						
							|  |  |  | void foo(QList<QVector<int> >) {} | 
					
						
							|  |  |  | void foo(QList<QVector<int> *>) {} | 
					
						
							|  |  |  | void foo(QList<QVector<int *> *>) {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template <class T> | 
					
						
							|  |  |  | void foo(QList<QVector<T> *>) {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace A { int barz() { return 42;} } | 
					
						
							|  |  |  | namespace B { int barz() { return 43;} } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace somespace { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class MyBase : public QObject | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     MyBase() {} | 
					
						
							|  |  |  |     virtual void doit(int i) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |        n = i; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | protected: | 
					
						
							|  |  |  |     int n; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace nested { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class MyFoo : public MyBase | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     MyFoo() {} | 
					
						
							|  |  |  |     virtual void doit(int i) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |        n = i; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | protected: | 
					
						
							|  |  |  |     int n; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class MyBar : public MyFoo | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     virtual void doit(int i) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |        n = i + 1; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class MyAnon : public MyBar | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     virtual void doit(int i) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |        n = i + 3; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace baz { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class MyBaz : public MyAnon | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     virtual void doit(int i) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |        n = i + 5; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // namespace baz
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // namespace anon
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // namespace nested
 | 
					
						
							|  |  |  | } // namespace somespace
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void testNamespace() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     using namespace somespace; | 
					
						
							|  |  |  |     using namespace nested; | 
					
						
							|  |  |  |     MyFoo foo; | 
					
						
							|  |  |  |     MyBar bar; | 
					
						
							|  |  |  |     MyAnon anon; | 
					
						
							|  |  |  |     baz::MyBaz baz; | 
					
						
							|  |  |  |     baz.doit(1); | 
					
						
							|  |  |  |     anon.doit(1); | 
					
						
							|  |  |  |     foo.doit(1); | 
					
						
							|  |  |  |     bar.doit(1); | 
					
						
							|  |  |  |     bar.doit(1); | 
					
						
							|  |  |  |     bar.doit(1); | 
					
						
							|  |  |  |     bar.doit(1); | 
					
						
							|  |  |  |     bar.doit(1); | 
					
						
							|  |  |  |     bar.doit(1); | 
					
						
							|  |  |  |     bar.doit(1); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 14:37:15 +01:00
										 |  |  | void testHidden() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     int  n = 1; | 
					
						
							|  |  |  |     n = 2; | 
					
						
							|  |  |  |     n = 3; | 
					
						
							|  |  |  |     n = 3; | 
					
						
							|  |  |  |     n = 3; | 
					
						
							|  |  |  |     n = 3; | 
					
						
							|  |  |  |     n = 3; | 
					
						
							|  |  |  |     n = 3; | 
					
						
							|  |  |  |     n = 3; | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         QString n = "2"; | 
					
						
							|  |  |  |         n = "3"; | 
					
						
							|  |  |  |         n = "4"; | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             double n = 3.5; | 
					
						
							|  |  |  |             ++n; | 
					
						
							|  |  |  |             ++n; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         n = "3"; | 
					
						
							|  |  |  |         n = "4"; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     ++n; | 
					
						
							|  |  |  |     ++n; | 
					
						
							| 
									
										
										
										
											2008-12-10 14:37:15 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-23 10:24:25 +02:00
										 |  |  | void testObject1() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QObject parent; | 
					
						
							|  |  |  |     parent.setObjectName("A Parent"); | 
					
						
							|  |  |  |     QObject child(&parent); | 
					
						
							|  |  |  |     child.setObjectName("A Child"); | 
					
						
							| 
									
										
										
										
											2009-06-25 15:00:57 +02:00
										 |  |  |     QObject::connect(&child, SIGNAL(destroyed()), qApp, SLOT(quit())); | 
					
						
							|  |  |  |     QObject::disconnect(&child, SIGNAL(destroyed()), qApp, SLOT(quit())); | 
					
						
							| 
									
										
										
										
											2009-06-23 10:24:25 +02:00
										 |  |  |     child.setObjectName("A renamed Child"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void testVector1() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     std::vector<std::list<int> *> vector; | 
					
						
							|  |  |  |     std::list<int> list; | 
					
						
							|  |  |  |     vector.push_back(new std::list<int>(list)); | 
					
						
							|  |  |  |     vector.push_back(0); | 
					
						
							|  |  |  |     list.push_back(45); | 
					
						
							|  |  |  |     vector.push_back(new std::list<int>(list)); | 
					
						
							|  |  |  |     vector.push_back(0); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void testQHash1() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QHash<QString, QList<int> > hash; | 
					
						
							|  |  |  |     hash.insert("Hallo", QList<int>()); | 
					
						
							|  |  |  |     hash.insert("Welt", QList<int>() << 1); | 
					
						
							|  |  |  |     hash.insert("!", QList<int>() << 1 << 2); | 
					
						
							|  |  |  |     hash.insert("!", QList<int>() << 1 << 2); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 14:37:15 +01:00
										 |  |  | int main(int argc, char *argv[]) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-06-23 10:24:25 +02:00
										 |  |  |     testObject1(); | 
					
						
							|  |  |  |     testVector1(); | 
					
						
							|  |  |  |     testQHash1(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-03 17:27:25 +01:00
										 |  |  |     QString hallo = "hallo"; | 
					
						
							|  |  |  |     QStringList list; | 
					
						
							|  |  |  |     list << "aaa" << "bbb" << "cc"; | 
					
						
							| 
									
										
										
										
											2009-05-25 17:19:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-16 13:25:58 +02:00
										 |  |  |     QList<const char *> list2; | 
					
						
							|  |  |  |     list2 << "foo"; | 
					
						
							|  |  |  |     list2 << "bar"; | 
					
						
							|  |  |  |     list2 << 0; | 
					
						
							|  |  |  |     list2 << "baz"; | 
					
						
							|  |  |  |     list2 << 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-03 12:46:55 +02:00
										 |  |  |     testQStandardItemModel(); | 
					
						
							| 
									
										
										
										
											2009-05-29 16:24:46 +02:00
										 |  |  |     testQImage(); | 
					
						
							| 
									
										
										
										
											2009-05-25 17:19:42 +02:00
										 |  |  |     testNoArgumentName(1, 2, 3); | 
					
						
							| 
									
										
										
										
											2009-02-23 21:15:32 +01:00
										 |  |  |     testIO(); | 
					
						
							| 
									
										
										
										
											2008-12-10 14:37:15 +01:00
										 |  |  |     testHidden(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     testArray(); | 
					
						
							| 
									
										
										
										
											2009-04-02 10:54:22 +02:00
										 |  |  |     testQByteArray(); | 
					
						
							| 
									
										
										
										
											2008-12-10 14:37:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-16 11:17:00 +01:00
										 |  |  |     testStdDeque(); | 
					
						
							| 
									
										
										
										
											2008-12-10 14:37:15 +01:00
										 |  |  |     testStdList(); | 
					
						
							| 
									
										
										
										
											2008-12-11 16:10:47 +01:00
										 |  |  |     testStdMap(); | 
					
						
							| 
									
										
										
										
											2009-03-11 13:31:38 +01:00
										 |  |  |     testStdSet(); | 
					
						
							| 
									
										
										
										
											2008-12-10 14:37:15 +01:00
										 |  |  |     testStdStack(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     testStdString(); | 
					
						
							| 
									
										
										
										
											2008-12-10 14:37:15 +01:00
										 |  |  |     testStdVector(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     testPlugin(); | 
					
						
							| 
									
										
										
										
											2008-12-10 16:31:50 +01:00
										 |  |  |     testQList(); | 
					
						
							| 
									
										
										
										
											2009-01-08 11:02:04 +01:00
										 |  |  |     testQLinkedList(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     testNamespace(); | 
					
						
							|  |  |  |     //return 0;
 | 
					
						
							| 
									
										
										
										
											2008-12-10 16:31:50 +01:00
										 |  |  |     testQHash(); | 
					
						
							|  |  |  |     testQImage(); | 
					
						
							|  |  |  |     testQMap(); | 
					
						
							| 
									
										
										
										
											2009-01-07 15:31:58 +01:00
										 |  |  |     testQMultiMap(); | 
					
						
							| 
									
										
										
										
											2008-12-10 16:31:50 +01:00
										 |  |  |     testQString(); | 
					
						
							|  |  |  |     testQSet(); | 
					
						
							| 
									
										
										
										
											2009-06-25 15:00:57 +02:00
										 |  |  |     #if QT_VERSION >= 0x040500
 | 
					
						
							| 
									
										
										
										
											2009-04-17 15:34:46 +02:00
										 |  |  |     testQSharedPointer(); | 
					
						
							| 
									
										
										
										
											2009-06-25 15:00:57 +02:00
										 |  |  |     #endif
 | 
					
						
							| 
									
										
										
										
											2008-12-10 16:31:50 +01:00
										 |  |  |     testQStringList(); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     testStruct(); | 
					
						
							|  |  |  |     //testThreads();
 | 
					
						
							| 
									
										
										
										
											2008-12-10 16:31:50 +01:00
										 |  |  |     testQVariant1(); | 
					
						
							|  |  |  |     testQVariant2(); | 
					
						
							|  |  |  |     testQVariant3(); | 
					
						
							|  |  |  |     testQVector(); | 
					
						
							|  |  |  |     testQVectorOfQList(); | 
					
						
							| 
									
										
										
										
											2008-12-08 11:58:36 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-05 14:13:09 +01:00
										 |  |  |     //*(int *)0 = 0;
 | 
					
						
							| 
									
										
										
										
											2008-12-08 11:58:36 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-10 16:31:50 +01:00
										 |  |  |     testQObject(argc, argv); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-08 11:58:36 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     //QColor color(255,128,10);
 | 
					
						
							|  |  |  |     //QFont font;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     while(true) | 
					
						
							|  |  |  |         ; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //Q_DECLARE_METATYPE(QHostAddress)
 | 
					
						
							|  |  |  | Q_DECLARE_METATYPE(QList<int>) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //#define COMMA ,
 | 
					
						
							|  |  |  | //Q_DECLARE_METATYPE(QMap<uint COMMA QStringList>)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QT_BEGIN_NAMESPACE | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template <> | 
					
						
							|  |  |  | struct QMetaTypeId<QHostAddress> | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     enum { Defined = 1 }; | 
					
						
							|  |  |  |     static int qt_metatype_id() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); | 
					
						
							|  |  |  |         if (!metatype_id) | 
					
						
							| 
									
										
										
										
											2009-04-06 10:58:48 +02:00
										 |  |  |              metatype_id = qRegisterMetaType<QHostAddress> | 
					
						
							|  |  |  |                 ("myns::QHostAddress"); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return metatype_id;                                    \ | 
					
						
							|  |  |  |     }                                                           \ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template <> | 
					
						
							|  |  |  | struct QMetaTypeId< QMap<uint, QStringList> > | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     enum { Defined = 1 }; | 
					
						
							|  |  |  |     static int qt_metatype_id() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); | 
					
						
							|  |  |  |         if (!metatype_id) | 
					
						
							| 
									
										
										
										
											2009-04-06 10:58:48 +02:00
										 |  |  |              metatype_id = qRegisterMetaType< QMap<uint, QStringList> > | 
					
						
							|  |  |  |                 ("myns::QMap<uint, myns::QStringList>"); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |         return metatype_id;                                    \ | 
					
						
							|  |  |  |     }                                                           \ | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2009-07-06 11:37:21 +02:00
										 |  |  | QT_END_NAMESPACE |