From 666b67b1646925620602c6023dad598ed3b05d82 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Wed, 20 Apr 2011 16:22:07 +0200 Subject: [PATCH] Displayed on the interactivities directory the 4 internal widget. Those widget hasn't a corresponding real file on interactivities directory. --- src/board/UBBoardController.cpp | 4 +--- src/board/UBBoardView.cpp | 18 +++++++----------- src/board/UBLibraryController.cpp | 26 +++++++++++++++++++++++++- src/board/UBLibraryController.h | 2 ++ src/gui/UBLibraryWidget.cpp | 2 +- src/gui/UBThumbnailWidget.cpp | 3 +-- src/gui/UBThumbnailWidget.h | 4 +--- 7 files changed, 38 insertions(+), 21 deletions(-) diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index 9216ba9b..45f4c262 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -1786,9 +1786,7 @@ void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPoint int index = 0; - foreach(const QUrl url, urls) - { - qWarning() << url; + foreach(const QUrl url, urls){ QPointF pos(pPos + QPointF(index * 15, index * 15)); downloadURL(url, pos); index++; diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp index 138c5c44..712d89b9 100644 --- a/src/board/UBBoardView.cpp +++ b/src/board/UBBoardView.cpp @@ -683,10 +683,6 @@ UBBoardView::dragMoveEvent (QDragMoveEvent *event) void UBBoardView::dropEvent (QDropEvent *event) { - qDebug () << event; - - qDebug() << event->source(); - if(!event->source() || dynamic_cast(event->source())) { mController->processMimeData (event->mimeData (), mapToScene (event->pos ())); @@ -801,9 +797,9 @@ UBBoardView::settingChanged (QVariant newValue) void UBBoardView::virtualKeyboardActivated(bool b) { - UBPlatformUtils::setWindowNonActivableFlag(this, b); - mVirtualKeyboardActive = b; - setInteractive(!b); + UBPlatformUtils::setWindowNonActivableFlag(this, b); + mVirtualKeyboardActive = b; + setInteractive(!b); } @@ -812,16 +808,16 @@ void UBBoardView::virtualKeyboardActivated(bool b) bool UBBoardView::isAbsurdPoint (QPoint point) { - QDesktopWidget *desktop = qApp->desktop (); - bool isValidPoint = false; + QDesktopWidget *desktop = qApp->desktop (); + bool isValidPoint = false; - for (int i = 0; i < desktop->numScreens (); i++) + for (int i = 0; i < desktop->numScreens (); i++) { QRect screenRect = desktop->screenGeometry (i); isValidPoint = isValidPoint || screenRect.contains (point); } - return !isValidPoint; + return !isValidPoint; } void diff --git a/src/board/UBLibraryController.cpp b/src/board/UBLibraryController.cpp index d82079b5..e8d5e0eb 100644 --- a/src/board/UBLibraryController.cpp +++ b/src/board/UBLibraryController.cpp @@ -49,6 +49,7 @@ static quint32 magicNumber = 0xACDCAFE0; static QString applicationsVirtualPath = "$applications$"; static QString picturesVirtualPath = "$pictures$"; static QString favoriteVirtualPath = "$favorite$"; +static QString interactivesCategoryPath; UBLibraryController::UBLibraryController(QWidget *pParentWidget, UBBoardController *pBoardController) : QObject(pParentWidget), @@ -78,6 +79,26 @@ UBLibraryController::UBLibraryController(QWidget *pParentWidget, UBBoardControll mPicturesStandardDirectoryPath = QUrl::fromLocalFile(UBDesktopServices::storageLocation(QDesktopServices::PicturesLocation)); userPath(mPicturesStandardDirectoryPath); + + createInternalWidgetItems(); + +} + +void UBLibraryController::createInternalWidgetItems() +{ + QStringList toolUris = UBToolsManager::manager()->allToolIDs(); + + foreach(QString toolUri, toolUris) + { + UBToolsManager::UBToolDescriptor tool = UBToolsManager::manager()->toolByID(toolUri); + UBLibElement *newTool = new UBLibElement(eUBLibElementType_InteractiveItem, QUrl(tool.id), tool.label); + QImage toolImage = tool.icon.toImage(); + newTool->setThumbnail(&toolImage); + newTool->setInformation(tool.label + " " + tool.version); + + mInternalLibElements << newTool; + } + } void UBLibraryController::createNewFolder(QString name, UBLibElement *parentElem) @@ -231,7 +252,8 @@ QList UBLibraryController::rootCategoriesList() categories << element; categoryImage = new QImage(":images/libpalette/InteractivesCategory.svg"); - element = new UBLibElement(eUBLibElementType_Folder, QUrl::fromLocalFile(UBSettings::settings()->uniboardGipLibraryDirectory()), tr("Interactives", "Interactives category element")); + interactivesCategoryPath = UBSettings::settings()->uniboardGipLibraryDirectory(); + element = new UBLibElement(eUBLibElementType_Folder, QUrl::fromLocalFile(interactivesCategoryPath), tr("Interactives", "Interactives category element")); element->setThumbnail(categoryImage); categories << element; @@ -317,6 +339,8 @@ QList UBLibraryController::listElementsInPath(const QString& pPat content << element; } + if (pPath == interactivesCategoryPath) + content << mInternalLibElements; return content; } diff --git a/src/board/UBLibraryController.h b/src/board/UBLibraryController.h index 0e0367e3..fcff4495 100644 --- a/src/board/UBLibraryController.h +++ b/src/board/UBLibraryController.h @@ -157,6 +157,7 @@ class UBLibraryController : public QObject QList mFavoriteList; void persistFavoriteList(); void readFavoriteList(); + QList mInternalLibElements; private: QList rootCategoriesList(); @@ -168,6 +169,7 @@ class UBLibraryController : public QObject QList elementsInPicturesVirtualForlder(); QList elementsInApplicationsVirtualForlder(); + void createInternalWidgetItems(); void routeItem(QString& pItem, QString pMiddleDirectory = QString()); void createDirectory(QUrl& pDirPath); diff --git a/src/gui/UBLibraryWidget.cpp b/src/gui/UBLibraryWidget.cpp index d4e905cb..3b6c5d62 100644 --- a/src/gui/UBLibraryWidget.cpp +++ b/src/gui/UBLibraryWidget.cpp @@ -104,7 +104,7 @@ void UBLibraryWidget::generateItems() { UBLibElement* pElem = mCurrentElems.at(i); mLabels << pElem->name(); - mItemsPaths << pElem->path().toLocalFile(); + mItemsPaths << pElem->path(); QGraphicsPixmapItem *pixmapItem = new UBThumbnailPixmap(QPixmap::fromImage(*pElem->thumbnail())); mGraphicItems << pixmapItem; } diff --git a/src/gui/UBThumbnailWidget.cpp b/src/gui/UBThumbnailWidget.cpp index 9e7a73e3..4d994f7b 100644 --- a/src/gui/UBThumbnailWidget.cpp +++ b/src/gui/UBThumbnailWidget.cpp @@ -341,8 +341,7 @@ void UBThumbnailWidget::mouseMoveEvent(QMouseEvent *event) if (mGraphicItems.contains(item)) { if (mGraphicItems.indexOf(item) <= mItemsPaths.size()){ - QString localFilePath = mItemsPaths.at(mGraphicItems.indexOf(item)).toString(); - qlElements << QUrl::fromLocalFile(localFilePath); + qlElements << mItemsPaths.at(mGraphicItems.indexOf(item)); } } } diff --git a/src/gui/UBThumbnailWidget.h b/src/gui/UBThumbnailWidget.h index a8d6eacd..47cf47a3 100644 --- a/src/gui/UBThumbnailWidget.h +++ b/src/gui/UBThumbnailWidget.h @@ -46,9 +46,7 @@ class UBThumbnailWidget : public QGraphicsView public slots: void setThumbnailWidth(qreal pThumbnailWidth); void setSpacing(qreal pSpacing); - virtual void setGraphicsItems(const QList& pGraphicsItems, - const QList& pItemPaths, const QStringList pLabels = QStringList(), - const QString& pMimeType = QString("")); + virtual void setGraphicsItems(const QList& pGraphicsItems, const QList& pItemPaths, const QStringList pLabels = QStringList(), const QString& pMimeType = QString("")); void refreshScene(); void sceneSelectionChanged();