preferencesAboutTextFull
shibakaneki 12 years ago
commit 558f2d4789
  1. BIN
      JournalDesModifications.pdf
  2. BIN
      ReleaseNotes.pdf
  3. 2
      Sankore_3.1.pro
  4. 19
      resources/style.qss
  5. 127
      src/board/UBBoardController.cpp
  6. 4
      src/board/UBBoardController.h
  7. 13
      src/board/UBBoardPaletteManager.cpp
  8. 404
      src/board/UBFeaturesController.cpp
  9. 82
      src/board/UBFeaturesController.h
  10. 23
      src/domain/UBGraphicsGroupContainerItem.cpp
  11. 2
      src/domain/UBGraphicsGroupContainerItem.h
  12. 35
      src/domain/UBGraphicsItemDelegate.cpp
  13. 29
      src/domain/UBGraphicsItemDelegate.h
  14. 36
      src/domain/UBGraphicsMediaItem.cpp
  15. 2
      src/domain/UBGraphicsMediaItem.h
  16. 23
      src/domain/UBGraphicsPDFItem.cpp
  17. 2
      src/domain/UBGraphicsPDFItem.h
  18. 26
      src/domain/UBGraphicsPixmapItem.cpp
  19. 2
      src/domain/UBGraphicsPixmapItem.h
  20. 36
      src/domain/UBGraphicsPolygonItem.cpp
  21. 1
      src/domain/UBGraphicsPolygonItem.h
  22. 8
      src/domain/UBGraphicsScene.cpp
  23. 4
      src/domain/UBGraphicsScene.h
  24. 21
      src/domain/UBGraphicsStrokesGroup.cpp
  25. 1
      src/domain/UBGraphicsStrokesGroup.h
  26. 25
      src/domain/UBGraphicsSvgItem.cpp
  27. 2
      src/domain/UBGraphicsSvgItem.h
  28. 40
      src/domain/UBGraphicsTextItem.cpp
  29. 3
      src/domain/UBGraphicsTextItem.h
  30. 72
      src/domain/UBGraphicsWidgetItem.cpp
  31. 5
      src/domain/UBGraphicsWidgetItem.h
  32. 3
      src/domain/UBItem.h
  33. 21
      src/gui/UBFeaturesActionBar.cpp
  34. 2
      src/gui/UBFeaturesActionBar.h
  35. 404
      src/gui/UBFeaturesWidget.cpp
  36. 121
      src/gui/UBFeaturesWidget.h
  37. 15
      src/tools/UBGraphicsCache.cpp
  38. 2
      src/tools/UBGraphicsCache.h
  39. 15
      src/tools/UBGraphicsCompass.cpp
  40. 2
      src/tools/UBGraphicsCompass.h
  41. 24
      src/tools/UBGraphicsCurtainItem.cpp
  42. 1
      src/tools/UBGraphicsCurtainItem.h
  43. 25
      src/tools/UBGraphicsProtractor.cpp
  44. 1
      src/tools/UBGraphicsProtractor.h
  45. 15
      src/tools/UBGraphicsRuler.cpp
  46. 1
      src/tools/UBGraphicsRuler.h
  47. 15
      src/tools/UBGraphicsTriangle.cpp
  48. 1
      src/tools/UBGraphicsTriangle.h

Binary file not shown.

Binary file not shown.

@ -11,7 +11,7 @@ CONFIG += debug_and_release \
VERSION_MAJ = 2
VERSION_MIN = 00
VERSION_TYPE = b # a = alpha, b = beta, r = release, other => error
VERSION_PATCH = 02
VERSION_PATCH = 03
VERSION = "$${VERSION_MAJ}.$${VERSION_MIN}.$${VERSION_TYPE}.$${VERSION_PATCH}"
VERSION = $$replace(VERSION, "\\.r", "")

@ -5,15 +5,21 @@ QWidget#UBLibNavigatorWidget,
QWidget#UBLibItemProperties,
QWidget#UBDownloadWidget,
QWidget#UBTeacherGuideWidget,
QWidget#UBFeatureProperties,
QWidget#UBFeaturesNavigatorWidget,
QWidget#PathList
QWidget#PathList,
QWidget#UBFeaturesCentralWidget
{
background: #EEEEEE;
border-radius: 10px;
border: 2px solid #999999;
}
QWidget#mAdditionalDataContainer
{
border-radius: 10px;
border: 2px solid #999999;
}
QWidget#UBMediaVideoContainer
{
background: #000000;
@ -30,15 +36,12 @@ QWidget#UBLibWebView
QListView
{
border: 0px;
border: 0px;
}
QWidget#UBFeaturesWebView
QWidget#UBFeatureProperties
{
background: #EEEEEE;
border-radius : 10px;
border: 2px solid #999999;
border: 2px;
}
QWebView#SearchEngineView

@ -53,6 +53,7 @@
#include "domain/UBGraphicsTextItem.h"
#include "domain/UBPageSizeUndoCommand.h"
#include "domain/UBGraphicsGroupContainerItem.h"
#include "domain/UBItem.h"
#include "tools/UBToolsManager.h"
@ -529,6 +530,92 @@ void UBBoardController::duplicateScene()
duplicateScene(mActiveSceneIndex);
}
void UBBoardController::duplicateItem(UBItem *item)
{
if (!item)
return;
QUrl sourceUrl;
QByteArray pData;
//common parameters for any item
QPointF itemPos;
QSizeF itemSize;
QGraphicsItem *commonItem = dynamic_cast<QGraphicsItem*>(item);
if (commonItem)
{
itemPos = commonItem->pos();
itemSize = commonItem->boundingRect().size();
}
QString contentTypeHeader = UBFileSystemUtils::mimeTypeFromFileName(item->sourceUrl().toLocalFile());
UBMimeType::Enum itemMimeType = UBFileSystemUtils::mimeTypeFromString(contentTypeHeader);
switch(static_cast<int>(itemMimeType))
{
case UBMimeType::AppleWidget:
case UBMimeType::W3CWidget:
{
UBGraphicsWidgetItem *witem = dynamic_cast<UBGraphicsWidgetItem*>(item);
if (witem)
{
sourceUrl = witem->getOwnFolder();
}
}break;
case UBMimeType::Video:
case UBMimeType::Audio:
{
UBGraphicsMediaItem *mitem = dynamic_cast<UBGraphicsMediaItem*>(item);
if (mitem)
{
sourceUrl = mitem->mediaFileUrl();
}
}break;
case UBMimeType::VectorImage:
{
UBGraphicsSvgItem *viitem = dynamic_cast<UBGraphicsSvgItem*>(item);
if (viitem)
{
pData = viitem->fileData();
sourceUrl = item->sourceUrl();
}
}break;
case UBMimeType::RasterImage:
{
UBGraphicsPixmapItem *pixitem = dynamic_cast<UBGraphicsPixmapItem*>(item);
if (pixitem)
{
QBuffer buffer(&pData);
buffer.open(QIODevice::WriteOnly);
QString format = UBFileSystemUtils::extension(item->sourceUrl().toLocalFile());
pixitem->pixmap().save(&buffer, format.toLatin1());
}
}break;
case UBMimeType::UNKNOWN:
{
QGraphicsItem *gitem = dynamic_cast<QGraphicsItem*>(item->deepCopy());
if (gitem)
{
mActiveScene->addItem(gitem);
gitem->setPos(itemPos);
}
return;
}break;
}
UBItem *createdItem = downloadFinished(true, sourceUrl, contentTypeHeader, pData, itemPos, QSize(itemSize.width(), itemSize.height()), false);
if (createdItem)
{
createdItem->setSourceUrl(item->sourceUrl());
item->copyItemParameters(createdItem);
}
}
void UBBoardController::deleteScene(int nIndex)
{
if (selectedDocument()->pageCount()>2)
@ -854,7 +941,7 @@ void UBBoardController::downloadURL(const QUrl& url, const QPointF& pPos, const
}
void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground)
UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground)
{
QString mimeType = pContentTypeHeader;
@ -869,7 +956,7 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
if (!pSuccess)
{
UBApplication::showMessage(tr("Downloading content %1 failed").arg(sourceUrl.toString()));
return;
return NULL;
}
if (!sourceUrl.toString().startsWith("file://") && !sourceUrl.toString().startsWith("uniboardTool://"))
@ -897,12 +984,14 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
pixItem->setSelected(true);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
}
return pixItem;
}
else if (UBMimeType::VectorImage == itemMimeType)
{
qDebug() << "accepting mime type" << mimeType << "as vecto image";
UBGraphicsSvgItem* svgItem = mActiveScene->addSvg(sourceUrl, pPos);
UBGraphicsSvgItem* svgItem = mActiveScene->addSvg(sourceUrl, pPos, pData);
svgItem->setSourceUrl(sourceUrl);
if (isBackground)
@ -915,6 +1004,8 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
svgItem->setSelected(true);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
}
return svgItem;
}
else if (UBMimeType::AppleWidget == itemMimeType) //mime type invented by us :-(
{
@ -939,6 +1030,8 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
{
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
}
return appleWidgetItem;
}
else if (UBMimeType::W3CWidget == itemMimeType)
{
@ -960,6 +1053,8 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
{
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
}
return w3cWidgetItem;
}
else if (UBMimeType::Video == itemMimeType)
{
@ -989,6 +1084,8 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
}
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
return mediaVideoItem;
}
else if (UBMimeType::Audio == itemMimeType)
{
@ -1018,6 +1115,8 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
}
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
return audioMediaItem;
}
else if (UBMimeType::Flash == itemMimeType)
@ -1061,6 +1160,8 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
widgetItem->setSourceUrl(sourceUrl);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
return widgetItem;
}
if (eduMediaFile)
@ -1182,6 +1283,8 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
widgetItem->setSourceUrl(sourceUrl);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
return widgetItem;
}
}
}
@ -1193,6 +1296,8 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
UBApplication::showMessage(tr("Unknown content type %1").arg(pContentTypeHeader));
qWarning() << "ignoring mime type" << pContentTypeHeader ;
}
return NULL;
}
void UBBoardController::setActiveDocumentScene(int pSceneIndex)
@ -1902,7 +2007,7 @@ UBGraphicsWidgetItem *UBBoardController::addW3cWidget(const QUrl &pUrl, const QP
}
return 0;
return w3cWidgetItem;
}
void UBBoardController::cut()
@ -1957,7 +2062,11 @@ void UBBoardController::copy()
UBItem* ubItem = dynamic_cast<UBItem*>(gi);
if (ubItem && !mActiveScene->tools().contains(gi))
selected << ubItem->deepCopy();
{
UBItem *itemCopy = ubItem->deepCopy();
if (itemCopy)
selected << itemCopy;
}
}
if (selected.size() > 0)
@ -2014,13 +2123,7 @@ void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPoint
{
foreach(UBItem* item, mimeData->items())
{
QGraphicsItem* gi = dynamic_cast<QGraphicsItem*>(item->deepCopy());
if (gi)
{
mActiveScene->addItem(gi);
gi->setPos(gi->pos() + QPointF(50, 50));
}
duplicateItem(item);
}
return;

@ -39,6 +39,7 @@ class UBGraphicsVideoItem;
class UBGraphicsAudioItem;
class UBGraphicsWidgetItem;
class UBBoardPaletteManager;
class UBItem;
class UBBoardController : public UBDocumentContainer
@ -157,6 +158,7 @@ class UBBoardController : public UBDocumentContainer
void moveSceneToIndex(int source, int target);
void duplicateScene(int index);
void duplicateItem(UBItem *item);
void deleteScene(int index);
bool cacheIsVisible() {return mCacheWidgetIsEnabled;}
@ -188,7 +190,7 @@ class UBBoardController : public UBDocumentContainer
void lastScene();
void groupButtonClicked();
void downloadURL(const QUrl& url, const QPointF& pPos = QPointF(0.0, 0.0), const QSize& pSize = QSize(), bool isBackground = false);
void downloadFinished(bool pSuccess, QUrl sourceUrl, QString pHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground = false);
UBItem *downloadFinished(bool pSuccess, QUrl sourceUrl, QString pHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground = false);
void changeBackground(bool isDark, bool isCrossed);
void setToolCursor(int tool);
void showMessage(const QString& message, bool showSpinningWheel);

@ -665,11 +665,8 @@ void UBBoardPaletteManager::addItem(const QUrl& pUrl)
mAddItemPalette->show();
mAddItemPalette->adjustSizeAndPosition();
QRect controlGeo = UBApplication::applicationController->displayManager()->controlGeometry();
mAddItemPalette->move(controlGeo.x() + ((controlGeo.width() - mAddItemPalette->geometry().width()) / 2),
(controlGeo.y() + (controlGeo.height() - mAddItemPalette->geometry().height()) / 5));
mAddItemPalette->move((mContainer->width() - mAddItemPalette->width()) / 2,
(mContainer->height() - mAddItemPalette->height()) / 5);
}
void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool isInit)
@ -835,13 +832,11 @@ void UBBoardPaletteManager::addItem(const QPixmap& pPixmap, const QPointF& pos,
mPos = pos;
mScaleFactor = scaleFactor;
QRect controlGeo = UBApplication::applicationController->displayManager()->controlGeometry();
mAddItemPalette->show();
mAddItemPalette->adjustSizeAndPosition();
mAddItemPalette->move(controlGeo.x() + ((controlGeo.width() - mAddItemPalette->geometry().width()) / 2),
(controlGeo.y() + (controlGeo.height() - mAddItemPalette->geometry().height()) / 5));
mAddItemPalette->move((mContainer->width() - mAddItemPalette->width()) / 2,
(mContainer->height() - mAddItemPalette->height()) / 5);
}

@ -1,5 +1,6 @@
#include <QGraphicsItem>
#include <QPointF>
#include <QtGui>
#include "core/UBApplication.h"
#include "board/UBBoardController.h"
@ -9,7 +10,6 @@
#include "frameworks/UBFileSystemUtils.h"
#include "frameworks/UBPlatformUtils.h"
#include "core/UBDownloadManager.h"
#include "domain/UBAbstractWidget.h"
#include "domain/UBGraphicsScene.h"
@ -22,20 +22,168 @@
const QString UBFeaturesController::virtualRootName = "root";
UBFeature::UBFeature(const QString &url, const QPixmap &icon, const QString &name, const QUrl &realPath, UBFeatureElementType type)
: virtualDir(url), mThumbnail(icon), mName(name), mPath(realPath), elementType(type)
void UBFeaturesComputingThread::scanFS(const QUrl & currentPath, const QString & currVirtualPath)
{
Q_ASSERT(QFileInfo(currentPath.toLocalFile()).exists());
QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(currentPath.toLocalFile());
QFileInfoList::iterator fileInfo;
for ( fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end(); fileInfo += 1) {
if (abort) {
return;
}
QString fullFileName = fileInfo->absoluteFilePath();
UBFeatureElementType featureType = UBFeaturesController::fileTypeFromUrl(fullFileName);
QString fileName = fileInfo->fileName();
QImage icon = UBFeaturesController::getIcon(fullFileName, featureType);
if ( fullFileName.contains(".thumbnail."))
continue;
UBFeature testFeature(currVirtualPath, icon, fileName, QUrl::fromLocalFile(fullFileName), featureType);
emit sendFeature(testFeature);
emit featureSent();
// featuresList->append(testFeature);
// if ( favoriteSet->find( QUrl::fromLocalFile( fullFileName ) ) != favoriteSet->end() ) {
// featuresList->append( UBFeature( favoritePath, icon, fileName, QUrl::fromLocalFile( fullFileName ), featureType ) );
// }
if (featureType == FEATURE_FOLDER) {
scanFS(QUrl::fromLocalFile(fullFileName), currVirtualPath + "/" + fileName);
}
}
}
UBFeature::~UBFeature()
void UBFeaturesComputingThread::scanAll(QList<QPair<QUrl, QString> > pScanningData)
{
for (int i = 0; i < mChildren.count(); i++) {
delete mChildren[i];
for (int i = 0; i < pScanningData.count(); i++) {
if (abort) {
return;
}
QPair<QUrl, QString> curPair = pScanningData.at(i);
scanFS(curPair.first, curPair.second);
}
}
for (int i = 0; i < mParents.count(); i++) {
mParents[i]->mChildren.removeAll(this);
int UBFeaturesComputingThread::featuresCount(const QUrl &pPath)
{
int noItems = 0;
QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(pPath.toLocalFile());
QFileInfoList::iterator fileInfo;
for ( fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end(); fileInfo += 1) {
QString fullFileName = fileInfo->absoluteFilePath();
UBFeatureElementType featureType = UBFeaturesController::fileTypeFromUrl(fullFileName);
if (featureType != FEATURE_INVALID && !fullFileName.contains(".thumbnail.")) {
noItems++;
} else {
continue;
}
if (featureType == FEATURE_FOLDER) {
noItems += featuresCount(QUrl::fromLocalFile(fullFileName));
}
}
return noItems;
}
int UBFeaturesComputingThread::featuresCountAll(QList<QPair<QUrl, QString> > pScanningData)
{
int noItems = 0;
for (int i = 0; i < pScanningData.count(); i++) {
QPair<QUrl, QString> curPair = pScanningData.at(i);
noItems += featuresCount(curPair.first);
}
return noItems;
}
UBFeaturesComputingThread::UBFeaturesComputingThread(QObject *parent) :
QThread(parent)
{
restart = false;
abort = false;
}
void UBFeaturesComputingThread::compute(const QList<QPair<QUrl, QString> > &pScanningData)
{
QMutexLocker curLocker(&mMutex);
mScanningData = pScanningData;
if (!isRunning()) {
start(LowPriority);
} else {
restart = true;
mWaitCondition.wakeOne();
}
}
void UBFeaturesComputingThread::run()
{
forever {
qDebug() << "Custom thread started execution";
mMutex.lock();
QList<QPair<QUrl, QString> > searchData = mScanningData;
mMutex.unlock();
if (abort) {
return;
}
if (restart) {
break;
}
QTime curTime = QTime::currentTime();
int fsCnt = featuresCountAll(searchData);
int msecsto = curTime.msecsTo(QTime::currentTime());
qDebug() << "time on evaluation" << msecsto;
emit maxFilesCountEvaluated(fsCnt);
emit scanStarted();
scanAll(searchData);
emit scanFinished();
mMutex.lock();
if (!restart) {
mWaitCondition.wait(&mMutex);
}
restart = false;
mMutex.unlock();
}
}
UBFeaturesComputingThread::~UBFeaturesComputingThread()
{
qDebug() << "thread destructor catched";
mMutex.lock();
abort = true;
mWaitCondition.wakeOne();
mMutex.unlock();
wait();
}
UBFeature::UBFeature(const QString &url, const QImage &icon, const QString &name, const QUrl &realPath, UBFeatureElementType type)
: virtualDir(url), mThumbnail(icon), mName(name), mPath(realPath), elementType(type)
{
}
UBFeature::~UBFeature()
{
}
QString UBFeature::getUrl() const
@ -108,18 +256,18 @@ UBFeaturesController::UBFeaturesController(QWidget *pParentWidget) :
mLibSearchDirectoryPath =QUrl::fromLocalFile(UBSettings::settings()->userSearchDirectory());
trashDirectoryPath = QUrl::fromLocalFile(UBSettings::userTrashDirPath());
rootElement = UBFeature(QString(), QPixmap( ":images/libpalette/home.png" ), "root", QUrl());
audiosElement = UBFeature( rootPath, QPixmap(":images/libpalette/AudiosCategory.svg"), "Audios" , mUserAudioDirectoryPath, FEATURE_CATEGORY);
moviesElement = UBFeature( rootPath, QPixmap(":images/libpalette/MoviesCategory.svg"), "Movies" , mUserVideoDirectoryPath, FEATURE_CATEGORY);
picturesElement = UBFeature( rootPath, QPixmap(":images/libpalette/PicturesCategory.svg"), "Pictures" , mUserPicturesDirectoryPath, FEATURE_CATEGORY);
flashElement = UBFeature( rootPath, QPixmap(":images/libpalette/FlashCategory.svg"), "Animations" , mUserAnimationDirectoryPath, FEATURE_CATEGORY);
interactElement = UBFeature( rootPath, QPixmap(":images/libpalette/InteractivesCategory.svg"), "Interactivities" , mLibInteractiveDirectoryPath, FEATURE_CATEGORY);
applicationsElement = UBFeature( rootPath, QPixmap(":images/libpalette/ApplicationsCategory.svg"), "Applications" , mUserInteractiveDirectoryPath, FEATURE_CATEGORY);
shapesElement = UBFeature( rootPath, QPixmap(":images/libpalette/ShapesCategory.svg"), "Shapes" , mLibShapesDirectoryPath, FEATURE_CATEGORY );
favoriteElement = UBFeature( rootPath, QPixmap(":images/libpalette/FavoritesCategory.svg"), "Favorites", QUrl("favorites"), FEATURE_FAVORITE );
webSearchElement = UBFeature( rootPath, QPixmap(":images/libpalette/WebSearchCategory.svg"), "Web search", mLibSearchDirectoryPath, FEATURE_CATEGORY);
rootElement = UBFeature(QString(), QImage( ":images/libpalette/home.png" ), "root", QUrl());
audiosElement = UBFeature( rootPath, QImage(":images/libpalette/AudiosCategory.svg"), "Audios" , mUserAudioDirectoryPath, FEATURE_CATEGORY);
moviesElement = UBFeature( rootPath, QImage(":images/libpalette/MoviesCategory.svg"), "Movies" , mUserVideoDirectoryPath, FEATURE_CATEGORY);
picturesElement = UBFeature( rootPath, QImage(":images/libpalette/PicturesCategory.svg"), "Pictures" , mUserPicturesDirectoryPath, FEATURE_CATEGORY);
flashElement = UBFeature( rootPath, QImage(":images/libpalette/FlashCategory.svg"), "Animations" , mUserAnimationDirectoryPath, FEATURE_CATEGORY);
interactElement = UBFeature( rootPath, QImage(":images/libpalette/InteractivesCategory.svg"), "Interactivities" , mLibInteractiveDirectoryPath, FEATURE_CATEGORY);
applicationsElement = UBFeature( rootPath, QImage(":images/libpalette/ApplicationsCategory.svg"), "Applications" , mUserInteractiveDirectoryPath, FEATURE_CATEGORY);
shapesElement = UBFeature( rootPath, QImage(":images/libpalette/ShapesCategory.svg"), "Shapes" , mLibShapesDirectoryPath, FEATURE_CATEGORY );
favoriteElement = UBFeature( rootPath, QImage(":images/libpalette/FavoritesCategory.svg"), "Favorites", QUrl("favorites"), FEATURE_FAVORITE );
webSearchElement = UBFeature( rootPath, QImage(":images/libpalette/WebSearchCategory.svg"), "Web search", mLibSearchDirectoryPath, FEATURE_CATEGORY);
trashElement = UBFeature( rootPath, QPixmap(":images/libpalette/TrashCategory.svg"), "Trash", trashDirectoryPath, FEATURE_TRASH );
trashElement = UBFeature( rootPath, QImage(":images/libpalette/TrashCategory.svg"), "Trash", trashDirectoryPath, FEATURE_TRASH );
featuresList = new QList <UBFeature>();
@ -142,7 +290,40 @@ UBFeaturesController::UBFeaturesController(QWidget *pParentWidget) :
featuresPathModel->setSourceModel(featuresModel);
connect(featuresModel, SIGNAL(dataRestructured()), featuresProxyModel, SLOT(invalidate()));
connect(&mCThread, SIGNAL(sendFeature(UBFeature)), featuresModel, SLOT(addItem(UBFeature)));
connect(&mCThread, SIGNAL(featureSent()), this, SIGNAL(featureAddedFromThread()));
connect(&mCThread, SIGNAL(scanStarted()), this, SIGNAL(scanStarted()));
connect(&mCThread, SIGNAL(scanFinished()), this, SIGNAL(scanFinished()));
connect(&mCThread, SIGNAL(maxFilesCountEvaluated(int)), this, SIGNAL(maxFilesCountEvaluated(int)));
//Very unsafe function. Considering using deleteLater() instead
// connect(qApp, SIGNAL(aboutToQuit()), &mCThread, SLOT(terminate()));
QTimer::singleShot(0, this, SLOT(startThread()));
// startThread();
}
void UBFeaturesController::startThread()
{
QList<QPair<QUrl, QString> > computingData;
computingData << QPair<QUrl, QString>(mLibAudiosDirectoryPath, audiosPath)
<< QPair<QUrl, QString>(mLibVideosDirectoryPath, moviesPath)
<< QPair<QUrl, QString>(mLibAnimationsDirectoryPath, flashPath)
<< QPair<QUrl, QString>(mLibPicturesDirectoryPath, picturesPath)
<< QPair<QUrl, QString>(mUserInteractiveDirectoryPath, appPath)
<< QPair<QUrl, QString>(mUserAudioDirectoryPath, audiosPath)
<< QPair<QUrl, QString>(mUserPicturesDirectoryPath, picturesPath)
<< QPair<QUrl, QString>(mUserVideoDirectoryPath, moviesPath)
<< QPair<QUrl, QString>(mUserAnimationDirectoryPath, flashPath)
<< QPair<QUrl, QString>(mLibApplicationsDirectoryPath, appPath)
<< QPair<QUrl, QString>(mLibShapesDirectoryPath, shapesPath)
<< QPair<QUrl, QString>(mLibInteractiveDirectoryPath, interactPath)
<< QPair<QUrl, QString>(trashDirectoryPath, trashPath)
<< QPair<QUrl, QString>(mLibSearchDirectoryPath, rootPath + "/" + "Web search" );
mCThread.compute(computingData);
}
void UBFeaturesController::scanFS()
@ -166,29 +347,55 @@ void UBFeaturesController::scanFS()
QList <UBToolsManager::UBToolDescriptor> tools = UBToolsManager::manager()->allTools();
foreach (UBToolsManager::UBToolDescriptor tool, tools) {
featuresList->append(UBFeature(appPath, tool.icon, tool.label, QUrl(tool.id), FEATURE_INTERNAL));
featuresList->append(UBFeature(appPath, tool.icon.toImage(), tool.label, QUrl(tool.id), FEATURE_INTERNAL));
if (favoriteSet->find(QUrl(tool.id)) != favoriteSet->end()) {
featuresList->append(UBFeature(favoritePath, tool.icon, tool.label, QUrl(tool.id), FEATURE_INTERNAL));
featuresList->append(UBFeature(favoritePath, tool.icon.toImage(), tool.label, QUrl(tool.id), FEATURE_INTERNAL));
}
}
QTime time = QTime::currentTime();
//Claudio:
// don't change the order of the scans
fileSystemScan( mLibAudiosDirectoryPath, audiosPath);
fileSystemScan( mLibVideosDirectoryPath, moviesPath);
fileSystemScan( mLibAnimationsDirectoryPath, flashPath);
fileSystemScan( mLibPicturesDirectoryPath, picturesPath );
// fileSystemScan( mLibAudiosDirectoryPath, audiosPath);
// fileSystemScan( mLibVideosDirectoryPath, moviesPath);
// fileSystemScan( mLibAnimationsDirectoryPath, flashPath);
// fileSystemScan( mLibPicturesDirectoryPath, picturesPath );
fileSystemScan( mUserInteractiveDirectoryPath, appPath );
fileSystemScan( mUserAudioDirectoryPath, audiosPath );
fileSystemScan( mUserPicturesDirectoryPath, picturesPath );
fileSystemScan( mUserVideoDirectoryPath, moviesPath );
fileSystemScan( mUserAnimationDirectoryPath, flashPath );
// fileSystemScan( mUserInteractiveDirectoryPath, appPath );
// fileSystemScan( mUserAudioDirectoryPath, audiosPath );
// fileSystemScan( mUserPicturesDirectoryPath, picturesPath );
// fileSystemScan( mUserVideoDirectoryPath, moviesPath );
// fileSystemScan( mUserAnimationDirectoryPath, flashPath );
fileSystemScan( mLibApplicationsDirectoryPath, appPath );
fileSystemScan( mLibShapesDirectoryPath, shapesPath );
fileSystemScan( mLibInteractiveDirectoryPath, interactPath );
fileSystemScan( trashDirectoryPath, trashPath );
fileSystemScan( mLibSearchDirectoryPath, rootPath + "/" + "Web search" );
// fileSystemScan( mLibApplicationsDirectoryPath, appPath );
// fileSystemScan( mLibShapesDirectoryPath, shapesPath );
// fileSystemScan( mLibInteractiveDirectoryPath, interactPath );
// fileSystemScan( trashDirectoryPath, trashPath );
// fileSystemScan( mLibSearchDirectoryPath, rootPath + "/" + "Web search" );
int i =0;
i += featuresCount(mLibAudiosDirectoryPath);
i += featuresCount(mLibVideosDirectoryPath);
i += featuresCount(mLibAnimationsDirectoryPath);
i += featuresCount(mLibPicturesDirectoryPath);
i += featuresCount(mUserInteractiveDirectoryPath);
i += featuresCount(mUserAudioDirectoryPath);
i += featuresCount(mUserPicturesDirectoryPath);
i += featuresCount(mUserVideoDirectoryPath);
i += featuresCount(mUserAnimationDirectoryPath);
i += featuresCount(mLibApplicationsDirectoryPath);
i += featuresCount(mLibShapesDirectoryPath);
i += featuresCount(mLibInteractiveDirectoryPath);
i += featuresCount(trashDirectoryPath);
i += featuresCount(mLibSearchDirectoryPath);
int msecs = QTime(time).msecsTo(QTime::currentTime());
qDebug() << "Loading library" << msecs << "msecs\nNumber of elements" << i;
// emit TopIndexingLimitSet(i);
// emit indexingProgressValueChanged(i / 4);
}
void UBFeaturesController::fileSystemScan(const QUrl & currentPath, const QString & currVirtualPath)
@ -201,7 +408,7 @@ void UBFeaturesController::fileSystemScan(const QUrl & currentPath, const QStrin
UBFeatureElementType featureType = fileTypeFromUrl(fullFileName);
QString fileName = fileInfo->fileName();
QPixmap icon(getIcon(fullFileName, featureType));
QImage icon = getIcon(fullFileName, featureType);
if ( fullFileName.contains(".thumbnail."))
continue;
@ -220,6 +427,31 @@ void UBFeaturesController::fileSystemScan(const QUrl & currentPath, const QStrin
}
}
int UBFeaturesController::featuresCount(const QUrl &currPath)
{
int noItems = 0;
QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(currPath.toLocalFile());
QFileInfoList::iterator fileInfo;
for ( fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end(); fileInfo += 1) {
QString fullFileName = fileInfo->absoluteFilePath();
UBFeatureElementType featureType = fileTypeFromUrl(fullFileName);
if (featureType != FEATURE_INVALID && !fullFileName.contains(".thumbnail.")) {
noItems++;
} else {
continue;
}
if (featureType == FEATURE_FOLDER) {
noItems += featuresCount(QUrl::fromLocalFile(fullFileName));
}
}
return noItems;
}
void UBFeaturesController::loadFavoriteList()
{
favoriteSet = new QSet<QUrl>();
@ -260,7 +492,7 @@ void UBFeaturesController::addToFavorite( const QUrl &path )
{
QFileInfo fileInfo( filePath );
QString fileName = fileInfo.fileName();
UBFeature elem( favoritePath, getIcon( filePath, FEATURE_CATEGORY ), fileName, path, fileTypeFromUrl(filePath) );
UBFeature elem(favoritePath, getIcon( filePath, FEATURE_CATEGORY ), fileName, path, fileTypeFromUrl(filePath) );
favoriteSet->insert( path );
saveFavoriteList();
@ -318,33 +550,30 @@ UBFeatureElementType UBFeaturesController::fileTypeFromUrl( const QString &path
return fileType;
}
QPixmap UBFeaturesController::getIcon(const QString &path, UBFeatureElementType pFType = FEATURE_INVALID)
QImage UBFeaturesController::getIcon(const QString &path, UBFeatureElementType pFType = FEATURE_INVALID)
{
if ( pFType == FEATURE_FOLDER )
{
return QPixmap(":images/libpalette/folder.svg");
}
else if ( pFType == FEATURE_INTERACTIVE )
{
return QPixmap( UBAbstractWidget::iconFilePath( QUrl::fromLocalFile(path) ) );
if (pFType == FEATURE_FOLDER) {
return QImage(":images/libpalette/folder.svg");
} else if (pFType == FEATURE_INTERACTIVE) {
return QImage(UBAbstractWidget::iconFilePath(QUrl::fromLocalFile(path)));
}
if ( path.contains("uniboardTool://") )
{
return QPixmap( UBToolsManager::manager()->iconFromToolId(path) );
}
if ( UBFileSystemUtils::mimeTypeFromFileName(path).contains("application") )
{
return QPixmap( UBAbstractWidget::iconFilePath( QUrl::fromLocalFile(path) ) );
if ( path.contains("uniboardTool://") ) {
return QImage( UBToolsManager::manager()->iconFromToolId(path) );
} if ( UBFileSystemUtils::mimeTypeFromFileName(path).contains("application")) {
return QImage( UBAbstractWidget::iconFilePath( QUrl::fromLocalFile(path) ) );
}
QPixmap thumb;
QString thumbnailPath = UBFileSystemUtils::thumbnailPath( path );
QImage thumb;
QString thumbnailPath = UBFileSystemUtils::thumbnailPath(path);
if ( QFileInfo( thumbnailPath ).exists() )
thumb = QPixmap( thumbnailPath );
thumb = QImage( thumbnailPath );
else thumb = createThumbnail( path );
return thumb;
}
@ -354,12 +583,11 @@ bool UBFeaturesController::isDeletable( const QUrl &url )
return type == FEATURE_ITEM;
}
QPixmap UBFeaturesController::createThumbnail(const QString &path)
QImage UBFeaturesController::createThumbnail(const QString &path)
{
QString thumbnailPath = UBFileSystemUtils::thumbnailPath(path);
QString mimetype = UBFileSystemUtils::mimeTypeFromFileName(path);
QString extension = QFileInfo(path).completeSuffix();
//UBApplication::showMessage(tr("Creating image thumbnail for %1.").arg(pElement->name()));
if ( mimetype.contains("audio" ))
thumbnailPath = ":images/libpalette/soundIcon.svg";
@ -373,7 +601,7 @@ QPixmap UBFeaturesController::createThumbnail(const QString &path)
}
else
{
QPixmap pix(path);
QImage pix(path);
if (!pix.isNull())
{
pix = pix.scaledToWidth(qMin(UBSettings::maxThumbnailWidth, pix.width()), Qt::SmoothTransformation);
@ -386,7 +614,7 @@ QPixmap UBFeaturesController::createThumbnail(const QString &path)
}
}
return QPixmap(thumbnailPath);
return QImage(thumbnailPath);
}
void UBFeaturesController::importImage(const QImage &image, const QString &fileName)
@ -394,6 +622,7 @@ void UBFeaturesController::importImage(const QImage &image, const QString &fileN
importImage(image, currentElement, fileName);
}
void UBFeaturesController::importImage( const QImage &image, const UBFeature &destination, const QString &fileName )
{
QString mFileName = fileName;
@ -412,7 +641,7 @@ void UBFeaturesController::importImage( const QImage &image, const UBFeature &de
QString filePath = dest.getFullPath().toLocalFile() + "/" + mFileName;
image.save(filePath);
QPixmap thumb = createThumbnail( filePath );
QImage thumb = createThumbnail( filePath );
UBFeature resultItem = UBFeature( dest.getFullVirtualPath(), thumb, mFileName,
QUrl::fromLocalFile( filePath ), FEATURE_ITEM );
@ -420,7 +649,28 @@ void UBFeaturesController::importImage( const QImage &image, const UBFeature &de
}
void UBFeaturesController::addNewFolder(const QString &name)
QStringList UBFeaturesController::getFileNamesInFolders()
{
QStringList strList;
Q_ASSERT(curListModel);
for (int i = 0; i < curListModel->rowCount(QModelIndex()); i++) {
QModelIndex ind = curListModel->index(i, 0);
if (!ind.isValid()) {
qDebug() << "incorrect model index catched";
continue;
}
UBFeature curFeature = curListModel->data(ind, Qt::UserRole + 1).value<UBFeature>();
if (curFeature.getType() == FEATURE_FOLDER) {
strList << QFileInfo(curFeature.getFullPath().toLocalFile()).fileName();
}
}
return strList;
}
void UBFeaturesController::addNewFolder(QString name)
{
QString path = currentElement.getFullPath().toLocalFile() + "/" + name;
@ -432,7 +682,7 @@ void UBFeaturesController::addNewFolder(const QString &name)
if(!QFileInfo(path).exists()) {
QDir().mkpath(path);
}
UBFeature newFeatureFolder = UBFeature( currentElement.getFullVirtualPath(), QPixmap(":images/libpalette/folder.svg"),
UBFeature newFeatureFolder = UBFeature( currentElement.getFullVirtualPath(), QImage(":images/libpalette/folder.svg"),
name, QUrl::fromLocalFile( path ), FEATURE_FOLDER );
featuresModel->addItem( newFeatureFolder );
@ -523,7 +773,7 @@ UBFeature UBFeaturesController::moveItemToFolder( const QUrl &url, const UBFeatu
deleteItem( url );
}
QPixmap thumb = getIcon( newFullPath );
QImage thumb = getIcon( newFullPath );
UBFeatureElementType type = FEATURE_ITEM;
if ( UBFileSystemUtils::mimeTypeFromFileName( newFullPath ).contains("application") )
@ -550,9 +800,24 @@ void UBFeaturesController::siftElements(const QString &pSiftValue)
featuresPathModel->invalidate();
}
UBFeature UBFeaturesController::getFeature(const QModelIndex &index, QListView *pOnView)
UBFeature UBFeaturesController::getFeature(const QModelIndex &index, const QString &listName)
{
return qobject_cast<QSortFilterProxyModel *>(pOnView->model())->data(index, Qt::UserRole + 1).value<UBFeature>();
// QSortFilterProxyModel *model = qobject_cast<QSortFilterProxyModel *>(pOnView->model());
QAbstractItemModel *model = 0;
if (listName == UBFeaturesWidget::objNamePathList) {
model = featuresPathModel;
} else if (listName == UBFeaturesWidget::objNameFeatureList) {
model = curListModel;
}
if (model) {
return model->data(index, Qt::UserRole + 1).value<UBFeature>();
}
return UBFeature();
// return pOnView->model()->data(index, Qt::UserRole + 1).value<UBFeature>(); /*featuresSearchModel->data(index, Qt::UserRole + 1).value<UBFeature>()*/;
}
void UBFeaturesController::searchStarted(const QString &pattern, QListView *pOnView)
@ -561,11 +826,13 @@ void UBFeaturesController::searchStarted(const QString &pattern, QListView *pOnV
pOnView->setModel(featuresProxyModel);
featuresProxyModel->invalidate();
} else if ( pattern.size() > 2 ) {
curListModel = featuresProxyModel;
} else if ( pattern.size() > 1 ) {
featuresSearchModel->setFilterWildcard( "*" + pattern + "*" );
pOnView->setModel(featuresSearchModel );
featuresSearchModel->invalidate();
curListModel = featuresSearchModel;
}
}
@ -599,7 +866,7 @@ UBFeature UBFeaturesController::copyItemToFolder( const QUrl &url, const UBFeatu
if (!sourcePath.compare(newFullPath, Qt::CaseInsensitive))
QFile(sourcePath).copy(newFullPath);
QPixmap thumb = getIcon(newFullPath);
QImage thumb = getIcon(newFullPath);
UBFeatureElementType type = FEATURE_ITEM;
if (UBFileSystemUtils::mimeTypeFromFileName(newFullPath).contains("application"))
@ -641,7 +908,7 @@ void UBFeaturesController::moveExternalData(const QUrl &url, const UBFeature &de
Q_ASSERT(QFileInfo(newFullPath).exists());
QPixmap thumb = getIcon(newFullPath, type);
QImage thumb = getIcon(newFullPath, type);
UBFeature newElement(destVirtualPath, thumb, name, QUrl::fromLocalFile(newFullPath), type);
featuresModel->addItem(newElement);
@ -710,6 +977,7 @@ void UBFeaturesController::assignFeaturesListVeiw(UBFeaturesListView *pList)
pList->setItemDelegate(itemDelegate);
pList->setModel(featuresProxyModel);
curListModel = featuresProxyModel;
}
void UBFeaturesController::assignPathListView(UBFeaturesListView *pList)

@ -12,6 +12,10 @@
#include <QUrl>
#include <QByteArray>
#include <QtGui>
#include <QImage>
#include <QThread>
#include <QMutex>
#include <QWaitCondition>
class UBFeaturesModel;
class UBFeaturesItemDelegate;
@ -20,8 +24,45 @@ class UBFeaturesProxyModel;
class UBFeaturesSearchProxyModel;
class UBFeaturesPathProxyModel;
class UBFeaturesListView;
class UBFeature;
class UBFeaturesComputingThread : public QThread
{
Q_OBJECT
public:
explicit UBFeaturesComputingThread(QObject *parent = 0);
virtual ~UBFeaturesComputingThread();
void compute(const QList<QPair<QUrl, QString> > &pScanningData);
protected:
void run();
signals:
void sendFeature(UBFeature pFeature);
void featureSent();
void scanStarted();
void scanFinished();
void maxFilesCountEvaluated(int max);
public slots:
private:
void scanFS(const QUrl & currentPath, const QString & currVirtualPath);
void scanAll(QList<QPair<QUrl, QString> > pScanningData);
int featuresCount(const QUrl &pPath);
int featuresCountAll(QList<QPair<QUrl, QString> > pScanningData);
private:
QMutex mMutex;
QWaitCondition mWaitCondition;
QUrl mScanningPath;
QString mScanningVirtualPath;
QList<QPair<QUrl, QString> > mScanningData;
bool restart;
bool abort;
};
//#include "UBDockPaletteWidget.h"
enum UBFeatureElementType
{
@ -41,12 +82,12 @@ class UBFeature
{
public:
UBFeature() {;}
//UBFeature(const UBFeature &f);
UBFeature(const QString &url, const QPixmap &icon, const QString &name, const QUrl &realPath, UBFeatureElementType type = FEATURE_CATEGORY);
// UBFeature(const UBFeature &f);
UBFeature(const QString &url, const QImage &icon, const QString &name, const QUrl &realPath, UBFeatureElementType type = FEATURE_CATEGORY);
// UBFeature();
virtual ~UBFeature();
QString getName() const { return mName; }
QPixmap getThumbnail() const {return mThumbnail;}
QImage getThumbnail() const {return mThumbnail;}
QString getVirtualPath() const { return virtualDir; }
//QString getPath() const { return mPath; };
QUrl getFullPath() const { return mPath; }
@ -64,20 +105,13 @@ public:
const QMap<QString,QString> & getMetadata() const { return metadata; }
void setMetadata( const QMap<QString,QString> &data ) { metadata = data; }
bool hasChildren() const {return mChildren.count();}
bool hasParents() const {return mParents.count();}
bool hasRelationships() const {return mChildren.count() && mParents.count();}
private:
QString virtualDir;
QPixmap mThumbnail;
QImage mThumbnail;
QString mName;
QUrl mPath;
UBFeatureElementType elementType;
QMap<QString,QString> metadata;
QList<UBFeature*> mChildren;
QList<UBFeature*> mParents;
};
Q_DECLARE_METATYPE( UBFeature )
@ -111,7 +145,7 @@ public:
void rescanModel();
void siftElements(const QString &pSiftValue);
//TODO make less complicated for betteer maintainence
UBFeature getFeature(const QModelIndex &index, QListView *pOnView);
UBFeature getFeature(const QModelIndex &index, const QString &listName);
void searchStarted(const QString &pattern, QListView *pOnView);
void refreshModels();
@ -119,18 +153,18 @@ public:
void deleteItem(const UBFeature &pFeature);
bool isTrash( const QUrl &url );
void moveToTrash(UBFeature feature, bool deleteManualy = false);
void addNewFolder(const QString &name);
void addToFavorite( const QUrl &path );
void removeFromFavorite(const QUrl &path, bool deleteManualy = false);
void importImage(const QImage &image, const QString &fileName = QString());
void importImage( const QImage &image, const UBFeature &destination, const QString &fileName = QString() );
QStringList getFileNamesInFolders();
void fileSystemScan(const QUrl &currPath, const QString & currVirtualPath);
int featuresCount(const QUrl &currPath);
static UBFeatureElementType fileTypeFromUrl( const QString &path );
static QString fileNameFromUrl( const QUrl &url );
static QPixmap getIcon( const QString &path, UBFeatureElementType pFType );
static QImage getIcon( const QString &path, UBFeatureElementType pFType );
static bool isDeletable( const QUrl &url );
static char featureTypeSplitter() {return ':';}
@ -139,6 +173,16 @@ public:
void assignFeaturesListVeiw(UBFeaturesListView *pList);
void assignPathListView(UBFeaturesListView *pList);
signals:
void maxFilesCountEvaluated(int pLimit);
void scanStarted();
void scanFinished();
void featureAddedFromThread();
private slots:
void addNewFolder(QString name);
void startThread();
private:
UBFeaturesItemDelegate *itemDelegate;
@ -149,16 +193,16 @@ private:
UBFeaturesSearchProxyModel *featuresSearchModel;
UBFeaturesPathProxyModel *featuresPathModel;
QAbstractItemModel *curListModel;
UBFeaturesComputingThread mCThread;
private:
static QPixmap createThumbnail(const QString &path);
static QImage createThumbnail(const QString &path);
//void addImageToCurrentPage( const QString &path );
void loadFavoriteList();
void saveFavoriteList();
QList <UBFeature> *featuresList;
QUrl mUserAudioDirectoryPath;

@ -157,18 +157,29 @@ UBGraphicsGroupContainerItem *UBGraphicsGroupContainerItem::deepCopy() const
UBGraphicsGroupContainerItem *copy = new UBGraphicsGroupContainerItem(parentItem());
copy->setPos(this->pos());
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);
copy->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
copy->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
copy->setUuid(this->uuid()); // this is OK for now as long as Widgets are imutable
copyItemParameters(copy);
// copy->resize(this->size());
return copy;
}
void UBGraphicsGroupContainerItem::copyItemParameters(UBItem *copy) const
{
UBGraphicsGroupContainerItem *cp = dynamic_cast<UBGraphicsGroupContainerItem*>(copy);
if (cp)
{
cp->setPos(this->pos());
cp->setTransform(this->transform());
cp->setFlag(QGraphicsItem::ItemIsMovable, true);
cp->setFlag(QGraphicsItem::ItemIsSelectable, true);
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
cp->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
}
}
void UBGraphicsGroupContainerItem::remove()
{
if (mDelegate)

@ -24,6 +24,8 @@ public:
virtual UBGraphicsScene* scene();
virtual UBGraphicsGroupContainerItem *deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual void remove();
enum { Type = UBGraphicsItemType::groupContainerType };

@ -410,6 +410,7 @@ void UBGraphicsItemDelegate::duplicate()
UBApplication::boardController->copy();
UBApplication::boardController->paste();
UBApplication::boardController->duplicateItem(dynamic_cast<UBItem*>(delegated()));
}
void UBGraphicsItemDelegate::increaseZLevelUp()
@ -727,7 +728,11 @@ void UBGraphicsToolBarItem::paint(QPainter *painter, const QStyleOptionGraphicsI
}
MediaTimer::MediaTimer(QGraphicsItem * parent): QGraphicsRectItem(parent)
{}
{
val = 0;
smallPoint = false;
setNumDigits(4);
}
MediaTimer::~MediaTimer()
{}
@ -810,9 +815,7 @@ void MediaTimer::drawDigit(const QPoint &pos, QPainter &p, int segLen,
}
}
char* MediaTimer::getSegments(char ch) // gets list of segments for ch
{
char segments[30][8] =
char MediaTimer::segments [][8] =
{
{ 0, 1, 2, 4, 5, 6,99, 0}, // 0 0
{ 2, 5,99, 0, 0, 0, 0, 0}, // 1 1
@ -827,16 +830,17 @@ char* MediaTimer::getSegments(char ch) // gets list of segments fo
{ 8, 9,99, 0, 0, 0, 0, 0}, // 10 :
{99, 0, 0, 0, 0, 0, 0, 0} // 11 empty
};
int n;
const char* MediaTimer::getSegments(char ch) // gets list of segments for ch
{
if (ch >= '0' && ch <= '9')
return segments[ch - '0'];
if (ch == ':')
n = 10;
return segments[10];
if (ch == ' ')
n = 11;
return segments[11];
return segments[n];
return NULL;
}
void MediaTimer::drawSegment(const QPoint &pos, char segmentNo, QPainter &p,
@ -1058,13 +1062,6 @@ void MediaTimer::internalSetString(const QString& s)
update();
}
void MediaTimer::init()
{
val = 0;
smallPoint = false;
setNumDigits(4);
}
void MediaTimer::display(const QString &s)
{
val = 0;
@ -1132,7 +1129,6 @@ DelegateMediaControl::DelegateMediaControl(UBGraphicsMediaItem* pDelegated, QGra
setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
lcdTimer = new MediaTimer(this);
lcdTimer->init();
update();
}
@ -1185,6 +1181,8 @@ void DelegateMediaControl::positionHandles()
mLCDTimerArea.setHeight(parentItem()->boundingRect().height());
lcdTimer->setRect(mLCDTimerArea);
lcdTimer->setPos(mSeecArea.width()-mLCDTimerArea.width(),0);
//lcdTimer->setRect(mLCDTimerArea);
//lcdTimer->setPos(mSeecArea.width()-mLCDTimerArea.width(),0);
mSeecArea.setWidth(rect().width()-mLCDTimerArea.width());
@ -1193,6 +1191,7 @@ void DelegateMediaControl::positionHandles()
setRect(selfRect);
lcdTimer->setPos(rect().width() - mLCDTimerArea.width(), 0);
//lcdTimer->setPos(rect().width() - mLCDTimerArea.width(), 0);
}
@ -1201,6 +1200,7 @@ void DelegateMediaControl::update()
QTime t;
t = t.addMSecs(mCurrentTimeInMs < 0 ? 0 : mCurrentTimeInMs);
lcdTimer->display(t.toString("m:ss"));
//lcdTimer->display(t.toString("m:ss"));
QGraphicsRectItem::update();
}
@ -1253,6 +1253,7 @@ void DelegateMediaControl::seekToMousePos(QPointF mousePos)
minX = frameWidth;
length = mSeecArea.width() - lcdTimer->rect().width();
length = mSeecArea.width() /*- lcdTimer->rect().width()*/;
qreal mouseX = mousePos.x();
if (mouseX >= (mSeecArea.width() - mSeecArea.height()/2))

@ -71,33 +71,40 @@ class DelegateButton: public QGraphicsSvgItem
};
/*
Code of this class is copied from QT QLCDNumber class sources
See src\gui\widgets\qlcdnumber.cpp for original code
*/
class MediaTimer: public QGraphicsRectItem
{
public:
MediaTimer(QGraphicsItem * parent = 0);
~MediaTimer();
char* getSegments(char);
void addPoint(QPolygon&, const QPoint&);
void init();
void internalSetString(const QString& s);
void drawString(const QString& s, QPainter &, QBitArray * = 0, bool = true);
void drawDigit(const QPoint &, QPainter &, int, char, char = ' ');
void drawSegment(const QPoint &, char, QPainter &, int, bool = false);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
void display(const QString &str);
void setNumDigits(int nDigits);
private:
static const char* getSegments(char);
void drawString(const QString& s, QPainter &, QBitArray * = 0, bool = true);
void drawDigit(const QPoint &, QPainter &, int, char, char = ' ');
void drawSegment(const QPoint &, char, QPainter &, int, bool = false);
void addPoint(QPolygon&, const QPoint&);
void internalSetString(const QString& s);
void setNumDigits(int nDigits);
static char segments [][8];
int ndigits;
QString digitStr;
QBitArray points;
double val;
uint shadow : 1;
uint smallPoint : 1;
uint shadow : 1;
uint smallPoint : 1;
};
class DelegateMediaControl: public QObject, public QGraphicsRectItem

@ -241,26 +241,34 @@ void UBGraphicsMediaItem::showOnDisplayChanged(bool shown)
UBItem* UBGraphicsMediaItem::deepCopy() const
{
QUrl url = this->mediaFileUrl();
UBGraphicsMediaItem *copy;
copy = new UBGraphicsMediaItem(url, parentItem());
UBGraphicsMediaItem *copy = new UBGraphicsMediaItem(url, parentItem());
copy->setPos(this->pos());
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);
copy->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
copy->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
copy->setUuid(this->uuid()); // this is OK as long as Videos are imutable
copy->setSourceUrl(this->sourceUrl());
copy->resize(this->size());
copy->setUuid(this->uuid()); // this is OK for now as long as Widgets are imutable
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), copy, SLOT(activeSceneChanged()));
// TODO UB 4.7 complete all members
copyItemParameters(copy);
return copy;
}
void UBGraphicsMediaItem::copyItemParameters(UBItem *copy) const
{
UBGraphicsMediaItem *cp = dynamic_cast<UBGraphicsMediaItem*>(copy);
if (cp)
{
cp->setPos(this->pos());
cp->setTransform(this->transform());
cp->setFlag(QGraphicsItem::ItemIsMovable, true);
cp->setFlag(QGraphicsItem::ItemIsSelectable, true);
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
cp->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
cp->setSourceUrl(this->sourceUrl());
cp->resize(this->size());
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), cp, SLOT(activeSceneChanged()));
// TODO UB 4.7 complete all members
}
}
void UBGraphicsMediaItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (mDelegate)

@ -95,6 +95,8 @@ public:
virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual void setSourceUrl(const QUrl &pSourceUrl)
{
UBAudioPresentationWidget* pAudioWidget = dynamic_cast<UBAudioPresentationWidget*>(mAudioWidget);

@ -89,17 +89,26 @@ UBItem* UBGraphicsPDFItem::deepCopy() const
{
UBGraphicsPDFItem *copy = new UBGraphicsPDFItem(mRenderer, mPageNumber, parentItem());
copy->setPos(this->pos());
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);
copy->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
copy->setUuid(this->uuid()); // this is OK for now as long as PDF are imutable
copy->setSourceUrl(this->sourceUrl());
copy->setUuid(this->uuid()); // this is OK for now as long as Widgets are imutable
copyItemParameters(copy);
return copy;
}
void UBGraphicsPDFItem::copyItemParameters(UBItem *copy) const
{
UBGraphicsPDFItem *cp = dynamic_cast<UBGraphicsPDFItem*>(copy);
if (cp)
{
cp->setPos(this->pos());
cp->setTransform(this->transform());
cp->setFlag(QGraphicsItem::ItemIsMovable, true);
cp->setFlag(QGraphicsItem::ItemIsSelectable, true);
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
cp->setSourceUrl(this->sourceUrl());
}
}
void UBGraphicsPDFItem::setRenderingQuality(RenderingQuality pRenderingQuality)
{

@ -41,6 +41,8 @@ class UBGraphicsPDFItem: public GraphicsPDFItem, public UBItem, public UBGraphic
virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual void setRenderingQuality(RenderingQuality pRenderingQuality);
virtual UBGraphicsScene* scene();

@ -114,22 +114,30 @@ UBItem* UBGraphicsPixmapItem::deepCopy() const
{
UBGraphicsPixmapItem* copy = new UBGraphicsPixmapItem();
copy->setPixmap(this->pixmap());
copy->setPos(this->pos());
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);
copy->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
copy->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
copy->setUuid(this->uuid()); // this is OK for now as long as Widgets are imutable
copy->setUuid(this->uuid()); // This is OK for now, as long as pixmaps are immutable -
copy->setSourceUrl(this->sourceUrl());
copyItemParameters(copy);
// TODO UB 4.7 ... complete all members ?
return copy;
}
void UBGraphicsPixmapItem::copyItemParameters(UBItem *copy) const
{
UBGraphicsPixmapItem *cp = dynamic_cast<UBGraphicsPixmapItem*>(copy);
if (cp)
{
cp->setPixmap(this->pixmap());
cp->setPos(this->pos());
cp->setTransform(this->transform());
cp->setFlag(QGraphicsItem::ItemIsMovable, true);
cp->setFlag(QGraphicsItem::ItemIsSelectable, true);
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
cp->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
cp->setSourceUrl(this->sourceUrl());
}
}
UBGraphicsScene* UBGraphicsPixmapItem::scene()
{

@ -40,6 +40,8 @@ class UBGraphicsPixmapItem : public QObject, public QGraphicsPixmapItem, public
}
virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual UBGraphicsScene* scene();
virtual void remove();

