NCL Composer  0.1.5
 All Classes Functions Variables Pages
mediapreviewplugin.cpp
1 
15 #include <mediapreviewplugin.h>
16 #include<QString>
17 #include<QTextStream>
18 #include<QIODevice>
19 #include<QMainWindow>
20 #include<audioplayer.h>
21 #include<gifview.h>
22 #include<hypertextview.h>
23 #include<nclview.h>
24 #include "videoplayer.h"
25 #include<QMovie>
26 #include<QIcon>
27 #include<QPalette>
28 #include<QHBoxLayout>
29 #include<QVBoxLayout>
30 #include<QFont>
31 #include<QString>
32 #include<QTextStream>
33 
34 
35 using namespace std;
36 
38 {
39  /*Main Widget*/
40  windowg = new QMainWindow(0);
41  windowg->setStyleSheet("* { background-color: rgb(220,220,220) }");
42  comp = "";
43 }
44 
46 {
47 
48 }
49 
51 {
52  return windowg;
53 }
54 
55 
56 void MediaPreviewPlugin::changeSelectedEntity(QString plugID, void *param)
57 {
58  QString *entityUID = (QString*) param;
59 
60  if(entityUID != NULL)
61  {
62 
63  Entity* entity = getProject()->getEntityById(*entityUID);
64  if(entity != NULL)
65  {
66  if(entity->getType() == "media")
67  {
68  QString attrSrc = "";
69  QString attrType = entity->getAttribute("type");
70 
71  QFileInfo finfo(getProject()->getLocation());
72  QString location = finfo.dir().absolutePath();
73 
74 
75  if (QFile::exists(entity->getAttribute("src")))
76  {
77  attrSrc = entity->getAttribute("src");
78  }
79  else if (QFile::exists(location+
80  QDir::separator()+
81  entity->getAttribute("src")))
82  {
83  attrSrc = location+
84  QDir::separator()+
85  entity->getAttribute("src");
86  }
87 
88  if (comp != entity->getUniqueId() && attrSrc != "")
89  {
90  comp=entity->getUniqueId();
91  QString type;
92 
93  /* Manejo das extensões dos objetos de mídia. Compara
94  se o valor contido na variavél attrSrc corresponde a um objeto
95  de mída do tipo vídeo, audio, imagem, hypertexto, ncl or lua.*/
96 
97 
98  /*Objeto de mídia do tipo VIDEO*/
99  if(attrSrc.endsWith(".mp4") ||
100  attrSrc.endsWith(".mpg")|| attrSrc.endsWith(".mp2") ||
101  attrSrc.endsWith(".mpe") || attrSrc.endsWith(".mpg4") ||
102  attrSrc.endsWith(".mng") || attrSrc.endsWith(".qt") ||
103  attrSrc.endsWith(".mov") || attrSrc.endsWith(".avi") )
104  {
105  type = "video";
106  }
107 
108  /*Objeto de mídia do tipo AUDIO*/
109  else if(attrSrc.endsWith(".mp3") || attrSrc.endsWith(".flv") ||
110  attrSrc.endsWith(".wav") || attrSrc.endsWith(".ua") ||
111  attrSrc.endsWith(".mp2") || attrSrc.endsWith(".mp4")||
112  attrSrc.endsWith(".mpg4"))
113  {
114  type = "audio";
115 
116  }
117 
118  /*Objeto de mídia do tipo IMAGEM*/
119  else if(attrSrc.endsWith(".jpeg") || attrSrc.endsWith(".png") ||
120  attrSrc.endsWith(".bmp") || attrSrc.endsWith(".jpg") ||
121  attrSrc.endsWith(".jpe"))
122  {
123  type = "image";
124  }
125 
126  /*Objeto de mídia do tipo GIF*/
127  else if (attrSrc.endsWith((".gif")))
128  {
129  type ="gif";
130  }
131 
132  /*Objeto de mídia do tipo HYPERTEXT*/
133  else if (attrSrc.startsWith ("http") ||attrSrc.endsWith(".html") ||
134  attrSrc.endsWith(".htm") || attrSrc.endsWith(".xhtml"))
135  {
136  type = "hypertext";
137  }
138 
139  /*Objeto de mídia do tipo TEXTO*/
140  else if (attrSrc.endsWith(".txt"))
141  {
142  type ="text";
143  }
144 
145  /*Objeto de mídia do tipo NCL*/
146  else if (attrSrc.endsWith(".ncl"))
147  {
148  type="ncl";
149  }
150 
151  /*Objeto de mídia do tipo LUA*/
152  else if (attrSrc.endsWith(".lua") )
153  {
154  type="lua";
155  }
156 
157  /*Objeto de mídia do tipo XML*/
158 
159  else if(attrSrc.endsWith(".xml"))
160  {
161  type ="xml";
162  }
163 
164  else if(attrSrc.endsWith(".css"))
165  {
166  type="css";
167  }
168 
169  /*Objeto de mídia do tipo XLT*/
170 
171  else if (attrSrc.endsWith(".xlt")|| attrSrc.endsWith(".xlet")|| attrSrc.endsWith(".class"))
172  {
173  type="let";
174  }
175 
176  /* Manejo do atributo type,attrType. (overwrite extension)*/
177 
178  if(attrType.contains("video/"))
179  {
180  type = "video";
181  }
182  else if(attrType.contains("audio/"))
183  {
184  type = "audio";
185 
186  }
187 
188  else if(attrType.contains("image/gif") )
189  {
190  type="gif";
191 
192  }
193 
194  else if (attrType.contains("image/bmp")||attrType.contains("image/png")|| attrType.contains("image/jpg")
195  ||attrType.contains("image/jpeg")||attrType.contains("image/jpe"))
196  {
197  type="image";
198  }
199 
200  else if(attrType.contains("text/xml"))
201  {
202  type="Markup language";
203  }
204  else if (attrType.contains("text/html"))
205  {
206  type ="hypertext";
207  }
208 
209  else if(attrType.contains("text/css"))
210  {
211  type="css";
212  }
213 
214  else if(attrType.contains("text/plain"))
215  {
216  type="text";
217  }
218 
219  else if(attrType.contains("application/x-ginga-ncl")||attrType.contains("application/x-ncl-NCL"))
220  {
221  type="ncl";
222  }
223 
224  else if (attrType.contains("application/x-ginga-NCLua")|| attrType.contains("application/x-ncl-NCLua"))
225  {
226  type="lua";
227 
228  }
229 
230  else if(attrType.contains("application/x-ginga-NCLet"))
231  {
232  type="let";
233  }
234 
235  /*Interface para exibir o objeto de mídia, dependendo da extensão y/ou tipo
236  da mída. Uma clase diferente para cada tipo de mídia foi criada. */
237 
238  /*audio*/
239  if (type =="audio")
240  {
241 
242  musicplayer = new audioplayer(attrSrc);
243  musicplayer->setParent(windowg);
244  windowg->setCentralWidget(musicplayer);
245 
246  }
247 
248 
249  /*video*/
250  if(type=="video")
251  {
252  videoplay = new videoplayer(attrSrc);
253  videoplay->setParent(windowg);
254  windowg->setCentralWidget(videoplay);
255 
256  }
257 
258 
259  /*image*/
260  if(type =="image")
261  {
262  imageview= new imagview(attrSrc);
263  imageview->setParent(windowg);
264  windowg->setCentralWidget(imageview);
265  }
266 
267  /*gif*/
268 
269  if(type=="gif")
270  {
271  picgifview = new gifview(attrSrc);
272  picgifview->setParent(windowg);
273  windowg->setCentralWidget(picgifview);
274  }
275 
276  /*text*/
277  if(type=="text")
278  {
279  txtview =new textview(attrSrc);
280  txtview->setParent(windowg);
281  windowg->setCentralWidget(txtview);
282  }
283 
284  /*hypertext*/
285  if(type=="hypertext")
286  {
287  hyperview = new hypertextview(attrSrc);
288  hyperview->setParent(windowg);
289  windowg->setCentralWidget(hyperview);
290 
291  }
292 
293  /*XML*/
294 
295  if(type=="xml")
296  {
297 
298  }
299 
300  /*NCL DOCUMENTS */
301  if(type=="ncl")
302  {
303  ncldocview =new nclview(attrSrc);
304  ncldocview->setParent(windowg);
305  windowg->setCentralWidget(ncldocview);
306  }
307 
308  /*LUA OBJECTS*/
309 
310  if(type=="lua")
311  {
312  luaobjview = new luaview(attrSrc);
313  luaobjview->setParent(windowg);
314  windowg->setCentralWidget(luaobjview);
315 
316  }
317 
318  }
319 
320  }
321  }
322  }
323  }
324 
325 
326