diff --git a/src/board/UBBoardPaletteManager.h b/src/board/UBBoardPaletteManager.h
index 45b982de..86ef4355 100644
--- a/src/board/UBBoardPaletteManager.h
+++ b/src/board/UBBoardPaletteManager.h
@@ -1,192 +1,192 @@
-/*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef UBBOARDPALETTEMANAGER_H_
-#define UBBOARDPALETTEMANAGER_H_
-
-#include
-#include
-
-#include "web/UBRoutedMouseEventWebView.h"
-#include "gui/UBLeftPalette.h"
-#include "gui/UBRightPalette.h"
-#include "gui/UBPageNavigationWidget.h"
-#include "gui/UBLibWidget.h"
-#include "gui/UBCachePropertiesWidget.h"
-#include "gui/UBDockDownloadWidget.h"
-#include "core/UBApplicationController.h"
-#include "gui/UBFeaturesWidget.h"
-
-
-class UBStylusPalette;
-class UBClockPalette;
-class UBPageNumberPalette;
-class UBZoomPalette;
-class UBActionPalette;
-class UBBoardController;
-class UBFloatingPalette;
-class UBServerXMLHttpRequest;
-class UBKeyboardPalette;
-class UBMainWindow;
-class UBApplicationController;
-class UBDockTeacherGuideWidget;
-
+/*
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef UBBOARDPALETTEMANAGER_H_
+#define UBBOARDPALETTEMANAGER_H_
+
+#include
+#include
+
+#include "web/UBRoutedMouseEventWebView.h"
+#include "gui/UBLeftPalette.h"
+#include "gui/UBRightPalette.h"
+#include "gui/UBPageNavigationWidget.h"
+#include "gui/UBLibWidget.h"
+#include "gui/UBCachePropertiesWidget.h"
+#include "gui/UBDockDownloadWidget.h"
+#include "core/UBApplicationController.h"
+#include "gui/UBFeaturesWidget.h"
+
+
+class UBStylusPalette;
+class UBClockPalette;
+class UBPageNumberPalette;
+class UBZoomPalette;
+class UBActionPalette;
+class UBBoardController;
+class UBFloatingPalette;
+class UBServerXMLHttpRequest;
+class UBKeyboardPalette;
+class UBMainWindow;
+class UBApplicationController;
+class UBDockTeacherGuideWidget;
+
// Uncomment this to use old-styles lib paletter
-// #define USE_WEB_WIDGET
-
-
-class UBBoardPaletteManager : public QObject
-{
- Q_OBJECT
-
- public:
- UBBoardPaletteManager(QWidget* container, UBBoardController* controller);
- virtual ~UBBoardPaletteManager();
-
- void setupLayout();
- UBLeftPalette* leftPalette(){return mLeftPalette;}
- UBRightPalette* rightPalette(){return mRightPalette;}
- UBStylusPalette* stylusPalette(){return mStylusPalette;}
- void showVirtualKeyboard(bool show = true);
- void initPalettesPosAtStartup();
- void connectToDocumentController();
- void refreshPalettes();
-
- UBKeyboardPalette *mKeyboardPalette;
-
- void processPalettersWidget(UBDockPalette *paletter, eUBDockPaletteWidgetMode mode);
- void changeMode(eUBDockPaletteWidgetMode newMode, bool isInit = false);
- void startDownloads();
- void stopDownloads();
-
- signals:
- void connectToDocController();
- void signal_changeMode(eUBDockPaletteWidgetMode newMode);
-
- public slots:
-
- void activeSceneChanged();
- void containerResized();
- void addItem(const QUrl& pUrl);
- void addItem(const QPixmap& pPixmap, const QPointF& p = QPointF(0.0, 0.0), qreal scale = 1.0, const QUrl& sourceUrl = QUrl());
-
- void slot_changeMainMode(UBApplicationController::MainMode);
- void slot_changeDesktopMode(bool);
-
- private:
-
- void setupPalettes();
- void connectPalettes();
- void positionFreeDisplayPalette();
- void setupDockPaletteWidgets();
-
- QWidget* mContainer;
- UBBoardController *mBoardControler;
-
- UBStylusPalette *mStylusPalette;
-
- UBZoomPalette *mZoomPalette;
-
- /** The left dock palette */
- UBLeftPalette* mLeftPalette;
- /** The right dock palette */
- UBRightPalette* mRightPalette;
-
- UBActionPalette *mBackgroundsPalette;
- UBActionPalette *mToolsPalette;
- UBActionPalette* mAddItemPalette;
- UBActionPalette* mErasePalette;
- UBActionPalette* mPagePalette;
-
- QUrl mItemUrl;
- QPixmap mPixmap;
- QPointF mPos;
- qreal mScaleFactor;
-
- QTime mPageButtonPressedTime;
- bool mPendingPageButtonPressed;
-
- QTime mZoomButtonPressedTime;
- bool mPendingZoomButtonPressed;
-
- QTime mPanButtonPressedTime;
- bool mPendingPanButtonPressed;
-
- QTime mEraseButtonPressedTime;
- bool mPendingEraseButtonPressed;
-
- /** The page navigator widget */
- UBPageNavigationWidget* mpPageNavigWidget;
-
-#ifdef USE_WEB_WIDGET
- /** The library widget */
- UBLibWidget* mpLibWidget;
-#endif
-
- /** The cache properties widget */
- UBCachePropertiesWidget* mpCachePropWidget;
-
- UBFeaturesWidget *mpFeaturesWidget;
-
- /** The download widget */
- UBDockDownloadWidget* mpDownloadWidget;
- // HACK: here we duplicate the lib widget for the desktop mode
- // we MUST refactor the architecture in order to use only one
- // lib widget!
- UBLibWidget* mpDesktopLibWidget;
-
- UBDockTeacherGuideWidget* mpTeacherGuideWidget;
-
- bool mDownloadInProgress;
-
- private slots:
-
- void changeBackground();
-
- void toggleBackgroundPalette(bool checked);
- void backgroundPaletteClosed();
-
- void toggleStylusPalette(bool checked);
- void tooglePodcastPalette(bool checked);
-
- void erasePaletteButtonPressed();
- void erasePaletteButtonReleased();
-
- void toggleErasePalette(bool ckecked);
- void erasePaletteClosed();
-
- void togglePagePalette(bool ckecked);
- void pagePaletteClosed();
-
- void pagePaletteButtonPressed();
- void pagePaletteButtonReleased();
-
- void addItemToCurrentPage();
- void addItemToNewPage();
- void addItemToLibrary();
-
- void purchaseLinkActivated(const QString&);
-
- void linkClicked(const QUrl& url);
-
- void zoomButtonPressed();
- void zoomButtonReleased();
- void panButtonPressed();
- void panButtonReleased();
-
- void changeStylusPaletteOrientation(QVariant var);
-};
-
-#endif /* UBBOARDPALETTEMANAGER_H_ */
+ #define USE_WEB_WIDGET
+
+
+class UBBoardPaletteManager : public QObject
+{
+ Q_OBJECT
+
+ public:
+ UBBoardPaletteManager(QWidget* container, UBBoardController* controller);
+ virtual ~UBBoardPaletteManager();
+
+ void setupLayout();
+ UBLeftPalette* leftPalette(){return mLeftPalette;}
+ UBRightPalette* rightPalette(){return mRightPalette;}
+ UBStylusPalette* stylusPalette(){return mStylusPalette;}
+ void showVirtualKeyboard(bool show = true);
+ void initPalettesPosAtStartup();
+ void connectToDocumentController();
+ void refreshPalettes();
+
+ UBKeyboardPalette *mKeyboardPalette;
+
+ void processPalettersWidget(UBDockPalette *paletter, eUBDockPaletteWidgetMode mode);
+ void changeMode(eUBDockPaletteWidgetMode newMode, bool isInit = false);
+ void startDownloads();
+ void stopDownloads();
+
+ signals:
+ void connectToDocController();
+ void signal_changeMode(eUBDockPaletteWidgetMode newMode);
+
+ public slots:
+
+ void activeSceneChanged();
+ void containerResized();
+ void addItem(const QUrl& pUrl);
+ void addItem(const QPixmap& pPixmap, const QPointF& p = QPointF(0.0, 0.0), qreal scale = 1.0, const QUrl& sourceUrl = QUrl());
+
+ void slot_changeMainMode(UBApplicationController::MainMode);
+ void slot_changeDesktopMode(bool);
+
+ private:
+
+ void setupPalettes();
+ void connectPalettes();
+ void positionFreeDisplayPalette();
+ void setupDockPaletteWidgets();
+
+ QWidget* mContainer;
+ UBBoardController *mBoardControler;
+
+ UBStylusPalette *mStylusPalette;
+
+ UBZoomPalette *mZoomPalette;
+
+ /** The left dock palette */
+ UBLeftPalette* mLeftPalette;
+ /** The right dock palette */
+ UBRightPalette* mRightPalette;
+
+ UBActionPalette *mBackgroundsPalette;
+ UBActionPalette *mToolsPalette;
+ UBActionPalette* mAddItemPalette;
+ UBActionPalette* mErasePalette;
+ UBActionPalette* mPagePalette;
+
+ QUrl mItemUrl;
+ QPixmap mPixmap;
+ QPointF mPos;
+ qreal mScaleFactor;
+
+ QTime mPageButtonPressedTime;
+ bool mPendingPageButtonPressed;
+
+ QTime mZoomButtonPressedTime;
+ bool mPendingZoomButtonPressed;
+
+ QTime mPanButtonPressedTime;
+ bool mPendingPanButtonPressed;
+
+ QTime mEraseButtonPressedTime;
+ bool mPendingEraseButtonPressed;
+
+ /** The page navigator widget */
+ UBPageNavigationWidget* mpPageNavigWidget;
+
+#ifdef USE_WEB_WIDGET
+ /** The library widget */
+ UBLibWidget* mpLibWidget;
+#endif
+
+ /** The cache properties widget */
+ UBCachePropertiesWidget* mpCachePropWidget;
+
+ UBFeaturesWidget *mpFeaturesWidget;
+
+ /** The download widget */
+ UBDockDownloadWidget* mpDownloadWidget;
+ // HACK: here we duplicate the lib widget for the desktop mode
+ // we MUST refactor the architecture in order to use only one
+ // lib widget!
+ UBLibWidget* mpDesktopLibWidget;
+
+ UBDockTeacherGuideWidget* mpTeacherGuideWidget;
+
+ bool mDownloadInProgress;
+
+ private slots:
+
+ void changeBackground();
+
+ void toggleBackgroundPalette(bool checked);
+ void backgroundPaletteClosed();
+
+ void toggleStylusPalette(bool checked);
+ void tooglePodcastPalette(bool checked);
+
+ void erasePaletteButtonPressed();
+ void erasePaletteButtonReleased();
+
+ void toggleErasePalette(bool ckecked);
+ void erasePaletteClosed();
+
+ void togglePagePalette(bool ckecked);
+ void pagePaletteClosed();
+
+ void pagePaletteButtonPressed();
+ void pagePaletteButtonReleased();
+
+ void addItemToCurrentPage();
+ void addItemToNewPage();
+ void addItemToLibrary();
+
+ void purchaseLinkActivated(const QString&);
+
+ void linkClicked(const QUrl& url);
+
+ void zoomButtonPressed();
+ void zoomButtonReleased();
+ void panButtonPressed();
+ void panButtonReleased();
+
+ void changeStylusPaletteOrientation(QVariant var);
+};
+
+#endif /* UBBOARDPALETTEMANAGER_H_ */
diff --git a/src/board/UBFeaturesController.cpp b/src/board/UBFeaturesController.cpp
index d6895498..fee95d61 100644
--- a/src/board/UBFeaturesController.cpp
+++ b/src/board/UBFeaturesController.cpp
@@ -18,15 +18,24 @@
#include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsWidgetItem.h"
-UBFeature::UBFeature(const QString &url, const QPixmap &icon, const QString &name, const QString &realPath, UBFeatureElementType type)
+UBFeature::UBFeature(const QString &url, const QPixmap &icon, const QString &name, const QUrl &realPath, UBFeatureElementType type)
: virtualPath(url), mThumbnail(icon), mName(name), mPath(realPath), elementType(type)
{
}
+QString UBFeature::getUrl() const
+{
+ if ( elementType == FEATURE_INTERNAL )
+ return getFullPath().toString();
+ /*if ( UBApplication::isFromWeb( getFullPath() ) )
+ return QUrl( getFullPath() );*/
+ return getFullPath().toLocalFile();
+}
+
bool UBFeature::operator ==( const UBFeature &f )const
{
- return virtualPath == f.getUrl() && mName == f.getName() && mPath == f.getFullPath() && elementType == f.getType();
+ return virtualPath == f.getVirtualPath() && mName == f.getName() && mPath == f.getFullPath() && elementType == f.getType();
}
bool UBFeature::operator !=( const UBFeature &f )const
@@ -55,24 +64,24 @@ UBFeaturesController::UBFeaturesController(QWidget *pParentWidget) :
void UBFeaturesController::initDirectoryTree()
{
- mUserAudioDirectoryPath = UBSettings::settings()->userAudioDirectory();
- mUserVideoDirectoryPath = UBSettings::settings()->userVideoDirectory();
- mUserPicturesDirectoryPath = UBSettings::settings()->userImageDirectory();
- mUserInteractiveDirectoryPath = UBSettings::settings()->userInteractiveDirectory();
- mUserAnimationDirectoryPath = UBSettings::settings()->userAnimationDirectory();
-
- mLibPicturesDirectoryPath = UBSettings::settings()->applicationImageLibraryDirectory();
- mLibInteractiveDirectoryPath = UBSettings::settings()->applicationInteractivesDirectory();
- mLibApplicationsDirectoryPath = UBSettings::settings()->applicationApplicationsLibraryDirectory();
- mLibShapesDirectoryPath = UBSettings::settings()->applicationShapeLibraryDirectory() ;
- mLibSearchDirectoryPath = UBSettings::settings()->userSearchDirectory();
- trashDirectoryPath = UBSettings::userTrashDirPath();
+ mUserAudioDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->userAudioDirectory() );
+ mUserVideoDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->userVideoDirectory() );
+ mUserPicturesDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->userImageDirectory() );
+ mUserInteractiveDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->userInteractiveDirectory() );
+ mUserAnimationDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->userAnimationDirectory() );
+
+ mLibPicturesDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->applicationImageLibraryDirectory() );
+ mLibInteractiveDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->applicationInteractivesDirectory() );
+ mLibApplicationsDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->applicationApplicationsLibraryDirectory() );
+ mLibShapesDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->applicationShapeLibraryDirectory() );
+ mLibSearchDirectoryPath =QUrl::fromLocalFile( UBSettings::settings()->userSearchDirectory() );
+ trashDirectoryPath = QUrl::fromLocalFile( UBSettings::userTrashDirPath() );
featuresList = new QList ();
QList tools = UBToolsManager::manager()->allTools();
- featuresList->append( UBFeature( QString(), QPixmap( ":images/libpalette/home.png" ), "root", QString() ) );
+ featuresList->append( UBFeature( QString(), QPixmap( ":images/libpalette/home.png" ), "root", QUrl() ) );
currentElement = featuresList->at(0);
appPath = rootPath + "/Applications";
@@ -99,7 +108,7 @@ void UBFeaturesController::initDirectoryTree()
featuresList->append( UBFeature( rootPath, QPixmap(":images/libpalette/ShapesCategory.svg"), "Shapes" , mLibShapesDirectoryPath ) );
trashElement = UBFeature( rootPath, QPixmap(":images/libpalette/TrashCategory.svg"), "Trash", trashDirectoryPath, FEATURE_TRASH );
featuresList->append( trashElement );
- favoriteElement = UBFeature( rootPath, QPixmap(":images/libpalette/FavoritesCategory.svg"), "Favorites", "favorites", FEATURE_FAVORITE );
+ favoriteElement = UBFeature( rootPath, QPixmap(":images/libpalette/FavoritesCategory.svg"), "Favorites", QUrl("favorites"), FEATURE_FAVORITE );
featuresList->append( favoriteElement );
webSearchElement = UBFeature( rootPath, QPixmap(":images/libpalette/WebSearchCategory.svg"), "Web search", mLibSearchDirectoryPath );
featuresList->append( webSearchElement );
@@ -107,10 +116,10 @@ void UBFeaturesController::initDirectoryTree()
foreach (UBToolsManager::UBToolDescriptor tool, tools)
{
- featuresList->append( UBFeature( appPath, tool.icon, tool.label, tool.id, FEATURE_INTERNAL ) );
- if ( favoriteSet->find( tool.id ) != favoriteSet->end() )
+ featuresList->append( UBFeature( appPath, tool.icon, tool.label, QUrl( tool.id ), FEATURE_INTERNAL ) );
+ if ( favoriteSet->find( QUrl( tool.id ) ) != favoriteSet->end() )
{
- featuresList->append( UBFeature( favoritePath, tool.icon, tool.label, tool.id, FEATURE_INTERNAL ) );
+ featuresList->append( UBFeature( favoritePath, tool.icon, tool.label, QUrl( tool.id ), FEATURE_INTERNAL ) );
}
}
fileSystemScan( mUserInteractiveDirectoryPath, appPath );
@@ -129,9 +138,9 @@ void UBFeaturesController::initDirectoryTree()
}
-void UBFeaturesController::fileSystemScan(const QString & currentPath, const QString & currVirtualPath)
+void UBFeaturesController::fileSystemScan(const QUrl & currentPath, const QString & currVirtualPath)
{
- QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(currentPath);
+ QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(currentPath.toLocalFile());
QFileInfoList::iterator fileInfo;
for ( fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end(); fileInfo += 1)
@@ -151,6 +160,7 @@ void UBFeaturesController::fileSystemScan(const QString & currentPath, const QSt
QString itemName = (fileType != FEATURE_ITEM) ? fileName : fileInfo->completeBaseName();
QPixmap icon = QPixmap(":images/libpalette/soundIcon.svg");
QString fullFileName = fileInfo->filePath();
+
if ( fileType == FEATURE_FOLDER )
{
@@ -171,15 +181,15 @@ void UBFeaturesController::fileSystemScan(const QString & currentPath, const QSt
icon = QPixmap( thumbnailPath );
else icon = createThumbnail( fullFileName );*/
}
- featuresList->append( UBFeature( currVirtualPath, icon, fileName, fullFileName, fileType ) );
- if ( favoriteSet->find( fullFileName ) != favoriteSet->end() )
+ featuresList->append( UBFeature( currVirtualPath, icon, fileName, QUrl::fromLocalFile( fullFileName ), fileType ) );
+ if ( favoriteSet->find( QUrl::fromLocalFile( fullFileName ) ) != favoriteSet->end() )
{
- featuresList->append( UBFeature( favoritePath, icon, fileName, fullFileName, fileType ) );
+ featuresList->append( UBFeature( favoritePath, icon, fileName, QUrl::fromLocalFile( fullFileName ), fileType ) );
}
if ( fileType == FEATURE_FOLDER )
{
- fileSystemScan( fullFileName, currVirtualPath + "/" + fileName );
+ fileSystemScan( QUrl::fromLocalFile( fullFileName ), currVirtualPath + "/" + fileName );
}
}
@@ -187,7 +197,7 @@ void UBFeaturesController::fileSystemScan(const QString & currentPath, const QSt
void UBFeaturesController::loadFavoriteList()
{
- favoriteSet = new QSet();
+ favoriteSet = new QSet();
QFile file( UBSettings::userDataDirectory() + "/favorites.dat" );
if ( file.exists() )
{
@@ -197,7 +207,7 @@ void UBFeaturesController::loadFavoriteList()
in >> elementsNumber;
for ( int i = 0; i < elementsNumber; ++i)
{
- QString path;
+ QUrl path;
in >> path;
/*QFileInfo fileInfo( path );
QString fileName = fileInfo.fileName();
@@ -216,7 +226,7 @@ void UBFeaturesController::saveFavoriteList()
file.open(QIODevice::WriteOnly);
QDataStream out(&file);
out << favoriteSet->size();
- for ( QSet::iterator it = favoriteSet->begin(); it != favoriteSet->end(); ++it )
+ for ( QSet::iterator it = favoriteSet->begin(); it != favoriteSet->end(); ++it )
{
out << (*it);
}
@@ -226,12 +236,12 @@ void UBFeaturesController::saveFavoriteList()
UBFeature UBFeaturesController::addToFavorite( const QUrl &path )
{
QString filePath = fileNameFromUrl( path );
- if ( favoriteSet->find( filePath ) == favoriteSet->end() )
+ if ( favoriteSet->find( path ) == favoriteSet->end() )
{
QFileInfo fileInfo( filePath );
QString fileName = fileInfo.fileName();
- UBFeature elem( favoritePath, thumbnailForFile( filePath ), fileName, filePath, fileTypeFromUrl(filePath) );
- favoriteSet->insert( filePath );
+ UBFeature elem( favoritePath, thumbnailForFile( filePath ), fileName, path, fileTypeFromUrl(filePath) );
+ favoriteSet->insert( path );
saveFavoriteList();
return elem;
}
@@ -241,9 +251,9 @@ UBFeature UBFeaturesController::addToFavorite( const QUrl &path )
void UBFeaturesController::removeFromFavorite( const QUrl &path )
{
QString filePath = fileNameFromUrl( path );
- if ( favoriteSet->find( filePath ) != favoriteSet->end() )
+ if ( favoriteSet->find( path ) != favoriteSet->end() )
{
- favoriteSet->erase( favoriteSet->find( filePath ) );
+ favoriteSet->erase( favoriteSet->find( path ) );
saveFavoriteList();
}
}
@@ -256,6 +266,7 @@ QString UBFeaturesController::fileNameFromUrl( const QUrl &url )
return url.toLocalFile();
}
+
UBFeatureElementType UBFeaturesController::fileTypeFromUrl( const QString &path )
{
QFileInfo fileInfo( path );
@@ -336,24 +347,26 @@ QPixmap UBFeaturesController::createThumbnail(const QString &path)
UBFeature UBFeaturesController::newFolder( const QString &name )
{
- QString path = currentElement.getFullPath() + "/" + name;
+ QString path = currentElement.getFullPath().toLocalFile() + "/" + name;
if(!QFileInfo(path).exists())
{
QDir().mkpath(path);
}
- return UBFeature( currentElement.getUrl() + "/" + currentElement.getName(), QPixmap(":images/libpalette/folder.svg"), name, path, FEATURE_FOLDER );
+ return UBFeature( currentElement.getFullVirtualPath(), QPixmap(":images/libpalette/folder.svg"),
+ name, QUrl::fromLocalFile( path ), FEATURE_FOLDER );
}
void UBFeaturesController::addItemToPage(const UBFeature &item)
{
- if ( item.getType() == FEATURE_INTERNAL )
+ UBApplication::boardController->downloadURL( item.getFullPath() );
+ /*if ( item.getType() == FEATURE_INTERNAL )
{
UBApplication::boardController->downloadURL( QUrl( item.getFullPath() ) );
}
else
{
UBApplication::boardController->downloadURL( QUrl::fromLocalFile( item.getFullPath() ) );
- }
+ }*/
}
UBFeature UBFeaturesController::getDestinationForItem( const QUrl &url )
@@ -394,14 +407,14 @@ UBFeature UBFeaturesController::copyItemToFolder( const QUrl &url, const UBFeatu
UBFeature dest = destination;
if ( destination != trashElement &&
- !destination.getVirtualPath().startsWith( possibleDest.getVirtualPath(), Qt::CaseInsensitive ) )
+ !destination.getFullVirtualPath().startsWith( possibleDest.getFullVirtualPath(), Qt::CaseInsensitive ) )
{
dest = possibleDest;
}
QString name = QFileInfo( sourcePath ).fileName();
- QString destPath = dest.getFullPath();
- QString destVirtualPath = dest.getVirtualPath();
+ QString destPath = dest.getFullPath().toLocalFile();
+ QString destVirtualPath = dest.getFullVirtualPath();
QString newFullPath = destPath + "/" + name;
QFile( sourcePath ).copy( newFullPath );
@@ -410,7 +423,7 @@ UBFeature UBFeaturesController::copyItemToFolder( const QUrl &url, const UBFeatu
UBFeatureElementType type = FEATURE_ITEM;
if ( UBFileSystemUtils::mimeTypeFromFileName( newFullPath ).contains("application") )
type = FEATURE_INTERACTIVE;
- UBFeature newElement( destVirtualPath, thumb, name, newFullPath, type );
+ UBFeature newElement( destVirtualPath, thumb, name, QUrl::fromLocalFile( newFullPath ), type );
return newElement;
}
@@ -420,7 +433,7 @@ void UBFeaturesController::deleteItem( const QUrl &url )
Q_ASSERT( QFileInfo( path ).exists() );
QString thumbnailPath = UBFileSystemUtils::thumbnailPath( path );
- if (thumbnailPath.length() && QFileInfo( thumbnailPath ).exists())
+ if ( thumbnailPath.length() && QFileInfo( thumbnailPath ).exists() )
{
QFile::remove(thumbnailPath);
}
@@ -429,7 +442,7 @@ void UBFeaturesController::deleteItem( const QUrl &url )
bool UBFeaturesController::isTrash( const QUrl &url )
{
- return url.toLocalFile().startsWith( trashDirectoryPath );
+ return url.toLocalFile().startsWith( trashDirectoryPath.toLocalFile() );
}
UBFeaturesController::~UBFeaturesController()
diff --git a/src/board/UBFeaturesController.h b/src/board/UBFeaturesController.h
index 4189add4..92f6a6a9 100644
--- a/src/board/UBFeaturesController.h
+++ b/src/board/UBFeaturesController.h
@@ -8,6 +8,8 @@
#include
#include
#include
+#include
+#include
//#include "UBDockPaletteWidget.h"
@@ -29,25 +31,30 @@ class UBFeature
public:
UBFeature() {;}
//UBFeature(const UBFeature &f);
- UBFeature(const QString &url, const QPixmap &icon, const QString &name, const QString &realPath, UBFeatureElementType type = FEATURE_CATEGORY);
+ UBFeature(const QString &url, const QPixmap &icon, const QString &name, const QUrl &realPath, UBFeatureElementType type = FEATURE_CATEGORY);
virtual ~UBFeature() {;}
QString getName() const { return mName; }
QPixmap getThumbnail() const {return mThumbnail;}
- QString getUrl() const { return virtualPath; }
+ QString getVirtualPath() const { return virtualPath; }
//QString getPath() const { return mPath; };
- QString getFullPath() const { return mPath; }
- QString getVirtualPath() const { return virtualPath + "/" + mName; }
+ QUrl getFullPath() const { return mPath; }
+ QString getFullVirtualPath() const { return virtualPath + "/" + mName; }
+ QString getUrl() const;
UBFeatureElementType getType() const { return elementType; }
+
bool isFolder() const;
bool isDeletable() const;
bool operator ==( const UBFeature &f )const;
bool operator !=( const UBFeature &f )const;
+ const QMap & getMetadata() const { return metadata; }
+ void setMetadata( const QMap &data ) { metadata = data; }
private:
QString virtualPath;
QPixmap mThumbnail;
QString mName;
- QString mPath;
+ QUrl mPath;
UBFeatureElementType elementType;
+ QMap metadata;
};
Q_DECLARE_METATYPE( UBFeature )
@@ -80,7 +87,7 @@ public:
static bool isDeletable( const QUrl &url );
private:
void initDirectoryTree();
- void fileSystemScan(const QString &currPath, const QString & currVirtualPath);
+ void fileSystemScan(const QUrl &currPath, const QString & currVirtualPath);
static QPixmap createThumbnail(const QString &path);
//void addImageToCurrentPage( const QString &path );
void loadFavoriteList();
@@ -92,22 +99,22 @@ private:
QList *featuresList;
UBFeature *rootElement;
- QString mUserAudioDirectoryPath;
- QString mUserVideoDirectoryPath;
- QString mUserPicturesDirectoryPath;
- QString mUserInteractiveDirectoryPath;
- QString mUserAnimationDirectoryPath;
+ QUrl mUserAudioDirectoryPath;
+ QUrl mUserVideoDirectoryPath;
+ QUrl mUserPicturesDirectoryPath;
+ QUrl mUserInteractiveDirectoryPath;
+ QUrl mUserAnimationDirectoryPath;
QString libraryPath;
- QString mLibAudioDirectoryPath;
- QString mLibVideoDirectoryPath;
- QString mLibPicturesDirectoryPath;
- QString mLibInteractiveDirectoryPath;
- QString mLibAnimationDirectoryPath;
- QString mLibApplicationsDirectoryPath;
- QString mLibShapesDirectoryPath;
- QString trashDirectoryPath;
- QString mLibSearchDirectoryPath;
+ QUrl mLibAudioDirectoryPath;
+ QUrl mLibVideoDirectoryPath;
+ QUrl mLibPicturesDirectoryPath;
+ QUrl mLibInteractiveDirectoryPath;
+ QUrl mLibAnimationDirectoryPath;
+ QUrl mLibApplicationsDirectoryPath;
+ QUrl mLibShapesDirectoryPath;
+ QUrl trashDirectoryPath;
+ QUrl mLibSearchDirectoryPath;
QString rootPath;
QString audiosPath;
@@ -132,7 +139,7 @@ private:
UBFeature shapesElement;
UBFeature webSearchElement;
- QSet *favoriteSet;
+ QSet *favoriteSet;
};
diff --git a/src/gui/UBFeaturesWidget.cpp b/src/gui/UBFeaturesWidget.cpp
index 5ab37c9b..5b211c83 100644
--- a/src/gui/UBFeaturesWidget.cpp
+++ b/src/gui/UBFeaturesWidget.cpp
@@ -124,6 +124,8 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
connect( pathListView, SIGNAL(clicked( const QModelIndex & ) ),
this, SLOT( currentPathChanged( const QModelIndex & ) ) );
connect( thumbSlider, SIGNAL( sliderMoved(int) ), this, SLOT(thumbnailSizeChanged( int ) ) );
+ connect( UBApplication::boardController, SIGNAL( displayMetadata( QMap ) ),
+ this, SLOT( onDisplayMetadata( QMap ) ) );
}
bool UBFeaturesWidget::eventFilter( QObject *target, QEvent *event )
@@ -165,7 +167,7 @@ void UBFeaturesWidget::currentSelected(const QModelIndex ¤t)
if ( feature.isFolder() )
{
- QString newPath = feature.getUrl() + "/" + feature.getName();
+ QString newPath = feature.getFullVirtualPath();
//pathViewer->addPathElement( feature.getThumbnail(), newPath );
controller->setCurrentElement( feature );
@@ -208,7 +210,7 @@ void UBFeaturesWidget::currentPathChanged(const QModelIndex &index)
if ( index.isValid() )
{
UBFeature feature = featuresPathModel->data(index, Qt::UserRole + 1).value();
- QString newPath = feature.getUrl() + "/" + feature.getName();
+ QString newPath = feature.getFullVirtualPath();
featuresPathModel->setPath( newPath );
featuresPathModel->invalidate();
@@ -281,7 +283,7 @@ void UBFeaturesWidget::addToFavorite( const QMimeData & mimeData )
foreach ( QUrl url, urls )
{
UBFeature elem = controller->addToFavorite( url );
- if ( !elem.getUrl().isEmpty() && !elem.getUrl().isNull() )
+ if ( !elem.getVirtualPath().isEmpty() && !elem.getVirtualPath().isNull() )
featuresModel->addItem( elem );
}
QSortFilterProxyModel *model = dynamic_cast( featuresListView->model() );
@@ -305,6 +307,16 @@ void UBFeaturesWidget::thumbnailSizeChanged( int value )
featuresListView->setGridSize( QSize( value * 1.75, value * 1.75 ) );
}
+void UBFeaturesWidget::onDisplayMetadata( QMap metadata )
+{
+ UBFeature feature( QString(), QPixmap(":images/libpalette/notFound.png"), QString(), metadata["Url"], FEATURE_ITEM );
+ feature.setMetadata( metadata );
+
+ featureProperties->showElement( feature );
+ switchToProperties();
+ mActionBar->setCurrentState( IN_PROPERTIES );
+}
+
void UBFeaturesWidget::switchToListView()
{
stackedWidget->setCurrentIndex(ID_LISTVIEW);
@@ -441,7 +453,7 @@ UBFeaturesWebView::~UBFeaturesWebView()
void UBFeaturesWebView::showElement(const UBFeature &elem)
{
QString qsWidgetName;
- QString path = elem.getFullPath();
+ QString path = elem.getFullPath().toLocalFile();
QString qsConfigPath = QString("%0/config.xml").arg(path);
@@ -490,6 +502,7 @@ UBFeatureProperties::UBFeatureProperties( QWidget *parent, const char *name ) :
, mpThumbnail(NULL)
, mpOrigPixmap(NULL)
, mpElement(NULL)
+ , mpObjInfos(NULL)
{
setObjectName(name);
@@ -529,10 +542,19 @@ UBFeatureProperties::UBFeatureProperties( QWidget *parent, const char *name ) :
mpButtonLayout->addStretch(1);
- mpObjInfoLabel = new QLabel(tr("Object informations"));
+ mpObjInfoLabel = new QLabel(tr("Object informations"));
mpObjInfoLabel->setStyleSheet(QString("color: #888888; font-size : 18px; font-weight:bold;"));
mpLayout->addWidget(mpObjInfoLabel, 0);
+ mpObjInfos = new QTreeWidget(this);
+ mpObjInfos->setColumnCount(2);
+ mpObjInfos->header()->hide();
+ mpObjInfos->setAlternatingRowColors(true);
+ mpObjInfos->setRootIsDecorated(false);
+ mpObjInfos->setObjectName("DockPaletteWidgetBox");
+ mpObjInfos->setStyleSheet("background:white;");
+ mpLayout->addWidget(mpObjInfos, 1);
+
connect(mpAddPageButton, SIGNAL(clicked()), this, SLOT(onAddToPage()));
}
@@ -552,46 +574,65 @@ void UBFeatureProperties::showElement( const UBFeature &elem )
mpElement = new UBFeature( elem );
mpOrigPixmap = new QPixmap( elem.getThumbnail() );
mpThumbnail->setPixmap(elem.getThumbnail().scaledToWidth(THUMBNAIL_WIDTH));
- //populateMetadata();
+ populateMetadata();
- if ( UBApplication::isFromWeb( elem.getUrl() ) )
+ if ( UBApplication::isFromWeb( elem.getFullPath().toString() ) )
{
mpAddToLibButton->show();
- /*if(elem->metadatas()["Type"].toLower().contains("image"))
+ if( elem.getMetadata()["Type"].toLower().contains("image") )
{
mpSetAsBackgroundButton->show();
}
else
{
mpSetAsBackgroundButton->hide();
- }*/
+ }
}
else
{
mpAddToLibButton->hide();
- if (UBFileSystemUtils::mimeTypeFromFileName( elem.getUrl() ).contains("image"))
+ if (UBFileSystemUtils::mimeTypeFromFileName( elem.getFullPath().toLocalFile() ).contains("image"))
{
mpSetAsBackgroundButton->show();
}
- else
+ else
{
mpSetAsBackgroundButton->hide();
}
}
}
+void UBFeatureProperties::populateMetadata()
+{
+ if(NULL != mpObjInfos){
+ mpObjInfos->clear();
+ QMap metas = mpElement->getMetadata();
+ QList lKeys = metas.keys();
+ QList lValues = metas.values();
+
+ for(int i=0; i< metas.size(); i++){
+ QStringList values;
+ values << lKeys.at(i);
+ values << lValues.at(i);
+ mpItem = new QTreeWidgetItem(values);
+ mpObjInfos->addTopLevelItem(mpItem);
+ }
+ mpObjInfos->resizeColumnToContents(0);
+ }
+}
+
void UBFeatureProperties::onAddToPage()
{
QWidget *w = parentWidget()->parentWidget();
UBFeaturesWidget* featuresWidget = dynamic_cast( w );
featuresWidget->getFeaturesController()->addItemToPage( *mpElement );
- /*if ( UBApplication::isFromWeb( mpElement->getUrl() ) )
+ /*if ( UBApplication::isFromWeb( mpElement->getVirtualPath() ) )
{
sDownloadFileDesc desc;
desc.isBackground = false;
desc.modal = true;
desc.name = QFileInfo( mpElement->getName() ).fileName();
- desc.url = mpElement->getUrl();
+ desc.url = mpElement->getVirtualPath();
UBDownloadManager::downloadManager()->addFileToDownload(desc);
}
@@ -641,7 +682,7 @@ QVariant UBFeaturesModel::data(const QModelIndex &index, int role) const
}
else if (role == Qt::UserRole)
{
- return featuresList->at(index.row()).getUrl();
+ return featuresList->at(index.row()).getVirtualPath();
}
else if (role == Qt::UserRole + 1)
{
@@ -669,7 +710,7 @@ QMimeData* UBFeaturesModel::mimeData(const QModelIndexList &indexes) const
}
else if ( element.getType() == FEATURE_INTERACTIVE || element.getType() == FEATURE_ITEM )
{
- urlList.push_back( QUrl::fromLocalFile(element.getFullPath()) );
+ urlList.push_back( element.getFullPath() );
}
}
}
@@ -731,8 +772,8 @@ void UBFeaturesModel::deleteFavoriteItem( const QString &path )
{
for ( int i = 0; i < featuresList->size(); ++i )
{
- if ( !QString::compare( featuresList->at(i).getFullPath(), path, Qt::CaseInsensitive ) &&
- !QString::compare( featuresList->at(i).getUrl(), "/root/favorites", Qt::CaseInsensitive ) )
+ if ( !QString::compare( featuresList->at(i).getUrl(), path, Qt::CaseInsensitive ) &&
+ !QString::compare( featuresList->at(i).getVirtualPath(), "/root/favorites", Qt::CaseInsensitive ) )
{
removeRow( i, QModelIndex() );
return;
@@ -776,7 +817,7 @@ Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const
item.getType() == FEATURE_ITEM ||
item.getType() == FEATURE_INTERNAL )
return Qt::ItemIsDragEnabled | defaultFlags;
- if ( item.isFolder() && !item.getFullPath().isNull() )
+ if ( item.isFolder() && !item.getVirtualPath().isNull() )
return defaultFlags | Qt::ItemIsDropEnabled;
else return defaultFlags | Qt::ItemIsDropEnabled;
}
@@ -846,9 +887,8 @@ bool UBFeaturesPathProxyModel::filterAcceptsRow( int sourceRow, const QModelInde
eUBLibElementType type = (eUBLibElementType)sourceModel()->data(index, Qt::UserRole + 1).toInt();*/
UBFeature feature = sourceModel()->data(index, Qt::UserRole + 1).value();
- QString virtualFullPath = feature.getUrl() + "/" + feature.getName();
- return feature.isFolder() && path.startsWith( virtualFullPath );
+ return feature.isFolder() && path.startsWith( feature.getFullVirtualPath() );
}
QString UBFeaturesItemDelegate::displayText ( const QVariant & value, const QLocale & locale ) const
diff --git a/src/gui/UBFeaturesWidget.h b/src/gui/UBFeaturesWidget.h
index faaea0c4..572adbc6 100644
--- a/src/gui/UBFeaturesWidget.h
+++ b/src/gui/UBFeaturesWidget.h
@@ -99,6 +99,7 @@ private slots:
void addToFavorite( const QMimeData & );
void removeFromFavorite( const QMimeData & );
void thumbnailSizeChanged( int );
+ void onDisplayMetadata( QMap );
protected:
bool eventFilter(QObject *target, QEvent *event);
};
@@ -160,18 +161,20 @@ private slots:
//void onBack();
private:
+ void populateMetadata();
+
QVBoxLayout* mpLayout;
QHBoxLayout* mpButtonLayout;
UBFeatureItemButton* mpAddPageButton;
UBFeatureItemButton* mpAddToLibButton;
UBFeatureItemButton* mpSetAsBackgroundButton;
QLabel* mpObjInfoLabel;
- //QTreeWidget* mpObjInfos;
+ QTreeWidget* mpObjInfos;
QLabel* mpThumbnail;
QPixmap* mpOrigPixmap;
int maxThumbHeight;
UBFeature *mpElement;
- //QTreeWidgetItem* mpItem;
+ QTreeWidgetItem* mpItem;
};