@ -156,29 +156,37 @@ UBGraphicsPolygonItem* UBGraphicsPolygonItem::deepCopy(const QPolygonF& pol) con
{
UBGraphicsPolygonItem* copy = new UBGraphicsPolygonItem(pol);
copy->mOriginalLine = QLineF();
copy->mOriginalWidth = -1;
copy->mIsNominalLine = false;
copyItemParameters(copy);
copy->setStroke(this->stroke());
copy->setStrokesGroup(this->strokesGroup());
copy->setBrush(this->brush());
copy->setPen(this->pen());
copy->mHasAlpha = this->mHasAlpha;
// TODO UB 4.7 ... complete all members ?
return copy;
copy->setColorOnDarkBackground(this->colorOnDarkBackground());
copy->setColorOnLightBackground(this->colorOnLightBackground());
}
void UBGraphicsPolygonItem::copyItemParameters(UBItem *copy) const
{
UBGraphicsPolygonItem *cp = dynamic_cast<UBGraphicsPolygonItem*>(copy);
if (cp)
{
cp->mOriginalLine = QLineF();
cp->mOriginalWidth = -1;
cp->mIsNominalLine = false;
copy->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
cp->setStroke(this->stroke());
cp->setStrokesGroup(this->strokesGroup());
cp->setBrush(this->brush());
cp->setPen(this->pen());
cp->mHasAlpha = this->mHasAlpha;
// TODO UB 4.7 ... complete all members ?
return copy;
cp->setColorOnDarkBackground(this->colorOnDarkBackground());
cp->setColorOnLightBackground(this->colorOnLightBackground());
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
}
}
void UBGraphicsPolygonItem::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
{
if(mHasAlpha && scene() && scene()->isLightBackground())

@ -88,6 +88,7 @@ class UBGraphicsPolygonItem : public QGraphicsPolygonItem, public UBItem
// optimisation (eraser)
UBGraphicsPolygonItem* deepCopy(const QPolygonF& pol) const;
virtual void copyItemParameters(UBItem *copy) const;
QLineF originalLine() { return mOriginalLine;}
qreal originalWidth() { return mOriginalWidth;}

@ -1539,11 +1539,15 @@ void UBGraphicsScene::addGroup(UBGraphicsGroupContainerItem *groupItem)
setDocumentUpdated();
}
UBGraphicsSvgItem* UBGraphicsScene::addSvg(const QUrl& pSvgFileUrl, const QPointF& pPos)
UBGraphicsSvgItem* UBGraphicsScene::addSvg(const QUrl& pSvgFileUrl, const QPointF& pPos, const QByteArray pData)
{
QString path = pSvgFileUrl.toLocalFile();
UBGraphicsSvgItem *svgItem = new UBGraphicsSvgItem(path);
UBGraphicsSvgItem *svgItem;
if (pData.isNull())
svgItem = new UBGraphicsSvgItem(path);
else
svgItem = new UBGraphicsSvgItem(pData);
svgItem->setFlag(QGraphicsItem::ItemIsMovable, true);
svgItem->setFlag(QGraphicsItem::ItemIsSelectable, true);

@ -109,6 +109,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const {Q_UNUSED(copy);}
UBGraphicsScene* sceneDeepCopy() const;
void clearItemsAndAnnotations();
@ -136,7 +138,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
UBGraphicsMediaItem* addMedia(const QUrl& pMediaFileUrl, bool shouldPlayAsap, const QPointF& pPos = QPointF(0, 0));
UBGraphicsMediaItem* addVideo(const QUrl& pVideoFileUrl, bool shouldPlayAsap, const QPointF& pPos = QPointF(0, 0));
UBGraphicsMediaItem* addAudio(const QUrl& pAudioFileUrl, bool shouldPlayAsap, const QPointF& pPos = QPointF(0, 0));
UBGraphicsSvgItem* addSvg(const QUrl& pSvgFileUrl, const QPointF& pPos = QPointF(0, 0));
UBGraphicsSvgItem* addSvg(const QUrl& pSvgFileUrl, const QPointF& pPos = QPointF(0, 0), const QByteArray pData = QByteArray());
UBGraphicsTextItem* addText(const QString& pString, const QPointF& pTopLeft = QPointF(0, 0));
UBGraphicsTextItem* textForObjectName(const QString& pString, const QString &objectName = "UBTGZeroPageSessionTitle");

@ -63,16 +63,25 @@ UBItem* UBGraphicsStrokesGroup::deepCopy() const
{
UBGraphicsStrokesGroup* copy = new UBGraphicsStrokesGroup();
copy->setPos(this->pos());
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);
copy->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
copy->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
copyItemParameters(copy);
return copy;
}
void UBGraphicsStrokesGroup::copyItemParameters(UBItem *copy) const
{
UBGraphicsStrokesGroup *cp = dynamic_cast<UBGraphicsStrokesGroup*>(copy);
{
cp->setPos(this->pos());
cp->setTransform(this->transform());
cp->setFlag(QGraphicsItem::ItemIsMovable, true);
cp->setFlag(QGraphicsItem::ItemIsSelectable, true);
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
cp->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
}
}
void UBGraphicsStrokesGroup::remove()
{
if (mDelegate)

@ -14,6 +14,7 @@ public:
UBGraphicsStrokesGroup(QGraphicsItem* parent = 0);
~UBGraphicsStrokesGroup();
virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual void remove();
virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate;}
enum { Type = UBGraphicsItemType::StrokeItemType };

