MCPcopy Create free account
hub / github.com/OpenBoard-org/OpenBoard / onDisplayMetadata

Method onDisplayMetadata

src/gui/UBFeaturesWidget.cpp:274–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

272}
273
274void UBFeaturesWidget::onDisplayMetadata( QMap<QString,QString> metadata )
275{
276 QString previewImageUrl = ":images/libpalette/notFound.png";
277
278 QString widgetsUrl = QUrl::fromEncoded(metadata["Url"].toLatin1()).toString()/*metadata.value("Url", QString())*/;
279 QString widgetsThumbsUrl = QUrl::fromEncoded(metadata["thumbnailUrl"].toLatin1()).toString();
280
281 QString strType = UBFileSystemUtils::mimeTypeFromFileName(widgetsUrl);
282 UBMimeType::Enum thumbType = UBFileSystemUtils::mimeTypeFromString(strType);
283
284 switch (static_cast<int>(thumbType)) {
285 case UBMimeType::Audio:
286 previewImageUrl = ":images/libpalette/soundIcon.svg";
287 break;
288
289 case UBMimeType::Video:
290 previewImageUrl = ":images/libpalette/movieIcon.svg";
291 break;
292
293 case UBMimeType::Flash:
294 previewImageUrl = ":images/libpalette/FlashIcon.svg";
295 break;
296
297 case UBMimeType::RasterImage:
298 case UBMimeType::VectorImage:
299 previewImageUrl = widgetsUrl;
300 break;
301 }
302
303 if (!widgetsThumbsUrl.isNull()) {
304 previewImageUrl = ":/images/libpalette/loading.png";
305 if (!imageGatherer)
306 imageGatherer = new UBDownloadHttpFile(0, this);
307
308 connect(imageGatherer, SIGNAL(downloadFinished(int, bool, QUrl, QUrl, QString, QByteArray, QPointF, QSize, bool)), this, SLOT(onPreviewLoaded(int, bool, QUrl, QUrl, QString, QByteArray, QPointF, QSize, bool)));
309
310 // We send here the request and store its reply in order to be able to cancel it if needed
311 imageGatherer->get(QUrl(widgetsThumbsUrl), QPoint(0,0), QSize(), false);
312 }
313
314 UBFeature feature( "/root", QImage(previewImageUrl), QString(), widgetsUrl, FEATURE_ITEM );
315 feature.setMetadata( metadata );
316
317 centralWidget->showElement(feature, UBFeaturesCentralWidget::FeaturePropertiesList);
318 mActionBar->setCurrentState( IN_PROPERTIES );
319}
320
321
322void UBFeaturesWidget::onPreviewLoaded(int id, bool pSuccess, QUrl sourceUrl, QUrl originalUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground)

Callers

nothing calls this directly

Calls 4

setMetadataMethod · 0.80
showElementMethod · 0.80
setCurrentStateMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected