Merge branch 'master' of github.com:Sankore/Sankore-3.1

preferencesAboutTextFull
Ivan Ilyin 12 years ago
commit 56eceb6605
  1. 7
      resources/style.qss
  2. 1
      src/adaptors/UBExportCFF.cpp
  3. 23
      src/board/UBBoardPaletteManager.cpp
  4. 376
      src/board/UBBoardPaletteManager.h
  5. 199
      src/board/UBFeaturesController.cpp
  6. 72
      src/board/UBFeaturesController.h
  7. 2
      src/core/main.cpp
  8. 2
      src/customWidgets/UBActionableWidget.cpp
  9. 2
      src/customWidgets/UBMediaWidget.cpp
  10. 2
      src/domain/UBAbstractUndoCommand.cpp
  11. 2
      src/domain/UBAngleWidget.cpp
  12. 1596
      src/domain/UBGraphicsDelegateFrame.cpp
  13. 101
      src/domain/UBGraphicsItemDelegate.cpp
  14. 54
      src/domain/UBGraphicsItemDelegate.h
  15. 4
      src/domain/UBGraphicsItemUndoCommand.cpp
  16. 4
      src/domain/UBGraphicsMediaItem.cpp
  17. 2
      src/domain/UBGraphicsStrokesGroup.cpp
  18. 17
      src/domain/UBGraphicsTextItemDelegate.cpp
  19. 687
      src/domain/UBGraphicsVideoItemDelegate.cpp
  20. 230
      src/domain/UBGraphicsVideoItemDelegate.h
  21. 2
      src/domain/ubgraphicsgroupcontaineritem.cpp
  22. 3
      src/domain/ubgraphicsgroupcontaineritemdelegate.cpp
  23. 3
      src/frameworks/UBCoreGraphicsScene.cpp
  24. 2
      src/gui/UBDockDownloadWidget.cpp
  25. 2
      src/gui/UBDockTeacherGuideWidget.cpp
  26. 19
      src/gui/UBFeaturesActionBar.cpp
  27. 3
      src/gui/UBFeaturesActionBar.h
  28. 342
      src/gui/UBFeaturesWidget.cpp
  29. 50
      src/gui/UBFeaturesWidget.h
  30. 3
      src/gui/UBLibItemProperties.cpp
  31. 3
      src/gui/UBLibNavigatorWidget.cpp
  32. 3
      src/gui/UBLibPathViewer.cpp
  33. 3
      src/gui/UBLibWebView.cpp
  34. 3
      src/gui/UBLibWidget.cpp
  35. 3
      src/gui/UBPageNavigationWidget.cpp
  36. 2
      src/gui/UBTGWidgetTreeDelegate.cpp
  37. 1
      src/gui/UBTeacherGuideDelegate.cpp
  38. 2
      src/gui/UBTeacherGuideWidget.cpp
  39. 2
      src/gui/UBTeacherGuideWidgetsTools.cpp
  40. 2
      src/pdf-merger/CCITTFaxDecode.cpp
  41. 2
      src/pdf-merger/DCTDecode.cpp
  42. 1
      src/pdf-merger/JBIG2Decode.cpp
  43. 2
      src/web/UBOEmbedParser.cpp

@ -26,6 +26,13 @@ QWidget#UBLibWebView
border: 2px solid #999999; border: 2px solid #999999;
} }
QWidget#UBFeaturesWebView
{
background: #EEEEEE;
border-radius : 10px;
border: 2px solid #999999;
}
QListView QListView
{ {
background: #EEEEEE; background: #EEEEEE;

@ -3,6 +3,7 @@
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"
#include "core/UBDocumentManager.h" #include "core/UBDocumentManager.h"
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "core/memcheck.h"
UBExportCFF::UBExportCFF(QObject *parent) UBExportCFF::UBExportCFF(QObject *parent)

@ -58,10 +58,10 @@
#include "UBBoardController.h" #include "UBBoardController.h"
#include "core/memcheck.h"
#include "document/UBDocumentController.h" #include "document/UBDocumentController.h"
#include "core/memcheck.h"
UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardController* pBoardController) UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardController* pBoardController)
: QObject(container) : QObject(container)
, mKeyboardPalette(0) , mKeyboardPalette(0)
@ -81,7 +81,9 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll
, mPendingPanButtonPressed(false) , mPendingPanButtonPressed(false)
, mPendingEraseButtonPressed(false) , mPendingEraseButtonPressed(false)
, mpPageNavigWidget(NULL) , mpPageNavigWidget(NULL)
#ifdef USE_WEB_WIDGET
, mpLibWidget(NULL) , mpLibWidget(NULL)
#endif
, mpCachePropWidget(NULL) , mpCachePropWidget(NULL)
, mpDownloadWidget(NULL) , mpDownloadWidget(NULL)
, mpDesktopLibWidget(NULL) , mpDesktopLibWidget(NULL)
@ -132,7 +134,9 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
mpPageNavigWidget = new UBPageNavigationWidget(); mpPageNavigWidget = new UBPageNavigationWidget();
#ifdef USE_WEB_WIDGET
mpLibWidget = new UBLibWidget(); mpLibWidget = new UBLibWidget();
#endif
mpCachePropWidget = new UBCachePropertiesWidget(); mpCachePropWidget = new UBCachePropertiesWidget();
@ -159,8 +163,11 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
mRightPalette->addTab(mpFeaturesWidget); mRightPalette->addTab(mpFeaturesWidget);
//Do not show deprecated lib widget to prevent collisions. Uncomment to return lib widget //Do not show deprecated lib widget to prevent collisions. Uncomment to return lib widget
// mRightPalette->registerWidget(mpLibWidget);
// mRightPalette->addTab(mpLibWidget); #ifdef USE_WEB_WIDGET
mRightPalette->registerWidget(mpLibWidget);
mRightPalette->addTab(mpLibWidget);
#endif
// The cache widget will be visible only if a cache is put on the page // The cache widget will be visible only if a cache is put on the page
@ -841,10 +848,10 @@ void UBBoardPaletteManager::addItemToLibrary()
} }
QImage image = mPixmap.toImage(); QImage image = mPixmap.toImage();
if(NULL != mpLibWidget) #ifdef USE_WEB_WIDGET
{ mpLibWidget->libNavigator()->libraryWidget()->libraryController()->importImageOnLibrary(image);
mpLibWidget->libNavigator()->libraryWidget()->libraryController()->importImageOnLibrary(image); #endif
}
} }
else else
{ {

@ -1,184 +1,192 @@
/* /*
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef UBBOARDPALETTEMANAGER_H_ #ifndef UBBOARDPALETTEMANAGER_H_
#define UBBOARDPALETTEMANAGER_H_ #define UBBOARDPALETTEMANAGER_H_
#include <QtGui> #include <QtGui>
#include <QtWebKit> #include <QtWebKit>
#include "web/UBRoutedMouseEventWebView.h" #include "web/UBRoutedMouseEventWebView.h"
#include "gui/UBLeftPalette.h" #include "gui/UBLeftPalette.h"
#include "gui/UBRightPalette.h" #include "gui/UBRightPalette.h"
#include "gui/UBPageNavigationWidget.h" #include "gui/UBPageNavigationWidget.h"
#include "gui/UBLibWidget.h" #include "gui/UBLibWidget.h"
#include "gui/UBCachePropertiesWidget.h" #include "gui/UBCachePropertiesWidget.h"
#include "gui/UBDockDownloadWidget.h" #include "gui/UBDockDownloadWidget.h"
#include "core/UBApplicationController.h" #include "core/UBApplicationController.h"
#include "gui/UBFeaturesWidget.h" #include "gui/UBFeaturesWidget.h"
class UBStylusPalette; class UBStylusPalette;
class UBClockPalette; class UBClockPalette;
class UBPageNumberPalette; class UBPageNumberPalette;
class UBZoomPalette; class UBZoomPalette;
class UBActionPalette; class UBActionPalette;
class UBBoardController; class UBBoardController;
class UBFloatingPalette; class UBFloatingPalette;
class UBServerXMLHttpRequest; class UBServerXMLHttpRequest;
class UBKeyboardPalette; class UBKeyboardPalette;
class UBMainWindow; class UBMainWindow;
class UBApplicationController; class UBApplicationController;
class UBDockTeacherGuideWidget; class UBDockTeacherGuideWidget;
class UBBoardPaletteManager : public QObject // Uncomment this to use old-styles lib paletter
{ // #define USE_WEB_WIDGET
Q_OBJECT
public: class UBBoardPaletteManager : public QObject
UBBoardPaletteManager(QWidget* container, UBBoardController* controller); {
virtual ~UBBoardPaletteManager(); Q_OBJECT
void setupLayout(); public:
UBLeftPalette* leftPalette(){return mLeftPalette;} UBBoardPaletteManager(QWidget* container, UBBoardController* controller);
UBRightPalette* rightPalette(){return mRightPalette;} virtual ~UBBoardPaletteManager();
UBStylusPalette* stylusPalette(){return mStylusPalette;}
void showVirtualKeyboard(bool show = true); void setupLayout();
void initPalettesPosAtStartup(); UBLeftPalette* leftPalette(){return mLeftPalette;}
void connectToDocumentController(); UBRightPalette* rightPalette(){return mRightPalette;}
void refreshPalettes(); UBStylusPalette* stylusPalette(){return mStylusPalette;}
void showVirtualKeyboard(bool show = true);
UBKeyboardPalette *mKeyboardPalette; void initPalettesPosAtStartup();
void connectToDocumentController();
void processPalettersWidget(UBDockPalette *paletter, eUBDockPaletteWidgetMode mode); void refreshPalettes();
void changeMode(eUBDockPaletteWidgetMode newMode, bool isInit = false);
void startDownloads(); UBKeyboardPalette *mKeyboardPalette;
void stopDownloads();
void processPalettersWidget(UBDockPalette *paletter, eUBDockPaletteWidgetMode mode);
signals: void changeMode(eUBDockPaletteWidgetMode newMode, bool isInit = false);
void connectToDocController(); void startDownloads();
void signal_changeMode(eUBDockPaletteWidgetMode newMode); void stopDownloads();
public slots: signals:
void connectToDocController();
void activeSceneChanged(); void signal_changeMode(eUBDockPaletteWidgetMode newMode);
void containerResized();
void addItem(const QUrl& pUrl); public slots:
void addItem(const QPixmap& pPixmap, const QPointF& p = QPointF(0.0, 0.0), qreal scale = 1.0, const QUrl& sourceUrl = QUrl());
void activeSceneChanged();
void slot_changeMainMode(UBApplicationController::MainMode); void containerResized();
void slot_changeDesktopMode(bool); 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());
private:
void slot_changeMainMode(UBApplicationController::MainMode);
void setupPalettes(); void slot_changeDesktopMode(bool);
void connectPalettes();
void positionFreeDisplayPalette(); private:
void setupDockPaletteWidgets();
void setupPalettes();
QWidget* mContainer; void connectPalettes();
UBBoardController *mBoardControler; void positionFreeDisplayPalette();
void setupDockPaletteWidgets();
UBStylusPalette *mStylusPalette;
QWidget* mContainer;
UBZoomPalette *mZoomPalette; UBBoardController *mBoardControler;
/** The left dock palette */ UBStylusPalette *mStylusPalette;
UBLeftPalette* mLeftPalette;
/** The right dock palette */ UBZoomPalette *mZoomPalette;
UBRightPalette* mRightPalette;
/** The left dock palette */
UBActionPalette *mBackgroundsPalette; UBLeftPalette* mLeftPalette;
UBActionPalette *mToolsPalette; /** The right dock palette */
UBActionPalette* mAddItemPalette; UBRightPalette* mRightPalette;
UBActionPalette* mErasePalette;
UBActionPalette* mPagePalette; UBActionPalette *mBackgroundsPalette;
UBActionPalette *mToolsPalette;
QUrl mItemUrl; UBActionPalette* mAddItemPalette;
QPixmap mPixmap; UBActionPalette* mErasePalette;
QPointF mPos; UBActionPalette* mPagePalette;
qreal mScaleFactor;
QUrl mItemUrl;
QTime mPageButtonPressedTime; QPixmap mPixmap;
bool mPendingPageButtonPressed; QPointF mPos;
qreal mScaleFactor;
QTime mZoomButtonPressedTime;
bool mPendingZoomButtonPressed; QTime mPageButtonPressedTime;
bool mPendingPageButtonPressed;
QTime mPanButtonPressedTime;
bool mPendingPanButtonPressed; QTime mZoomButtonPressedTime;
bool mPendingZoomButtonPressed;
QTime mEraseButtonPressedTime;
bool mPendingEraseButtonPressed; QTime mPanButtonPressedTime;
bool mPendingPanButtonPressed;
/** The page navigator widget */
UBPageNavigationWidget* mpPageNavigWidget; QTime mEraseButtonPressedTime;
/** The library widget */ bool mPendingEraseButtonPressed;
UBLibWidget* mpLibWidget;
/** The cache properties widget */ /** The page navigator widget */
UBCachePropertiesWidget* mpCachePropWidget; UBPageNavigationWidget* mpPageNavigWidget;
UBFeaturesWidget *mpFeaturesWidget; #ifdef USE_WEB_WIDGET
/** The library widget */
/** The download widget */ UBLibWidget* mpLibWidget;
UBDockDownloadWidget* mpDownloadWidget; #endif
// HACK: here we duplicate the lib widget for the desktop mode
// we MUST refactor the architecture in order to use only one /** The cache properties widget */
// lib widget! UBCachePropertiesWidget* mpCachePropWidget;
UBLibWidget* mpDesktopLibWidget;
UBFeaturesWidget *mpFeaturesWidget;
UBDockTeacherGuideWidget* mpTeacherGuideWidget;
/** The download widget */
bool mDownloadInProgress; UBDockDownloadWidget* mpDownloadWidget;
// HACK: here we duplicate the lib widget for the desktop mode
private slots: // we MUST refactor the architecture in order to use only one
// lib widget!
void changeBackground(); UBLibWidget* mpDesktopLibWidget;
void toggleBackgroundPalette(bool checked); UBDockTeacherGuideWidget* mpTeacherGuideWidget;
void backgroundPaletteClosed();
bool mDownloadInProgress;
void toggleStylusPalette(bool checked);
void tooglePodcastPalette(bool checked); private slots:
void erasePaletteButtonPressed(); void changeBackground();
void erasePaletteButtonReleased();
void toggleBackgroundPalette(bool checked);
void toggleErasePalette(bool ckecked); void backgroundPaletteClosed();
void erasePaletteClosed();
void toggleStylusPalette(bool checked);
void togglePagePalette(bool ckecked); void tooglePodcastPalette(bool checked);
void pagePaletteClosed();
void erasePaletteButtonPressed();
void pagePaletteButtonPressed(); void erasePaletteButtonReleased();
void pagePaletteButtonReleased();
void toggleErasePalette(bool ckecked);
void addItemToCurrentPage(); void erasePaletteClosed();
void addItemToNewPage();
void addItemToLibrary(); void togglePagePalette(bool ckecked);
void pagePaletteClosed();
void purchaseLinkActivated(const QString&);
void pagePaletteButtonPressed();
void linkClicked(const QUrl& url); void pagePaletteButtonReleased();
void zoomButtonPressed(); void addItemToCurrentPage();
void zoomButtonReleased(); void addItemToNewPage();
void panButtonPressed(); void addItemToLibrary();
void panButtonReleased();
void purchaseLinkActivated(const QString&);
void changeStylusPaletteOrientation(QVariant var);
}; void linkClicked(const QUrl& url);
#endif /* UBBOARDPALETTEMANAGER_H_ */ void zoomButtonPressed();
void zoomButtonReleased();
void panButtonPressed();
void panButtonReleased();
void changeStylusPaletteOrientation(QVariant var);
};
#endif /* UBBOARDPALETTEMANAGER_H_ */

@ -18,13 +18,30 @@
#include "domain/UBGraphicsVideoItem.h" #include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsWidgetItem.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) : 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.getVirtualPath() && mName == f.getName() && mPath == f.getFullPath() && elementType == f.getType();
}
bool UBFeature::operator !=( const UBFeature &f )const
{
return !(*this == f);
}
bool UBFeature::isFolder() const bool UBFeature::isFolder() const
{ {
@ -32,6 +49,10 @@ bool UBFeature::isFolder() const
|| elementType == FEATURE_FOLDER; || elementType == FEATURE_FOLDER;
} }
bool UBFeature::isDeletable()const
{
return elementType == FEATURE_ITEM;
}
UBFeaturesController::UBFeaturesController(QWidget *pParentWidget) : UBFeaturesController::UBFeaturesController(QWidget *pParentWidget) :
QObject(pParentWidget), QObject(pParentWidget),
@ -43,23 +64,24 @@ UBFeaturesController::UBFeaturesController(QWidget *pParentWidget) :
void UBFeaturesController::initDirectoryTree() void UBFeaturesController::initDirectoryTree()
{ {
mUserAudioDirectoryPath = UBSettings::settings()->userAudioDirectory(); mUserAudioDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->userAudioDirectory() );
mUserVideoDirectoryPath = UBSettings::settings()->userVideoDirectory(); mUserVideoDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->userVideoDirectory() );
mUserPicturesDirectoryPath = UBSettings::settings()->userImageDirectory(); mUserPicturesDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->userImageDirectory() );
mUserInteractiveDirectoryPath = UBSettings::settings()->userInteractiveDirectory(); mUserInteractiveDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->userInteractiveDirectory() );
mUserAnimationDirectoryPath = UBSettings::settings()->userAnimationDirectory(); mUserAnimationDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->userAnimationDirectory() );
mLibPicturesDirectoryPath = UBSettings::settings()->applicationImageLibraryDirectory(); mLibPicturesDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->applicationImageLibraryDirectory() );
mLibInteractiveDirectoryPath = UBSettings::settings()->applicationInteractivesDirectory(); mLibInteractiveDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->applicationInteractivesDirectory() );
mLibApplicationsDirectoryPath = UBSettings::settings()->applicationApplicationsLibraryDirectory(); mLibApplicationsDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->applicationApplicationsLibraryDirectory() );
mLibShapesDirectoryPath = UBSettings::settings()->applicationShapeLibraryDirectory() ; mLibShapesDirectoryPath = QUrl::fromLocalFile( UBSettings::settings()->applicationShapeLibraryDirectory() );
trashDirectoryPath = UBSettings::userTrashDirPath(); mLibSearchDirectoryPath =QUrl::fromLocalFile( UBSettings::settings()->userSearchDirectory() );
trashDirectoryPath = QUrl::fromLocalFile( UBSettings::userTrashDirPath() );
featuresList = new QList <UBFeature>(); featuresList = new QList <UBFeature>();
QList <UBToolsManager::UBToolDescriptor> tools = UBToolsManager::manager()->allTools(); QList <UBToolsManager::UBToolDescriptor> 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); currentElement = featuresList->at(0);
appPath = rootPath + "/Applications"; appPath = rootPath + "/Applications";
@ -72,26 +94,32 @@ void UBFeaturesController::initDirectoryTree()
trashPath = rootPath + "/Trash"; trashPath = rootPath + "/Trash";
favoritePath = rootPath + "/Favorites"; favoritePath = rootPath + "/Favorites";
featuresList->append( UBFeature( rootPath, QPixmap(":images/libpalette/AudiosCategory.svg"), "Audios" , mUserAudioDirectoryPath ) ); audiosElement = UBFeature( rootPath, QPixmap(":images/libpalette/AudiosCategory.svg"), "Audios" , mUserAudioDirectoryPath );
featuresList->append( UBFeature( rootPath, QPixmap(":images/libpalette/MoviesCategory.svg"), "Movies" , mUserVideoDirectoryPath ) ); featuresList->append( audiosElement );
featuresList->append( UBFeature( rootPath, QPixmap(":images/libpalette/PicturesCategory.svg"), "Pictures" , mUserPicturesDirectoryPath ) ); moviesElement = UBFeature( rootPath, QPixmap(":images/libpalette/MoviesCategory.svg"), "Movies" , mUserVideoDirectoryPath );
featuresList->append( moviesElement );
picturesElement = UBFeature( rootPath, QPixmap(":images/libpalette/PicturesCategory.svg"), "Pictures" , mUserPicturesDirectoryPath );
featuresList->append( picturesElement );
featuresList->append( UBFeature( rootPath, QPixmap(":images/libpalette/ApplicationsCategory.svg"), "Applications" , mUserInteractiveDirectoryPath ) ); featuresList->append( UBFeature( rootPath, QPixmap(":images/libpalette/ApplicationsCategory.svg"), "Applications" , mUserInteractiveDirectoryPath ) );
featuresList->append( UBFeature( rootPath, QPixmap(":images/libpalette/FlashCategory.svg"), "Animations" , mUserAnimationDirectoryPath ) ); flashElement = UBFeature( rootPath, QPixmap(":images/libpalette/FlashCategory.svg"), "Animations" , mUserAnimationDirectoryPath );
featuresList->append( UBFeature( rootPath, QPixmap(":images/libpalette/InteractivesCategory.svg"), "Interactivities" , mLibInteractiveDirectoryPath ) ); featuresList->append( flashElement );
interactElement = UBFeature( rootPath, QPixmap(":images/libpalette/InteractivesCategory.svg"), "Interactivities" , mLibInteractiveDirectoryPath );
featuresList->append( interactElement );
featuresList->append( UBFeature( rootPath, QPixmap(":images/libpalette/ShapesCategory.svg"), "Shapes" , mLibShapesDirectoryPath ) ); featuresList->append( UBFeature( rootPath, QPixmap(":images/libpalette/ShapesCategory.svg"), "Shapes" , mLibShapesDirectoryPath ) );
trashElement = UBFeature( rootPath, QPixmap(":images/libpalette/TrashCategory.svg"), "Trash", trashDirectoryPath, FEATURE_TRASH ); trashElement = UBFeature( rootPath, QPixmap(":images/libpalette/TrashCategory.svg"), "Trash", trashDirectoryPath, FEATURE_TRASH );
featuresList->append( trashElement ); 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 ); featuresList->append( favoriteElement );
webSearchElement = UBFeature( rootPath, QPixmap(":images/libpalette/WebSearchCategory.svg"), "Web search", mLibSearchDirectoryPath );
featuresList->append( webSearchElement );
loadFavoriteList(); loadFavoriteList();
foreach (UBToolsManager::UBToolDescriptor tool, tools) foreach (UBToolsManager::UBToolDescriptor tool, tools)
{ {
featuresList->append( UBFeature( appPath, tool.icon, tool.label, tool.id, FEATURE_INTERNAL ) ); featuresList->append( UBFeature( appPath, tool.icon, tool.label, QUrl( tool.id ), FEATURE_INTERNAL ) );
if ( favoriteSet->find( tool.id ) != favoriteSet->end() ) 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 ); fileSystemScan( mUserInteractiveDirectoryPath, appPath );
@ -105,14 +133,14 @@ void UBFeaturesController::initDirectoryTree()
fileSystemScan( mLibShapesDirectoryPath, shapesPath ); fileSystemScan( mLibShapesDirectoryPath, shapesPath );
fileSystemScan( mLibInteractiveDirectoryPath, interactPath ); fileSystemScan( mLibInteractiveDirectoryPath, interactPath );
fileSystemScan( trashDirectoryPath, trashPath ); fileSystemScan( trashDirectoryPath, trashPath );
fileSystemScan( mLibSearchDirectoryPath, rootPath + "/" + "Web search" );
} }
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; QFileInfoList::iterator fileInfo;
for ( fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end(); fileInfo += 1) for ( fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end(); fileInfo += 1)
@ -120,12 +148,19 @@ void UBFeaturesController::fileSystemScan(const QString & currentPath, const QSt
UBFeatureElementType fileType = fileInfo->isDir() ? FEATURE_FOLDER : FEATURE_ITEM; UBFeatureElementType fileType = fileInfo->isDir() ? FEATURE_FOLDER : FEATURE_ITEM;
QString fileName = fileInfo->fileName(); QString fileName = fileInfo->fileName();
if ( UBFileSystemUtils::mimeTypeFromFileName(fileName).contains("application") ) { if ( UBFileSystemUtils::mimeTypeFromFileName(fileName).contains("application") )
fileType = FEATURE_INTERACTIVE; {
if ( UBFileSystemUtils::mimeTypeFromFileName(fileName).contains("application/search") )
{
fileType = FEATURE_SEARCH;
}
else
fileType = FEATURE_INTERACTIVE;
} }
QString itemName = (fileType != FEATURE_ITEM) ? fileName : fileInfo->completeBaseName(); QString itemName = (fileType != FEATURE_ITEM) ? fileName : fileInfo->completeBaseName();
QPixmap icon = QPixmap(":images/libpalette/soundIcon.svg"); QPixmap icon = QPixmap(":images/libpalette/soundIcon.svg");
QString fullFileName = fileInfo->filePath(); QString fullFileName = fileInfo->filePath();
if ( fileType == FEATURE_FOLDER ) if ( fileType == FEATURE_FOLDER )
{ {
@ -146,15 +181,15 @@ void UBFeaturesController::fileSystemScan(const QString & currentPath, const QSt
icon = QPixmap( thumbnailPath ); icon = QPixmap( thumbnailPath );
else icon = createThumbnail( fullFileName );*/ else icon = createThumbnail( fullFileName );*/
} }
featuresList->append( UBFeature( currVirtualPath, icon, fileName, fullFileName, fileType ) ); featuresList->append( UBFeature( currVirtualPath, icon, fileName, QUrl::fromLocalFile( fullFileName ), fileType ) );
if ( favoriteSet->find( fullFileName ) != favoriteSet->end() ) 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 ) if ( fileType == FEATURE_FOLDER )
{ {
fileSystemScan( fullFileName, currVirtualPath + "/" + fileName ); fileSystemScan( QUrl::fromLocalFile( fullFileName ), currVirtualPath + "/" + fileName );
} }
} }
@ -162,7 +197,7 @@ void UBFeaturesController::fileSystemScan(const QString & currentPath, const QSt
void UBFeaturesController::loadFavoriteList() void UBFeaturesController::loadFavoriteList()
{ {
favoriteSet = new QSet<QString>(); favoriteSet = new QSet<QUrl>();
QFile file( UBSettings::userDataDirectory() + "/favorites.dat" ); QFile file( UBSettings::userDataDirectory() + "/favorites.dat" );
if ( file.exists() ) if ( file.exists() )
{ {
@ -172,7 +207,7 @@ void UBFeaturesController::loadFavoriteList()
in >> elementsNumber; in >> elementsNumber;
for ( int i = 0; i < elementsNumber; ++i) for ( int i = 0; i < elementsNumber; ++i)
{ {
QString path; QUrl path;
in >> path; in >> path;
/*QFileInfo fileInfo( path ); /*QFileInfo fileInfo( path );
QString fileName = fileInfo.fileName(); QString fileName = fileInfo.fileName();
@ -191,7 +226,7 @@ void UBFeaturesController::saveFavoriteList()
file.open(QIODevice::WriteOnly); file.open(QIODevice::WriteOnly);
QDataStream out(&file); QDataStream out(&file);
out << favoriteSet->size(); out << favoriteSet->size();
for ( QSet<QString>::iterator it = favoriteSet->begin(); it != favoriteSet->end(); ++it ) for ( QSet<QUrl>::iterator it = favoriteSet->begin(); it != favoriteSet->end(); ++it )
{ {
out << (*it); out << (*it);
} }
@ -201,12 +236,12 @@ void UBFeaturesController::saveFavoriteList()
UBFeature UBFeaturesController::addToFavorite( const QUrl &path ) UBFeature UBFeaturesController::addToFavorite( const QUrl &path )
{ {
QString filePath = fileNameFromUrl( path ); QString filePath = fileNameFromUrl( path );
if ( favoriteSet->find( filePath ) == favoriteSet->end() ) if ( favoriteSet->find( path ) == favoriteSet->end() )
{ {
QFileInfo fileInfo( filePath ); QFileInfo fileInfo( filePath );
QString fileName = fileInfo.fileName(); QString fileName = fileInfo.fileName();
UBFeature elem( favoritePath, thumbnailForFile( filePath ), fileName, filePath, fileTypeFromUrl(filePath) ); UBFeature elem( favoritePath, thumbnailForFile( filePath ), fileName, path, fileTypeFromUrl(filePath) );
favoriteSet->insert( filePath ); favoriteSet->insert( path );
saveFavoriteList(); saveFavoriteList();
return elem; return elem;
} }
@ -216,9 +251,9 @@ UBFeature UBFeaturesController::addToFavorite( const QUrl &path )
void UBFeaturesController::removeFromFavorite( const QUrl &path ) void UBFeaturesController::removeFromFavorite( const QUrl &path )
{ {
QString filePath = fileNameFromUrl( 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(); saveFavoriteList();
} }
} }
@ -231,6 +266,7 @@ QString UBFeaturesController::fileNameFromUrl( const QUrl &url )
return url.toLocalFile(); return url.toLocalFile();
} }
UBFeatureElementType UBFeaturesController::fileTypeFromUrl( const QString &path ) UBFeatureElementType UBFeaturesController::fileTypeFromUrl( const QString &path )
{ {
QFileInfo fileInfo( path ); QFileInfo fileInfo( path );
@ -268,6 +304,12 @@ QPixmap UBFeaturesController::thumbnailForFile(const QString &path)
return thumb; return thumb;
} }
bool UBFeaturesController::isDeletable( const QUrl &url )
{
UBFeatureElementType type = fileTypeFromUrl( fileNameFromUrl(url) );
return type == FEATURE_ITEM;
}
QPixmap UBFeaturesController::createThumbnail(const QString &path) QPixmap UBFeaturesController::createThumbnail(const QString &path)
{ {
QString thumbnailPath = UBFileSystemUtils::thumbnailPath(path); QString thumbnailPath = UBFileSystemUtils::thumbnailPath(path);
@ -305,24 +347,63 @@ QPixmap UBFeaturesController::createThumbnail(const QString &path)
UBFeature UBFeaturesController::newFolder( const QString &name ) UBFeature UBFeaturesController::newFolder( const QString &name )
{ {
QString path = currentElement.getFullPath() + "/" + name; QString path = currentElement.getFullPath().toLocalFile() + "/" + name;
if(!QFileInfo(path).exists()) if(!QFileInfo(path).exists())
{ {
QDir().mkpath(path); 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) void UBFeaturesController::addItemToPage(const UBFeature &item)
{ {
if ( item.getType() == FEATURE_INTERNAL ) UBApplication::boardController->downloadURL( item.getFullPath() );
{ }
UBApplication::boardController->downloadURL( QUrl( item.getFullPath() ) );
} void UBFeaturesController::addItemAsBackground(const UBFeature &item)
else {
UBApplication::boardController->downloadURL( item.getFullPath(), QPointF(), QSize(), true );
}
UBFeature UBFeaturesController::getDestinationForItem( const QUrl &url )
{
QString mimetype = UBFileSystemUtils::mimeTypeFromFileName( url.toString() );
if ( mimetype.contains("audio") )
return audiosElement;
if ( mimetype.contains("video") )
return moviesElement;
else if ( mimetype.contains("image") )
return picturesElement;
else if ( mimetype.contains("application") )
{ {
UBApplication::boardController->downloadURL( QUrl::fromLocalFile( item.getFullPath() ) ); if ( mimetype.contains( "x-shockwave-flash") )
} return flashElement;
else
return interactElement;
}
return UBFeature();
}
UBFeature UBFeaturesController::addDownloadedFile( const QUrl &sourceUrl, const QByteArray &pData )
{
UBFeature dest = getDestinationForItem( sourceUrl );
if ( dest == UBFeature() )
return UBFeature();
QString fileName = QFileInfo( sourceUrl.toString() ).fileName();
QString filePath = dest.getFullPath().toLocalFile() + "/" + fileName;
QFile file( filePath );
if( file.open(QIODevice::WriteOnly ))
{
file.write(pData);
file.close();
return UBFeature( dest.getFullVirtualPath(), thumbnailForFile( filePath ),
fileName, QUrl::fromLocalFile(filePath), FEATURE_ITEM );
}
return UBFeature();
} }
UBFeature UBFeaturesController::moveItemToFolder( const QUrl &url, const UBFeature &destination ) UBFeature UBFeaturesController::moveItemToFolder( const QUrl &url, const UBFeature &destination )
@ -338,9 +419,19 @@ UBFeature UBFeaturesController::copyItemToFolder( const QUrl &url, const UBFeatu
Q_ASSERT( QFileInfo( sourcePath ).exists() ); Q_ASSERT( QFileInfo( sourcePath ).exists() );
UBFeature possibleDest = getDestinationForItem( url );
UBFeature dest = destination;
if ( destination != trashElement &&
!destination.getFullVirtualPath().startsWith( possibleDest.getFullVirtualPath(), Qt::CaseInsensitive ) )
{
dest = possibleDest;
}
QString name = QFileInfo( sourcePath ).fileName(); QString name = QFileInfo( sourcePath ).fileName();
QString destPath = destination.getFullPath(); QString destPath = dest.getFullPath().toLocalFile();
QString destVirtualPath = destination.getUrl() + "/" + destination.getName(); QString destVirtualPath = dest.getFullVirtualPath();
QString newFullPath = destPath + "/" + name; QString newFullPath = destPath + "/" + name;
QFile( sourcePath ).copy( newFullPath ); QFile( sourcePath ).copy( newFullPath );
@ -349,7 +440,7 @@ UBFeature UBFeaturesController::copyItemToFolder( const QUrl &url, const UBFeatu
UBFeatureElementType type = FEATURE_ITEM; UBFeatureElementType type = FEATURE_ITEM;
if ( UBFileSystemUtils::mimeTypeFromFileName( newFullPath ).contains("application") ) if ( UBFileSystemUtils::mimeTypeFromFileName( newFullPath ).contains("application") )
type = FEATURE_INTERACTIVE; type = FEATURE_INTERACTIVE;
UBFeature newElement( destVirtualPath, thumb, name, newFullPath, type ); UBFeature newElement( destVirtualPath, thumb, name, QUrl::fromLocalFile( newFullPath ), type );
return newElement; return newElement;
} }
@ -359,7 +450,7 @@ void UBFeaturesController::deleteItem( const QUrl &url )
Q_ASSERT( QFileInfo( path ).exists() ); Q_ASSERT( QFileInfo( path ).exists() );
QString thumbnailPath = UBFileSystemUtils::thumbnailPath( path ); QString thumbnailPath = UBFileSystemUtils::thumbnailPath( path );
if (thumbnailPath.length() && QFileInfo( thumbnailPath ).exists()) if ( thumbnailPath.length() && QFileInfo( thumbnailPath ).exists() )
{ {
QFile::remove(thumbnailPath); QFile::remove(thumbnailPath);
} }
@ -368,7 +459,7 @@ void UBFeaturesController::deleteItem( const QUrl &url )
bool UBFeaturesController::isTrash( const QUrl &url ) bool UBFeaturesController::isTrash( const QUrl &url )
{ {
return url.toLocalFile().startsWith( trashDirectoryPath ); return url.toLocalFile().startsWith( trashDirectoryPath.toLocalFile() );
} }
UBFeaturesController::~UBFeaturesController() UBFeaturesController::~UBFeaturesController()

@ -4,9 +4,13 @@
#include <QMetaType> #include <QMetaType>
#include <QObject> #include <QObject>
#include <QWidget> #include <QWidget>
#include <QSet>
#include <QVector> #include <QVector>
#include <QString> #include <QString>
#include <QPixmap> #include <QPixmap>
#include <QMap>
#include <QUrl>
#include <QByteArray>
//#include "UBDockPaletteWidget.h" //#include "UBDockPaletteWidget.h"
@ -19,7 +23,8 @@ enum UBFeatureElementType
FEATURE_INTERNAL, FEATURE_INTERNAL,
FEATURE_ITEM, FEATURE_ITEM,
FEATURE_TRASH, FEATURE_TRASH,
FEATURE_FAVORITE FEATURE_FAVORITE,
FEATURE_SEARCH
}; };
class UBFeature class UBFeature
@ -27,21 +32,30 @@ class UBFeature
public: public:
UBFeature() {;} UBFeature() {;}
//UBFeature(const UBFeature &f); //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() {;} virtual ~UBFeature() {;}
QString getName() const { return mName; } QString getName() const { return mName; }
QPixmap getThumbnail() const {return mThumbnail;} QPixmap getThumbnail() const {return mThumbnail;}
QString getUrl() const { return virtualPath; } QString getVirtualPath() const { return virtualPath; }
//QString getPath() const { return mPath; }; //QString getPath() const { return mPath; };
QString getFullPath() const { return mPath; } QUrl getFullPath() const { return mPath; }
QString getFullVirtualPath() const { return virtualPath + "/" + mName; }
QString getUrl() const;
UBFeatureElementType getType() const { return elementType; } UBFeatureElementType getType() const { return elementType; }
bool isFolder() const; bool isFolder() const;
bool isDeletable() const;
bool operator ==( const UBFeature &f )const;
bool operator !=( const UBFeature &f )const;
const QMap<QString,QString> & getMetadata() const { return metadata; }
void setMetadata( const QMap<QString,QString> &data ) { metadata = data; }
private: private:
QString virtualPath; QString virtualPath;
QPixmap mThumbnail; QPixmap mThumbnail;
QString mName; QString mName;
QString mPath; QUrl mPath;
UBFeatureElementType elementType; UBFeatureElementType elementType;
QMap<QString,QString> metadata;
}; };
Q_DECLARE_METATYPE( UBFeature ) Q_DECLARE_METATYPE( UBFeature )
@ -57,10 +71,14 @@ public:
const QString& getRootPath()const { return rootPath; } const QString& getRootPath()const { return rootPath; }
void addItemToPage(const UBFeature &item); void addItemToPage( const UBFeature &item );
void addItemAsBackground( const UBFeature &item );
const UBFeature& getCurrentElement()const { return currentElement; } const UBFeature& getCurrentElement()const { return currentElement; }
void setCurrentElement( const UBFeature &elem ) { currentElement = elem; } void setCurrentElement( const UBFeature &elem ) { currentElement = elem; }
const UBFeature & getTrashElement () const { return trashElement; } const UBFeature & getTrashElement () const { return trashElement; }
UBFeature addDownloadedFile( const QUrl &sourceUrl, const QByteArray &pData );
UBFeature moveItemToFolder( const QUrl &url, const UBFeature &destination ); UBFeature moveItemToFolder( const QUrl &url, const UBFeature &destination );
UBFeature copyItemToFolder( const QUrl &url, const UBFeature &destination ); UBFeature copyItemToFolder( const QUrl &url, const UBFeature &destination );
void deleteItem( const QUrl &url ); void deleteItem( const QUrl &url );
@ -71,34 +89,37 @@ public:
static QString fileNameFromUrl( const QUrl &url ); static QString fileNameFromUrl( const QUrl &url );
static QPixmap thumbnailForFile( const QString &path ); static QPixmap thumbnailForFile( const QString &path );
static bool isDeletable( const QUrl &url );
private: private:
void initDirectoryTree(); void initDirectoryTree();
void fileSystemScan(const QString &currPath, const QString & currVirtualPath); void fileSystemScan(const QUrl &currPath, const QString & currVirtualPath);
static QPixmap createThumbnail(const QString &path); static QPixmap createThumbnail(const QString &path);
//void addImageToCurrentPage( const QString &path ); //void addImageToCurrentPage( const QString &path );
void loadFavoriteList(); void loadFavoriteList();
void saveFavoriteList(); void saveFavoriteList();
UBFeature getDestinationForItem( const QUrl &url );
static UBFeatureElementType fileTypeFromUrl( const QString &path ); static UBFeatureElementType fileTypeFromUrl( const QString &path );
QList <UBFeature> *featuresList; QList <UBFeature> *featuresList;
UBFeature *rootElement; UBFeature *rootElement;
QString mUserAudioDirectoryPath; QUrl mUserAudioDirectoryPath;
QString mUserVideoDirectoryPath; QUrl mUserVideoDirectoryPath;
QString mUserPicturesDirectoryPath; QUrl mUserPicturesDirectoryPath;
QString mUserInteractiveDirectoryPath; QUrl mUserInteractiveDirectoryPath;
QString mUserAnimationDirectoryPath; QUrl mUserAnimationDirectoryPath;
QString libraryPath; QString libraryPath;
QString mLibAudioDirectoryPath; QUrl mLibAudioDirectoryPath;
QString mLibVideoDirectoryPath; QUrl mLibVideoDirectoryPath;
QString mLibPicturesDirectoryPath; QUrl mLibPicturesDirectoryPath;
QString mLibInteractiveDirectoryPath; QUrl mLibInteractiveDirectoryPath;
QString mLibAnimationDirectoryPath; QUrl mLibAnimationDirectoryPath;
QString mLibApplicationsDirectoryPath; QUrl mLibApplicationsDirectoryPath;
QString mLibShapesDirectoryPath; QUrl mLibShapesDirectoryPath;
QString trashDirectoryPath; QUrl trashDirectoryPath;
QUrl mLibSearchDirectoryPath;
QString rootPath; QString rootPath;
QString audiosPath; QString audiosPath;
@ -115,8 +136,15 @@ private:
UBFeature currentElement; UBFeature currentElement;
UBFeature trashElement; UBFeature trashElement;
UBFeature favoriteElement; UBFeature favoriteElement;
UBFeature audiosElement;
QSet <QString> *favoriteSet; UBFeature moviesElement;
UBFeature picturesElement;
UBFeature interactElement;
UBFeature flashElement;
UBFeature shapesElement;
UBFeature webSearchElement;
QSet <QUrl> *favoriteSet;
}; };

@ -72,7 +72,7 @@ int main(int argc, char *argv[])
// Uncomment next section to have memory leaks information // Uncomment next section to have memory leaks information
// tracing in VC++ debug mode under Windows // tracing in VC++ debug mode under Windows
/* /*
#if defined(_MSC_VER) && defined(_DEBUG) #if defined(_MSC_VER) && defined(_DEBUG)
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif #endif

@ -18,6 +18,8 @@
#include "UBActionableWidget.h" #include "UBActionableWidget.h"
#include "core/memcheck.h"
UBActionableWidget::UBActionableWidget(QWidget *parent, const char *name):QWidget(parent) UBActionableWidget::UBActionableWidget(QWidget *parent, const char *name):QWidget(parent)
, mShowActions(false) , mShowActions(false)
{ {

@ -16,6 +16,8 @@
#include "globals/UBGlobals.h" #include "globals/UBGlobals.h"
#include "UBMediaWidget.h" #include "UBMediaWidget.h"
#include "core/memcheck.h"
/** /**
* \brief Constructor * \brief Constructor
* @param type as the media type * @param type as the media type

@ -15,6 +15,8 @@
#include "UBAbstractUndoCommand.h" #include "UBAbstractUndoCommand.h"
#include "core/memcheck.h"
UBAbstractUndoCommand::UBAbstractUndoCommand() UBAbstractUndoCommand::UBAbstractUndoCommand()
{ {
// NOOP // NOOP

@ -1,6 +1,8 @@
#include "UBAngleWidget.h" #include "UBAngleWidget.h"
#include <QPainter> #include <QPainter>
#include "core/memcheck.h"
UBAngleWidget::UBAngleWidget(QWidget *parent) UBAngleWidget::UBAngleWidget(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {

File diff suppressed because it is too large Load Diff

@ -37,6 +37,9 @@
#include "UBGraphicsWidgetItem.h" #include "UBGraphicsWidgetItem.h"
#include "domain/UBAbstractWidget.h" #include "domain/UBAbstractWidget.h"
#include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsVideoItem.h"
#include "web/UBWebController.h" #include "web/UBWebController.h"
@ -47,6 +50,27 @@
class UBGraphicsParaschoolEditorWidgetItem; class UBGraphicsParaschoolEditorWidgetItem;
DelegateButton::DelegateButton(const QString & fileName, QGraphicsItem* pDelegated, QGraphicsItem * parent, Qt::WindowFrameSection section)
: QGraphicsSvgItem(fileName, parent)
, mDelegated(pDelegated)
, mIsTransparentToMouseEvent(false)
, mButtonAlignmentSection(section)
{
setAcceptedMouseButtons(Qt::LeftButton);
setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
}
DelegateButton::~DelegateButton()
{
// NOOP
}
void DelegateButton::setFileName(const QString & fileName)
{
QGraphicsSvgItem::setSharedRenderer(new QSvgRenderer (fileName, this));
}
void DelegateButton::mousePressEvent(QGraphicsSceneMouseEvent *event) void DelegateButton::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
// make sure delegate is selected, to avoid control being hidden // make sure delegate is selected, to avoid control being hidden
@ -93,6 +117,8 @@ UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObjec
void UBGraphicsItemDelegate::init() void UBGraphicsItemDelegate::init()
{ {
mToolBarItem = new UBGraphicsToolBarItem(delegated());
mFrame = new UBGraphicsDelegateFrame(this, QRectF(0, 0, 0, 0), mFrameWidth, mRespectRatio); mFrame = new UBGraphicsDelegateFrame(this, QRectF(0, 0, 0, 0), mFrameWidth, mRespectRatio);
mFrame->hide(); mFrame->hide();
mFrame->setFlag(QGraphicsItem::ItemIsSelectable, true); mFrame->setFlag(QGraphicsItem::ItemIsSelectable, true);
@ -123,10 +149,13 @@ void UBGraphicsItemDelegate::init()
foreach(DelegateButton* button, mButtons) foreach(DelegateButton* button, mButtons)
{ {
if (button->getSection() != Qt::TitleBarArea)
{
button->hide(); button->hide();
button->setFlag(QGraphicsItem::ItemIsSelectable, true); button->setFlag(QGraphicsItem::ItemIsSelectable, true);
} }
} }
}
UBGraphicsItemDelegate::~UBGraphicsItemDelegate() UBGraphicsItemDelegate::~UBGraphicsItemDelegate()
@ -292,13 +321,20 @@ void UBGraphicsItemDelegate::positionHandles()
updateButtons(true); updateButtons(true);
if (mToolBarItem->isVisibleOnBoard())
{
updateToolBar();
mToolBarItem->show();
}
} else { } else {
foreach(DelegateButton* button, mButtons) foreach(DelegateButton* button, mButtons)
button->hide(); button->hide();
mFrame->hide(); mFrame->hide();
mToolBarItem->hide();
} }
} }
void UBGraphicsItemDelegate::setZOrderButtonsVisible(bool visible) void UBGraphicsItemDelegate::setZOrderButtonsVisible(bool visible)
{ {
if (visible) { if (visible) {
@ -335,6 +371,7 @@ void UBGraphicsItemDelegate::remove(bool canUndo)
scene->removeItem(mFrame); scene->removeItem(mFrame);
scene->removeItem(mDelegated); scene->removeItem(mDelegated);
scene->removeItem(mToolBarItem);
if (canUndo) if (canUndo)
{ {
@ -577,14 +614,16 @@ void UBGraphicsItemDelegate::updateButtons(bool showUpdated)
int i = 1, j = 0, k = 0; int i = 1, j = 0, k = 0;
while ((i + j + k) < mButtons.size()) { while ((i + j + k) < mButtons.size()) {
DelegateButton* button = mButtons[i + j]; DelegateButton* button = mButtons[i + j];
button->setParentItem(mFrame);
button->setTransform(tr);
if (button->getSection() == Qt::TopLeftSection) { if (button->getSection() == Qt::TopLeftSection) {
button->setParentItem(mFrame);
button->setPos(topX + (i++ * 1.6 * mFrameWidth * mAntiScaleRatio), topY); button->setPos(topX + (i++ * 1.6 * mFrameWidth * mAntiScaleRatio), topY);
button->setTransform(tr);
} else if (button->getSection() == Qt::BottomLeftSection) { } else if (button->getSection() == Qt::BottomLeftSection) {
button->setParentItem(mFrame);
button->setPos(bottomX + (++j * 1.6 * mFrameWidth * mAntiScaleRatio), bottomY); button->setPos(bottomX + (++j * 1.6 * mFrameWidth * mAntiScaleRatio), bottomY);
} else if (button->getSection() == Qt::NoSection) { button->setTransform(tr);
} else if (button->getSection() == Qt::TitleBarArea || button->getSection() == Qt::NoSection){
++k; ++k;
} }
if (!button->scene()) if (!button->scene())
@ -599,9 +638,65 @@ void UBGraphicsItemDelegate::updateButtons(bool showUpdated)
} }
} }
void UBGraphicsItemDelegate::updateToolBar()
{
QTransform transformForToolbarButtons;
transformForToolbarButtons.scale(mAntiScaleRatio, 1);
QRectF toolBarRect = mToolBarItem->rect();
toolBarRect.setWidth(delegated()->boundingRect().width() - 10);
mToolBarItem->setRect(toolBarRect);
if (mToolBarItem->isShifting())
mToolBarItem->setPos(delegated()->boundingRect().bottomLeft() + QPointF(5 * mAntiScaleRatio, 0));
else mToolBarItem->setPos(delegated()->boundingRect().bottomLeft() - QPointF(-5 * mAntiScaleRatio, mToolBarItem->rect().height() * 1.1 * mAntiScaleRatio));
int offsetOnToolBar = 5 * mAntiScaleRatio;
QList<QGraphicsItem*> itemList = mToolBarItem->itemsOnToolBar();
foreach (QGraphicsItem* item, itemList)
{
item->setPos(offsetOnToolBar, 0);
offsetOnToolBar += (item->boundingRect().width() + 5) * mAntiScaleRatio;
item->setTransform(transformForToolbarButtons);
item->show();
}
mToolBarItem->setOffsetOnToolBar(offsetOnToolBar);
QTransform tr;
tr.scale(1, mAntiScaleRatio);
mToolBarItem->setTransform(tr);
}
void UBGraphicsItemDelegate::setButtonsVisible(bool visible) void UBGraphicsItemDelegate::setButtonsVisible(bool visible)
{ {
foreach(DelegateButton* pButton, mButtons){ foreach(DelegateButton* pButton, mButtons){
pButton->setVisible(visible); pButton->setVisible(visible);
} }
} }
UBGraphicsToolBarItem::UBGraphicsToolBarItem(QGraphicsItem * parent) :
QGraphicsRectItem(parent),
mShifting(true),
mVisible(false),
mMinWidth(200)
{
QRectF rect = this->rect();
rect.setHeight(26);
this->setRect(rect);
setBrush(QColor(UBSettings::paletteColor));
setPen(Qt::NoPen);
hide();
}
void UBGraphicsToolBarItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
QPainterPath path;
path.addRoundedRect(rect(), 10, 10);
painter->fillPath(path, brush());
}

@ -35,30 +35,16 @@ class DelegateButton: public QGraphicsSvgItem
Q_OBJECT Q_OBJECT
public: public:
DelegateButton(const QString & fileName, QGraphicsItem* pDelegated, QGraphicsItem * parent = 0, Qt::WindowFrameSection section = Qt::TopLeftSection) DelegateButton(const QString & fileName, QGraphicsItem* pDelegated, QGraphicsItem * parent = 0, Qt::WindowFrameSection section = Qt::TopLeftSection);
: QGraphicsSvgItem(fileName, parent)
, mDelegated(pDelegated)
, mIsTransparentToMouseEvent(false)
, mButtonAlignmentSection(section)
{
setAcceptedMouseButtons(Qt::LeftButton);
setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
}
virtual ~DelegateButton() virtual ~DelegateButton();
{
// NOOP
}
void setTransparentToMouseEvent(bool tr) void setTransparentToMouseEvent(bool tr)
{ {
mIsTransparentToMouseEvent = tr; mIsTransparentToMouseEvent = tr;
} }
void setFileName(const QString & fileName) void setFileName(const QString & fileName);
{
QGraphicsSvgItem::setSharedRenderer(new QSvgRenderer (fileName, this));
}
void setSection(Qt::WindowFrameSection section) {mButtonAlignmentSection = section;} void setSection(Qt::WindowFrameSection section) {mButtonAlignmentSection = section;}
Qt::WindowFrameSection getSection() const {return mButtonAlignmentSection;} Qt::WindowFrameSection getSection() const {return mButtonAlignmentSection;}
@ -84,6 +70,31 @@ class DelegateButton: public QGraphicsSvgItem
}; };
class UBGraphicsToolBarItem : public QGraphicsRectItem, public QObject
{
public:
UBGraphicsToolBarItem(QGraphicsItem * parent = 0);
virtual ~UBGraphicsToolBarItem() {};
bool isVisibleOnBoard() const { return mVisible; }
void setVisibleOnBoard(bool visible) { mVisible = visible; }
bool isShifting() const { return mShifting; }
void setShifting(bool shifting) { mShifting = shifting; }
int offsetOnToolBar() const { return mOffsetOnToolBar; }
void setOffsetOnToolBar(int pOffset) { mOffsetOnToolBar = pOffset; }
QList<QGraphicsItem*> itemsOnToolBar() const { return mItemsOnToolBar; }
void setItemsOnToolBar(QList<QGraphicsItem*> itemsOnToolBar) { mItemsOnToolBar = itemsOnToolBar;}
int minWidth() { return mMinWidth; }
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
private:
bool mShifting;
bool mVisible;
int mOffsetOnToolBar;
int mMinWidth;
QList<QGraphicsItem*> mItemsOnToolBar;
};
class UBGraphicsItemDelegate : public QObject class UBGraphicsItemDelegate : public QObject
{ {
@ -138,6 +149,10 @@ class UBGraphicsItemDelegate : public QObject
void setButtonsVisible(bool visible); void setButtonsVisible(bool visible);
UBGraphicsToolBarItem* getToolBarItem() const { return mToolBarItem; }
qreal antiScaleRatio() const { return mAntiScaleRatio; }
signals: signals:
void showOnDisplayChanged(bool shown); void showOnDisplayChanged(bool shown);
void lockChanged(bool locked); void lockChanged(bool locked);
@ -183,12 +198,17 @@ class UBGraphicsItemDelegate : public QObject
QList<DelegateButton*> mButtons; QList<DelegateButton*> mButtons;
UBGraphicsToolBarItem* mToolBarItem;
protected slots: protected slots:
virtual void gotoContentSource(bool checked); virtual void gotoContentSource(bool checked);
private: private:
void updateFrame(); void updateFrame();
void updateButtons(bool showUpdated = false); void updateButtons(bool showUpdated = false);
void updateToolBar();
QPointF mOffset; QPointF mOffset;
QTransform mPreviousTransform; QTransform mPreviousTransform;

@ -19,12 +19,12 @@
#include "UBGraphicsScene.h" #include "UBGraphicsScene.h"
#include "core/memcheck.h"
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "core/memcheck.h"
UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet<QGraphicsItem*>& pRemovedItems, UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet<QGraphicsItem*>& pRemovedItems,
const QSet<QGraphicsItem*>& pAddedItems) const QSet<QGraphicsItem*>& pAddedItems)
: mScene(pScene) : mScene(pScene)

@ -23,10 +23,10 @@
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "core/memcheck.h"
#include "frameworks/UBFileSystemUtils.h" #include "frameworks/UBFileSystemUtils.h"
#include "core/memcheck.h"
bool UBGraphicsMediaItem::sIsMutedByDefault = false; bool UBGraphicsMediaItem::sIsMutedByDefault = false;
UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsItem *parent) UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsItem *parent)

@ -1,5 +1,7 @@
#include "UBGraphicsStrokesGroup.h" #include "UBGraphicsStrokesGroup.h"
#include "core/memcheck.h"
UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent):QGraphicsItemGroup(parent) UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent):QGraphicsItemGroup(parent)
{ {
mDelegate = new UBGraphicsItemDelegate(this, 0, true, true); mDelegate = new UBGraphicsItemDelegate(this, 0, true, true);

@ -24,9 +24,10 @@
#include "domain/UBGraphicsDelegateFrame.h" #include "domain/UBGraphicsDelegateFrame.h"
#include "core/UBSettings.h" #include "core/UBSettings.h"
#include "core/memcheck.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "core/memcheck.h"
const int UBGraphicsTextItemDelegate::sMinPixelSize = 8; const int UBGraphicsTextItemDelegate::sMinPixelSize = 8;
const int UBGraphicsTextItemDelegate::sMinPointSize = 8; const int UBGraphicsTextItemDelegate::sMinPointSize = 8;
@ -94,17 +95,21 @@ void UBGraphicsTextItemDelegate::buildButtons()
{ {
UBGraphicsItemDelegate::buildButtons(); UBGraphicsItemDelegate::buildButtons();
mFontButton = new DelegateButton(":/images/font.svg", mDelegated, mFrame, Qt::TopLeftSection); mFontButton = new DelegateButton(":/images/font.svg", mDelegated, mToolBarItem, Qt::TitleBarArea);
mColorButton = new DelegateButton(":/images/color.svg", mDelegated, mFrame, Qt::TopLeftSection); mColorButton = new DelegateButton(":/images/color.svg", mDelegated, mToolBarItem, Qt::TitleBarArea);
mDecreaseSizeButton = new DelegateButton(":/images/minus.svg", mDelegated, mFrame, Qt::TopLeftSection); mDecreaseSizeButton = new DelegateButton(":/images/minus.svg", mDelegated, mToolBarItem, Qt::TitleBarArea);
mIncreaseSizeButton = new DelegateButton(":/images/plus.svg", mDelegated, mFrame, Qt::TopLeftSection); mIncreaseSizeButton = new DelegateButton(":/images/plus.svg", mDelegated, mToolBarItem, Qt::TitleBarArea);
connect(mFontButton, SIGNAL(clicked(bool)), this, SLOT(pickFont())); connect(mFontButton, SIGNAL(clicked(bool)), this, SLOT(pickFont()));
connect(mColorButton, SIGNAL(clicked(bool)), this, SLOT(pickColor())); connect(mColorButton, SIGNAL(clicked(bool)), this, SLOT(pickColor()));
connect(mDecreaseSizeButton, SIGNAL(clicked(bool)), this, SLOT(decreaseSize())); connect(mDecreaseSizeButton, SIGNAL(clicked(bool)), this, SLOT(decreaseSize()));
connect(mIncreaseSizeButton, SIGNAL(clicked(bool)), this, SLOT(increaseSize())); connect(mIncreaseSizeButton, SIGNAL(clicked(bool)), this, SLOT(increaseSize()));
mButtons << mFontButton << mColorButton << mDecreaseSizeButton << mIncreaseSizeButton; QList<QGraphicsItem*> itemsOnToolBar;
itemsOnToolBar << mFontButton << mColorButton << mDecreaseSizeButton << mIncreaseSizeButton;
mToolBarItem->setItemsOnToolBar(itemsOnToolBar);
mToolBarItem->setVisibleOnBoard(true);
} }
void UBGraphicsTextItemDelegate::contentsChanged() void UBGraphicsTextItemDelegate::contentsChanged()

@ -1,336 +1,351 @@
/* /*
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <QtGui> #include <QtGui>
#include <QtSvg> #include <QtSvg>
#include "UBGraphicsVideoItemDelegate.h" #include "UBGraphicsVideoItemDelegate.h"
#include "UBGraphicsScene.h" #include "UBGraphicsScene.h"
#include "core/UBSettings.h" #include "core/UBSettings.h"
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "core/UBApplicationController.h" #include "core/UBApplicationController.h"
#include "core/UBDisplayManager.h" #include "core/UBDisplayManager.h"
#include "domain/UBGraphicsVideoItem.h" #include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsDelegateFrame.h" #include "domain/UBGraphicsDelegateFrame.h"
#include "core/memcheck.h" #include "core/memcheck.h"
UBGraphicsVideoItemDelegate::UBGraphicsVideoItemDelegate(UBGraphicsVideoItem* pDelegated, Phonon::MediaObject* pMedia, QObject * parent) UBGraphicsVideoItemDelegate::UBGraphicsVideoItemDelegate(UBGraphicsVideoItem* pDelegated, Phonon::MediaObject* pMedia, QObject * parent)
: UBGraphicsItemDelegate(pDelegated, parent, true, false) : UBGraphicsItemDelegate(pDelegated, parent, true, false)
, mMedia(pMedia) , mMedia(pMedia)
{ {
// NOOP // NOOP
} }
void UBGraphicsVideoItemDelegate::buildButtons() void UBGraphicsVideoItemDelegate::buildButtons()
{ {
mPlayPauseButton = new DelegateButton(":/images/play.svg", mDelegated, mFrame); mPlayPauseButton = new DelegateButton(":/images/play.svg", mDelegated, mToolBarItem, Qt::TitleBarArea);
mStopButton = new DelegateButton(":/images/stop.svg", mDelegated, mFrame); mStopButton = new DelegateButton(":/images/stop.svg", mDelegated, mToolBarItem, Qt::TitleBarArea);
mStopButton->hide();
mVideoControl = new DelegateVideoControl(delegated(), mToolBarItem);
if (delegated()->isMuted()) UBGraphicsItem::assignZValue(mVideoControl, delegated()->zValue());
mMuteButton = new DelegateButton(":/images/soundOff.svg", mDelegated, mFrame); mVideoControl->setFlag(QGraphicsItem::ItemIsSelectable, true);
else
mMuteButton = new DelegateButton(":/images/soundOn.svg", mDelegated, mFrame); if (delegated()->isMuted())
mMuteButton = new DelegateButton(":/images/soundOff.svg", mDelegated, mToolBarItem, Qt::TitleBarArea);
mMuteButton->hide(); else
mMuteButton = new DelegateButton(":/images/soundOn.svg", mDelegated, mToolBarItem, Qt::TitleBarArea);
mVideoControl = new DelegateVideoControl(delegated(), mFrame);
UBGraphicsItem::assignZValue(mVideoControl, delegated()->zValue()); connect(mPlayPauseButton, SIGNAL(clicked(bool)), this, SLOT(togglePlayPause()));
mVideoControl->setFlag(QGraphicsItem::ItemIsSelectable, true); connect(mStopButton, SIGNAL(clicked(bool)), mMedia, SLOT(stop()));
connect(mMuteButton, SIGNAL(clicked(bool)), delegated(), SLOT(toggleMute()));
connect(mPlayPauseButton, SIGNAL(clicked(bool)), this, SLOT(togglePlayPause())); connect(mMuteButton, SIGNAL(clicked(bool)), this, SLOT(toggleMute()));
connect(mStopButton, SIGNAL(clicked(bool)), mMedia, SLOT(stop()));
connect(mMuteButton, SIGNAL(clicked(bool)), delegated(), SLOT(toggleMute())); mButtons << mPlayPauseButton << mStopButton << mMuteButton;
connect(mMuteButton, SIGNAL(clicked(bool)), this, SLOT(toggleMute()));
QList<QGraphicsItem*> itemsOnToolBar;
mButtons << mPlayPauseButton << mStopButton << mMuteButton; itemsOnToolBar << mPlayPauseButton << mStopButton << mVideoControl << mMuteButton;
mToolBarItem->setItemsOnToolBar(itemsOnToolBar);
mMedia->setTickInterval(50);
mMedia->setTickInterval(50);
connect(mMedia, SIGNAL(stateChanged (Phonon::State, Phonon::State)), this, SLOT(mediaStateChanged (Phonon::State, Phonon::State)));
connect(mMedia, SIGNAL(finished()), this, SLOT(updatePlayPauseState())); connect(mMedia, SIGNAL(stateChanged (Phonon::State, Phonon::State)), this, SLOT(mediaStateChanged (Phonon::State, Phonon::State)));
connect(mMedia, SIGNAL(tick(qint64)), this, SLOT(updateTicker(qint64))); connect(mMedia, SIGNAL(finished()), this, SLOT(updatePlayPauseState()));
connect(mMedia, SIGNAL(totalTimeChanged(qint64)), this, SLOT(totalTimeChanged(qint64))); connect(mMedia, SIGNAL(tick(qint64)), this, SLOT(updateTicker(qint64)));
connect(mMedia, SIGNAL(totalTimeChanged(qint64)), this, SLOT(totalTimeChanged(qint64)));
}
mToolBarItem->setVisibleOnBoard(true);
mToolBarItem->setShifting(false);
UBGraphicsVideoItemDelegate::~UBGraphicsVideoItemDelegate() }
{
//NOOP
} UBGraphicsVideoItemDelegate::~UBGraphicsVideoItemDelegate()
{
//NOOP
void UBGraphicsVideoItemDelegate::positionHandles() }
{
UBGraphicsItemDelegate::positionHandles();
void UBGraphicsVideoItemDelegate::positionHandles()
if (mDelegated->isSelected()) {
{ UBGraphicsItemDelegate::positionHandles();
qreal scaledFrameWidth = mFrameWidth * mAntiScaleRatio;
if (mDelegated->isSelected())
{
qreal width = mFrame->rect().width(); qreal scaledFrameWidth = mFrameWidth * mAntiScaleRatio;
qreal height = mFrame->rect().height();
int offset = 0;
qreal x = mFrame->rect().left(); foreach (DelegateButton* button, mButtons)
qreal y = mFrame->rect().top(); {
if (button->getSection() == Qt::TitleBarArea)
mVideoControl->setRect(x + 2 * scaledFrameWidth offset += button->boundingRect().width() * mAntiScaleRatio;
, y + height - 3 * scaledFrameWidth }
, width - 4 * scaledFrameWidth
, 2 * scaledFrameWidth); mVideoControl->setRect(mVideoControl->rect().x()
, scaledFrameWidth/6 - 0.5
if (!mVideoControl->scene()) , (mToolBarItem->rect().width() - 35 - offset) / mAntiScaleRatio
{ , (2 * scaledFrameWidth) / mAntiScaleRatio);
mVideoControl->setParentItem(mFrame);//update parent for the case the item has been previously removed from scene
mDelegated->scene()->addItem(mVideoControl); offset += (mVideoControl->rect().width() + 5) * mAntiScaleRatio;
} mMuteButton->setPos(offset, 0);
mVideoControl->setAntiScale(mAntiScaleRatio); if (!mVideoControl->scene())
mVideoControl->setZValue(delegated()->zValue()); {
mVideoControl->show(); mVideoControl->setParentItem(mToolBarItem);//update parent for the case the item has been previously removed from scene
} mDelegated->scene()->addItem(mVideoControl);
else }
{
mVideoControl->hide(); mVideoControl->setAntiScale(mAntiScaleRatio);
} mVideoControl->setZValue(delegated()->zValue());
} mVideoControl->show();
}
else
void UBGraphicsVideoItemDelegate::remove(bool canUndo) {
{ mVideoControl->hide();
if (delegated() && delegated()->mediaObject()) }
delegated()->mediaObject()->stop(); }
QGraphicsScene* scene = mDelegated->scene();
void UBGraphicsVideoItemDelegate::remove(bool canUndo)
scene->removeItem(mVideoControl); {
if (delegated() && delegated()->mediaObject())
UBGraphicsItemDelegate::remove(canUndo); delegated()->mediaObject()->stop();
}
QGraphicsScene* scene = mDelegated->scene();
void UBGraphicsVideoItemDelegate::toggleMute() scene->removeItem(mVideoControl);
{
if (delegated()->isMuted()) UBGraphicsItemDelegate::remove(canUndo);
mMuteButton->setFileName(":/images/soundOff.svg"); }
else
mMuteButton->setFileName(":/images/soundOn.svg");
void UBGraphicsVideoItemDelegate::toggleMute()
} {
if (delegated()->isMuted())
mMuteButton->setFileName(":/images/soundOff.svg");
UBGraphicsVideoItem* UBGraphicsVideoItemDelegate::delegated() else
{ mMuteButton->setFileName(":/images/soundOn.svg");
return static_cast<UBGraphicsVideoItem*>(mDelegated);
} }
void UBGraphicsVideoItemDelegate::togglePlayPause() UBGraphicsVideoItem* UBGraphicsVideoItemDelegate::delegated()
{ {
if (delegated() && delegated()->mediaObject()) { return static_cast<UBGraphicsVideoItem*>(mDelegated);
}
Phonon::MediaObject* media = delegated()->mediaObject();
if (media->state() == Phonon::StoppedState) {
media->play(); void UBGraphicsVideoItemDelegate::togglePlayPause()
} else if (media->state() == Phonon::PlayingState) { {
if (media->remainingTime() <= 0) { if (delegated() && delegated()->mediaObject()) {
media->stop();
media->play(); Phonon::MediaObject* media = delegated()->mediaObject();
} else { if (media->state() == Phonon::StoppedState) {
media->pause(); media->play();
if(delegated()->scene()) } else if (media->state() == Phonon::PlayingState) {
delegated()->scene()->setModified(true); if (media->remainingTime() <= 0) {
} media->stop();
} else if (media->state() == Phonon::PausedState) { media->play();
if (media->remainingTime() <= 0) { } else {
media->stop(); media->pause();
} if(delegated()->scene())
media->play(); delegated()->scene()->setModified(true);
} else if ( media->state() == Phonon::LoadingState ) { }
delegated()->mediaObject()->setCurrentSource(delegated()->mediaFileUrl()); } else if (media->state() == Phonon::PausedState) {
media->play(); if (media->remainingTime() <= 0) {
} else if (media->state() == Phonon::ErrorState){ media->stop();
qDebug() << "Error appeared." << media->errorString(); }
} media->play();
} } else if ( media->state() == Phonon::LoadingState ) {
} delegated()->mediaObject()->setCurrentSource(delegated()->mediaFileUrl());
media->play();
void UBGraphicsVideoItemDelegate::mediaStateChanged ( Phonon::State newstate, Phonon::State oldstate ) } else if (media->state() == Phonon::ErrorState){
{ qDebug() << "Error appeared." << media->errorString();
Q_UNUSED(newstate); }
Q_UNUSED(oldstate); }
updatePlayPauseState(); }
}
void UBGraphicsVideoItemDelegate::mediaStateChanged ( Phonon::State newstate, Phonon::State oldstate )
{
void UBGraphicsVideoItemDelegate::updatePlayPauseState() Q_UNUSED(newstate);
{ Q_UNUSED(oldstate);
Phonon::MediaObject* media = delegated()->mediaObject(); updatePlayPauseState();
}
if (media->state() == Phonon::PlayingState)
mPlayPauseButton->setFileName(":/images/pause.svg");
else void UBGraphicsVideoItemDelegate::updatePlayPauseState()
mPlayPauseButton->setFileName(":/images/play.svg"); {
} Phonon::MediaObject* media = delegated()->mediaObject();
if (media->state() == Phonon::PlayingState)
void UBGraphicsVideoItemDelegate::updateTicker(qint64 time) mPlayPauseButton->setFileName(":/images/pause.svg");
{ else
Phonon::MediaObject* media = delegated()->mediaObject(); mPlayPauseButton->setFileName(":/images/play.svg");
mVideoControl->totalTimeChanged(media->totalTime()); }
mVideoControl->updateTicker(time);
} void UBGraphicsVideoItemDelegate::updateTicker(qint64 time)
{
Phonon::MediaObject* media = delegated()->mediaObject();
void UBGraphicsVideoItemDelegate::totalTimeChanged(qint64 newTotalTime) mVideoControl->totalTimeChanged(media->totalTime());
{
mVideoControl->totalTimeChanged(newTotalTime); mVideoControl->updateTicker(time);
} }
DelegateVideoControl::DelegateVideoControl(UBGraphicsVideoItem* pDelegated, QGraphicsItem * parent) void UBGraphicsVideoItemDelegate::totalTimeChanged(qint64 newTotalTime)
: QGraphicsRectItem(parent) {
, mDelegate(pDelegated) mVideoControl->totalTimeChanged(newTotalTime);
, mDisplayCurrentTime(false) }
, mAntiScale(1.0)
, mCurrentTimeInMs(0)
, mTotalTimeInMs(0) DelegateVideoControl::DelegateVideoControl(UBGraphicsVideoItem* pDelegated, QGraphicsItem * parent)
{ : QGraphicsRectItem(parent)
setAcceptedMouseButtons(Qt::LeftButton); , mDelegate(pDelegated)
, mDisplayCurrentTime(false)
setBrush(QBrush(UBSettings::paletteColor)); , mAntiScale(1.0)
setPen(Qt::NoPen); , mCurrentTimeInMs(0)
setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control)); , mTotalTimeInMs(0)
} , mStartWidth(200)
{
setAcceptedMouseButtons(Qt::LeftButton);
void DelegateVideoControl::paint(QPainter *painter,
const QStyleOptionGraphicsItem *option, QWidget *widget) setBrush(QBrush(Qt::white));
{ setPen(Qt::NoPen);
Q_UNUSED(option); setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
Q_UNUSED(widget);
QRectF rect = this->rect();
painter->fillPath(shape(), brush()); rect.setWidth(mStartWidth);
this->setRect(rect);
qreal frameWidth = rect().height() / 2; }
int position = frameWidth;
if (mTotalTimeInMs > 0) void DelegateVideoControl::paint(QPainter *painter,
{ const QStyleOptionGraphicsItem *option, QWidget *widget)
position = frameWidth + (rect().width() - (2 * frameWidth)) / mTotalTimeInMs * mCurrentTimeInMs; {
} Q_UNUSED(option);
Q_UNUSED(widget);
int radius = rect().height() / 6;
QRectF r(rect().x() + position - radius, rect().y() + (rect().height() / 4) - radius, radius * 2, radius * 2); painter->fillPath(shape(), brush());
painter->setBrush(UBSettings::documentViewLightColor); qreal frameWidth = rect().height() / 2;
painter->drawEllipse(r); int position = frameWidth;
if(mDisplayCurrentTime) if (mTotalTimeInMs > 0)
{ {
painter->setBrush(UBSettings::paletteColor); position = frameWidth + (rect().width() - (2 * frameWidth)) / mTotalTimeInMs * mCurrentTimeInMs;
painter->setPen(QPen(Qt::NoPen)); }
QRectF balloon(rect().x() + position - frameWidth, rect().y() - (frameWidth * 1.2), 2 * frameWidth, frameWidth);
painter->drawRoundedRect(balloon, frameWidth/2, frameWidth/2); int radius = rect().height() / 6;
QRectF r(rect().x() + position - radius, rect().y() + (rect().height() / 4) - radius, radius * 2, radius * 2);
QTime t;
t = t.addMSecs(mCurrentTimeInMs < 0 ? 0 : mCurrentTimeInMs); painter->setBrush(UBSettings::documentViewLightColor);
QFont f = painter->font(); painter->drawEllipse(r);
f.setPointSizeF(f.pointSizeF() * mAntiScale);
painter->setFont(f); if(mDisplayCurrentTime)
painter->setPen(Qt::white); {
painter->drawText(balloon, Qt::AlignCenter, t.toString("m:ss")); painter->setBrush(UBSettings::paletteColor);
} painter->setPen(QPen(Qt::NoPen));
} mBalloon.setRect(rect().x() + position - frameWidth, rect().y() - (frameWidth * 1.2), 2 * frameWidth, frameWidth);
painter->drawRoundedRect(mBalloon, frameWidth/2, frameWidth/2);
QPainterPath DelegateVideoControl::shape() const QTime t;
{ t = t.addMSecs(mCurrentTimeInMs < 0 ? 0 : mCurrentTimeInMs);
QPainterPath path; QFont f = painter->font();
QRectF r = rect().adjusted(0,0,0,- rect().height() / 2); f.setPointSizeF(f.pointSizeF() * mAntiScale);
path.addRoundedRect(r, rect().height() / 4, rect().height() / 4); painter->setFont(f);
return path; painter->setPen(Qt::white);
} painter->drawText(mBalloon, Qt::AlignCenter, t.toString("m:ss"));
}
}
void DelegateVideoControl::updateTicker(qint64 time )
{
mCurrentTimeInMs = time; QPainterPath DelegateVideoControl::shape() const
update(); {
} QPainterPath path;
QRectF r = rect().adjusted(0,0,0,- rect().height() / 2);
path.addRoundedRect(r, rect().height() / 4, rect().height() / 4);
void DelegateVideoControl::totalTimeChanged(qint64 newTotalTime) return path;
{ }
mTotalTimeInMs = newTotalTime;
update();
} void DelegateVideoControl::updateTicker(qint64 time )
{
mCurrentTimeInMs = time;
void DelegateVideoControl::mousePressEvent(QGraphicsSceneMouseEvent *event) update();
{ }
mDisplayCurrentTime = true;
seekToMousePos(event->pos());
update(); void DelegateVideoControl::totalTimeChanged(qint64 newTotalTime)
event->accept(); {
} mTotalTimeInMs = newTotalTime;
update();
}
void DelegateVideoControl::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
seekToMousePos(event->pos()); void DelegateVideoControl::mousePressEvent(QGraphicsSceneMouseEvent *event)
update(); {
event->accept(); mDisplayCurrentTime = true;
} seekToMousePos(event->pos());
update();
event->accept();
void DelegateVideoControl::seekToMousePos(QPointF mousePos) }
{
qreal minX, length;
qreal frameWidth = rect().height() / 2; void DelegateVideoControl::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
minX = rect().x() + frameWidth; if (shape().contains(event->pos() - QPointF(mBalloon.width()/2,0))
length = rect().width() - (2 * frameWidth); && shape().contains(event->pos() + QPointF(mBalloon.width()/2,0)))
{
qreal mouseX = mousePos.x(); seekToMousePos(event->pos());
update();
if (mTotalTimeInMs > 0 && length > 0 && mDelegate event->accept();
&& mDelegate->mediaObject() && mDelegate->mediaObject()->isSeekable()) }
{ }
qint64 tickPos = mTotalTimeInMs / length * (mouseX - minX);
mDelegate->mediaObject()->seek(tickPos);
void DelegateVideoControl::seekToMousePos(QPointF mousePos)
//OSX is a bit lazy {
updateTicker(tickPos); qreal minX, length;
} qreal frameWidth = rect().height() / 2;
}
minX = rect().x() + frameWidth;
void DelegateVideoControl::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) length = rect().width() - (2 * frameWidth);
{
mDisplayCurrentTime = false; qreal mouseX = mousePos.x();
update();
event->accept(); if (mTotalTimeInMs > 0 && length > 0 && mDelegate
} && mDelegate->mediaObject() && mDelegate->mediaObject()->isSeekable())
{
qint64 tickPos = mTotalTimeInMs / length * (mouseX - minX);
mDelegate->mediaObject()->seek(tickPos);
//OSX is a bit lazy
updateTicker(tickPos);
}
}
void DelegateVideoControl::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
mDisplayCurrentTime = false;
update();
event->accept();
}

@ -1,114 +1,116 @@
/* /*
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef UBGRAPHICSVIDEOITEMDELEGATE_H_ #ifndef UBGRAPHICSVIDEOITEMDELEGATE_H_
#define UBGRAPHICSVIDEOITEMDELEGATE_H_ #define UBGRAPHICSVIDEOITEMDELEGATE_H_
#include <QtGui> #include <QtGui>
#include <phonon/MediaObject> #include <phonon/MediaObject>
#include "core/UB.h" #include "core/UB.h"
#include "UBGraphicsItemDelegate.h" #include "UBGraphicsItemDelegate.h"
class QGraphicsSceneMouseEvent; class QGraphicsSceneMouseEvent;
class QGraphicsItem; class QGraphicsItem;
class UBGraphicsVideoItem; class UBGraphicsVideoItem;
class DelegateVideoControl: public QGraphicsRectItem class DelegateVideoControl: public QGraphicsRectItem
{ {
public: public:
DelegateVideoControl(UBGraphicsVideoItem* pDelegated, QGraphicsItem * parent = 0); DelegateVideoControl(UBGraphicsVideoItem* pDelegated, QGraphicsItem * parent = 0);
virtual ~DelegateVideoControl() virtual ~DelegateVideoControl()
{ {
// NOOP // NOOP
} }
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget); QWidget *widget);
QPainterPath shape() const; QPainterPath shape() const;
void setAntiScale(qreal antiScale){ mAntiScale = antiScale; } void setAntiScale(qreal antiScale){ mAntiScale = antiScale; }
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void updateTicker(qint64 time); void updateTicker(qint64 time);
void totalTimeChanged( qint64 newTotalTime); void totalTimeChanged( qint64 newTotalTime);
protected: protected:
void seekToMousePos(QPointF mousePos); void seekToMousePos(QPointF mousePos);
UBGraphicsVideoItem* mDelegate; UBGraphicsVideoItem* mDelegate;
bool mDisplayCurrentTime; bool mDisplayCurrentTime;
qreal mAntiScale; qreal mAntiScale;
qint64 mCurrentTimeInMs; qint64 mCurrentTimeInMs;
qint64 mTotalTimeInMs; qint64 mTotalTimeInMs;
}; private:
int mStartWidth;
QRectF mBalloon;
class UBGraphicsVideoItemDelegate : public UBGraphicsItemDelegate };
{
Q_OBJECT
class UBGraphicsVideoItemDelegate : public UBGraphicsItemDelegate
public: {
UBGraphicsVideoItemDelegate(UBGraphicsVideoItem* pDelegated, Phonon::MediaObject* pMedia, QObject * parent = 0); Q_OBJECT
virtual ~UBGraphicsVideoItemDelegate();
public:
virtual void positionHandles(); UBGraphicsVideoItemDelegate(UBGraphicsVideoItem* pDelegated, Phonon::MediaObject* pMedia, QObject * parent = 0);
virtual ~UBGraphicsVideoItemDelegate();
public slots:
virtual void positionHandles();
void toggleMute();
void updateTicker(qint64 time); public slots:
protected slots: void toggleMute();
void updateTicker(qint64 time);
virtual void remove(bool canUndo = true);
protected slots:
void togglePlayPause();
virtual void remove(bool canUndo = true);
void mediaStateChanged ( Phonon::State newstate, Phonon::State oldstate );
void togglePlayPause();
void updatePlayPauseState();
void mediaStateChanged ( Phonon::State newstate, Phonon::State oldstate );
void totalTimeChanged( qint64 newTotalTime);
void updatePlayPauseState();
protected:
void totalTimeChanged( qint64 newTotalTime);
virtual void buildButtons();
protected:
private:
virtual void buildButtons();
UBGraphicsVideoItem* delegated();
private:
DelegateButton* mPlayPauseButton;
DelegateButton* mStopButton; UBGraphicsVideoItem* delegated();
DelegateButton* mMuteButton;
DelegateVideoControl *mVideoControl; DelegateButton* mPlayPauseButton;
DelegateButton* mStopButton;
Phonon::MediaObject* mMedia; DelegateButton* mMuteButton;
DelegateVideoControl *mVideoControl;
};
Phonon::MediaObject* mMedia;
};
#endif /* UBGRAPHICSVIDEOITEMDELEGATE_H_ */
#endif /* UBGRAPHICSVIDEOITEMDELEGATE_H_ */

@ -6,6 +6,8 @@
#include "domain/ubgraphicsgroupcontaineritemdelegate.h" #include "domain/ubgraphicsgroupcontaineritemdelegate.h"
#include "domain/UBGraphicsScene.h" #include "domain/UBGraphicsScene.h"
#include "core/memcheck.h"
UBGraphicsGroupContainerItem::UBGraphicsGroupContainerItem(QGraphicsItem *parent) UBGraphicsGroupContainerItem::UBGraphicsGroupContainerItem(QGraphicsItem *parent)
: QGraphicsItemGroup(parent) : QGraphicsItemGroup(parent)
{ {

@ -8,9 +8,10 @@
#include "domain/UBGraphicsDelegateFrame.h" #include "domain/UBGraphicsDelegateFrame.h"
#include "domain/ubgraphicsgroupcontaineritem.h" #include "domain/ubgraphicsgroupcontaineritem.h"
#include "core/memcheck.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "core/memcheck.h"
UBGraphicsGroupContainerItemDelegate::UBGraphicsGroupContainerItemDelegate(QGraphicsItem *pDelegated, QObject *parent) : UBGraphicsGroupContainerItemDelegate::UBGraphicsGroupContainerItemDelegate(QGraphicsItem *pDelegated, QObject *parent) :
UBGraphicsItemDelegate(pDelegated, parent), mDestroyGroupButton(0) UBGraphicsItemDelegate(pDelegated, parent), mDestroyGroupButton(0)

@ -15,12 +15,13 @@
#include "UBCoreGraphicsScene.h" #include "UBCoreGraphicsScene.h"
#include "core/memcheck.h"
#include "domain/UBGraphicsAudioItem.h" #include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsVideoItem.h" #include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsMediaItem.h" #include "domain/UBGraphicsMediaItem.h"
#include "domain/UBGraphicsWidgetItem.h" #include "domain/UBGraphicsWidgetItem.h"
#include "core/memcheck.h"
UBCoreGraphicsScene::UBCoreGraphicsScene(QObject * parent) UBCoreGraphicsScene::UBCoreGraphicsScene(QObject * parent)
: QGraphicsScene ( parent ) : QGraphicsScene ( parent )
{ {

@ -17,6 +17,8 @@
#include "globals/UBGlobals.h" #include "globals/UBGlobals.h"
#include "core/memcheck.h"
UBDockDownloadWidget::UBDockDownloadWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent, name) UBDockDownloadWidget::UBDockDownloadWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent, name)
, mpLayout(NULL) , mpLayout(NULL)
, mpDLWidget(NULL) , mpDLWidget(NULL)

@ -19,6 +19,8 @@
#include "UBDockTeacherGuideWidget.h" #include "UBDockTeacherGuideWidget.h"
#include "UBTeacherGuideWidget.h" #include "UBTeacherGuideWidget.h"
#include "core/memcheck.h"
UBDockTeacherGuideWidget::UBDockTeacherGuideWidget(QWidget* parent, const char* name): UBDockTeacherGuideWidget::UBDockTeacherGuideWidget(QWidget* parent, const char* name):
UBDockPaletteWidget(parent,name) UBDockPaletteWidget(parent,name)

@ -1,4 +1,5 @@
#include "UBFeaturesActionBar.h" #include "UBFeaturesActionBar.h"
#include "core/memcheck.h"
UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWidget* parent, const char* name ) : QWidget (parent) UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWidget* parent, const char* name ) : QWidget (parent)
, featuresController(controller) , featuresController(controller)
@ -143,6 +144,16 @@ void UBFeaturesActionBar::setButtons()
mpRemoveFavoriteBtn->show(); mpRemoveFavoriteBtn->show();
mpNewFolderBtn->hide(); mpNewFolderBtn->hide();
break; break;
case IN_TRASH:
mpFavoriteBtn->hide();
mpSocialBtn->hide();
mSearchBar->show();
//mpSearchBtn->show();
//mpDeleteBtn->hide();
mpCloseBtn->hide();
//mpRemoveFavoriteBtn->show();
mpNewFolderBtn->hide();
break;
default: default:
break; break;
} }
@ -169,7 +180,9 @@ void UBFeaturesActionBar::dragMoveEvent(QDragMoveEvent *event)
void UBFeaturesActionBar::dragEnterEvent( QDragEnterEvent *event ) void UBFeaturesActionBar::dragEnterEvent( QDragEnterEvent *event )
{ {
if (event->mimeData()->hasFormat("text/uri-list")) if (event->mimeData()->hasFormat("text/uri-list"))
{
event->acceptProposedAction(); event->acceptProposedAction();
}
} }
void UBFeaturesActionBar::dropEvent( QDropEvent *event ) void UBFeaturesActionBar::dropEvent( QDropEvent *event )
@ -177,6 +190,12 @@ void UBFeaturesActionBar::dropEvent( QDropEvent *event )
QWidget *dest = childAt( event->pos() ); QWidget *dest = childAt( event->pos() );
if ( dest == mpDeleteBtn ) if ( dest == mpDeleteBtn )
{ {
QList <QUrl> urls = event->mimeData()->urls();
foreach ( QUrl url, urls )
{
if ( !UBFeaturesController::isDeletable( url ) )
return;
}
event->setDropAction( Qt::MoveAction ); event->setDropAction( Qt::MoveAction );
event->accept(); event->accept();
emit deleteElements( *event->mimeData() ); emit deleteElements( *event->mimeData() );

@ -12,7 +12,8 @@ enum UBFeaturesActionBarState
IN_ROOT, IN_ROOT,
IN_FOLDER, IN_FOLDER,
IN_PROPERTIES, IN_PROPERTIES,
IN_FAVORITE IN_FAVORITE,
IN_TRASH
}; };
class UBFeaturesActionBar : public QWidget class UBFeaturesActionBar : public QWidget

@ -1,3 +1,5 @@
#include <QDomDocument>
#include "UBFeaturesWidget.h" #include "UBFeaturesWidget.h"
#include "domain/UBAbstractWidget.h" #include "domain/UBAbstractWidget.h"
#include "gui/UBThumbnailWidget.h" #include "gui/UBThumbnailWidget.h"
@ -6,6 +8,7 @@
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "core/UBDownloadManager.h" #include "core/UBDownloadManager.h"
#include "globals/UBGlobals.h" #include "globals/UBGlobals.h"
#include "board/UBBoardController.h"
UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent) UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent)
{ {
@ -56,6 +59,7 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
featuresListView->setViewMode( QListView::IconMode ); featuresListView->setViewMode( QListView::IconMode );
itemDelegate = new UBFeaturesItemDelegate( this, featuresListView ); itemDelegate = new UBFeaturesItemDelegate( this, featuresListView );
featuresListView->setItemDelegate( itemDelegate ); featuresListView->setItemDelegate( itemDelegate );
//featuresListView->setSelectionRectVisible(false);
featuresListView->setIconSize( QSize(defaultThumbnailSize, defaultThumbnailSize) ); featuresListView->setIconSize( QSize(defaultThumbnailSize, defaultThumbnailSize) );
featuresListView->setGridSize( QSize(defaultThumbnailSize * 1.75, defaultThumbnailSize * 1.75) ); featuresListView->setGridSize( QSize(defaultThumbnailSize * 1.75, defaultThumbnailSize * 1.75) );
@ -71,6 +75,9 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
pathListView->setSelectionMode( QAbstractItemView::NoSelection ); pathListView->setSelectionMode( QAbstractItemView::NoSelection );
pathListView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); pathListView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
pathListView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOn ); pathListView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
pathListView->setFlow( QListView::LeftToRight );
pathListView->setWrapping(false);
//pathListView->setResizeMode( QListView::Adjust ); //pathListView->setResizeMode( QListView::Adjust );
//pathListView->setMovement( QListView::Static ); //pathListView->setMovement( QListView::Static );
pathListView->setDragDropMode( QAbstractItemView::DropOnly ); pathListView->setDragDropMode( QAbstractItemView::DropOnly );
@ -78,6 +85,7 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
pathScene = new QGraphicsScene(this); pathScene = new QGraphicsScene(this);
//pathViewer = new UBFeaturesPathViewer( QPixmap(":images/libpalette/home.png"), controller->getRootPath(), pathScene, this ); //pathViewer = new UBFeaturesPathViewer( QPixmap(":images/libpalette/home.png"), controller->getRootPath(), pathScene, this );
featureProperties = new UBFeatureProperties(this); featureProperties = new UBFeatureProperties(this);
webView = new UBFeaturesWebView(this);
//layout->addWidget( pathViewer ); //layout->addWidget( pathViewer );
//pathViewer->show(); //pathViewer->show();
@ -87,6 +95,7 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
stackedWidget->addWidget( featuresListView ); stackedWidget->addWidget( featuresListView );
stackedWidget->addWidget( featureProperties ); stackedWidget->addWidget( featureProperties );
stackedWidget->addWidget( webView );
stackedWidget->setCurrentIndex(ID_LISTVIEW); stackedWidget->setCurrentIndex(ID_LISTVIEW);
currentStackedWidget = ID_LISTVIEW; currentStackedWidget = ID_LISTVIEW;
@ -107,7 +116,7 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
this, SLOT(currentSelected(const QModelIndex &)));*/ this, SLOT(currentSelected(const QModelIndex &)));*/
connect( featuresListView, SIGNAL(clicked ( const QModelIndex & ) ), connect( featuresListView, SIGNAL(clicked ( const QModelIndex & ) ),
this, SLOT( currentSelected(const QModelIndex &) ) ); this, SLOT( currentSelected(const QModelIndex &) ) );
connect( mActionBar, SIGNAL( searchElement(const QString &) ), this, SLOT( const searchStarted(QString &) ) ); connect( mActionBar, SIGNAL( searchElement(const QString &) ), this, SLOT( searchStarted(const QString &) ) );
connect( mActionBar, SIGNAL( newFolderToCreate() ), this, SLOT( createNewFolder() ) ); connect( mActionBar, SIGNAL( newFolderToCreate() ), this, SLOT( createNewFolder() ) );
connect( mActionBar, SIGNAL( deleteElements(const QMimeData &) ), this, SLOT( deleteElements(const QMimeData &) ) ); connect( mActionBar, SIGNAL( deleteElements(const QMimeData &) ), this, SLOT( deleteElements(const QMimeData &) ) );
connect( mActionBar, SIGNAL( addToFavorite(const QMimeData &) ), this, SLOT( addToFavorite(const QMimeData &) ) ); connect( mActionBar, SIGNAL( addToFavorite(const QMimeData &) ), this, SLOT( addToFavorite(const QMimeData &) ) );
@ -115,6 +124,10 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
connect( pathListView, SIGNAL(clicked( const QModelIndex & ) ), connect( pathListView, SIGNAL(clicked( const QModelIndex & ) ),
this, SLOT( currentPathChanged( const QModelIndex & ) ) ); this, SLOT( currentPathChanged( const QModelIndex & ) ) );
connect( thumbSlider, SIGNAL( sliderMoved(int) ), this, SLOT(thumbnailSizeChanged( int ) ) ); connect( thumbSlider, SIGNAL( sliderMoved(int) ), this, SLOT(thumbnailSizeChanged( int ) ) );
connect( UBApplication::boardController, SIGNAL( displayMetadata( QMap<QString,QString> ) ),
this, SLOT( onDisplayMetadata( QMap<QString,QString> ) ) );
connect( UBDownloadManager::downloadManager(), SIGNAL( addDownloadedFileToLibrary( bool, QUrl, QString, QByteArray ) ),
this, SLOT( onAddDownloadedFileToLibrary( bool, QUrl, QString,QByteArray ) ) );
} }
bool UBFeaturesWidget::eventFilter( QObject *target, QEvent *event ) bool UBFeaturesWidget::eventFilter( QObject *target, QEvent *event )
@ -156,7 +169,7 @@ void UBFeaturesWidget::currentSelected(const QModelIndex &current)
if ( feature.isFolder() ) if ( feature.isFolder() )
{ {
QString newPath = feature.getUrl() + "/" + feature.getName(); QString newPath = feature.getFullVirtualPath();
//pathViewer->addPathElement( feature.getThumbnail(), newPath ); //pathViewer->addPathElement( feature.getThumbnail(), newPath );
controller->setCurrentElement( feature ); controller->setCurrentElement( feature );
@ -170,11 +183,20 @@ void UBFeaturesWidget::currentSelected(const QModelIndex &current)
{ {
mActionBar->setCurrentState( IN_FAVORITE ); mActionBar->setCurrentState( IN_FAVORITE );
} }
else if (feature.getType() == FEATURE_TRASH)
{
mActionBar->setCurrentState( IN_TRASH );
}
else else
{ {
mActionBar->setCurrentState( IN_FOLDER ); mActionBar->setCurrentState( IN_FOLDER );
} }
} }
else if ( feature.getType() == FEATURE_SEARCH )
{
webView->showElement( feature );
switchToWebView();
}
else else
{ {
featureProperties->showElement( feature ); featureProperties->showElement( feature );
@ -190,7 +212,7 @@ void UBFeaturesWidget::currentPathChanged(const QModelIndex &index)
if ( index.isValid() ) if ( index.isValid() )
{ {
UBFeature feature = featuresPathModel->data(index, Qt::UserRole + 1).value<UBFeature>(); UBFeature feature = featuresPathModel->data(index, Qt::UserRole + 1).value<UBFeature>();
QString newPath = feature.getUrl() + "/" + feature.getName(); QString newPath = feature.getFullVirtualPath();
featuresPathModel->setPath( newPath ); featuresPathModel->setPath( newPath );
featuresPathModel->invalidate(); featuresPathModel->invalidate();
@ -208,6 +230,10 @@ void UBFeaturesWidget::currentPathChanged(const QModelIndex &index)
{ {
mActionBar->setCurrentState( IN_FAVORITE ); mActionBar->setCurrentState( IN_FAVORITE );
} }
else if (feature.getType() == FEATURE_TRASH)
{
mActionBar->setCurrentState( IN_TRASH );
}
else else
{ {
mActionBar->setCurrentState( IN_FOLDER ); mActionBar->setCurrentState( IN_FOLDER );
@ -224,7 +250,6 @@ void UBFeaturesWidget::createNewFolder()
featuresModel->addItem( newFolder ); featuresModel->addItem( newFolder );
featuresProxyModel->invalidate(); featuresProxyModel->invalidate();
} }
} }
void UBFeaturesWidget::deleteElements( const QMimeData & mimeData ) void UBFeaturesWidget::deleteElements( const QMimeData & mimeData )
@ -260,7 +285,7 @@ void UBFeaturesWidget::addToFavorite( const QMimeData & mimeData )
foreach ( QUrl url, urls ) foreach ( QUrl url, urls )
{ {
UBFeature elem = controller->addToFavorite( url ); UBFeature elem = controller->addToFavorite( url );
if ( !elem.getUrl().isEmpty() && !elem.getUrl().isNull() ) if ( !elem.getVirtualPath().isEmpty() && !elem.getVirtualPath().isNull() )
featuresModel->addItem( elem ); featuresModel->addItem( elem );
} }
QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( featuresListView->model() ); QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( featuresListView->model() );
@ -284,6 +309,30 @@ void UBFeaturesWidget::thumbnailSizeChanged( int value )
featuresListView->setGridSize( QSize( value * 1.75, value * 1.75 ) ); featuresListView->setGridSize( QSize( value * 1.75, value * 1.75 ) );
} }
void UBFeaturesWidget::onDisplayMetadata( QMap<QString,QString> 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::onAddDownloadedFileToLibrary(bool pSuccess, QUrl sourceUrl, QString pContentHeader, QByteArray pData)
{
if ( pSuccess )
{
UBFeature newFeature = controller->addDownloadedFile( sourceUrl, pData );
if ( newFeature != UBFeature() )
{
featuresModel->addItem( newFeature );
QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( featuresListView->model() );
model->invalidate();
}
}
}
void UBFeaturesWidget::switchToListView() void UBFeaturesWidget::switchToListView()
{ {
stackedWidget->setCurrentIndex(ID_LISTVIEW); stackedWidget->setCurrentIndex(ID_LISTVIEW);
@ -296,6 +345,11 @@ void UBFeaturesWidget::switchToProperties()
currentStackedWidget = ID_PROPERTIES; currentStackedWidget = ID_PROPERTIES;
} }
void UBFeaturesWidget::switchToWebView()
{
stackedWidget->setCurrentIndex(ID_WEBVIEW);
currentStackedWidget = ID_WEBVIEW;
}
/* /*
@ -315,11 +369,39 @@ UBFeaturesWidget::~UBFeaturesWidget()
{ {
} }
UBFeaturesListView::UBFeaturesListView( QWidget* parent, const char* name ) : QListView(parent) UBFeaturesListView::UBFeaturesListView( QWidget* parent, const char* name )
: QListView(parent)
{ {
setObjectName(name); setObjectName(name);
//rubberBand = new UBRubberBand( QRubberBand::Rectangle, this );
}
/*
void UBFeaturesListView::mousePressEvent( QMouseEvent *event )
{
rubberOrigin = event->pos();
rubberBand->setGeometry( QRect( rubberOrigin, QSize() ) );
//qDebug() << rubberOrigin.x() << rubberOrigin.y();
rubberBand->show();
QListView::mousePressEvent(event);
}
void UBFeaturesListView::mouseMoveEvent( QMouseEvent *event )
{
QPoint current = event->pos();
rubberBand->setGeometry( QRect( rubberOrigin, current ).normalized() );
//setSelection( rubberBand->rect(), QItemSelectionModel::Select );
QListView::mouseMoveEvent(event);
}
void UBFeaturesListView::mouseReleaseEvent( QMouseEvent *event )
{
rubberBand->hide();
QListView::mouseReleaseEvent(event);
} }
*/
void UBFeaturesListView::dragEnterEvent( QDragEnterEvent *event ) void UBFeaturesListView::dragEnterEvent( QDragEnterEvent *event )
{ {
if ( event->mimeData()->hasUrls() ) if ( event->mimeData()->hasUrls() )
@ -336,6 +418,96 @@ void UBFeaturesListView::dropEvent( QDropEvent *event )
} }
UBFeaturesWebView::UBFeaturesWebView(QWidget* parent, const char* name):QWidget(parent)
, mpView(NULL)
, mpWebSettings(NULL)
, mpLayout(NULL)
, mpSankoreAPI(NULL)
{
setObjectName(name);
SET_STYLE_SHEET();
mpLayout = new QVBoxLayout();
setLayout(mpLayout);
mpView = new QWebView(this);
mpView->setObjectName("SearchEngineView");
mpSankoreAPI = new UBWidgetUniboardAPI(UBApplication::boardController->activeScene());
mpView->page()->mainFrame()->addToJavaScriptWindowObject("sankore", mpSankoreAPI);
mpWebSettings = QWebSettings::globalSettings();
mpWebSettings->setAttribute(QWebSettings::JavaEnabled, true);
mpWebSettings->setAttribute(QWebSettings::PluginsEnabled, true);
mpWebSettings->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, true);
mpWebSettings->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true);
mpWebSettings->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true);
mpWebSettings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true);
mpWebSettings->setAttribute(QWebSettings::DnsPrefetchEnabled, true);
mpLayout->addWidget(mpView);
connect(mpView, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool)));
}
UBFeaturesWebView::~UBFeaturesWebView()
{
if(NULL != mpSankoreAPI){
delete mpSankoreAPI;
mpSankoreAPI = NULL;
}
if(NULL != mpView){
delete mpView;
mpView = NULL;
}
if(NULL != mpLayout){
delete mpLayout;
mpLayout = NULL;
}
}
void UBFeaturesWebView::showElement(const UBFeature &elem)
{
QString qsWidgetName;
QString path = elem.getFullPath().toLocalFile();
QString qsConfigPath = QString("%0/config.xml").arg(path);
if(QFile::exists(qsConfigPath))
{
QFile f(qsConfigPath);
if(f.open(QIODevice::ReadOnly))
{
QDomDocument domDoc;
domDoc.setContent(QString(f.readAll()));
QDomElement root = domDoc.documentElement();
QDomNode node = root.firstChild();
while(!node.isNull())
{
if(node.toElement().tagName() == "content")
{
QDomAttr srcAttr = node.toElement().attributeNode("src");
qsWidgetName = srcAttr.value();
break;
}
node = node.nextSibling();
}
f.close();
}
}
mpView->load(QUrl::fromLocalFile(QString("%0/%1").arg(path).arg(qsWidgetName)));
}
void UBFeaturesWebView::onLoadFinished(bool ok)
{
if(ok && NULL != mpSankoreAPI){
mpView->page()->mainFrame()->addToJavaScriptWindowObject("sankore", mpSankoreAPI);
}
}
UBFeatureProperties::UBFeatureProperties( QWidget *parent, const char *name ) : QWidget(parent) UBFeatureProperties::UBFeatureProperties( QWidget *parent, const char *name ) : QWidget(parent)
, mpLayout(NULL) , mpLayout(NULL)
, mpButtonLayout(NULL) , mpButtonLayout(NULL)
@ -346,6 +518,7 @@ UBFeatureProperties::UBFeatureProperties( QWidget *parent, const char *name ) :
, mpThumbnail(NULL) , mpThumbnail(NULL)
, mpOrigPixmap(NULL) , mpOrigPixmap(NULL)
, mpElement(NULL) , mpElement(NULL)
, mpObjInfos(NULL)
{ {
setObjectName(name); setObjectName(name);
@ -385,12 +558,49 @@ UBFeatureProperties::UBFeatureProperties( QWidget *parent, const char *name ) :
mpButtonLayout->addStretch(1); 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;")); mpObjInfoLabel->setStyleSheet(QString("color: #888888; font-size : 18px; font-weight:bold;"));
mpLayout->addWidget(mpObjInfoLabel, 0); mpLayout->addWidget(mpObjInfoLabel, 0);
connect(mpAddPageButton, SIGNAL(clicked()), this, SLOT(onAddToPage())); 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()) );
connect( mpSetAsBackgroundButton, SIGNAL( clicked() ), this, SLOT( onSetAsBackground() ) );
connect( mpAddToLibButton, SIGNAL( clicked() ), this, SLOT(onAddToLib() ) );
}
void UBFeatureProperties::resizeEvent( QResizeEvent *event )
{
Q_UNUSED(event);
adaptSize();
}
void UBFeatureProperties::showEvent (QShowEvent *event )
{
Q_UNUSED(event);
adaptSize();
}
void UBFeatureProperties::adaptSize()
{
if( NULL != mpOrigPixmap )
{
if( width() < THUMBNAIL_WIDTH + 40 )
{
mpThumbnail->setPixmap( mpOrigPixmap->scaledToWidth( width() - 40 ) );
}
else
{
mpThumbnail->setPixmap( mpOrigPixmap->scaledToWidth( THUMBNAIL_WIDTH ) );
}
}
} }
void UBFeatureProperties::showElement( const UBFeature &elem ) void UBFeatureProperties::showElement( const UBFeature &elem )
@ -408,59 +618,95 @@ void UBFeatureProperties::showElement( const UBFeature &elem )
mpElement = new UBFeature( elem ); mpElement = new UBFeature( elem );
mpOrigPixmap = new QPixmap( elem.getThumbnail() ); mpOrigPixmap = new QPixmap( elem.getThumbnail() );
mpThumbnail->setPixmap(elem.getThumbnail().scaledToWidth(THUMBNAIL_WIDTH)); mpThumbnail->setPixmap(elem.getThumbnail().scaledToWidth(THUMBNAIL_WIDTH));
//populateMetadata(); populateMetadata();
if ( UBApplication::isFromWeb( elem.getUrl() ) ) if ( UBApplication::isFromWeb( elem.getFullPath().toString() ) )
{ {
mpAddToLibButton->show(); mpAddToLibButton->show();
/*if(elem->metadatas()["Type"].toLower().contains("image")) if( elem.getMetadata()["Type"].toLower().contains("image") )
{ {
mpSetAsBackgroundButton->show(); mpSetAsBackgroundButton->show();
} }
else else
{ {
mpSetAsBackgroundButton->hide(); mpSetAsBackgroundButton->hide();
}*/ }
} }
else else
{ {
mpAddToLibButton->hide(); mpAddToLibButton->hide();
if (UBFileSystemUtils::mimeTypeFromFileName( elem.getUrl() ).contains("image")) if (UBFileSystemUtils::mimeTypeFromFileName( elem.getFullPath().toLocalFile() ).contains("image"))
{ {
mpSetAsBackgroundButton->show(); mpSetAsBackgroundButton->show();
} }
else else
{ {
mpSetAsBackgroundButton->hide(); mpSetAsBackgroundButton->hide();
} }
} }
} }
void UBFeatureProperties::populateMetadata()
{
if(NULL != mpObjInfos){
mpObjInfos->clear();
QMap<QString, QString> metas = mpElement->getMetadata();
QList<QString> lKeys = metas.keys();
QList<QString> 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() void UBFeatureProperties::onAddToPage()
{ {
QWidget *w = parentWidget()->parentWidget(); QWidget *w = parentWidget()->parentWidget();
UBFeaturesWidget* featuresWidget = dynamic_cast<UBFeaturesWidget*>( w ); UBFeaturesWidget* featuresWidget = dynamic_cast<UBFeaturesWidget*>( w );
featuresWidget->getFeaturesController()->addItemToPage( *mpElement ); featuresWidget->getFeaturesController()->addItemToPage( *mpElement );
/*if ( UBApplication::isFromWeb( mpElement->getUrl() ) ) }
{
void UBFeatureProperties::onAddToLib()
{
if ( UBApplication::isFromWeb( mpElement->getFullPath().toString() ) )
{
sDownloadFileDesc desc; sDownloadFileDesc desc;
desc.isBackground = false; desc.isBackground = false;
desc.modal = true; desc.modal = false;
desc.name = QFileInfo( mpElement->getName() ).fileName(); desc.name = QFileInfo( mpElement->getFullPath().toString()).fileName();
desc.url = mpElement->getUrl(); qDebug() << desc.name;
desc.url = mpElement->getFullPath().toString();
qDebug() << desc.url;
UBDownloadManager::downloadManager()->addFileToDownload(desc); UBDownloadManager::downloadManager()->addFileToDownload(desc);
} }
else }
{
QWidget *w = parentWidget()->parentWidget();
UBFeaturesWidget* featuresWidget = dynamic_cast<UBFeaturesWidget*>( w ); void UBFeatureProperties::onSetAsBackground()
featuresWidget->getFeaturesController()->addItemToPage( *mpElement ); {
}*/ QWidget *w = parentWidget()->parentWidget();
UBFeaturesWidget* featuresWidget = dynamic_cast<UBFeaturesWidget*>( w );
featuresWidget->getFeaturesController()->addItemAsBackground( *mpElement );
} }
UBFeatureProperties::~UBFeatureProperties() UBFeatureProperties::~UBFeatureProperties()
{ {
if ( mpOrigPixmap )
{
delete mpOrigPixmap;
mpOrigPixmap = NULL;
}
if ( mpElement )
{
delete mpElement;
mpElement = NULL;
}
} }
UBFeatureItemButton::UBFeatureItemButton(QWidget *parent, const char *name):QPushButton(parent) UBFeatureItemButton::UBFeatureItemButton(QWidget *parent, const char *name):QPushButton(parent)
@ -487,7 +733,7 @@ QVariant UBFeaturesModel::data(const QModelIndex &index, int role) const
} }
else if (role == Qt::UserRole) else if (role == Qt::UserRole)
{ {
return featuresList->at(index.row()).getUrl(); return featuresList->at(index.row()).getVirtualPath();
} }
else if (role == Qt::UserRole + 1) else if (role == Qt::UserRole + 1)
{ {
@ -509,14 +755,15 @@ QMimeData* UBFeaturesModel::mimeData(const QModelIndexList &indexes) const
if ( index.isValid() ) if ( index.isValid() )
{ {
UBFeature element = data( index, Qt::UserRole + 1 ).value<UBFeature>(); UBFeature element = data( index, Qt::UserRole + 1 ).value<UBFeature>();
if ( element.getType() == FEATURE_INTERNAL ) urlList.push_back( element.getFullPath() );
/*if ( element.getType() == FEATURE_INTERNAL )
{ {
urlList.push_back( QUrl( element.getFullPath() ) ); urlList.push_back( QUrl( element.getFullPath() ) );
} }
else if ( element.getType() == FEATURE_INTERACTIVE || element.getType() == FEATURE_ITEM ) else if ( element.getType() == FEATURE_INTERACTIVE || element.getType() == FEATURE_ITEM )
{ {
urlList.push_back( QUrl::fromLocalFile(element.getFullPath()) ); urlList.push_back( element.getFullPath() );
} }*/
} }
} }
mimeData->setUrls( urlList ); mimeData->setUrls( urlList );
@ -537,19 +784,15 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act
int endRow = 0; int endRow = 0;
UBFeature parentFeature;
if ( !parent.isValid() ) if ( !parent.isValid() )
{ {
return false; parentFeature = dynamic_cast<UBFeaturesWidget *>(QObject::parent())->getFeaturesController()->getCurrentElement();
/*if (row < 0)
endRow = featuresList->size();
else
endRow = qMin( row, featuresList->size() );*/
} }
else else
endRow = parent.row(); {
Q_UNUSED(endRow) //why do we need this variable? parentFeature = parent.data( Qt::UserRole + 1).value<UBFeature>();
}
UBFeature parentFeature = parent.data( Qt::UserRole + 1).value<UBFeature>();
QList<QUrl> urls = mimeData->urls(); QList<QUrl> urls = mimeData->urls();
@ -581,8 +824,8 @@ void UBFeaturesModel::deleteFavoriteItem( const QString &path )
{ {
for ( int i = 0; i < featuresList->size(); ++i ) for ( int i = 0; i < featuresList->size(); ++i )
{ {
if ( !QString::compare( featuresList->at(i).getFullPath(), path, Qt::CaseInsensitive ) && if ( !QString::compare( featuresList->at(i).getUrl(), path, Qt::CaseInsensitive ) &&
!QString::compare( featuresList->at(i).getUrl(), "/root/favorites", Qt::CaseInsensitive ) ) !QString::compare( featuresList->at(i).getVirtualPath(), "/root/favorites", Qt::CaseInsensitive ) )
{ {
removeRow( i, QModelIndex() ); removeRow( i, QModelIndex() );
return; return;
@ -626,9 +869,9 @@ Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const
item.getType() == FEATURE_ITEM || item.getType() == FEATURE_ITEM ||
item.getType() == FEATURE_INTERNAL ) item.getType() == FEATURE_INTERNAL )
return Qt::ItemIsDragEnabled | defaultFlags; return Qt::ItemIsDragEnabled | defaultFlags;
if ( item.isFolder() && !item.getFullPath().isNull() ) if ( item.isFolder() && !item.getVirtualPath().isNull() )
return defaultFlags | Qt::ItemIsDropEnabled; return defaultFlags | Qt::ItemIsDropEnabled;
else return defaultFlags; else return defaultFlags | Qt::ItemIsDropEnabled;
} }
/*if ( index.isValid() ) /*if ( index.isValid() )
{ {
@ -647,7 +890,7 @@ Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const
default:; default:;
} }
}*/ }*/
return defaultFlags; return defaultFlags | Qt::ItemIsDropEnabled;
} }
@ -696,9 +939,8 @@ bool UBFeaturesPathProxyModel::filterAcceptsRow( int sourceRow, const QModelInde
eUBLibElementType type = (eUBLibElementType)sourceModel()->data(index, Qt::UserRole + 1).toInt();*/ eUBLibElementType type = (eUBLibElementType)sourceModel()->data(index, Qt::UserRole + 1).toInt();*/
UBFeature feature = sourceModel()->data(index, Qt::UserRole + 1).value<UBFeature>(); UBFeature feature = sourceModel()->data(index, Qt::UserRole + 1).value<UBFeature>();
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 QString UBFeaturesItemDelegate::displayText ( const QVariant & value, const QLocale & locale ) const
@ -710,13 +952,7 @@ QString UBFeaturesItemDelegate::displayText ( const QVariant & value, const QLoc
{ {
const QFontMetrics fm = listView->fontMetrics(); const QFontMetrics fm = listView->fontMetrics();
const QSize iSize = listView->iconSize(); const QSize iSize = listView->iconSize();
return elidedText( fm, iSize.width(), Qt::ElideRight, text );
if ( iSize.width() > 0 && fm.width(text) > iSize.width() )
{
while (fm.width(text) > iSize.width())
text.resize(text.size()-1);
text += "...";
}
} }
return text; return text;
} }