@ -135,14 +135,9 @@ UBItem* UBGraphicsSvgItem::deepCopy() const
{
UBGraphicsSvgItem* copy = new UBGraphicsSvgItem(this->fileData());
copy->setPos(this->pos());
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);
copy->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
copy->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
copy->setUuid(this->uuid()); // this is OK for now as long as SVG are imutable
copy->setSourceUrl(this->sourceUrl());
copy->setUuid(this->uuid()); // this is OK for now as long as Widgets are imutable
copyItemParameters(copy);
// TODO UB 4.7... complete all members ?
@ -150,6 +145,20 @@ UBItem* UBGraphicsSvgItem::deepCopy() const
}
void UBGraphicsSvgItem::copyItemParameters(UBItem *copy) const
{
UBGraphicsSvgItem *cp = dynamic_cast<UBGraphicsSvgItem*>(copy);
if (cp)
{
cp->setPos(this->pos());
cp->setTransform(this->transform());
cp->setFlag(QGraphicsItem::ItemIsMovable, true);
cp->setFlag(QGraphicsItem::ItemIsSelectable, true);
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
cp->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
cp->setSourceUrl(this->sourceUrl());
}
}
void UBGraphicsSvgItem::setRenderingQuality(RenderingQuality pRenderingQuality)
{

@ -52,6 +52,8 @@ class UBGraphicsSvgItem: public QGraphicsSvgItem, public UBItem, public UBGraphi
virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual void setRenderingQuality(RenderingQuality pRenderingQuality);
virtual UBGraphicsScene* scene();

@ -201,28 +201,36 @@ UBItem* UBGraphicsTextItem::deepCopy() const
{
UBGraphicsTextItem* copy = new UBGraphicsTextItem();
copy->setHtml(toHtml());
copy->setPos(this->pos());
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);
copy->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
copy->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
copy->setData(UBGraphicsItemData::ItemEditable, data(UBGraphicsItemData::ItemEditable).toBool());
// copy->setDefaultTextColor(this->defaultTextColor());
// copy->setFont(this->font());
// copy->setColorOnDarkBackground(this->colorOnDarkBackground());
// copy->setColorOnLightBackground(this->colorOnLightBackground());
copy->setTextWidth(this->textWidth());
copy->setTextHeight(this->textHeight());
copy->setSourceUrl(this->sourceUrl());
copyItemParameters(copy);
// TODO UB 4.7 ... complete all members ?
return copy;
}
void UBGraphicsTextItem::copyItemParameters(UBItem *copy) const
{
UBGraphicsTextItem *cp = dynamic_cast<UBGraphicsTextItem*>(copy);
if (cp)
{
cp->setHtml(toHtml());
cp->setPos(this->pos());
cp->setTransform(this->transform());
cp->setFlag(QGraphicsItem::ItemIsMovable, true);
cp->setFlag(QGraphicsItem::ItemIsSelectable, true);
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
cp->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
cp->setData(UBGraphicsItemData::ItemEditable, data(UBGraphicsItemData::ItemEditable).toBool());
// cp->setDefaultTextColor(this->defaultTextColor());
// cp->setFont(this->font());
// cp->setColorOnDarkBackground(this->colorOnDarkBackground());
// cp->setColorOnLightBackground(this->colorOnLightBackground());
cp->setTextWidth(this->textWidth());
cp->setTextHeight(this->textHeight());
cp->setSourceUrl(this->sourceUrl());
}
}
QRectF UBGraphicsTextItem::boundingRect() const
{

@ -40,6 +40,9 @@ class UBGraphicsTextItem : public QGraphicsTextItem, public UBItem, public UBRes
}
virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual UBGraphicsScene* scene();
virtual QRectF boundingRect() const;

@ -330,19 +330,29 @@ UBItem* UBGraphicsAppleWidgetItem::deepCopy() const
{
UBGraphicsAppleWidgetItem *appleWidget = new UBGraphicsAppleWidgetItem(mWebKitWidget->widgetUrl(), parentItem());
foreach(QString key, mPreferences.keys())
{
appleWidget->setPreference(key, mPreferences.value(key));
}
copyItemParameters(appleWidget);
return appleWidget;
foreach(QString key, mDatastore.keys())
}
void UBGraphicsAppleWidgetItem::copyItemParameters(UBItem *copy) const
{
UBGraphicsAppleWidgetItem *cp = dynamic_cast<UBGraphicsAppleWidgetItem*>(copy);
if (cp)
{
appleWidget->setDatastoreEntry(key, mDatastore.value(key));
}
foreach(QString key, mPreferences.keys())
{
cp->setPreference(key, mPreferences.value(key));
}
appleWidget->setSourceUrl(this->sourceUrl());
foreach(QString key, mDatastore.keys())
{
cp->setDatastoreEntry(key, mDatastore.value(key));
}
return appleWidget;
cp->setSourceUrl(this->sourceUrl());
}
}
void UBGraphicsAppleWidgetItem::setUuid(const QUuid &pUuid)
@ -431,27 +441,35 @@ UBW3CWidget* UBGraphicsW3CWidgetItem::w3cWidget() const
UBItem* UBGraphicsW3CWidgetItem::deepCopy() const
{
UBGraphicsW3CWidgetItem *copy = new UBGraphicsW3CWidgetItem(mWebKitWidget->widgetUrl(), parentItem());
copy->setPos(this->pos());
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);
copy->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
copy->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
copy->setUuid(this->uuid()); // this is OK for now as long as Widgets are imutable
copy->setSourceUrl(this->sourceUrl());
copyItemParameters(copy);
copy->resize(this->size());
return copy;
}
foreach(QString key, mPreferences.keys())
void UBGraphicsW3CWidgetItem::copyItemParameters(UBItem *copy) const
{
UBGraphicsW3CWidgetItem *cp = dynamic_cast<UBGraphicsW3CWidgetItem*>(copy);
if (cp)
{
copy->setPreference(key, mPreferences.value(key));
}
cp->setPos(this->pos());
cp->setTransform(this->transform());
cp->setFlag(QGraphicsItem::ItemIsMovable, true);
cp->setFlag(QGraphicsItem::ItemIsSelectable, true);
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
cp->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
cp->setSourceUrl(this->sourceUrl());
foreach(QString key, mDatastore.keys())
{
copy->setDatastoreEntry(key, mDatastore.value(key));
}
cp->resize(this->size());
return copy;
}
foreach(QString key, mPreferences.keys())
{
cp->setPreference(key, mPreferences.value(key));
}
foreach(QString key, mDatastore.keys())
{
cp->setDatastoreEntry(key, mDatastore.value(key));
}
}
}

@ -130,6 +130,9 @@ class UBGraphicsAppleWidgetItem : public UBGraphicsWidgetItem
}
virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual void setUuid(const QUuid &pUuid);
};
@ -152,6 +155,8 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
UBW3CWidget::Metadata metadatas() const;
UBW3CWidget* w3cWidget() const;

@ -20,6 +20,7 @@
#include "core/UB.h"
class UBGraphicsScene;
class UBGraphicsItem;
class UBItem
{
@ -58,6 +59,8 @@ class UBItem
virtual UBItem* deepCopy() const = 0;
virtual void copyItemParameters(UBItem *copy) const = 0;
virtual UBGraphicsScene* scene() // TODO UB 4.x should be pure virtual ...
{
return 0;

@ -53,6 +53,7 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
//mpSearchBtn = new UBActionButton(this, mpSearchAction);
mpRescanModelBtn = new UBActionButton(this, mpRescanModelAction);
mpRescanModelBtn->hide();
mpDeleteBtn = new UBActionButton(this, mpDeleteAction);
mpCloseBtn = new UBActionButton(this, mpCloseAction);
@ -124,7 +125,7 @@ void UBFeaturesActionBar::setButtons()
mpNewFolderBtn->show();
mpNewFolderBtn->setEnabled(true);
mpDeleteBtn->setEnabled(true);
mpRescanModelBtn->show();
// mpRescanModelBtn->show();
break;
case IN_ROOT:
mpFavoriteBtn->show();
@ -136,7 +137,7 @@ void UBFeaturesActionBar::setButtons()
mpNewFolderBtn->show();
mpNewFolderBtn->setEnabled(false);
mpDeleteBtn->setEnabled(false);
mpRescanModelBtn->show();
// mpRescanModelBtn->show();
break;
case IN_PROPERTIES:
mpFavoriteBtn->show();
@ -147,7 +148,7 @@ void UBFeaturesActionBar::setButtons()
mpCloseBtn->hide();
mpRemoveFavoriteBtn->hide();
mpNewFolderBtn->hide();
mpRescanModelBtn->hide();
// mpRescanModelBtn->hide();
break;
case IN_FAVORITE:
mpFavoriteBtn->hide();
@ -158,7 +159,7 @@ void UBFeaturesActionBar::setButtons()
mpCloseBtn->hide();
mpRemoveFavoriteBtn->show();
mpNewFolderBtn->hide();
mpRescanModelBtn->hide();
// mpRescanModelBtn->hide();
break;
case IN_TRASH:
mpFavoriteBtn->hide();
@ -171,7 +172,7 @@ void UBFeaturesActionBar::setButtons()
mpCloseBtn->hide();
//mpRemoveFavoriteBtn->show();
mpNewFolderBtn->hide();
mpRescanModelBtn->hide();
// mpRescanModelBtn->hide();
break;
default:
break;
@ -208,6 +209,16 @@ void UBFeaturesActionBar::onActionRescanModel()
emit rescanModel();
}
void UBFeaturesActionBar::lockIt()
{
setEnabled(false);
}
void UBFeaturesActionBar::unlockIt()
{
setEnabled(true);
}
void UBFeaturesActionBar::dragEnterEvent( QDragEnterEvent *event )
{
const UBFeaturesMimeData *fMimeData = qobject_cast<const UBFeaturesMimeData*>(event->mimeData());

@ -45,6 +45,8 @@ private slots:
void onActionRemoveFavorite();
void onActionTrash();
void onActionRescanModel();
void lockIt();
void unlockIt();
protected:
void dragEnterEvent( QDragEnterEvent *event );

@ -1,5 +1,4 @@
#include <QDomDocument>
#include "UBFeaturesWidget.h"
#include "domain/UBAbstractWidget.h"
#include "gui/UBThumbnailWidget.h"
@ -8,9 +7,14 @@
#include "core/UBDownloadManager.h"
#include "globals/UBGlobals.h"
#include "board/UBBoardController.h"
#include "globals/UBGlobals.h"
const char *UBFeaturesWidget::objNamePathList = "PathList";
const char *UBFeaturesWidget::objNameFeatureList = "FeatureList";
const char *objNamePathList = "PathList";
const char *objNameFeatureList = "FeatureList";
const QString UBFeaturesNewFolderDialog::acceptText = tr("Accept");
const QString UBFeaturesNewFolderDialog::cancelText = tr("Cancel");
const QString UBFeaturesNewFolderDialog::labelText = tr("Enter a new folder name");
const QMargins FeatureListMargins(0, 0, 0, 30);
const int FeatureListBorderOffset = 10;
@ -43,39 +47,20 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name)
pathListView = new UBFeaturesListView(this, objNamePathList);
controller->assignPathListView(pathListView);
//Maintains the view of the main part of the palette. Consists of
//mNavigator
//featureProperties
//webVeiw
stackedWidget = new QStackedWidget(this);
//Main features icon view with QSlider on the bottom
mNavigator = new UBFeaturesNavigatorWidget(this);
controller->assignFeaturesListVeiw(mNavigator->listView());
mNavigator->setSliderPosition(UBSettings::settings()->featureSliderPosition->get().toInt());
//Specifies the properties of a standalone element
featureProperties = new UBFeatureProperties(this);
//Used to show search bar on the search widget
webView = new UBFeaturesWebView(this);
//filling stackwidget
stackedWidget->addWidget(mNavigator);
stackedWidget->addWidget(featureProperties);
stackedWidget->addWidget(webView);
stackedWidget->setCurrentIndex(ID_LISTVIEW);
currentStackedWidget = ID_LISTVIEW;
centralWidget = new UBFeaturesCentralWidget(this);
controller->assignFeaturesListVeiw(centralWidget->listView());
centralWidget->setSliderPosition(UBSettings::settings()->featureSliderPosition->get().toInt());
//Bottom actionbar for DnD, quick search etc
mActionBar = new UBFeaturesActionBar(controller, this);
//Filling main layout
layout->addWidget(pathListView);
layout->addWidget(stackedWidget);
layout->addWidget(centralWidget);
layout->addWidget(mActionBar);
connect(mNavigator->listView(), SIGNAL(clicked(const QModelIndex &)), this, SLOT(currentSelected(const QModelIndex &)));
connect(centralWidget->listView(), SIGNAL(clicked(const QModelIndex &)), this, SLOT(currentSelected(const QModelIndex &)));
connect(this, SIGNAL(sendFileNameList(QStringList)), centralWidget, SIGNAL(sendFileNameList(QStringList)));
connect(mActionBar, SIGNAL(searchElement(const QString &)), this, SLOT( searchStarted(const QString &)));
connect(mActionBar, SIGNAL(newFolderToCreate()), this, SLOT(createNewFolder()));
connect(mActionBar, SIGNAL(deleteElements(const UBFeaturesMimeData *)), this, SLOT(deleteElements(const UBFeaturesMimeData *)));
@ -90,6 +75,14 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name)
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)));
connect(centralWidget, SIGNAL(lockMainWidget(bool)), this, SLOT(lockIt(bool)));
connect(centralWidget, SIGNAL(createNewFolderSignal(QString)), controller, SLOT(addNewFolder(QString)));
connect(controller, SIGNAL(scanStarted()), centralWidget, SLOT(scanStarted()));
connect(controller, SIGNAL(scanFinished()), centralWidget, SLOT(scanFinished()));
connect(controller, SIGNAL(scanStarted()), mActionBar, SLOT(lockIt()));
connect(controller, SIGNAL(scanFinished()), mActionBar, SLOT(unlockIt()));
connect(controller, SIGNAL(maxFilesCountEvaluated(int)), centralWidget, SIGNAL(maxFilesCountEvaluated(int)));
connect(controller, SIGNAL(featureAddedFromThread()), centralWidget, SLOT(increaseStatusBarValue()));
}
UBFeaturesWidget::~UBFeaturesWidget()
@ -100,7 +93,7 @@ UBFeaturesWidget::~UBFeaturesWidget()
void UBFeaturesWidget::searchStarted(const QString &pattern)
{
controller->searchStarted(pattern, mNavigator->listView());
controller->searchStarted(pattern, centralWidget->listView());
}
void UBFeaturesWidget::currentSelected(const QModelIndex &current)
@ -110,25 +103,16 @@ void UBFeaturesWidget::currentSelected(const QModelIndex &current)
return;
}
//Calling to reset the model for listView. Maybe separate function needed
controller->searchStarted("", mNavigator->listView());
QString objName = sender()->objectName();
if (objName.isEmpty()) {
qWarning() << "incorrrect sender";
} else if (objName == objNamePathList) {
//Calling to reset the model for listView. Maybe separate function needed
controller->searchStarted("", centralWidget->listView());
}
QListView *calledList = 0;
if (objName == objNamePathList) {
calledList = pathListView;
} else if (objName == objNameFeatureList) {
calledList = mNavigator->listView();
}
UBFeature feature = controller->getFeature(current, calledList);
// QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( mNavigator->listView()->model() );
// UBFeature feature = model->data(current, Qt::UserRole + 1).value<UBFeature>();
UBFeature feature = controller->getFeature(current, objName);
if ( feature.isFolder() ) {
QString newPath = feature.getFullVirtualPath();
@ -136,7 +120,7 @@ void UBFeaturesWidget::currentSelected(const QModelIndex &current)
controller->setCurrentElement(feature);
controller->siftElements(newPath);
switchToListView();
centralWidget->switchTo(UBFeaturesCentralWidget::MainList);
if ( feature.getType() == FEATURE_FAVORITE ) {
mActionBar->setCurrentState( IN_FAVORITE );
@ -145,35 +129,25 @@ void UBFeaturesWidget::currentSelected(const QModelIndex &current)
mActionBar->setCurrentState( IN_ROOT );
} else if (feature.getType() == FEATURE_TRASH) {
mActionBar->setCurrentState( IN_TRASH );
mActionBar->setCurrentState(IN_TRASH);
} else {
mActionBar->setCurrentState( IN_FOLDER );
mActionBar->setCurrentState(IN_FOLDER);
}
} else if ( feature.getType() == FEATURE_SEARCH ) {
webView->showElement( feature );
switchToWebView();
} else if (feature.getType() == FEATURE_SEARCH) {
centralWidget->showElement(feature, UBFeaturesCentralWidget::FeaturesWebView);
} else {
featureProperties->showElement( feature );
switchToProperties();
centralWidget->showElement(feature, UBFeaturesCentralWidget::FeaturePropertiesList);
mActionBar->setCurrentState( IN_PROPERTIES );
}
}
void UBFeaturesWidget::createNewFolder()
{
if (!mkFolderDlg)
{
mkFolderDlg = new UBNewFolderDlg(this);
connect (mkFolderDlg, SIGNAL(accepted()), this, SLOT(addFolder()));
}
mkFolderDlg->setWindowFlags(Qt::WindowStaysOnTopHint);
mkFolderDlg->resize(this->size().width()-20 ,80);
mkFolderDlg->move(5,this->size().height()-200);
mkFolderDlg->show();
centralWidget->showAdditionalData(UBFeaturesCentralWidget::NewFolderDialog, UBFeaturesCentralWidget::Modal);
emit sendFileNameList(controller->getFileNamesInFolders());
}
void UBFeaturesWidget::addFolder()
@ -203,7 +177,7 @@ void UBFeaturesWidget::deleteElements( const UBFeaturesMimeData * mimeData )
void UBFeaturesWidget::deleteSelectedElements()
{
QModelIndexList selected = mNavigator->listView()->selectionModel()->selectedIndexes();
QModelIndexList selected = centralWidget->listView()->selectionModel()->selectedIndexes();
foreach ( QModelIndex sel, selected )
{
@ -224,6 +198,14 @@ void UBFeaturesWidget::rescanModel()
controller->rescanModel();
}
void UBFeaturesWidget::lockIt(bool pLock)
{
mActionBar->setEnabled(!pLock);
pathListView->setEnabled(!pLock);
centralWidget->setLockedExcludingAdditional(pLock);
// pathListView->setLocked(true);
}
void UBFeaturesWidget::addToFavorite( const UBFeaturesMimeData * mimeData )
{
if ( !mimeData->hasUrls() )
@ -253,7 +235,7 @@ void UBFeaturesWidget::onDisplayMetadata( QMap<QString,QString> metadata )
{
QString previewImageUrl;
switch (UBFileSystemUtils::mimeTypeFromUrl(QUrl(metadata["Url"])))
switch (static_cast<int>(UBFileSystemUtils::mimeTypeFromUrl(QUrl(metadata["Url"]))))
{
case UBMimeType::RasterImage:
case UBMimeType::VectorImage:
@ -282,11 +264,10 @@ void UBFeaturesWidget::onDisplayMetadata( QMap<QString,QString> metadata )
}break;
}
UBFeature feature( QString(), QPixmap(previewImageUrl), QString(), metadata["Url"], FEATURE_ITEM );
UBFeature feature( QString(), QImage(previewImageUrl), QString(), metadata["Url"], FEATURE_ITEM );
feature.setMetadata( metadata );
featureProperties->showElement( feature );
switchToProperties();
centralWidget->showElement(feature, UBFeaturesCentralWidget::FeaturePropertiesList);
mActionBar->setCurrentState( IN_PROPERTIES );
}
@ -298,12 +279,14 @@ void UBFeaturesWidget::onPreviewLoaded(int id, bool pSuccess, QUrl sourceUrl, QS
Q_UNUSED(isBackground);
Q_UNUSED(pSize);
Q_UNUSED(pPos);
Q_UNUSED(sourceUrl);
Q_UNUSED(pContentTypeHeader)
QImage img;
img.loadFromData(pData);
QPixmap pix = QPixmap::fromImage(img);
featureProperties->setOrigPixmap(pix);
featureProperties->setThumbnail(pix);
centralWidget->setPropertiesPixmap(pix);
centralWidget->setPropertiesThumbnail(pix);
}
void UBFeaturesWidget::onAddDownloadedFileToLibrary(bool pSuccess, QUrl sourceUrl, QString pContentHeader, QByteArray pData)
@ -318,14 +301,14 @@ void UBFeaturesWidget::onAddDownloadedFileToLibrary(bool pSuccess, QUrl sourceUr
void UBFeaturesWidget::addElementsToFavorite()
{
if ( currentStackedWidget == ID_PROPERTIES ) {
UBFeature feature = featureProperties->getCurrentElement();
if ( centralWidget->currentView() == UBFeaturesCentralWidget::FeaturePropertiesList ) {
UBFeature feature = centralWidget->getCurElementFromProperties();
if ( feature != UBFeature() && !UBApplication::isFromWeb(feature.getFullPath().toString())) {
controller->addToFavorite( feature.getFullPath() );
}
} else if ( currentStackedWidget == ID_LISTVIEW ) {
QModelIndexList selected = mNavigator->listView()->selectionModel()->selectedIndexes();
} else if ( centralWidget->currentView() == UBFeaturesCentralWidget::MainList ) {
QModelIndexList selected = centralWidget->listView()->selectionModel()->selectedIndexes();
for ( int i = 0; i < selected.size(); ++i ) {
UBFeature feature = selected.at(i).data( Qt::UserRole + 1 ).value<UBFeature>();
controller->addToFavorite(feature.getFullPath());
@ -337,7 +320,7 @@ void UBFeaturesWidget::addElementsToFavorite()
void UBFeaturesWidget::removeElementsFromFavorite()
{
QModelIndexList selected = mNavigator->listView()->selectionModel()->selectedIndexes();
QModelIndexList selected = centralWidget->listView()->selectionModel()->selectedIndexes();
QList <QUrl> items;
for ( int i = 0; i < selected.size(); ++i ) {
UBFeature feature = selected.at(i).data( Qt::UserRole + 1 ).value<UBFeature>();
@ -363,20 +346,20 @@ void UBFeaturesWidget::resizeEvent(QResizeEvent *event)
void UBFeaturesWidget::switchToListView()
{
stackedWidget->setCurrentIndex(ID_LISTVIEW);
currentStackedWidget = ID_LISTVIEW;
// stackedWidget->setCurrentIndex(ID_LISTVIEW);
// currentStackedWidget = ID_LISTVIEW;
}
void UBFeaturesWidget::switchToProperties()
{
stackedWidget->setCurrentIndex(ID_PROPERTIES);
currentStackedWidget = ID_PROPERTIES;
// stackedWidget->setCurrentIndex(ID_PROPERTIES);
// currentStackedWidget = ID_PROPERTIES;
}
void UBFeaturesWidget::switchToWebView()
{
stackedWidget->setCurrentIndex(ID_WEBVIEW);
currentStackedWidget = ID_WEBVIEW;
// stackedWidget->setCurrentIndex(ID_WEBVIEW);
// currentStackedWidget = ID_WEBVIEW;
}
QStringList UBFeaturesMimeData::formats() const
@ -390,9 +373,9 @@ void UBFeaturesWidget::importImage(const QImage &image, const QString &fileName)
}
UBFeaturesListView::UBFeaturesListView( QWidget* parent, const char* name )
: QListView(parent)
: QListView(parent)
{
setObjectName(name);
setObjectName(name);
}
void UBFeaturesListView::dragEnterEvent( QDragEnterEvent *event )
@ -423,7 +406,7 @@ void UBFeaturesListView::dragMoveEvent( QDragMoveEvent *event )
void UBFeaturesListView::dropEvent( QDropEvent *event )
{
QWidget *eventSource = event->source();
if (eventSource && eventSource->objectName() == objNameFeatureList) {
if (eventSource && eventSource->objectName() == UBFeaturesWidget::objNameFeatureList) {
event->setDropAction( Qt::MoveAction );
}
@ -445,9 +428,9 @@ UBFeaturesNavigatorWidget::UBFeaturesNavigatorWidget(QWidget *parent, const char
name = "UBFeaturesNavigatorWidget";
setObjectName(name);
SET_STYLE_SHEET()
// SET_STYLE_SHEET()
mListView = new UBFeaturesListView(this, objNameFeatureList);
mListView = new UBFeaturesListView(this, UBFeaturesWidget::objNameFeatureList);
mListSlder = new QSlider(Qt::Horizontal, this);
@ -461,7 +444,7 @@ UBFeaturesNavigatorWidget::UBFeaturesNavigatorWidget(QWidget *parent, const char
mainLayer->addWidget(mListView, 1);
mainLayer->addWidget(mListSlder, 0);
mainLayer->setMargin(0);
connect(mListSlder, SIGNAL(valueChanged(int)), mListView, SLOT(thumbnailSizeChanged(int)));
}
@ -471,6 +454,229 @@ void UBFeaturesNavigatorWidget::setSliderPosition(int pValue)
mListSlder->setValue(pValue);
}
UBFeaturesCentralWidget::UBFeaturesCentralWidget(QWidget *parent) : QWidget(parent)
{
setObjectName("UBFeaturesCentralWidget");
SET_STYLE_SHEET();
QVBoxLayout *mLayout = new QVBoxLayout(this);
setLayout(mLayout);
//Maintains the view of the main part of the palette. Consists of
//mNavigator
//featureProperties
//webVeiw
mStackedWidget = new QStackedWidget(this);
//Main features icon view with QSlider on the bottom
mNavigator = new UBFeaturesNavigatorWidget(this);
//Specifies the properties of a standalone element
mFeatureProperties = new UBFeatureProperties(this);
//Used to show search bar on the search widget
webView = new UBFeaturesWebView(this);
//filling stackwidget
mStackedWidget->addWidget(mNavigator);
mStackedWidget->addWidget(mFeatureProperties);
mStackedWidget->addWidget(webView);
mStackedWidget->setCurrentIndex(MainList);
mStackedWidget->setContentsMargins(0, 0, 0, 0);
mAdditionalDataContainer = new QStackedWidget(this);
mAdditionalDataContainer->setObjectName("mAdditionalDataContainer");
//New folder dialog
UBFeaturesNewFolderDialog *dlg = new UBFeaturesNewFolderDialog(mAdditionalDataContainer);
mAdditionalDataContainer->addWidget(dlg);
mAdditionalDataContainer->setCurrentIndex(NewFolderDialog);
connect(dlg, SIGNAL(createNewFolder(QString)), this, SLOT(createNewFolderSlot(QString)));
connect(dlg, SIGNAL(closeDialog()), this, SLOT(hideAdditionalData()));
connect(this, SIGNAL(sendFileNameList(QStringList)), dlg, SLOT(setFileNameList(QStringList)));
//Progress bar to show scanning progress
QProgressBar *progressBar = new QProgressBar();
mAdditionalDataContainer->addWidget(progressBar);
mAdditionalDataContainer->setCurrentIndex(ProgressBarWidget);
progressBar->setMinimum(0);
progressBar->setValue(0);
progressBar->setMaximum(10000);
connect(this, SIGNAL(maxFilesCountEvaluated(int)), progressBar, SLOT(setMaximum(int)));
mLayout->addWidget(mStackedWidget, 1);
mLayout->addWidget(mAdditionalDataContainer, 0);
mAdditionalDataContainer->hide();
}
void UBFeaturesCentralWidget::showElement(const UBFeature &feature, StackElement pView)
{
if (pView == FeaturesWebView) {
webView->showElement(feature);
mStackedWidget->setCurrentIndex(FeaturesWebView);
} else if (pView == FeaturePropertiesList) {
mFeatureProperties->showElement(feature);
mStackedWidget->setCurrentIndex(FeaturePropertiesList);
}
}
void UBFeaturesCentralWidget::switchTo(StackElement pView)
{
mStackedWidget->setCurrentIndex(pView);
}
void UBFeaturesCentralWidget::setPropertiesPixmap(const QPixmap &pix)
{
mFeatureProperties->setOrigPixmap(pix);
}
void UBFeaturesCentralWidget::setPropertiesThumbnail(const QPixmap &pix)
{
mFeatureProperties->setThumbnail(pix);
}
UBFeature UBFeaturesCentralWidget::getCurElementFromProperties()
{
return mFeatureProperties->getCurrentElement();
}
void UBFeaturesCentralWidget::showAdditionalData(AddWidget pWidgetType, AddWidgetState pState)
{
mAdditionalDataContainer->setMaximumHeight(mAdditionalDataContainer->widget(pWidgetType)->sizeHint().height());
mAdditionalDataContainer->setCurrentIndex(pWidgetType);
mAdditionalDataContainer->show();
emit lockMainWidget(pState == Modal ? true : false);
}
void UBFeaturesCentralWidget::setLockedExcludingAdditional(bool pLock)
{
// Lock all the members excluding mAdditionalDataContainer
mStackedWidget->setEnabled(!pLock);
}
void UBFeaturesCentralWidget::createNewFolderSlot(QString pStr)
{
emit createNewFolderSignal(pStr);
hideAdditionalData();
}
void UBFeaturesCentralWidget::hideAdditionalData()
{
emit lockMainWidget(false);
mAdditionalDataContainer->hide();
}
void UBFeaturesCentralWidget::scanStarted()
{
if (!mAdditionalDataContainer->widget(ProgressBarWidget)) {
return;
}
QProgressBar *progressBar = qobject_cast<QProgressBar*>(mAdditionalDataContainer->widget(ProgressBarWidget));
if (progressBar && !progressBar->isVisible()) {
showAdditionalData((AddWidget)1);
}
}
void UBFeaturesCentralWidget::scanFinished()
{
if (!mAdditionalDataContainer->widget(ProgressBarWidget)) {
return;
}
QProgressBar *progressBar = qobject_cast<QProgressBar*>(mAdditionalDataContainer->widget(ProgressBarWidget));
if (progressBar && progressBar->isVisible()) {
hideAdditionalData();
qDebug() << "progressBar max value is " << progressBar->maximum();
}
}
void UBFeaturesCentralWidget::increaseStatusBarValue()
{
if (!mAdditionalDataContainer->widget(ProgressBarWidget)) {
return;
}
QProgressBar *progressBar = qobject_cast<QProgressBar*>(mAdditionalDataContainer->widget(ProgressBarWidget));
if (progressBar) {
progressBar->setValue(progressBar->value() + 1);
}
}
UBFeaturesNewFolderDialog::UBFeaturesNewFolderDialog(QWidget *parent) : QWidget(parent)
{
this->setStyleSheet("background:white;");
QVBoxLayout *mainLayout = new QVBoxLayout();
setLayout(mainLayout);
QVBoxLayout *labelLayout = new QVBoxLayout(this);
QLabel *mLabel = new QLabel(labelText, this);
mLineEdit = new QLineEdit(this);
mValidator = new QRegExpValidator(QRegExp("[^\\/\\:\\?\\*\\|\\<\\>\\\"]{2,}"), this);
mLineEdit->setValidator(mValidator);
labelLayout->addWidget(mLabel);
labelLayout->addWidget(mLineEdit);
QHBoxLayout *buttonLayout = new QHBoxLayout(this);
acceptButton = new QPushButton(acceptText, this);
QPushButton *cancelButton = new QPushButton(cancelText, this);
buttonLayout->addWidget(acceptButton);
buttonLayout->addWidget(cancelButton);
mainLayout->addLayout(labelLayout);
mainLayout->addLayout(buttonLayout);
acceptButton->setEnabled(false);
connect(acceptButton, SIGNAL(clicked()), this, SLOT(accept()));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
connect(mLineEdit, SIGNAL(textEdited(QString)), this, SLOT(reactOnTextChanged(QString)));
reactOnTextChanged(QString());
}
void UBFeaturesNewFolderDialog::setRegexp(const QRegExp pRegExp)
{
mValidator->setRegExp(pRegExp);
}
bool UBFeaturesNewFolderDialog::validString(const QString &pStr)
{
return mLineEdit->hasAcceptableInput() && !mFileNameList.contains(pStr, Qt::CaseSensitive);
}
void UBFeaturesNewFolderDialog::accept()
{
// Setting all the constraints we need
emit createNewFolder(mLineEdit->text());
mLineEdit->clear();
}
void UBFeaturesNewFolderDialog::reject()
{
mLineEdit->clear();
emit closeDialog();
}
void UBFeaturesNewFolderDialog::setFileNameList(const QStringList &pLst)
{
mFileNameList = pLst;
}
void UBFeaturesNewFolderDialog::reactOnTextChanged(const QString &pStr)
{
if (validString(pStr)) {
acceptButton->setEnabled(true);
mLineEdit->setStyleSheet("background:white;");
} else {
acceptButton->setEnabled(false);
mLineEdit->setStyleSheet("background:#FFB3C8;");
}
}
UBFeaturesWebView::UBFeaturesWebView(QWidget* parent, const char* name):QWidget(parent)
, mpView(NULL)
, mpWebSettings(NULL)
@ -499,6 +705,7 @@ UBFeaturesWebView::UBFeaturesWebView(QWidget* parent, const char* name):QWidget(
mpWebSettings->setAttribute(QWebSettings::DnsPrefetchEnabled, true);
mpLayout->addWidget(mpView);
mpLayout->setMargin(0);
connect(mpView, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool)));
}
@ -578,8 +785,6 @@ UBFeatureProperties::UBFeatureProperties( QWidget *parent, const char *name ) :
{
setObjectName(name);
SET_STYLE_SHEET();
// Create the GUI
mpLayout = new QVBoxLayout(this);
setLayout(mpLayout);
@ -625,6 +830,7 @@ UBFeatureProperties::UBFeatureProperties( QWidget *parent, const char *name ) :
mpObjInfos->setObjectName("DockPaletteWidgetBox");
mpObjInfos->setStyleSheet("background:white;");
mpLayout->addWidget(mpObjInfos, 1);
mpLayout->setMargin(0);
connect( mpAddPageButton, SIGNAL(clicked()), this, SLOT(onAddToPage()) );
connect( mpSetAsBackgroundButton, SIGNAL( clicked() ), this, SLOT( onSetAsBackground() ) );
@ -700,7 +906,7 @@ UBFeature UBFeatureProperties::getCurrentElement() const
return UBFeature();
}
void UBFeatureProperties::setOrigPixmap(QPixmap &pix)
void UBFeatureProperties::setOrigPixmap(const QPixmap &pix)
{
if (mpOrigPixmap)
@ -709,7 +915,7 @@ void UBFeatureProperties::setOrigPixmap(QPixmap &pix)
mpOrigPixmap = new QPixmap(pix);
}
void UBFeatureProperties::setThumbnail(QPixmap &pix)
void UBFeatureProperties::setThumbnail(const QPixmap &pix)
{
mpThumbnail->setPixmap(pix.scaledToWidth(THUMBNAIL_WIDTH));
adaptSize();
@ -730,7 +936,7 @@ void UBFeatureProperties::adaptSize()
}
}
void UBFeatureProperties::showElement( const UBFeature &elem )
void UBFeatureProperties::showElement(const UBFeature &elem)
{
if ( mpOrigPixmap )
{
@ -742,9 +948,9 @@ void UBFeatureProperties::showElement( const UBFeature &elem )
delete mpElement;
mpElement = NULL;
}
mpElement = new UBFeature( elem );
mpOrigPixmap = new QPixmap( elem.getThumbnail() );
mpThumbnail->setPixmap(elem.getThumbnail().scaledToWidth(THUMBNAIL_WIDTH));
mpElement = new UBFeature(elem);
mpOrigPixmap = new QPixmap(QPixmap::fromImage(elem.getThumbnail()));
mpThumbnail->setPixmap(QPixmap::fromImage(elem.getThumbnail()).scaledToWidth(THUMBNAIL_WIDTH));
populateMetadata();
if ( UBApplication::isFromWeb( elem.getFullPath().toString() ) )
@ -794,8 +1000,8 @@ void UBFeatureProperties::populateMetadata()
void UBFeatureProperties::onAddToPage()
{
QWidget *w = parentWidget()->parentWidget();
UBFeaturesWidget* featuresWidget = dynamic_cast<UBFeaturesWidget*>( w );
QWidget *w = parentWidget()->parentWidget()->parentWidget();
UBFeaturesWidget* featuresWidget = qobject_cast<UBFeaturesWidget*>( w );
if (featuresWidget)
featuresWidget->getFeaturesController()->addItemToPage( *mpElement );
}
@ -818,8 +1024,8 @@ void UBFeatureProperties::onAddToLib()
void UBFeatureProperties::onSetAsBackground()
{
QWidget *w = parentWidget()->parentWidget();
UBFeaturesWidget* featuresWidget = dynamic_cast<UBFeaturesWidget*>( w );
QWidget *w = parentWidget()->parentWidget()->parentWidget();
UBFeaturesWidget* featuresWidget = qobject_cast<UBFeaturesWidget*>( w );
featuresWidget->getFeaturesController()->addItemAsBackground( *mpElement );
}
@ -845,7 +1051,7 @@ QVariant UBFeaturesModel::data(const QModelIndex &index, int role) const
}
else if (role == Qt::DecorationRole) {
return QIcon( featuresList->at(index.row()).getThumbnail() );
return QIcon( QPixmap::fromImage(featuresList->at(index.row()).getThumbnail()));
} else if (role == Qt::UserRole) {
return featuresList->at(index.row()).getVirtualPath();
@ -1017,7 +1223,7 @@ void UBFeaturesModel::moveData(const UBFeature &source, const UBFeature &destina
QString sourceVirtualPath = source.getVirtualPath();
UBFeatureElementType sourceType = source.getType();
QPixmap sourceIcon = source.getThumbnail();
QImage sourceIcon = source.getThumbnail();
Q_ASSERT( QFileInfo( sourcePath ).exists() );
@ -1183,7 +1389,7 @@ void UBFeaturesPathItemDelegate::paint( QPainter *painter, const QStyleOptionVie
{
painter->drawPixmap( rect.left() - 10, rect.center().y() - 5, *arrowPixmap );
}
painter->drawPixmap( rect.left() + 5, rect.center().y() - 5, feature.getThumbnail().scaledToHeight( 30, Qt::SmoothTransformation ) );
painter->drawImage( rect.left() + 5, rect.center().y() - 5, feature.getThumbnail().scaledToHeight( 30, Qt::SmoothTransformation ) );
}
UBFeaturesPathItemDelegate::~UBFeaturesPathItemDelegate()

@ -43,6 +43,8 @@ class UBFeaturesListView;
class UBFeaturesWebView;
class UBFeaturesNavigatorWidget;
class UBFeaturesMimeData;
class UBFeaturesCentralWidget;
class UBFeaturesNewFolderDialog;
class UBFeaturesWidget : public UBDockPaletteWidget
{
@ -63,10 +65,16 @@ public:
static const int maxThumbnailSize = 100;
static const int defaultThumbnailSize = 40;
static const char *objNamePathList;
static const char *objNameFeatureList;
public:
int scrollbarHorisontalPadding() const { return 10;}
int scrollbarVerticalIndent() const { return 0;}
signals:
void sendFileNameList(const QStringList lst);
private slots:
void onPreviewLoaded(int id, bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground);
void currentSelected( const QModelIndex & );
@ -82,6 +90,7 @@ private slots:
void removeElementsFromFavorite();
void deleteSelectedElements();
void rescanModel();
void lockIt(bool pLock);
private:
void resizeEvent(QResizeEvent *event);
@ -91,17 +100,12 @@ private:
private:
UBFeaturesController *controller;
UBFeaturesNavigatorWidget *mNavigator;
UBFeaturesListView *pathListView;
QVBoxLayout *layout;
UBFeaturesActionBar *mActionBar;
UBFeatureProperties *featureProperties;
UBFeaturesWebView *webView;
QStackedWidget *stackedWidget;
int currentStackedWidget;
UBDownloadHttpFile* imageGatherer;
UBNewFolderDlg *mkFolderDlg;
UBFeaturesCentralWidget *centralWidget;
};
@ -128,12 +132,13 @@ public:
virtual ~UBFeaturesListView() {;}
protected:
virtual void dragEnterEvent( QDragEnterEvent *event );
virtual void dragEnterEvent( QDragEnterEvent *event );
virtual void dropEvent( QDropEvent *event );
virtual void dragMoveEvent( QDragMoveEvent *event );
private slots:
void thumbnailSizeChanged(int);
};
@ -153,6 +158,99 @@ private:
};
class UBFeaturesCentralWidget : public QWidget
{
Q_OBJECT
public:
enum StackElement{
MainList = 0,
FeaturePropertiesList,
FeaturesWebView
};
enum AddWidget {
NewFolderDialog = 0,
ProgressBarWidget
};
enum AddWidgetState {
NonModal = 0,
Modal
};
UBFeaturesCentralWidget(QWidget *parent = 0);
void setSliderPosition(int pValue) {mNavigator->setSliderPosition(pValue);}
UBFeaturesListView *listView() {return mNavigator->listView();}
void showElement(const UBFeature &feature, StackElement pView);
void switchTo(StackElement pView);
void setPropertiesPixmap(const QPixmap &pix);
void setPropertiesThumbnail(const QPixmap &pix);
StackElement currentView() const {return static_cast<StackElement>(mStackedWidget->currentIndex());}
UBFeature getCurElementFromProperties();
void showAdditionalData(AddWidget pWidgetType, AddWidgetState pState = NonModal);
void setLockedExcludingAdditional(bool pLock);
QStackedWidget *mStackedWidget;
UBFeaturesNavigatorWidget *mNavigator;
UBFeatureProperties *mFeatureProperties;
UBFeaturesWebView *webView;
QStackedWidget *mAdditionalDataContainer;
signals:
void lockMainWidget(bool pLock);
void createNewFolderSignal(QString pStr);
void sendFileNameList(const QStringList lst);
// progressbar widget related signals
void maxFilesCountEvaluated(int pValue);
private slots:
void createNewFolderSlot(QString pStr);
void hideAdditionalData();
void scanStarted();
void scanFinished();
void increaseStatusBarValue();
private:
};
class UBFeaturesNewFolderDialog : public QWidget
{
Q_OBJECT
public:
static const QString acceptText;
static const QString cancelText;
static const QString labelText;
UBFeaturesNewFolderDialog(QWidget *parent = 0);
void setRegexp(const QRegExp pRegExp);
bool validString(const QString &pStr);
signals:
void createNewFolder(QString str);
void closeDialog();
private slots:
void accept();
void reject();
void setFileNameList(const QStringList &pLst);
void reactOnTextChanged(const QString &pStr);
private:
QLineEdit *mLineEdit;
QRegExpValidator *mValidator;
QStringList mFileNameList;
QPushButton *acceptButton;
};
class UBFeaturesWebView : public QWidget
{
@ -182,8 +280,8 @@ public:
void showElement(const UBFeature &elem);
UBFeature getCurrentElement() const;
void setOrigPixmap(QPixmap &pix);
void setThumbnail(QPixmap &pix);
void setOrigPixmap(const QPixmap &pix);
void setThumbnail(const QPixmap &pix);
protected:
void resizeEvent(QResizeEvent *event);
@ -231,7 +329,6 @@ public:
UBFeaturesModel(QList<UBFeature> *pFeaturesList, QObject *parent = 0) : QAbstractListModel(parent), featuresList(pFeaturesList) {;}
virtual ~UBFeaturesModel(){;}
void addItem( const UBFeature &item );
void deleteFavoriteItem( const QString &path );
void deleteItem( const QString &path );
void deleteItem(const UBFeature &feature);
@ -251,6 +348,9 @@ public:
Qt::DropActions supportedDropActions() const { return Qt::MoveAction | Qt::CopyAction; }
// void setFeaturesList(QList <UBFeature> *flist ) { featuresList = flist; }
public slots:
void addItem( const UBFeature &item );
private:
QList <UBFeature> *featuresList;
};
@ -314,4 +414,5 @@ private:
QPixmap *arrowPixmap;
};
#endif // UBFEATURESWIDGET_H

@ -45,15 +45,24 @@ UBItem* UBGraphicsCache::deepCopy() const
{
UBGraphicsCache* copy = new UBGraphicsCache();
copy->setPos(this->pos());
copy->setRect(this->rect());
copy->setTransform(this->transform());
copyItemParameters(copy);
// TODO UB 4.7 ... complete all members ?
return copy;
}
void UBGraphicsCache::copyItemParameters(UBItem *copy) const
{
UBGraphicsCache *cp = dynamic_cast<UBGraphicsCache*>(copy);
if (cp)
{
cp->setPos(this->pos());
cp->setRect(this->rect());
cp->setTransform(this->transform());
}
}
QColor UBGraphicsCache::maskColor()
{
return mMaskColor;

@ -39,6 +39,8 @@ public:
virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
QColor maskColor();
void setMaskColor(QColor color);
eMaskShape maskshape();

@ -86,15 +86,24 @@ UBItem* UBGraphicsCompass::deepCopy() const
{
UBGraphicsCompass* copy = new UBGraphicsCompass();
copy->setPos(this->pos());
copy->setRect(this->rect());
copy->setTransform(this->transform());
copyItemParameters(copy);
// TODO UB 4.7 ... complete all members ?
return copy;
}
void UBGraphicsCompass::copyItemParameters(UBItem *copy) const
{
UBGraphicsCompass *cp = dynamic_cast<UBGraphicsCompass*>(copy);
if (cp)
{
cp->setPos(this->pos());
cp->setRect(this->rect());
cp->setTransform(this->transform());
}
}
void UBGraphicsCompass::paint(QPainter *painter, const QStyleOptionGraphicsItem *styleOption, QWidget *widget)
{
Q_UNUSED(styleOption);

@ -41,6 +41,8 @@ class UBGraphicsCompass: public QObject, public QGraphicsRectItem, public UBItem
virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
signals:
void hidden();

@ -133,20 +133,28 @@ UBItem* UBGraphicsCurtainItem::deepCopy() const
{
UBGraphicsCurtainItem* copy = new UBGraphicsCurtainItem();
copy->setRect(this->rect());
copy->setPos(this->pos());
copy->setBrush(this->brush());
copy->setPen(this->pen());
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);
copy->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
copyItemParameters(copy);
// TODO UB 4.7 ... complete all members ?
return copy;
}
void UBGraphicsCurtainItem::copyItemParameters(UBItem *copy) const
{
UBGraphicsCurtainItem *cp = dynamic_cast<UBGraphicsCurtainItem*>(copy);
if (cp)
{
cp->setRect(this->rect());
cp->setPos(this->pos());
cp->setBrush(this->brush());
cp->setPen(this->pen());
cp->setTransform(this->transform());
cp->setFlag(QGraphicsItem::ItemIsMovable, true);
cp->setFlag(QGraphicsItem::ItemIsSelectable, true);
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
}
}
QColor UBGraphicsCurtainItem::drawColor() const
{

@ -42,6 +42,7 @@ class UBGraphicsCurtainItem : public QObject, public QGraphicsRectItem, public U
}
virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual void remove();

@ -579,20 +579,27 @@ UBItem* UBGraphicsProtractor::deepCopy() const
{
UBGraphicsProtractor* copy = new UBGraphicsProtractor();
copy->setPos(this->pos());
copy->setRect(this->rect());
copy->setTransform(this->transform());
copy->mCurrentAngle = this->mCurrentAngle;
copy->mSpan = this->mSpan;
copy->mStartAngle = this->mStartAngle;
copy->mScaleFactor = this->mScaleFactor;
copyItemParameters(copy);
// TODO UB 4.7 ... complete all members ?
return copy;
}
void UBGraphicsProtractor::copyItemParameters(UBItem *copy) const
{
UBGraphicsProtractor *cp = dynamic_cast<UBGraphicsProtractor*>(copy);
if (cp)
{
cp->setPos(this->pos());
cp->setRect(this->rect());
cp->setTransform(this->transform());
cp->mCurrentAngle = this->mCurrentAngle;
cp->mSpan = this->mSpan;
cp->mStartAngle = this->mStartAngle;
cp->mScaleFactor = this->mScaleFactor;
}
}
void UBGraphicsProtractor::rotateAroundCenter(qreal angle)
{

@ -40,6 +40,7 @@ class UBGraphicsProtractor : public UBAbstractDrawRuler, public QGraphicsEllipse
void setMarkerAngle (qreal angle) { mCurrentAngle = angle; }
virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
enum { Type = UBGraphicsItemType::ProtractorItemType };

@ -75,15 +75,24 @@ UBItem* UBGraphicsRuler::deepCopy() const
{
UBGraphicsRuler* copy = new UBGraphicsRuler();
copy->setPos(this->pos());
copy->setRect(this->rect());
copy->setTransform(this->transform());
copyItemParameters(copy);
// TODO UB 4.7 ... complete all members ?
return copy;
}
void UBGraphicsRuler::copyItemParameters(UBItem *copy) const
{
UBGraphicsRuler *cp = dynamic_cast<UBGraphicsRuler*>(copy);
if (cp)
{
cp->setPos(this->pos());
cp->setRect(this->rect());
cp->setTransform(this->transform());
}
}
void UBGraphicsRuler::paint(QPainter *painter, const QStyleOptionGraphicsItem *styleOption, QWidget *widget)
{
Q_UNUSED(styleOption);

@ -41,6 +41,7 @@ class UBGraphicsRuler : public UBAbstractDrawRuler, public QGraphicsRectItem, pu
}
virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual void StartLine(const QPointF& position, qreal width);
virtual void DrawLine(const QPointF& position, qreal width);

@ -94,9 +94,7 @@ UBItem* UBGraphicsTriangle::deepCopy(void) const
{
UBGraphicsTriangle* copy = new UBGraphicsTriangle();
copy->setPos(this->pos());
copy->setPolygon(this->polygon());
copy->setTransform(this->transform());
copyItemParameters(copy);
// TODO UB 4.7 ... complete all members ?
@ -104,6 +102,17 @@ UBItem* UBGraphicsTriangle::deepCopy(void) const
}
void UBGraphicsTriangle::copyItemParameters(UBItem *copy) const
{
UBGraphicsTriangle* cp = dynamic_cast<UBGraphicsTriangle*>(copy);
if (cp)
{
cp->setPos(this->pos());
cp->setPolygon(this->polygon());
cp->setTransform(this->transform());
}
}
void UBGraphicsTriangle::setRect(qreal x, qreal y, qreal w, qreal h, UBGraphicsTriangleOrientation orientation)
{
QPolygonF polygon;

@ -45,6 +45,7 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt
virtual UBItem* deepCopy(void) const;
virtual void copyItemParameters(UBItem *copy) const;
virtual void StartLine(const QPointF& scenePos, qreal width);
virtual void DrawLine(const QPointF& position, qreal width);

Loading…
Cancel
Save