NCL Composer  0.1.5
 All Classes Functions Variables Pages
DebugConsolePlugin.cpp
1 /*
2  * Copyright 2011 TeleMidia/PUC-Rio.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library. If not, see
16  * <http://www.gnu.org/licenses/>.
17  */
18 #include "DebugConsolePlugin.h"
19 
20 DebugConsolePlugin::DebugConsolePlugin()
21 {
22  window = new QWidget();
23  QGridLayout *layout = new QGridLayout(window);
24  QPushButton *bt = new QPushButton(window);
25  bt->setText(tr("Clear"));
26  layout->addWidget(bt);
27  list = new QListWidget(window);
28  list->setAlternatingRowColors(true);
29  layout->addWidget(list);
30  connect(bt, SIGNAL(clicked()), list, SLOT(clear()));
31  connect(bt, SIGNAL(clicked()), this, SLOT(sendToAll()));
32  window->setLayout(layout);
33  window->setWindowIcon(QIcon(":/images/icon.png"));
34  project = NULL;
35 
36 }
37 
38 DebugConsolePlugin::~DebugConsolePlugin()
39 {
40  if(window != NULL)
41  delete window;
42  window = NULL;
43 }
44 
46 {
47  //TODO: All
48 }
49 
51 {
52  return window;
53 }
54 
55 void DebugConsolePlugin::onEntityAdded(QString ID, Entity *entity)
56 {
57  QString line = "PLUGIN (" + ID + ") added the Entity (" +
58  entity->getType() + " - " + entity->getUniqueId() +")";
59  list->insertItem(0, new QListWidgetItem(line));
60  /* if(list->count())
61  list->item(0)->setText(line);
62  else
63  list->addItem(new QListWidgetItem(line));*/
64 }
65 
66 void DebugConsolePlugin::errorMessage(QString error)
67 {
68  // list->insertItem(0, new QListWidgetItem(error));
69  if(list->count())
70  list->item(0)->setText(error);
71  else
72  list->addItem(new QListWidgetItem(error));
73 }
74 
75 void DebugConsolePlugin::onEntityChanged(QString ID, Entity * entity)
76 {
77  QString line = "PLUGIN (" + ID + ") changed the Entity (" +
78  entity->getType() + " - " + entity->getUniqueId() +")";
79  list->insertItem(0, new QListWidgetItem(line));
80 /* if(list->count())
81  list->item(0)->setText(line);
82  else
83  list->addItem(new QListWidgetItem(line)); */
84 }
85 
86 /*void DebugConsolePlugin::onEntityAboutToRemove(Entity *)
87 {
88 
89 }*/
90 
91 void DebugConsolePlugin::onEntityRemoved(QString ID, QString entityID)
92 {
93  QString line = "PLUGIN (" + ID + ") removed Entity (" +
94  entityID + ")";
95  list->insertItem(0, new QListWidgetItem(line));
96  /*if(list->count())
97  list->item(0)->setText(line);
98  else
99  list->addItem(new QListWidgetItem(line));*/
100 }
101 
103 {
104  //TODO: All
105  return true;
106 }
107 
108 void DebugConsolePlugin::sendToAll()
109 {
110  /* Invoker <Result> in;
111  in.addArgument<int>(10);
112  in.addArgument<int>(20);
113  in.addArgument<int>(30);
114 
115  in.sendBroadcastMessage("debugHasSendClearAll"); */
116 
117  emit sendBroadcastMessage("debugHasSendClearAll", NULL);
118 }
119