@ -18,12 +18,15 @@
#include "UBDockPaletteWidget.h" #include "UBDockPaletteWidget.h"
//#include "UBLibActionBar.h" //#include "UBLibActionBar.h"
#include "board/UBFeaturesController.h" #include "board/UBFeaturesController.h"
#include "api/UBWidgetUniboardAPI.h"
#include "UBFeaturesActionBar.h" #include "UBFeaturesActionBar.h"
#include "UBRubberBand.h"
#define THUMBNAIL_WIDTH 400 #define THUMBNAIL_WIDTH 400
#define ID_LISTVIEW 0 #define ID_LISTVIEW 0
#define ID_PROPERTIES 1 #define ID_PROPERTIES 1
#define ID_WEBVIEW 2
class UBListModel; class UBListModel;
@ -37,6 +40,7 @@ class UBFeaturesPathViewer;
class UBFeatureProperties; class UBFeatureProperties;
class UBFeatureItemButton; class UBFeatureItemButton;
class UBFeaturesListView; class UBFeaturesListView;
class UBFeaturesWebView;
class UBFeaturesWidget : public UBDockPaletteWidget class UBFeaturesWidget : public UBDockPaletteWidget
{ {
@ -58,6 +62,7 @@ public:
private: private:
void switchToListView(); void switchToListView();
void switchToProperties(); void switchToProperties();
void switchToWebView();
UBFeaturesController *controller; UBFeaturesController *controller;
@ -78,7 +83,9 @@ private:
QGraphicsScene *pathScene; QGraphicsScene *pathScene;
UBFeaturesActionBar *mActionBar; UBFeaturesActionBar *mActionBar;
UBFeatureProperties *featureProperties; UBFeatureProperties *featureProperties;
UBFeaturesWebView *webView;
QStackedWidget *stackedWidget; QStackedWidget *stackedWidget;
int currentStackedWidget; int currentStackedWidget;
QModelIndex trashIndex; QModelIndex trashIndex;
@ -92,6 +99,8 @@ private slots:
void addToFavorite( const QMimeData & ); void addToFavorite( const QMimeData & );
void removeFromFavorite( const QMimeData & ); void removeFromFavorite( const QMimeData & );
void thumbnailSizeChanged( int ); void thumbnailSizeChanged( int );
void onDisplayMetadata( QMap<QString,QString> );
void onAddDownloadedFileToLibrary(bool, QUrl, QString, QByteArray);
protected: protected:
bool eventFilter(QObject *target, QEvent *event); bool eventFilter(QObject *target, QEvent *event);
}; };
@ -105,8 +114,32 @@ public:
protected: protected:
virtual void dragEnterEvent( QDragEnterEvent *event ); virtual void dragEnterEvent( QDragEnterEvent *event );
virtual void dropEvent( QDropEvent *event ); virtual void dropEvent( QDropEvent *event );
/*virtual void mousePressEvent( QMouseEvent *event );
virtual void mouseMoveEvent( QMouseEvent *event );
virtual void mouseReleaseEvent( QMouseEvent *event );*/
private:
//UBRubberBand *rubberBand;
//QPoint rubberOrigin;
}; };
class UBFeaturesWebView : public QWidget
{
Q_OBJECT
public:
UBFeaturesWebView(QWidget* parent = 0, const char* name = "UBFeaturesWebView");
~UBFeaturesWebView();
void showElement(const UBFeature &elem);
private slots:
void onLoadFinished(bool ok);
private:
QWebView* mpView;
QWebSettings* mpWebSettings;
QVBoxLayout* mpLayout;
UBWidgetUniboardAPI* mpSankoreAPI;
};
class UBFeatureProperties : public QWidget class UBFeatureProperties : public QWidget
{ {
@ -119,28 +152,31 @@ public:
protected: protected:
//void resizeEvent(QResizeEvent *event); void resizeEvent(QResizeEvent *event);
//void showEvent(QShowEvent *event); void showEvent(QShowEvent *event);
private slots: private slots:
void onAddToPage(); void onAddToPage();
//void onAddToLib(); void onAddToLib();
//void onSetAsBackground(); void onSetAsBackground();
//void onBack(); //void onBack();
private: private:
void populateMetadata();
void adaptSize();
QVBoxLayout* mpLayout; QVBoxLayout* mpLayout;
QHBoxLayout* mpButtonLayout; QHBoxLayout* mpButtonLayout;
UBFeatureItemButton* mpAddPageButton; UBFeatureItemButton* mpAddPageButton;
UBFeatureItemButton* mpAddToLibButton; UBFeatureItemButton* mpAddToLibButton;
UBFeatureItemButton* mpSetAsBackgroundButton; UBFeatureItemButton* mpSetAsBackgroundButton;
QLabel* mpObjInfoLabel; QLabel* mpObjInfoLabel;
//QTreeWidget* mpObjInfos; QTreeWidget* mpObjInfos;
QLabel* mpThumbnail; QLabel* mpThumbnail;
QPixmap* mpOrigPixmap; QPixmap* mpOrigPixmap;
int maxThumbHeight; int maxThumbHeight;
UBFeature *mpElement; UBFeature *mpElement;
//QTreeWidgetItem* mpItem; QTreeWidgetItem* mpItem;
}; };
@ -174,7 +210,7 @@ public:
Qt::DropActions supportedDropActions() const { return Qt::MoveAction | Qt::CopyAction; } Qt::DropActions supportedDropActions() const { return Qt::MoveAction | Qt::CopyAction; }
void setFeaturesList( QList <UBFeature> *flist ) { featuresList = flist; } void setFeaturesList(QList <UBFeature> *flist ) { featuresList = flist; }
private: private:
QList <UBFeature> *featuresList; QList <UBFeature> *featuresList;
}; };

@ -18,12 +18,13 @@
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "core/UBDownloadManager.h" #include "core/UBDownloadManager.h"
#include "core/memcheck.h"
#include "frameworks/UBFileSystemUtils.h" #include "frameworks/UBFileSystemUtils.h"
#include "globals/UBGlobals.h" #include "globals/UBGlobals.h"
#include "core/memcheck.h"
/** /**
* \brief Constructor * \brief Constructor

@ -16,10 +16,11 @@
#include "UBLibWidget.h" #include "UBLibWidget.h"
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "core/memcheck.h"
#include "globals/UBGlobals.h" #include "globals/UBGlobals.h"
#include "core/memcheck.h"
static int lowBoundForSlider = 40; static int lowBoundForSlider = 40;
static int topBoundForSlider = 120; static int topBoundForSlider = 120;
static int tickIntervalForSlider = 10; static int tickIntervalForSlider = 10;

@ -20,10 +20,11 @@
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "core/memcheck.h"
#include "core/UBDownloadManager.h" #include "core/UBDownloadManager.h"
#include "board/UBBoardPaletteManager.h" #include "board/UBBoardPaletteManager.h"
#include "core/memcheck.h"
/** /**
* \brief Constructor * \brief Constructor
* @param parent as the parent widget * @param parent as the parent widget

@ -1,7 +1,6 @@
#include <QDomDocument> #include <QDomDocument>
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "core/memcheck.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
@ -9,7 +8,7 @@
#include "UBLibWebView.h" #include "UBLibWebView.h"
#include "core/memcheck.h"
UBLibWebView::UBLibWebView(QWidget* parent, const char* name):QWidget(parent) UBLibWebView::UBLibWebView(QWidget* parent, const char* name):QWidget(parent)
, mpView(NULL) , mpView(NULL)

@ -17,10 +17,11 @@
#include "UBLibWidget.h" #include "UBLibWidget.h"
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "core/memcheck.h"
#include "globals/UBGlobals.h" #include "globals/UBGlobals.h"
#include "core/memcheck.h"
/** /**
* \brief Constructor * \brief Constructor
* @param parent as the parent widget * @param parent as the parent widget

@ -14,12 +14,13 @@
*/ */
#include "UBPageNavigationWidget.h" #include "UBPageNavigationWidget.h"
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "core/memcheck.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "globals/UBGlobals.h" #include "globals/UBGlobals.h"
#include "core/memcheck.h"
/** /**
* \brief Constructor * \brief Constructor
* @param parent as the parent widget * @param parent as the parent widget

@ -7,6 +7,8 @@
#include <QModelIndex> #include <QModelIndex>
#include "UBTGWidgetTreeDelegate.h" #include "UBTGWidgetTreeDelegate.h"
#include "core/memcheck.h"
UBTGWidgetTreeDelegate::UBTGWidgetTreeDelegate(QObject *parent) : UBTGWidgetTreeDelegate::UBTGWidgetTreeDelegate(QObject *parent) :
QStyledItemDelegate(parent) QStyledItemDelegate(parent)
{ {

@ -1,4 +1,5 @@
#include "UBTeacherGuideDelegate.h" #include "UBTeacherGuideDelegate.h"
#include "core/memcheck.h"
UBTeacherGuideDelegate::UBTeacherGuideDelegate() UBTeacherGuideDelegate::UBTeacherGuideDelegate()
{ {

@ -40,6 +40,8 @@
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"
#include "document/UBDocumentController.h" #include "document/UBDocumentController.h"
#include "core/memcheck.h"
#define UBTG_SEPARATOR_FIXED_HEIGHT 3 #define UBTG_SEPARATOR_FIXED_HEIGHT 3

@ -32,6 +32,8 @@
#include "frameworks/UBFileSystemUtils.h" #include "frameworks/UBFileSystemUtils.h"
#include "core/memcheck.h"
/*************************************************************************** /***************************************************************************
* class UBAddItem * * class UBAddItem *

@ -16,6 +16,8 @@
#include <QtGlobal> #include <QtGlobal>
#include "CCITTFaxDecode.h" #include "CCITTFaxDecode.h"
#include "core/memcheck.h"
using namespace merge_lib; using namespace merge_lib;
bool CCITTFaxDecode::encode(std::string & decoded) bool CCITTFaxDecode::encode(std::string & decoded)

@ -16,6 +16,8 @@
#include <QtGlobal> #include <QtGlobal>
#include "DCTDecode.h" #include "DCTDecode.h"
#include "core/memcheck.h"
using namespace merge_lib; using namespace merge_lib;
bool DCTDecode::encode(std::string & decoded) bool DCTDecode::encode(std::string & decoded)

@ -15,6 +15,7 @@
#include <QtGlobal> #include <QtGlobal>
#include "JBIG2Decode.h" #include "JBIG2Decode.h"
#include "core/memcheck.h"
using namespace merge_lib; using namespace merge_lib;

@ -24,6 +24,8 @@
#include "UBOEmbedParser.h" #include "UBOEmbedParser.h"
#include "core/memcheck.h"
UBOEmbedParser::UBOEmbedParser(QObject *parent, const char* name) UBOEmbedParser::UBOEmbedParser(QObject *parent, const char* name)
{ {
Q_UNUSED(parent); Q_UNUSED(parent);

Loading…
Cancel
Save