Advertisement
houmingc

QLinkedList

May 15th, 2015
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.41 KB | None | 0 0
  1.  
  2.  
  3. class CComponent{
  4. public:
  5. QString ComponentID;
  6. QString ComponentType;
  7. int ComponentX;
  8. int ComponentY;
  9. int ComponentWidth;
  10. int ComponentHeight;
  11. int ComponentZOrder;
  12. int ComponentAspectRatio;
  13. int Transparent;
  14. int Red;
  15. int Green;
  16. int Blue;
  17.  
  18. void SetComponentID(QString ID){
  19. ComponentID = ID;
  20. }
  21. void SetComponentType(QString Type){
  22. ComponentType = Type;
  23. }
  24. void SetComponentX(int X){
  25. ComponentX = X;
  26. }
  27. void SetComponentY(int Y){
  28. ComponentY = Y;
  29. }
  30. void SetComponentWidth(int Width){
  31. ComponentWidth = Width;
  32. }
  33. void SetComponentHeight(int Height){
  34. ComponentHeight = Height;
  35. }
  36. void SetComponentZOrder(int Z){
  37. ComponentZOrder = Z;
  38. }
  39. void SetComponentAspectRatio(int AS){
  40. ComponentAspectRatio = AS;
  41. }
  42. void SetComponentBackgroundTransparent(int T){
  43. Transparent = T;
  44. }
  45. void SetComponentBackgroundRed(int red){
  46. Red = red;
  47. }
  48. void SetComponentBackgroundGreen(int green){
  49. Green = green;
  50. }
  51. void SetComponentBackgroundBlue(int blue){
  52. Blue = blue;
  53. }
  54.  
  55. };
  56.  
  57.  
  58.  
  59.  
  60. int main(int argc, char **argv)
  61. {
  62. QApplication app(argc, argv);
  63. qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime()));
  64.  
  65. QXmlGet xmlGet;
  66. xmlGet.load("/opt/TMP00000000.xml");
  67. QLinkedList<CComponent> ComponentList;
  68. CComponent ComponentTemplate;
  69. while (xmlGet.findNextAndDescend("Component"))
  70. {
  71.  
  72. QString ComponentID = xmlGet.getAttributeString("ID","unknown");
  73. QString ComponentType = xmlGet.getAttributeString("Type","unknown");
  74. int ComponentX = xmlGet.getAttributeInt("X");
  75. int ComponentY = xmlGet.getAttributeInt("Y");
  76. int ComponentWidth = xmlGet.getAttributeInt("Width");
  77. int ComponentHeight = xmlGet.getAttributeInt("Height");
  78. int ComponentZOrder = xmlGet.getAttributeInt("ZOrder");
  79. int ComponentAspectRatio = xmlGet.getAttributeInt("AspectRatio");
  80.  
  81. ComponentTemplate.SetComponentID(ComponentID);
  82. ComponentTemplate.SetComponentType(ComponentType);
  83. ComponentTemplate.SetComponentX(ComponentX);
  84. ComponentTemplate.SetComponentY(ComponentY);
  85. ComponentTemplate.SetComponentWidth(ComponentWidth);
  86. ComponentTemplate.SetComponentHeight(ComponentHeight);
  87. ComponentTemplate.SetComponentZOrder(ComponentZOrder);
  88. ComponentTemplate.SetComponentAspectRatio(ComponentAspectRatio);
  89.  
  90.  
  91. ComponentList.append(ComponentTemplate);
  92.  
  93.  
  94. qDebug()<<"ComponentID is "<<ComponentID;
  95. qDebug()<<"ComponentType is "<<ComponentType;
  96. qDebug()<<"ComponentX is "<<ComponentX;
  97. qDebug()<<"ComponentY is "<<ComponentY;
  98. qDebug()<<"ComponentWidth is "<<ComponentWidth;
  99. qDebug()<<"ComponentHeight is "<<ComponentHeight;
  100. qDebug()<<"ComponentZOrder is "<<ComponentZOrder;
  101. qDebug()<<"ComponentAspectRatio is "<<ComponentAspectRatio;
  102.  
  103. if (xmlGet.findNext("Background"))
  104. {
  105. int Transparent = xmlGet.getAttributeInt("Transparent");
  106. int Red = xmlGet.getAttributeInt("Red");
  107. int Green = xmlGet.getAttributeInt("Green");
  108. int Blue = xmlGet.getAttributeInt("Blue");
  109.  
  110. ComponentTemplate.SetComponentBackgroundTransparent(Transparent);
  111. ComponentTemplate.SetComponentBackgroundRed(Red);
  112. ComponentTemplate.SetComponentBackgroundGreen(Green);
  113. ComponentTemplate.SetComponentBackgroundBlue(Blue);
  114.  
  115. qDebug()<<"BackgroundTransparent is "<<Transparent;
  116. qDebug()<<"BackgroundRed is "<<Red;
  117. qDebug()<<"BackgroundGreen is "<<Green;
  118. qDebug()<<"BackgroundBlue is "<<Blue;
  119. qDebug()<<QT_VERSION_STR;
  120. }
  121. xmlGet.rise();
  122. ComponentList.append(ComponentTemplate);
  123. }
  124.  
  125.  
  126. for(i=0 ;i<3 ;i++)
  127. {
  128.  
  129.  
  130. }
  131. foreach(QString s, ComponentList) qDebug()<< s;
  132.  
  133.  
  134.  
  135.  
  136. QGraphicsScene scene;
  137. scene.setSceneRect(-300, -300, 600, 600);
  138.  
  139. scene.setItemIndexMethod(QGraphicsScene::NoIndex);
  140.  
  141. for (int i = 0; i < MouseCount; ++i) {
  142. Mouse *mouse = new Mouse;
  143. mouse->setPos(::sin((i * 6.28) / MouseCount) * 200,
  144. ::cos((i * 6.28) / MouseCount) * 200);
  145. scene.addItem(mouse);
  146. }
  147.  
  148.  
  149. WidgetCircle *circleTest = new WidgetCircle;
  150. WidgetCountdown *CountdownTest = new WidgetCountdown;
  151. WidgetMarqueeLabel *MarqueeTest = new WidgetMarqueeLabel;
  152. DigitalClock *ClockTest = new DigitalClock;
  153. QVideoWidget *videoTest = new QVideoWidget;
  154.  
  155. //videoTest
  156.  
  157. MarqueeTest->setDirection(1);
  158. MarqueeTest->setSpeed(1);
  159. MarqueeTest->setText("How are you everyone everybody ");
  160.  
  161.  
  162.  
  163. QGraphicsProxyWidget *proxy = scene.addWidget(CountdownTest);
  164. //proxy->setPos(30,30);
  165. // proxy->setPos(::sin((6.28) ) * 200,
  166. // ::cos((6.28) ) * 200);
  167.  
  168. proxy->setPos(-200,-200);
  169. // proxy->setPos(100,100);
  170. proxy->moveBy(4,4);
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178. // TimeGraphics *timerWidget = new TimeGraphics;
  179. // // scene.addItem(timerWidget);
  180. // MyRect *rect = new MyRect;
  181.  
  182.  
  183. // QGraphicsProxyWidget *proxy = scene.addWidget(rect);
  184.  
  185.  
  186.  
  187. /*
  188. MyRect *rect = new MyRect();
  189. rect->setRect(60,60,100,100);
  190. scene.addItem(rect);
  191. scene.addText("Hello /n There eVeryOne /n every where");
  192. scene.addSimpleText(" How are you");
  193. myGraphicsWidget* graphicsWidget = new myGraphicsWidget("This is my custom");
  194. scene.addItem(graphicsWidget);
  195. QGraphicsTextItem* item1 = new QGraphicsTextItem("QGraphicsTextItem Text Colro1");
  196. QGraphicsTextItem* item2 = new QGraphicsTextItem("Hellow there ");
  197. item1->setDefaultTextColor(Qt::red);
  198. item2->setDefaultTextColor(Qt::blue);
  199. scene.addItem(item1);
  200. scene.addItem(item2);
  201. item1->setRotation(30);
  202. item2->setRotation(60);
  203. item1->setPos(200,200);
  204. item2->setPos(-120,-120);
  205. */
  206.  
  207.  
  208.  
  209.  
  210.  
  211. QGraphicsView view(&scene);
  212. view.setRenderHint(QPainter::Antialiasing);
  213. //view.setBackgroundBrush(QPixmap(":/images/cheese.jpg"));
  214.  
  215. view.setCacheMode(QGraphicsView::CacheBackground);
  216. view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
  217. view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  218. view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  219. //view.setDragMode(QGraphicsView::ScrollHandDrag);
  220.  
  221. view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Colliding Mice"));
  222. view.resize(400, 300);
  223. view.show();
  224.  
  225.  
  226. int ItemCount = 1;
  227. for (int i =0; i< ItemCount; i++)
  228. {
  229. BoxAnimation *item = new BoxAnimation();
  230. scene.addItem(item);
  231.  
  232. }
  233.  
  234.  
  235.  
  236. QTimer timer;
  237. QObject::connect(&timer, SIGNAL(timeout()), &scene, SLOT(advance()));
  238. timer.start(1000 / 33);
  239.  
  240. return app.exec();
  241. }
  242. //! [6]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement