Merge branch 'develop' of github.com:Sankore/Sankore-3.1 into aleksei_kanash_dev

preferencesAboutTextFull
Aleksei Kanash 12 years ago
commit 1a799632ab
  1. BIN
      resources/images/toque.png
  2. 1
      resources/sankore.qrc
  3. 2
      src/adaptors/UBSvgSubsetAdaptor.cpp
  4. 2
      src/api/UBWidgetMessageAPI.cpp
  5. 4
      src/board/UBBoardController.cpp
  6. 14
      src/board/UBFeaturesController.cpp
  7. 3
      src/core/UBPersistenceManager.cpp
  8. 23
      src/document/UBDocumentController.cpp
  9. 36
      src/domain/UBGraphicsGroupContainerItem.cpp
  10. 5
      src/domain/UBGraphicsGroupContainerItem.h
  11. 2
      src/domain/UBGraphicsItemDelegate.cpp
  12. 4
      src/domain/UBGraphicsItemGroupUndoCommand.cpp
  13. 62
      src/domain/UBGraphicsItemUndoCommand.cpp
  14. 6
      src/domain/UBGraphicsItemUndoCommand.h
  15. 23
      src/domain/UBGraphicsMediaItem.cpp
  16. 1
      src/domain/UBGraphicsMediaItem.h
  17. 24
      src/domain/UBGraphicsPDFItem.cpp
  18. 4
      src/domain/UBGraphicsPDFItem.h
  19. 29
      src/domain/UBGraphicsPixmapItem.cpp
  20. 3
      src/domain/UBGraphicsPixmapItem.h
  21. 37
      src/domain/UBGraphicsProxyWidget.cpp
  22. 8
      src/domain/UBGraphicsProxyWidget.h
  23. 22
      src/domain/UBGraphicsScene.cpp
  24. 2
      src/domain/UBGraphicsScene.h
  25. 29
      src/domain/UBGraphicsStrokesGroup.cpp
  26. 2
      src/domain/UBGraphicsStrokesGroup.h
  27. 25
      src/domain/UBGraphicsSvgItem.cpp
  28. 3
      src/domain/UBGraphicsSvgItem.h
  29. 51
      src/domain/UBGraphicsTextItem.cpp
  30. 3
      src/domain/UBGraphicsTextItem.h
  31. 152
      src/domain/UBGraphicsWebView.cpp
  32. 61
      src/domain/UBGraphicsWebView.h
  33. 127
      src/domain/UBGraphicsWidgetItem.cpp
  34. 19
      src/domain/UBGraphicsWidgetItem.h
  35. 24
      src/domain/UBItem.cpp
  36. 22
      src/domain/UBItem.h
  37. 6
      src/domain/domain.pri
  38. 32
      src/gui/UBDocumentNavigator.cpp
  39. 96
      src/gui/UBTeacherGuideWidget.cpp
  40. 9
      src/gui/UBTeacherGuideWidget.h
  41. 14
      src/gui/UBTeacherGuideWidgetsTools.cpp
  42. 2
      src/gui/UBTeacherGuideWidgetsTools.h
  43. 11
      src/pdf-merger/Utils.cpp
  44. 23
      src/tools/UBGraphicsCurtainItem.cpp
  45. 3
      src/tools/UBGraphicsCurtainItem.h
  46. 5
      src/tools/UBGraphicsCurtainItemDelegate.h

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

@ -365,5 +365,6 @@
<file>images/teacherGuide/pencil.svg</file> <file>images/teacherGuide/pencil.svg</file>
<file>images/duplicateDisabled.svg</file> <file>images/duplicateDisabled.svg</file>
<file>images/teacherGuide/flash_24x24.svg</file> <file>images/teacherGuide/flash_24x24.svg</file>
<file>images/toque.png</file>
</qresource> </qresource>
</RCC> </RCC>

@ -1084,7 +1084,7 @@ QGraphicsItem *UBSvgSubsetAdaptor::UBSvgSubsetReader::readElementFromGroup()
{ {
QGraphicsItem *result = 0; QGraphicsItem *result = 0;
result = mScene->itemByUuid(QUuid(mXmlReader.attributes().value(aId).toString())); result = mScene->itemForUuid(QUuid(mXmlReader.attributes().value(aId).toString()));
mXmlReader.skipCurrentElement(); mXmlReader.skipCurrentElement();
mXmlReader.readNext(); mXmlReader.readNext();

@ -17,8 +17,6 @@
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "domain/UBGraphicsWebView.h"
#include "core/memcheck.h" #include "core/memcheck.h"
UBWidgetMessageAPI::UBWidgetMessageAPI(UBGraphicsWidgetItem *graphicsWidgetItem, QObject *parent) UBWidgetMessageAPI::UBWidgetMessageAPI(UBGraphicsWidgetItem *graphicsWidgetItem, QObject *parent)

@ -1132,7 +1132,7 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QStri
QString destFile; QString destFile;
bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(selectedDocument(), bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(selectedDocument(),
"", sourceUrl.toString(),
UBPersistenceManager::videoDirectory, UBPersistenceManager::videoDirectory,
uuid, uuid,
destFile, destFile,
@ -1175,7 +1175,7 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QStri
QString destFile; QString destFile;
bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(selectedDocument(), bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(selectedDocument(),
"", sourceUrl.toString(),
UBPersistenceManager::audioDirectory, UBPersistenceManager::audioDirectory,
uuid, uuid,
destFile, destFile,

@ -144,7 +144,7 @@ void UBFeaturesComputingThread::compute(const QList<QPair<QUrl, UBFeature> > &pS
void UBFeaturesComputingThread::run() void UBFeaturesComputingThread::run()
{ {
forever { forever {
qDebug() << "Custom thread started execution"; // qDebug() << "Custom thread started execution";
mMutex.lock(); mMutex.lock();
QList<QPair<QUrl, UBFeature> > searchData = mScanningData; QList<QPair<QUrl, UBFeature> > searchData = mScanningData;
@ -158,17 +158,17 @@ void UBFeaturesComputingThread::run()
break; break;
} }
QTime curTime = QTime::currentTime(); // QTime curTime = QTime::currentTime();
int fsCnt = featuresCountAll(searchData); int fsCnt = featuresCountAll(searchData);
int msecsto = curTime.msecsTo(QTime::currentTime()); // int msecsto = curTime.msecsTo(QTime::currentTime());
qDebug() << "time on evaluation" << msecsto; // qDebug() << "time on evaluation" << msecsto;
emit maxFilesCountEvaluated(fsCnt); emit maxFilesCountEvaluated(fsCnt);
emit scanStarted(); emit scanStarted();
curTime = QTime::currentTime(); // curTime = QTime::currentTime();
scanAll(searchData, favoriteSet); scanAll(searchData, favoriteSet);
qDebug() << "Time on finishing" << curTime.msecsTo(QTime::currentTime()); // qDebug() << "Time on finishing" << curTime.msecsTo(QTime::currentTime());
emit scanFinished(); emit scanFinished();
mMutex.lock(); mMutex.lock();
@ -183,7 +183,7 @@ void UBFeaturesComputingThread::run()
UBFeaturesComputingThread::~UBFeaturesComputingThread() UBFeaturesComputingThread::~UBFeaturesComputingThread()
{ {
qDebug() << "thread destructor catched"; // qDebug() << "thread destructor catched";
mMutex.lock(); mMutex.lock();
abort = true; abort = true;

@ -913,6 +913,7 @@ bool UBPersistenceManager::addFileToDocument(UBDocumentProxy* pDocumentProxy,
QString& destinationPath, QString& destinationPath,
QByteArray* data) QByteArray* data)
{ {
Q_ASSERT(path.length());
QFileInfo fi(path); QFileInfo fi(path);
if (!pDocumentProxy || objectUuid.isNull()) if (!pDocumentProxy || objectUuid.isNull())
@ -920,6 +921,8 @@ bool UBPersistenceManager::addFileToDocument(UBDocumentProxy* pDocumentProxy,
if (data == NULL && !fi.exists()) if (data == NULL && !fi.exists())
return false; return false;
qDebug() << fi.suffix();
QString fileName = subdir + "/" + objectUuid.toString() + "." + fi.suffix(); QString fileName = subdir + "/" + objectUuid.toString() + "." + fi.suffix();
destinationPath = pDocumentProxy->persistencePath() + "/" + fileName; destinationPath = pDocumentProxy->persistencePath() + "/" + fileName;

@ -366,25 +366,18 @@ void UBDocumentController::setupViews()
connect(mDocumentUI->thumbnailWidget, SIGNAL(sceneDropped(UBDocumentProxy*, int, int)), this, SLOT(moveSceneToIndex ( UBDocumentProxy*, int, int))); connect(mDocumentUI->thumbnailWidget, SIGNAL(sceneDropped(UBDocumentProxy*, int, int)), this, SLOT(moveSceneToIndex ( UBDocumentProxy*, int, int)));
connect(mDocumentUI->thumbnailWidget, SIGNAL(resized()), this, SLOT(thumbnailViewResized())); connect(mDocumentUI->thumbnailWidget, SIGNAL(resized()), this, SLOT(thumbnailViewResized()));
connect(mDocumentUI->thumbnailWidget, SIGNAL(mouseDoubleClick(QGraphicsItem*, int)), connect(mDocumentUI->thumbnailWidget, SIGNAL(mouseDoubleClick(QGraphicsItem*, int)), this, SLOT(pageDoubleClicked(QGraphicsItem*, int)));
this, SLOT(pageDoubleClicked(QGraphicsItem*, int))); connect(mDocumentUI->thumbnailWidget, SIGNAL(mouseClick(QGraphicsItem*, int)), this, SLOT(pageClicked(QGraphicsItem*, int)));
connect(mDocumentUI->thumbnailWidget, SIGNAL(mouseClick(QGraphicsItem*, int)),
this, SLOT(pageClicked(QGraphicsItem*, int)));
connect(mDocumentUI->thumbnailWidget->scene(), SIGNAL(selectionChanged()), connect(mDocumentUI->thumbnailWidget->scene(), SIGNAL(selectionChanged()), this, SLOT(pageSelectionChanged()));
this, SLOT(pageSelectionChanged()));
connect(UBPersistenceManager::persistenceManager(), SIGNAL(documentCreated(UBDocumentProxy*)), connect(UBPersistenceManager::persistenceManager(), SIGNAL(documentCreated(UBDocumentProxy*)), this, SLOT(addDocumentInTree(UBDocumentProxy*)));
this, SLOT(addDocumentInTree(UBDocumentProxy*)));
connect(UBPersistenceManager::persistenceManager(), SIGNAL(documentMetadataChanged(UBDocumentProxy*)), connect(UBPersistenceManager::persistenceManager(), SIGNAL(documentMetadataChanged(UBDocumentProxy*)), this, SLOT(updateDocumentInTree(UBDocumentProxy*)));
this, SLOT(updateDocumentInTree(UBDocumentProxy*)));
connect(UBPersistenceManager::persistenceManager(), SIGNAL(documentSceneCreated(UBDocumentProxy*, int)), connect(UBPersistenceManager::persistenceManager(), SIGNAL(documentSceneCreated(UBDocumentProxy*, int)), this, SLOT(documentSceneChanged(UBDocumentProxy*, int)));
this, SLOT(documentSceneChanged(UBDocumentProxy*, int)));
connect(UBPersistenceManager::persistenceManager(), SIGNAL(documentSceneWillBeDeleted(UBDocumentProxy*, int)), connect(UBPersistenceManager::persistenceManager(), SIGNAL(documentSceneWillBeDeleted(UBDocumentProxy*, int)), this, SLOT(documentSceneChanged(UBDocumentProxy*, int)));
this, SLOT(documentSceneChanged(UBDocumentProxy*, int)));
mDocumentUI->thumbnailWidget->setBackgroundBrush(UBSettings::documentViewLightColor); mDocumentUI->thumbnailWidget->setBackgroundBrush(UBSettings::documentViewLightColor);
@ -1006,7 +999,7 @@ void UBDocumentController::addFolderOfImages()
if (importedImageNumber == 0) if (importedImageNumber == 0)
{ {
showMessage(tr("Folder does not contain any image files!")); showMessage(tr("Folder does not contain any image files"));
UBApplication::applicationController->showDocument(); UBApplication::applicationController->showDocument();
} }
else else

@ -16,8 +16,8 @@ UBGraphicsGroupContainerItem::UBGraphicsGroupContainerItem(QGraphicsItem *parent
{ {
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
mDelegate = new UBGraphicsGroupContainerItemDelegate(this, 0); setDelegate(new UBGraphicsGroupContainerItemDelegate(this, 0));
mDelegate->init(); Delegate()->init();
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
setFlag(QGraphicsItem::ItemIsSelectable, true); setFlag(QGraphicsItem::ItemIsSelectable, true);
@ -32,8 +32,6 @@ UBGraphicsGroupContainerItem::UBGraphicsGroupContainerItem(QGraphicsItem *parent
UBGraphicsGroupContainerItem::~UBGraphicsGroupContainerItem() UBGraphicsGroupContainerItem::~UBGraphicsGroupContainerItem()
{ {
if (mDelegate)
delete mDelegate;
} }
void UBGraphicsGroupContainerItem::addToGroup(QGraphicsItem *item) void UBGraphicsGroupContainerItem::addToGroup(QGraphicsItem *item)
@ -50,14 +48,14 @@ void UBGraphicsGroupContainerItem::addToGroup(QGraphicsItem *item)
//Check if group is allready rotatable or flippable //Check if group is allready rotatable or flippable
if (childItems().count()) { if (childItems().count()) {
if (UBGraphicsItem::isFlippable(this) && !UBGraphicsItem::isFlippable(item)) { if (UBGraphicsItem::isFlippable(this) && !UBGraphicsItem::isFlippable(item)) {
mDelegate->setFlippable(false); Delegate()->setFlippable(false);
} }
if (UBGraphicsItem::isRotatable(this) && !UBGraphicsItem::isRotatable(item)) { if (UBGraphicsItem::isRotatable(this) && !UBGraphicsItem::isRotatable(item)) {
mDelegate->setRotatable(false); Delegate()->setRotatable(false);
} }
} else { } else {
mDelegate->setFlippable(UBGraphicsItem::isFlippable(item)); Delegate()->setFlippable(UBGraphicsItem::isFlippable(item));
mDelegate->setRotatable(UBGraphicsItem::isRotatable(item)); Delegate()->setRotatable(UBGraphicsItem::isRotatable(item));
} }
// COMBINE // COMBINE
@ -125,6 +123,8 @@ void UBGraphicsGroupContainerItem::removeFromGroup(QGraphicsItem *item)
pRemoveFromGroup(item); pRemoveFromGroup(item);
item->setFlags(ItemIsSelectable | ItemIsFocusable);
} }
void UBGraphicsGroupContainerItem::deselectCurrentItem() void UBGraphicsGroupContainerItem::deselectCurrentItem()
@ -207,19 +207,13 @@ void UBGraphicsGroupContainerItem::copyItemParameters(UBItem *copy) const
} }
} }
void UBGraphicsGroupContainerItem::remove()
{
if (mDelegate)
mDelegate->remove();
}
void UBGraphicsGroupContainerItem::setUuid(const QUuid &pUuid) void UBGraphicsGroupContainerItem::setUuid(const QUuid &pUuid)
{ {
UBItem::setUuid(pUuid); UBItem::setUuid(pUuid);
setData(UBGraphicsItemData::ItemUuid, QVariant(pUuid)); //store item uuid inside the QGraphicsItem to fast operations with Items on the scene setData(UBGraphicsItemData::ItemUuid, QVariant(pUuid)); //store item uuid inside the QGraphicsItem to fast operations with Items on the scene
} }
void UBGraphicsGroupContainerItem::destroy() { void UBGraphicsGroupContainerItem::destroy(bool canUndo) {
foreach (QGraphicsItem *item, childItems()) { foreach (QGraphicsItem *item, childItems()) {
pRemoveFromGroup(item); pRemoveFromGroup(item);
@ -227,7 +221,7 @@ void UBGraphicsGroupContainerItem::destroy() {
item->setFlag(QGraphicsItem::ItemIsFocusable, true); item->setFlag(QGraphicsItem::ItemIsFocusable, true);
} }
remove(); remove(canUndo);
} }
void UBGraphicsGroupContainerItem::clearSource() void UBGraphicsGroupContainerItem::clearSource()
@ -244,7 +238,7 @@ void UBGraphicsGroupContainerItem::clearSource()
void UBGraphicsGroupContainerItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsGroupContainerItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mousePressEvent(event)) { if (Delegate()->mousePressEvent(event)) {
//NOOP //NOOP
} else { } else {
@ -257,7 +251,7 @@ void UBGraphicsGroupContainerItem::mousePressEvent(QGraphicsSceneMouseEvent *eve
void UBGraphicsGroupContainerItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsGroupContainerItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mouseMoveEvent(event)) { if (Delegate()->mouseMoveEvent(event)) {
// NOOP; // NOOP;
} else { } else {
QGraphicsItem::mouseMoveEvent(event); QGraphicsItem::mouseMoveEvent(event);
@ -273,7 +267,7 @@ void UBGraphicsGroupContainerItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e
QVariant UBGraphicsGroupContainerItem::itemChange(GraphicsItemChange change, const QVariant &value) QVariant UBGraphicsGroupContainerItem::itemChange(GraphicsItemChange change, const QVariant &value)
{ {
QVariant newValue = mDelegate->itemChange(change, value); QVariant newValue = Delegate()->itemChange(change, value);
foreach(QGraphicsItem *child, children()) foreach(QGraphicsItem *child, children())
{ {
@ -317,8 +311,8 @@ void UBGraphicsGroupContainerItem::pRemoveFromGroup(QGraphicsItem *item)
break; break;
} }
} }
mDelegate->setFlippable(flippableNow); Delegate()->setFlippable(flippableNow);
mDelegate->setRotatable(rotatableNow); Delegate()->setRotatable(rotatableNow);
} }
} }

@ -22,13 +22,10 @@ public:
QRectF boundingRect() const; QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
virtual UBGraphicsItemDelegate* Delegate() const { return mDelegate;}
virtual UBCoreGraphicsScene *corescene(); virtual UBCoreGraphicsScene *corescene();
virtual UBGraphicsGroupContainerItem *deepCopy() const; virtual UBGraphicsGroupContainerItem *deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const; virtual void copyItemParameters(UBItem *copy) const;
virtual void remove();
enum { Type = UBGraphicsItemType::groupContainerType }; enum { Type = UBGraphicsItemType::groupContainerType };
virtual int type() const virtual int type() const
@ -37,7 +34,7 @@ public:
} }
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);
void destroy(); void destroy(bool canUndo = true);
virtual void clearSource(); virtual void clearSource();

@ -407,7 +407,7 @@ void UBGraphicsItemDelegate::remove(bool canUndo)
scene->removeItem(mFrame); scene->removeItem(mFrame);
/* this is performed because when removing delegated from scene while it contains flash content, segfault happens because of QGraphicsScene::removeItem() */ /* this is performed because when removing delegated from scene while it contains flash content, segfault happens because of QGraphicsScene::removeItem() */
UBGraphicsWebView *mDelegated_casted = dynamic_cast<UBGraphicsWebView*>(mDelegated); UBGraphicsWidgetItem *mDelegated_casted = dynamic_cast<UBGraphicsWidgetItem*>(mDelegated);
if (mDelegated_casted) if (mDelegated_casted)
mDelegated_casted->setHtml(QString()); mDelegated_casted->setHtml(QString());

@ -22,7 +22,7 @@ UBGraphicsItemGroupUndoCommand::~UBGraphicsItemGroupUndoCommand()
void UBGraphicsItemGroupUndoCommand::undo() void UBGraphicsItemGroupUndoCommand::undo()
{ {
mGroup->destroy(); mGroup->destroy(false);
foreach(QGraphicsItem *item, mItems) { foreach(QGraphicsItem *item, mItems) {
item->setSelected(true); item->setSelected(true);
} }
@ -41,7 +41,7 @@ void UBGraphicsItemGroupUndoCommand::redo()
QList<QGraphicsItem*> childItems = item->childItems(); QList<QGraphicsItem*> childItems = item->childItems();
UBGraphicsGroupContainerItem *currentGroup = dynamic_cast<UBGraphicsGroupContainerItem*>(item); UBGraphicsGroupContainerItem *currentGroup = dynamic_cast<UBGraphicsGroupContainerItem*>(item);
if (currentGroup) { if (currentGroup) {
currentGroup->destroy(); currentGroup->destroy(false);
} }
foreach (QGraphicsItem *chItem, childItems) { foreach (QGraphicsItem *chItem, childItems) {
mGroup->addToGroup(chItem); mGroup->addToGroup(chItem);

@ -27,10 +27,11 @@
#include "domain/UBGraphicsGroupContainerItem.h" #include "domain/UBGraphicsGroupContainerItem.h"
UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet<QGraphicsItem*>& pRemovedItems, UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet<QGraphicsItem*>& pRemovedItems,
const QSet<QGraphicsItem*>& pAddedItems) const QSet<QGraphicsItem*>& pAddedItems, const GroupDataTable &groupsMap)
: mScene(pScene) : mScene(pScene)
, mRemovedItems(pRemovedItems - pAddedItems) , mRemovedItems(pRemovedItems - pAddedItems)
, mAddedItems(pAddedItems - pRemovedItems) , mAddedItems(pAddedItems - pRemovedItems)
, mExcludedFromGroup(groupsMap)
{ {
mFirstRedo = true; mFirstRedo = true;
@ -110,6 +111,36 @@ void UBGraphicsItemUndoCommand::undo()
} }
} }
QMapIterator<UBGraphicsGroupContainerItem*, QUuid> curMapElement(mExcludedFromGroup);
UBGraphicsGroupContainerItem *nextGroup = 0;
UBGraphicsGroupContainerItem *previousGroupItem;
bool groupChanged = false;
while (curMapElement.hasNext()) {
curMapElement.next();
groupChanged = previousGroupItem != curMapElement.key();
//trying to find the group on the scene;
if (!nextGroup || groupChanged) {
UBGraphicsGroupContainerItem *groupCandidate = curMapElement.key();
if (groupCandidate) {
nextGroup = groupCandidate;
if(!mScene->items().contains(nextGroup)) {
mScene->addItem(nextGroup);
}
nextGroup->setVisible(true);
}
}
QGraphicsItem *groupedItem = mScene->itemForUuid(curMapElement.value());
if (groupedItem) {
nextGroup->addToGroup(groupedItem);
}
previousGroupItem = curMapElement.key();
UBGraphicsItem::Delegate(nextGroup)->update();
}
// force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint // force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint
mScene->update(mScene->sceneRect()); mScene->update(mScene->sceneRect());
@ -125,6 +156,35 @@ void UBGraphicsItemUndoCommand::redo()
return; return;
} }
QMapIterator<UBGraphicsGroupContainerItem*, QUuid> curMapElement(mExcludedFromGroup);
UBGraphicsGroupContainerItem *nextGroup = 0;
UBGraphicsGroupContainerItem *previousGroupItem;
bool groupChanged = false;
while (curMapElement.hasNext()) {
curMapElement.next();
groupChanged = previousGroupItem != curMapElement.key();
//trying to find the group on the scene;
if (!nextGroup || groupChanged) {
UBGraphicsGroupContainerItem *groupCandidate = curMapElement.key();
if (groupCandidate) {
nextGroup = groupCandidate;
}
}
QGraphicsItem *groupedItem = mScene->itemForUuid(curMapElement.value());
if (groupedItem) {
if (nextGroup->childItems().count() == 1) {
nextGroup->destroy(false);
break;
}
nextGroup->removeFromGroup(groupedItem);
}
previousGroupItem = curMapElement.key();
UBGraphicsItem::Delegate(nextGroup)->update();
}
QSetIterator<QGraphicsItem*> itRemoved(mRemovedItems); QSetIterator<QGraphicsItem*> itRemoved(mRemovedItems);
while (itRemoved.hasNext()) while (itRemoved.hasNext())
{ {

@ -18,6 +18,7 @@
#include <QtGui> #include <QtGui>
#include "UBAbstractUndoCommand.h" #include "UBAbstractUndoCommand.h"
#include "UBGraphicsGroupContainerItem.h"
class UBGraphicsScene; class UBGraphicsScene;
@ -26,8 +27,10 @@ class UBGraphicsScene;
class UBGraphicsItemUndoCommand : public UBAbstractUndoCommand class UBGraphicsItemUndoCommand : public UBAbstractUndoCommand
{ {
public: public:
typedef QMultiMap<UBGraphicsGroupContainerItem*, QUuid> GroupDataTable;
UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet<QGraphicsItem*>& pRemovedItems, UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet<QGraphicsItem*>& pRemovedItems,
const QSet<QGraphicsItem*>& pAddedItems); const QSet<QGraphicsItem*>& pAddedItems, const GroupDataTable &groupsMap = GroupDataTable());
UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, QGraphicsItem* pRemovedItem, UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, QGraphicsItem* pRemovedItem,
QGraphicsItem* pAddedItem); QGraphicsItem* pAddedItem);
@ -47,6 +50,7 @@ class UBGraphicsItemUndoCommand : public UBAbstractUndoCommand
UBGraphicsScene* mScene; UBGraphicsScene* mScene;
QSet<QGraphicsItem*> mRemovedItems; QSet<QGraphicsItem*> mRemovedItems;
QSet<QGraphicsItem*> mAddedItems; QSet<QGraphicsItem*> mAddedItems;
GroupDataTable mExcludedFromGroup;
bool mFirstRedo; bool mFirstRedo;
}; };

@ -72,6 +72,10 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
update(); update();
mMediaObject = new Phonon::MediaObject(this); mMediaObject = new Phonon::MediaObject(this);
setDelegate(new UBGraphicsMediaItemDelegate(this, mMediaObject));
Delegate()->init();
if (pMediaFileUrl.toLocalFile().contains("videos")) if (pMediaFileUrl.toLocalFile().contains("videos"))
{ {
mMediaType = mediaType_Video; mMediaType = mediaType_Video;
@ -116,18 +120,14 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
mSource = Phonon::MediaSource(pMediaFileUrl); mSource = Phonon::MediaSource(pMediaFileUrl);
mMediaObject->setCurrentSource(mSource); mMediaObject->setCurrentSource(mSource);
UBGraphicsMediaItemDelegate* itemDelegate = new UBGraphicsMediaItemDelegate(this, mMediaObject);
itemDelegate->init();
setDelegate(itemDelegate);
if (mediaType_Audio == mMediaType) if (mediaType_Audio == mMediaType)
mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::ResizingHorizontally); Delegate()->frame()->setOperationMode(UBGraphicsDelegateFrame::ResizingHorizontally);
else else
mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing); Delegate()->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing);
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
connect(mDelegate, SIGNAL(showOnDisplayChanged(bool)), this, SLOT(showOnDisplayChanged(bool))); connect(Delegate(), SIGNAL(showOnDisplayChanged(bool)), this, SLOT(showOnDisplayChanged(bool)));
connect(mMediaObject, SIGNAL(hasVideoChanged(bool)), this, SLOT(hasMediaChanged(bool))); connect(mMediaObject, SIGNAL(hasVideoChanged(bool)), this, SLOT(hasMediaChanged(bool)));
} }
@ -220,7 +220,7 @@ void UBGraphicsMediaItem::hasMediaChanged(bool hasMedia)
{ {
Q_UNUSED(hasMedia); Q_UNUSED(hasMedia);
mMediaObject->seek(mInitialPos); mMediaObject->seek(mInitialPos);
UBGraphicsMediaItemDelegate *med = dynamic_cast<UBGraphicsMediaItemDelegate *>(mDelegate); UBGraphicsMediaItemDelegate *med = dynamic_cast<UBGraphicsMediaItemDelegate *>(Delegate());
if (med) if (med)
med->updateTicker(initialPos()); med->updateTicker(initialPos());
} }
@ -289,9 +289,9 @@ void UBGraphicsMediaItem::copyItemParameters(UBItem *copy) const
void UBGraphicsMediaItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsMediaItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate) if (Delegate())
{ {
mDelegate->mousePressEvent(event); Delegate()->mousePressEvent(event);
if (parentItem() && UBGraphicsGroupContainerItem::Type == parentItem()->type()) if (parentItem() && UBGraphicsGroupContainerItem::Type == parentItem()->type())
{ {
UBGraphicsGroupContainerItem *group = qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(parentItem()); UBGraphicsGroupContainerItem *group = qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(parentItem());
@ -304,7 +304,7 @@ void UBGraphicsMediaItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
} }
group->setCurrentItem(this); group->setCurrentItem(this);
this->setSelected(true); this->setSelected(true);
mDelegate->positionHandles(); Delegate()->positionHandles();
} }
} }
@ -351,3 +351,4 @@ void UBGraphicsMediaItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
event->accept(); event->accept();
} }

@ -112,7 +112,6 @@ protected:
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void clearSource(); virtual void clearSource();
Phonon::MediaObject *mMediaObject; Phonon::MediaObject *mMediaObject;

@ -28,21 +28,20 @@ UBGraphicsPDFItem::UBGraphicsPDFItem(PDFRenderer *renderer, int pageNumber, QGra
{ {
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); //deprecated setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); //deprecated
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::BackgroundItem)); //Necessary to set if we want z value to be assigned correctly setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::BackgroundItem)); //Necessary to set if we want z value to be assigned correctly
mDelegate = new UBGraphicsItemDelegate(this,0, true, false, false);
mDelegate->init(); setDelegate(new UBGraphicsItemDelegate(this,0, true, false, false));
Delegate()->init();
} }
UBGraphicsPDFItem::~UBGraphicsPDFItem() UBGraphicsPDFItem::~UBGraphicsPDFItem()
{ {
if (mDelegate)
delete mDelegate;
} }
QVariant UBGraphicsPDFItem::itemChange(GraphicsItemChange change, const QVariant &value) QVariant UBGraphicsPDFItem::itemChange(GraphicsItemChange change, const QVariant &value)
{ {
QVariant newValue = mDelegate->itemChange(change, value); QVariant newValue = Delegate()->itemChange(change, value);
return GraphicsPDFItem::itemChange(change, newValue); return GraphicsPDFItem::itemChange(change, newValue);
} }
@ -54,7 +53,7 @@ void UBGraphicsPDFItem::setUuid(const QUuid &pUuid)
void UBGraphicsPDFItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsPDFItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mousePressEvent(event)) if (Delegate()->mousePressEvent(event))
{ {
// NOOP // NOOP
} }
@ -67,7 +66,7 @@ void UBGraphicsPDFItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsPDFItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsPDFItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mouseMoveEvent(event)) if (Delegate()->mouseMoveEvent(event))
{ {
// NOOP // NOOP
} }
@ -80,7 +79,7 @@ void UBGraphicsPDFItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsPDFItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsPDFItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
mDelegate->mouseReleaseEvent(event); Delegate()->mouseReleaseEvent(event);
GraphicsPDFItem::mouseReleaseEvent(event); GraphicsPDFItem::mouseReleaseEvent(event);
} }
@ -131,13 +130,6 @@ UBGraphicsScene* UBGraphicsPDFItem::scene()
} }
void UBGraphicsPDFItem::remove()
{
if (mDelegate)
mDelegate->remove(true);
}
UBGraphicsPixmapItem* UBGraphicsPDFItem::toPixmapItem() const UBGraphicsPixmapItem* UBGraphicsPDFItem::toPixmapItem() const
{ {
QPixmap pixmap(mRenderer->pageSizeF(mPageNumber).toSize()); QPixmap pixmap(mRenderer->pageSizeF(mPageNumber).toSize());
@ -155,3 +147,5 @@ UBGraphicsPixmapItem* UBGraphicsPDFItem::toPixmapItem() const
return pixmapItem; return pixmapItem;
} }

@ -47,10 +47,7 @@ class UBGraphicsPDFItem: public GraphicsPDFItem, public UBItem, public UBGraphic
virtual UBGraphicsScene* scene(); virtual UBGraphicsScene* scene();
virtual void remove();
virtual UBGraphicsPixmapItem* toPixmapItem() const; virtual UBGraphicsPixmapItem* toPixmapItem() const;
virtual UBGraphicsItemDelegate *Delegate() const {return mDelegate;}
virtual void clearSource(){;} virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);
@ -63,7 +60,6 @@ class UBGraphicsPDFItem: public GraphicsPDFItem, public UBItem, public UBGraphic
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
// UBGraphicsItemDelegate* mDelegate;
}; };
#endif /* UBGRAPHICSPDFITEM_H_ */ #endif /* UBGRAPHICSPDFITEM_H_ */

@ -28,10 +28,10 @@
UBGraphicsPixmapItem::UBGraphicsPixmapItem(QGraphicsItem* parent) UBGraphicsPixmapItem::UBGraphicsPixmapItem(QGraphicsItem* parent)
: QGraphicsPixmapItem(parent) : QGraphicsPixmapItem(parent)
{ {
mDelegate = new UBGraphicsItemDelegate(this, 0, true); setDelegate(new UBGraphicsItemDelegate(this, 0, true));
mDelegate->init(); Delegate()->init();
mDelegate->setFlippable(true); Delegate()->setFlippable(true);
mDelegate->setRotatable(true); Delegate()->setRotatable(true);
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
setTransformationMode(Qt::SmoothTransformation); setTransformationMode(Qt::SmoothTransformation);
@ -44,13 +44,11 @@ UBGraphicsPixmapItem::UBGraphicsPixmapItem(QGraphicsItem* parent)
UBGraphicsPixmapItem::~UBGraphicsPixmapItem() UBGraphicsPixmapItem::~UBGraphicsPixmapItem()
{ {
if (mDelegate)
delete mDelegate;
} }
QVariant UBGraphicsPixmapItem::itemChange(GraphicsItemChange change, const QVariant &value) QVariant UBGraphicsPixmapItem::itemChange(GraphicsItemChange change, const QVariant &value)
{ {
QVariant newValue = mDelegate->itemChange(change, value); QVariant newValue = Delegate()->itemChange(change, value);
return QGraphicsPixmapItem::itemChange(change, newValue); return QGraphicsPixmapItem::itemChange(change, newValue);
} }
@ -64,14 +62,14 @@ void UBGraphicsPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
QMimeData* pMime = new QMimeData(); QMimeData* pMime = new QMimeData();
pMime->setImageData(pixmap().toImage()); pMime->setImageData(pixmap().toImage());
mDelegate->setMimeData(pMime); Delegate()->setMimeData(pMime);
qreal k = (qreal)pixmap().width() / 100.0; qreal k = (qreal)pixmap().width() / 100.0;
QSize newSize((int)(pixmap().width() / k), (int)(pixmap().height() / k)); QSize newSize((int)(pixmap().width() / k), (int)(pixmap().height() / k));
mDelegate->setDragPixmap(pixmap().scaled(newSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); Delegate()->setDragPixmap(pixmap().scaled(newSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
if (mDelegate->mousePressEvent(event)) if (Delegate()->mousePressEvent(event))
{ {
//NOOP //NOOP
} }
@ -83,7 +81,7 @@ void UBGraphicsPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsPixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsPixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mouseMoveEvent(event)) if (Delegate()->mouseMoveEvent(event))
{ {
// NOOP; // NOOP;
} }
@ -95,7 +93,7 @@ void UBGraphicsPixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
mDelegate->mouseReleaseEvent(event); Delegate()->mouseReleaseEvent(event);
QGraphicsPixmapItem::mouseReleaseEvent(event); QGraphicsPixmapItem::mouseReleaseEvent(event);
} }
@ -145,13 +143,6 @@ UBGraphicsScene* UBGraphicsPixmapItem::scene()
} }
void UBGraphicsPixmapItem::remove()
{
if (mDelegate)
mDelegate->remove(true);
}
void UBGraphicsPixmapItem::setOpacity(qreal op) void UBGraphicsPixmapItem::setOpacity(qreal op)
{ {
QGraphicsPixmapItem::setOpacity(op); QGraphicsPixmapItem::setOpacity(op);

@ -44,14 +44,11 @@ class UBGraphicsPixmapItem : public QObject, public QGraphicsPixmapItem, public
virtual UBGraphicsScene* scene(); virtual UBGraphicsScene* scene();
virtual void remove();
Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity) Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity)
void setOpacity(qreal op); void setOpacity(qreal op);
qreal opacity() const; qreal opacity() const;
virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate;}
virtual void clearSource(){;} virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);

@ -29,8 +29,9 @@ UBGraphicsProxyWidget::UBGraphicsProxyWidget(QGraphicsItem* parent)
{ {
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
mDelegate = new UBGraphicsItemDelegate(this,0, true, false, false); //UBGraphicsItemDelegate* delegate = new UBGraphicsItemDelegate(this,0, true, false, false);
mDelegate->init(); //delegate->init();
//setDelegate(delegate);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
@ -40,8 +41,6 @@ UBGraphicsProxyWidget::UBGraphicsProxyWidget(QGraphicsItem* parent)
UBGraphicsProxyWidget::~UBGraphicsProxyWidget() UBGraphicsProxyWidget::~UBGraphicsProxyWidget()
{ {
if (mDelegate)
delete mDelegate;
} }
@ -67,7 +66,7 @@ QVariant UBGraphicsProxyWidget::itemChange(GraphicsItemChange change, const QVar
} }
} }
QVariant newValue = mDelegate->itemChange(change, value); QVariant newValue = Delegate()->itemChange(change, value);
return QGraphicsProxyWidget::itemChange(change, newValue); return QGraphicsProxyWidget::itemChange(change, newValue);
} }
@ -79,7 +78,7 @@ void UBGraphicsProxyWidget::setUuid(const QUuid &pUuid)
void UBGraphicsProxyWidget::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsProxyWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mousePressEvent(event)) if (Delegate()->mousePressEvent(event))
{ {
//NOOP //NOOP
} }
@ -95,7 +94,7 @@ void UBGraphicsProxyWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsProxyWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsProxyWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mouseMoveEvent(event)) if (Delegate()->mouseMoveEvent(event))
{ {
// NOOP; // NOOP;
} }
@ -108,13 +107,13 @@ void UBGraphicsProxyWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsProxyWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsProxyWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
mDelegate->mouseReleaseEvent(event); Delegate()->mouseReleaseEvent(event);
QGraphicsProxyWidget::mouseReleaseEvent(event); QGraphicsProxyWidget::mouseReleaseEvent(event);
} }
void UBGraphicsProxyWidget::wheelEvent(QGraphicsSceneWheelEvent *event) void UBGraphicsProxyWidget::wheelEvent(QGraphicsSceneWheelEvent *event)
{ {
if( mDelegate->weelEvent(event) ) if( Delegate()->weelEvent(event) )
{ {
QGraphicsProxyWidget::wheelEvent(event); QGraphicsProxyWidget::wheelEvent(event);
event->accept(); event->accept();
@ -132,17 +131,6 @@ void UBGraphicsProxyWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
// NOOP // NOOP
} }
void UBGraphicsProxyWidget::setDelegate(UBGraphicsItemDelegate* pDelegate)
{
if (mDelegate)
{
delete mDelegate;
}
mDelegate = pDelegate;
}
void UBGraphicsProxyWidget::resize(qreal w, qreal h) void UBGraphicsProxyWidget::resize(qreal w, qreal h)
{ {
UBGraphicsProxyWidget::resize(QSizeF(w, h)); UBGraphicsProxyWidget::resize(QSizeF(w, h));
@ -177,8 +165,8 @@ void UBGraphicsProxyWidget::resize(const QSizeF & pSize)
QGraphicsProxyWidget::resize(size.width(), size.height()); QGraphicsProxyWidget::resize(size.width(), size.height());
if (widget()) if (widget())
widget()->resize(size.width(), size.height()); widget()->resize(size.width(), size.height());
if (mDelegate) if (Delegate())
mDelegate->positionHandles(); Delegate()->positionHandles();
if (scene()) if (scene())
scene()->setModified(true); scene()->setModified(true);
} }
@ -197,8 +185,3 @@ UBGraphicsScene* UBGraphicsProxyWidget::scene()
} }
void UBGraphicsProxyWidget::remove()
{
if (mDelegate)
mDelegate->remove(true);
}

@ -27,7 +27,6 @@ class UBGraphicsItemDelegate;
class UBGraphicsProxyWidget: public QGraphicsProxyWidget, public UBItem, public UBResizableGraphicsItem, public UBGraphicsItem class UBGraphicsProxyWidget: public QGraphicsProxyWidget, public UBItem, public UBResizableGraphicsItem, public UBGraphicsItem
{ {
public: public:
UBGraphicsProxyWidget(QGraphicsItem* parent = 0);
virtual ~UBGraphicsProxyWidget(); virtual ~UBGraphicsProxyWidget();
virtual void resize(qreal w, qreal h); virtual void resize(qreal w, qreal h);
@ -35,18 +34,13 @@ class UBGraphicsProxyWidget: public QGraphicsProxyWidget, public UBItem, public
virtual QSizeF size() const; virtual QSizeF size() const;
void setDelegate(UBGraphicsItemDelegate* pDelegate);
virtual UBGraphicsScene* scene(); virtual UBGraphicsScene* scene();
virtual void remove();
virtual UBGraphicsItemDelegate* Delegate() const { return mDelegate;}
virtual void clearSource(){;} virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);
protected: protected:
UBGraphicsProxyWidget(QGraphicsItem* parent = 0);
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);

@ -1067,6 +1067,7 @@ UBItem* UBGraphicsScene::deepCopy() const
void UBGraphicsScene::clearContent(clearCase pCase) void UBGraphicsScene::clearContent(clearCase pCase)
{ {
QSet<QGraphicsItem*> removedItems; QSet<QGraphicsItem*> removedItems;
UBGraphicsItemUndoCommand::GroupDataTable groupsMap;
switch (pCase) { switch (pCase) {
case clearBackground : case clearBackground :
@ -1106,8 +1107,14 @@ void UBGraphicsScene::clearContent(clearCase pCase)
if(shouldDelete) { if(shouldDelete) {
if (itemGroup) { if (itemGroup) {
itemGroup->removeFromGroup(item); itemGroup->removeFromGroup(item);
groupsMap.insert(itemGroup, UBGraphicsItem::getOwnUuid(item));
if (itemGroup->childItems().count() == 1) { if (itemGroup->childItems().count() == 1) {
itemGroup->destroy(); groupsMap.insert(itemGroup, UBGraphicsItem::getOwnUuid(itemGroup->childItems().first()));
QGraphicsItem *lastItem = itemGroup->childItems().first();
bool isSelected = itemGroup->isSelected();
itemGroup->destroy(false);
lastItem->setSelected(isSelected);
} }
itemGroup->Delegate()->update(); itemGroup->Delegate()->update();
} }
@ -1123,7 +1130,8 @@ void UBGraphicsScene::clearContent(clearCase pCase)
update(sceneRect()); update(sceneRect());
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, removedItems, QSet<QGraphicsItem*>());
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, removedItems, QSet<QGraphicsItem*>(), groupsMap);
UBApplication::undoStack->push(uc); UBApplication::undoStack->push(uc);
} }
@ -1442,6 +1450,7 @@ UBGraphicsTextItem* UBGraphicsScene::textForObjectName(const QString& pString, c
textItem->setObjectName(objectName); textItem->setObjectName(objectName);
QSizeF size = textItem->size(); QSizeF size = textItem->size();
textItem->setPos(QPointF(-size.width()/2.0,-size.height()/2.0)); textItem->setPos(QPointF(-size.width()/2.0,-size.height()/2.0));
textItem->setData(UBGraphicsItemData::ItemEditable,QVariant(false));
} }
textItem->setPlainText(pString); textItem->setPlainText(pString);
@ -1571,8 +1580,9 @@ void UBGraphicsScene::removeItem(QGraphicsItem* item)
void UBGraphicsScene::removeItems(const QSet<QGraphicsItem*>& items) void UBGraphicsScene::removeItems(const QSet<QGraphicsItem*>& items)
{ {
foreach(QGraphicsItem* item, items) foreach(QGraphicsItem* item, items) {
UBCoreGraphicsScene::removeItem(item); UBCoreGraphicsScene::removeItem(item);
}
mItemCount -= items.size(); mItemCount -= items.size();
@ -1665,7 +1675,7 @@ QRectF UBGraphicsScene::normalizedSceneRect(qreal ratio)
return normalizedRect; return normalizedRect;
} }
QGraphicsItem *UBGraphicsScene::itemByUuid(QUuid uuid) QGraphicsItem *UBGraphicsScene::itemForUuid(QUuid uuid)
{ {
QGraphicsItem *result = 0; QGraphicsItem *result = 0;
@ -2041,8 +2051,8 @@ void UBGraphicsScene::drawItems (QPainter * painter, int numItems,
{ {
if (!mTools.contains(rootItem(items[i]))) if (!mTools.contains(rootItem(items[i])))
{ {
UBGraphicsPDFItem *pdfItem = qgraphicsitem_cast<UBGraphicsPDFItem*> (items[i]); bool isPdfItem = qgraphicsitem_cast<UBGraphicsPDFItem*> (items[i]) != NULL;
if(!pdfItem || mRenderingContext == NonScreen) if(!isPdfItem || mRenderingContext == NonScreen)
{ {
itemsFiltered[count] = items[i]; itemsFiltered[count] = items[i];
optionsFiltered[count] = options[i]; optionsFiltered[count] = options[i];

@ -174,7 +174,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
QRectF normalizedSceneRect(qreal ratio = -1.0); QRectF normalizedSceneRect(qreal ratio = -1.0);
QGraphicsItem *itemByUuid(QUuid uuid); QGraphicsItem *itemForUuid(QUuid uuid);
void moveTo(const QPointF& pPoint); void moveTo(const QPointF& pPoint);
void drawLineTo(const QPointF& pEndPoint, const qreal& pWidth, bool bLineStyle); void drawLineTo(const QPointF& pEndPoint, const qreal& pWidth, bool bLineStyle);

@ -4,12 +4,14 @@
#include "core/memcheck.h" #include "core/memcheck.h"
UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent):QGraphicsItemGroup(parent) UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent)
:QGraphicsItemGroup(parent), UBGraphicsItem()
{ {
mDelegate = new UBGraphicsItemDelegate(this, 0, true, true, false); setDelegate(new UBGraphicsItemDelegate(this, 0, true, true, false));
mDelegate->init(); Delegate()->init();
mDelegate->setFlippable(true); Delegate()->setFlippable(true);
mDelegate->setRotatable(true); Delegate()->setRotatable(true);
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
@ -22,9 +24,6 @@ UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent):QGraphicsI
UBGraphicsStrokesGroup::~UBGraphicsStrokesGroup() UBGraphicsStrokesGroup::~UBGraphicsStrokesGroup()
{ {
if(mDelegate){
delete mDelegate;
}
} }
void UBGraphicsStrokesGroup::setUuid(const QUuid &pUuid) void UBGraphicsStrokesGroup::setUuid(const QUuid &pUuid)
@ -83,7 +82,7 @@ QColor UBGraphicsStrokesGroup::color(colorType pColorType) const
void UBGraphicsStrokesGroup::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsStrokesGroup::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mousePressEvent(event)) if (Delegate()->mousePressEvent(event))
{ {
//NOOP //NOOP
} }
@ -95,7 +94,7 @@ void UBGraphicsStrokesGroup::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsStrokesGroup::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsStrokesGroup::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mouseMoveEvent(event)) if (Delegate()->mouseMoveEvent(event))
{ {
// NOOP; // NOOP;
} }
@ -107,7 +106,7 @@ void UBGraphicsStrokesGroup::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsStrokesGroup::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsStrokesGroup::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
mDelegate->mouseReleaseEvent(event); Delegate()->mouseReleaseEvent(event);
QGraphicsItemGroup::mouseReleaseEvent(event); QGraphicsItemGroup::mouseReleaseEvent(event);
} }
@ -150,12 +149,6 @@ void UBGraphicsStrokesGroup::copyItemParameters(UBItem *copy) const
} }
} }
void UBGraphicsStrokesGroup::remove()
{
if (mDelegate)
mDelegate->remove(true);
}
void UBGraphicsStrokesGroup::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void UBGraphicsStrokesGroup::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{ {
// Never draw the rubber band, we draw our custom selection with the DelegateFrame // Never draw the rubber band, we draw our custom selection with the DelegateFrame
@ -167,7 +160,7 @@ void UBGraphicsStrokesGroup::paint(QPainter *painter, const QStyleOptionGraphics
QVariant UBGraphicsStrokesGroup::itemChange(GraphicsItemChange change, const QVariant &value) QVariant UBGraphicsStrokesGroup::itemChange(GraphicsItemChange change, const QVariant &value)
{ {
QVariant newValue = mDelegate->itemChange(change, value); QVariant newValue = Delegate()->itemChange(change, value);
return QGraphicsItemGroup::itemChange(change, newValue); return QGraphicsItemGroup::itemChange(change, newValue);
} }

@ -21,8 +21,6 @@ public:
~UBGraphicsStrokesGroup(); ~UBGraphicsStrokesGroup();
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const; virtual void copyItemParameters(UBItem *copy) const;
virtual void remove();
virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate;}
enum { Type = UBGraphicsItemType::StrokeItemType }; enum { Type = UBGraphicsItemType::StrokeItemType };
virtual int type() const virtual int type() const
{ {

@ -53,10 +53,11 @@ void UBGraphicsSvgItem::init()
{ {
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
mDelegate = new UBGraphicsItemDelegate(this, 0, true, true, false); setDelegate(new UBGraphicsItemDelegate(this, 0, true, true, false));
mDelegate->init(); Delegate()->init();
mDelegate->setFlippable(true); Delegate()->setFlippable(true);
mDelegate->setRotatable(true); Delegate()->setRotatable(true);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
@ -71,8 +72,6 @@ void UBGraphicsSvgItem::init()
UBGraphicsSvgItem::~UBGraphicsSvgItem() UBGraphicsSvgItem::~UBGraphicsSvgItem()
{ {
if (mDelegate)
delete mDelegate;
} }
@ -84,14 +83,14 @@ QByteArray UBGraphicsSvgItem::fileData() const
QVariant UBGraphicsSvgItem::itemChange(GraphicsItemChange change, const QVariant &value) QVariant UBGraphicsSvgItem::itemChange(GraphicsItemChange change, const QVariant &value)
{ {
QVariant newValue = mDelegate->itemChange(change, value); QVariant newValue = Delegate()->itemChange(change, value);
return QGraphicsSvgItem::itemChange(change, newValue); return QGraphicsSvgItem::itemChange(change, newValue);
} }
void UBGraphicsSvgItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsSvgItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mousePressEvent(event)) if (Delegate()->mousePressEvent(event))
{ {
//NOOP //NOOP
} }
@ -104,7 +103,7 @@ void UBGraphicsSvgItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsSvgItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsSvgItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mouseMoveEvent(event)) if (Delegate()->mouseMoveEvent(event))
{ {
// NOOP; // NOOP;
} }
@ -117,7 +116,7 @@ void UBGraphicsSvgItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsSvgItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsSvgItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
mDelegate->mouseReleaseEvent(event); Delegate()->mouseReleaseEvent(event);
QGraphicsSvgItem::mouseReleaseEvent(event); QGraphicsSvgItem::mouseReleaseEvent(event);
} }
@ -182,12 +181,6 @@ UBGraphicsScene* UBGraphicsSvgItem::scene()
} }
void UBGraphicsSvgItem::remove()
{
if (mDelegate)
mDelegate->remove(true);
}
UBGraphicsPixmapItem* UBGraphicsSvgItem::toPixmapItem() const UBGraphicsPixmapItem* UBGraphicsSvgItem::toPixmapItem() const
{ {

@ -58,10 +58,7 @@ class UBGraphicsSvgItem: public QGraphicsSvgItem, public UBItem, public UBGraphi
virtual UBGraphicsScene* scene(); virtual UBGraphicsScene* scene();
virtual void remove();
virtual UBGraphicsPixmapItem* toPixmapItem() const; virtual UBGraphicsPixmapItem* toPixmapItem() const;
virtual UBGraphicsItemDelegate *Delegate() const {return mDelegate;}
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);

@ -30,17 +30,18 @@
QColor UBGraphicsTextItem::lastUsedTextColor; QColor UBGraphicsTextItem::lastUsedTextColor;
UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent) UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent) :
: QGraphicsTextItem(parent) QGraphicsTextItem(parent)
, UBGraphicsItem()
, mMultiClickState(0) , mMultiClickState(0)
, mLastMousePressTime(QTime::currentTime()) , mLastMousePressTime(QTime::currentTime())
{ {
mDelegate = new UBGraphicsTextItemDelegate(this, 0); setDelegate(new UBGraphicsTextItemDelegate(this, 0));
mDelegate->init(); Delegate()->init();
mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing); Delegate()->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing);
mDelegate->setFlippable(false); Delegate()->setFlippable(false);
mDelegate->setRotatable(true); Delegate()->setRotatable(true);
mTypeTextHereLabel = tr("<Type Text Here>"); mTypeTextHereLabel = tr("<Type Text Here>");
@ -58,7 +59,7 @@ UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent)
setUuid(QUuid::createUuid()); setUuid(QUuid::createUuid());
connect(document(), SIGNAL(contentsChanged()), mDelegate, SLOT(contentsChanged())); connect(document(), SIGNAL(contentsChanged()), Delegate(), SLOT(contentsChanged()));
connect(document(), SIGNAL(undoCommandAdded()), this, SLOT(undoCommandAdded())); connect(document(), SIGNAL(undoCommandAdded()), this, SLOT(undoCommandAdded()));
connect(document()->documentLayout(), SIGNAL(documentSizeChanged(const QSizeF &)), connect(document()->documentLayout(), SIGNAL(documentSizeChanged(const QSizeF &)),
@ -68,18 +69,14 @@ UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent)
UBGraphicsTextItem::~UBGraphicsTextItem() UBGraphicsTextItem::~UBGraphicsTextItem()
{ {
if (mDelegate)
{
delete mDelegate;
}
} }
QVariant UBGraphicsTextItem::itemChange(GraphicsItemChange change, const QVariant &value) QVariant UBGraphicsTextItem::itemChange(GraphicsItemChange change, const QVariant &value)
{ {
QVariant newValue = value; QVariant newValue = value;
if(mDelegate) if(Delegate())
newValue = mDelegate->itemChange(change, value); newValue = Delegate()->itemChange(change, value);
return QGraphicsTextItem::itemChange(change, newValue); return QGraphicsTextItem::itemChange(change, newValue);
} }
@ -95,10 +92,10 @@ void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
return; return;
} }
if (mDelegate) if (Delegate())
{ {
mDelegate->mousePressEvent(event); Delegate()->mousePressEvent(event);
if (mDelegate && parentItem() && UBGraphicsGroupContainerItem::Type == parentItem()->type()) if (Delegate() && parentItem() && UBGraphicsGroupContainerItem::Type == parentItem()->type())
{ {
UBGraphicsGroupContainerItem *group = qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(parentItem()); UBGraphicsGroupContainerItem *group = qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(parentItem());
if (group) if (group)
@ -110,13 +107,13 @@ void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
} }
group->setCurrentItem(this); group->setCurrentItem(this);
this->setSelected(true); this->setSelected(true);
mDelegate->positionHandles(); Delegate()->positionHandles();
} }
} }
else else
{ {
mDelegate->getToolBarItem()->show(); Delegate()->getToolBarItem()->show();
} }
} }
@ -165,7 +162,7 @@ void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if (!mDelegate || !mDelegate->mouseMoveEvent(event)) if (!Delegate() || !Delegate()->mouseMoveEvent(event))
{ {
QGraphicsTextItem::mouseMoveEvent(event); QGraphicsTextItem::mouseMoveEvent(event);
} }
@ -184,8 +181,8 @@ void UBGraphicsTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
if (mMultiClickState == 1) if (mMultiClickState == 1)
{ {
if (mDelegate) if (Delegate())
mDelegate->mouseReleaseEvent(event); Delegate()->mouseReleaseEvent(event);
QGraphicsTextItem::mouseReleaseEvent(event); QGraphicsTextItem::mouseReleaseEvent(event);
} }
@ -324,8 +321,8 @@ void UBGraphicsTextItem::resize(qreal w, qreal h)
setTextWidth(w); setTextWidth(w);
setTextHeight(h); setTextHeight(h);
if (mDelegate) if (Delegate())
mDelegate->positionHandles(); Delegate()->positionHandles();
} }
@ -347,12 +344,6 @@ void UBGraphicsTextItem::undoCommandAdded()
} }
void UBGraphicsTextItem::remove()
{
if (mDelegate)
mDelegate->remove(true);
}
void UBGraphicsTextItem::documentSizeChanged(const QSizeF & newSize) void UBGraphicsTextItem::documentSizeChanged(const QSizeF & newSize)
{ {
resize(newSize.width(), newSize.height()); resize(newSize.width(), newSize.height());

@ -58,8 +58,6 @@ class UBGraphicsTextItem : public QGraphicsTextItem, public UBItem, public UBRes
virtual QSizeF size() const; virtual QSizeF size() const;
virtual void remove();
static QColor lastUsedTextColor; static QColor lastUsedTextColor;
QColor colorOnDarkBackground() const QColor colorOnDarkBackground() const
@ -81,7 +79,6 @@ class UBGraphicsTextItem : public QGraphicsTextItem, public UBItem, public UBRes
{ {
mColorOnLightBackground = pColorOnLightBackground; mColorOnLightBackground = pColorOnLightBackground;
} }
virtual UBGraphicsItemDelegate *Delegate() const {return mDelegate;}
virtual void clearSource(){;} virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);

@ -1,152 +0,0 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QtGui>
#include <QtWebKit>
#include "UBGraphicsWebView.h"
#include "UBGraphicsScene.h"
#include "UBGraphicsItemDelegate.h"
#include "UBGraphicsDelegateFrame.h"
#include "core/memcheck.h"
UBGraphicsWebView::UBGraphicsWebView(QGraphicsItem* parent)
: QGraphicsWebView(parent)
{
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
mDelegate = new UBGraphicsItemDelegate(this, 0, true);
mDelegate->init();
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
QGraphicsWebView::setAcceptHoverEvents(true);
}
UBGraphicsWebView::~UBGraphicsWebView()
{
if (mDelegate)
delete mDelegate;
}
QVariant UBGraphicsWebView::itemChange(GraphicsItemChange change, const QVariant &value)
{
if ((change == QGraphicsItem::ItemSelectedHasChanged) && scene()) {
if (isSelected())
scene()->setActiveWindow(this);
else
if(scene()->activeWindow() == this)
scene()->setActiveWindow(0);
}
QVariant newValue = mDelegate->itemChange(change, value);
return QGraphicsWebView::itemChange(change, newValue);
}
void UBGraphicsWebView::setUuid(const QUuid &pUuid)
{
UBItem::setUuid(pUuid);
setData(UBGraphicsItemData::ItemUuid, QVariant(pUuid)); //store item uuid inside the QGraphicsItem to fast operations with Items on the scene
}
void UBGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (!mDelegate->mousePressEvent(event))
setSelected(true); /* forcing selection */
QGraphicsWebView::mousePressEvent(event);
}
void UBGraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if (!mDelegate->mouseMoveEvent(event))
QGraphicsWebView::mouseMoveEvent(event);
}
void UBGraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
mDelegate->mouseReleaseEvent(event);
QGraphicsWebView::mouseReleaseEvent(event);
}
void UBGraphicsWebView::wheelEvent(QGraphicsSceneWheelEvent *event)
{
if (mDelegate->weelEvent(event))
{
QGraphicsWebView::wheelEvent(event);
event->accept();
}
}
void UBGraphicsWebView::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event)
/* NOOP */
}
void UBGraphicsWebView::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event)
/* NOOP */
}
void UBGraphicsWebView::setDelegate(UBGraphicsItemDelegate* pDelegate)
{
if (mDelegate)
delete mDelegate;
mDelegate = pDelegate;
}
void UBGraphicsWebView::resize(qreal w, qreal h)
{
UBGraphicsWebView::resize(QSizeF(w, h));
}
void UBGraphicsWebView::resize(const QSizeF & pSize)
{
if (pSize != size()) {
QGraphicsWebView::setMaximumSize(pSize.width(), pSize.height());
QGraphicsWebView::resize(pSize.width(), pSize.height());
if (mDelegate)
mDelegate->positionHandles();
if (scene())
scene()->setModified(true);
}
}
QSizeF UBGraphicsWebView::size() const
{
return QGraphicsWebView::size();
}
UBGraphicsScene* UBGraphicsWebView::scene()
{
return static_cast<UBGraphicsScene*>(QGraphicsItem::scene());
}
void UBGraphicsWebView::remove()
{
if (mDelegate)
mDelegate->remove(true);
}

@ -1,61 +0,0 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBGRAPHICSWEBVIEW_H_
#define UBGRAPHICSWEBVIEW_H_
#include <QtGui>
#include <QtWebKit>
#include "UBItem.h"
#include "UBResizableGraphicsItem.h"
class UBGraphicsItemDelegate;
class UBGraphicsWebView: public QGraphicsWebView, public UBItem, public UBResizableGraphicsItem, public UBGraphicsItem
{
public:
UBGraphicsWebView(QGraphicsItem* parent = 0);
virtual ~UBGraphicsWebView();
virtual void resize(qreal w, qreal h);
virtual void resize(const QSizeF & size);
virtual QSizeF size() const;
void setDelegate(UBGraphicsItemDelegate* pDelegate);
virtual UBGraphicsScene* scene();
virtual void remove();
virtual UBGraphicsItemDelegate* Delegate() const { return mDelegate;}
virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid);
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
};
#endif /* UBGRAPHICSWEBVIEW_H_ */

@ -45,7 +45,7 @@ bool UBGraphicsWidgetItem::sInlineJavaScriptLoaded = false;
QStringList UBGraphicsWidgetItem::sInlineJavaScripts; QStringList UBGraphicsWidgetItem::sInlineJavaScripts;
UBGraphicsWidgetItem::UBGraphicsWidgetItem(const QUrl &pWidgetUrl, QGraphicsItem *parent) UBGraphicsWidgetItem::UBGraphicsWidgetItem(const QUrl &pWidgetUrl, QGraphicsItem *parent)
: UBGraphicsWebView(parent) : QGraphicsWebView(parent)
, mInitialLoadDone(false) , mInitialLoadDone(false)
, mIsFreezable(true) , mIsFreezable(true)
, mIsResizable(false) , mIsResizable(false)
@ -58,7 +58,7 @@ UBGraphicsWidgetItem::UBGraphicsWidgetItem(const QUrl &pWidgetUrl, QGraphicsItem
, mShouldMoveWidget(false) , mShouldMoveWidget(false)
, mUniboardAPI(0) , mUniboardAPI(0)
{ {
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly setData(UBGraphicsItemData::ItemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
QGraphicsWebView::setPage(new UBWebPage(this)); QGraphicsWebView::setPage(new UBWebPage(this));
QGraphicsWebView::settings()->setAttribute(QWebSettings::JavaEnabled, true); QGraphicsWebView::settings()->setAttribute(QWebSettings::JavaEnabled, true);
@ -84,9 +84,11 @@ UBGraphicsWidgetItem::UBGraphicsWidgetItem(const QUrl &pWidgetUrl, QGraphicsItem
viewPalette.setBrush(QPalette::Window, QBrush(Qt::transparent)); viewPalette.setBrush(QPalette::Window, QBrush(Qt::transparent));
setPalette(viewPalette); setPalette(viewPalette);
UBGraphicsWidgetItemDelegate* delegate = new UBGraphicsWidgetItemDelegate(this); setDelegate(new UBGraphicsWidgetItemDelegate(this));
delegate->init(); Delegate()->init();
setDelegate(delegate);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
QGraphicsWebView::setAcceptHoverEvents(true);
} }
@ -97,11 +99,11 @@ UBGraphicsWidgetItem::~UBGraphicsWidgetItem()
void UBGraphicsWidgetItem::initialize() void UBGraphicsWidgetItem::initialize()
{ {
UBGraphicsWebView::setMinimumSize(nominalSize()); setMinimumSize(nominalSize());
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); // Necessary to set if we want z value to be assigned correctly setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); // Necessary to set if we want z value to be assigned correctly
if (mDelegate && mDelegate->frame() && resizable()) if (Delegate() && Delegate()->frame() && resizable())
mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing); Delegate()->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing);
QPalette palette = page()->palette(); QPalette palette = page()->palette();
palette.setBrush(QPalette::Base, QBrush(Qt::transparent)); palette.setBrush(QPalette::Base, QBrush(Qt::transparent));
@ -260,17 +262,6 @@ void UBGraphicsWidgetItem::removeAllDatastoreEntries()
mDatastore.clear(); mDatastore.clear();
} }
UBGraphicsItemDelegate* UBGraphicsWidgetItem::Delegate() const
{
return mDelegate;
}
void UBGraphicsWidgetItem::remove()
{
if (mDelegate)
mDelegate->remove();
}
void UBGraphicsWidgetItem::removeScript() void UBGraphicsWidgetItem::removeScript()
{ {
if (page() && page()->mainFrame()) if (page() && page()->mainFrame())
@ -360,6 +351,8 @@ QPixmap UBGraphicsWidgetItem::takeSnapshot()
mIsTakingSnapshot = false; mIsTakingSnapshot = false;
mSnapshot = pixmap;
return pixmap; return pixmap;
} }
@ -502,7 +495,7 @@ bool UBGraphicsWidgetItem::event(QEvent *event)
else if (event->type() == QEvent::ShortcutOverride) else if (event->type() == QEvent::ShortcutOverride)
event->accept(); event->accept();
return UBGraphicsWebView::event(event); return QGraphicsWebView::event(event);
} }
void UBGraphicsWidgetItem::dropEvent(QGraphicsSceneDragDropEvent *event) void UBGraphicsWidgetItem::dropEvent(QGraphicsSceneDragDropEvent *event)
@ -513,7 +506,10 @@ void UBGraphicsWidgetItem::dropEvent(QGraphicsSceneDragDropEvent *event)
void UBGraphicsWidgetItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsWidgetItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
UBGraphicsWebView::mousePressEvent(event); if (!Delegate()->mousePressEvent(event))
setSelected(true); /* forcing selection */
QGraphicsWebView::mousePressEvent(event);
// did webkit consume the mouse press ? // did webkit consume the mouse press ?
mShouldMoveWidget = !event->isAccepted() && (event->buttons() & Qt::LeftButton); mShouldMoveWidget = !event->isAccepted() && (event->buttons() & Qt::LeftButton);
@ -527,24 +523,19 @@ void UBGraphicsWidgetItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
mShouldMoveWidget = false; mShouldMoveWidget = false;
UBGraphicsWebView::mouseReleaseEvent(event); Delegate()->mouseReleaseEvent(event);
QGraphicsWebView::mouseReleaseEvent(event);
} }
void UBGraphicsWidgetItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void UBGraphicsWidgetItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
sendJSEnterEvent(); sendJSEnterEvent();
mDelegate->hoverEnterEvent(event); Delegate()->hoverEnterEvent(event);
UBGraphicsWebView::hoverEnterEvent(event);
} }
void UBGraphicsWidgetItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) void UBGraphicsWidgetItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{ {
sendJSLeaveEvent(); sendJSLeaveEvent();
mDelegate->hoverLeaveEvent(event); Delegate()->hoverLeaveEvent(event);
UBGraphicsWebView::hoverLeaveEvent(event);
}
void UBGraphicsWidgetItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
UBGraphicsWebView::hoverMoveEvent(event);
} }
void UBGraphicsWidgetItem::sendJSEnterEvent() void UBGraphicsWidgetItem::sendJSEnterEvent()
@ -572,11 +563,14 @@ void UBGraphicsWidgetItem::injectInlineJavaScript()
void UBGraphicsWidgetItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void UBGraphicsWidgetItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{ {
if (mIsFrozen) if (scene()->renderingContext() != UBGraphicsScene::Screen)
painter->drawPixmap(0, 0, mSnapshot); {
painter->drawPixmap(0, 0, snapshot());
}
else else
UBGraphicsWebView::paint(painter, option, widget); {
if (!mInitialLoadDone || mLoadIsErronous) { if (!mInitialLoadDone || mLoadIsErronous)
{
QString message; QString message;
if (mInitialLoadDone && mLoadIsErronous) if (mInitialLoadDone && mLoadIsErronous)
@ -599,6 +593,10 @@ void UBGraphicsWidgetItem::paint( QPainter *painter, const QStyleOptionGraphicsI
painter->setPen(Qt::white); painter->setPen(Qt::white);
painter->drawText(rect(), Qt::AlignCenter, message); painter->drawText(rect(), Qt::AlignCenter, message);
} }
else
QGraphicsWebView::paint(painter, option, widget);
}
} }
void UBGraphicsWidgetItem::geometryChangeRequested(const QRect& geom) void UBGraphicsWidgetItem::geometryChangeRequested(const QRect& geom)
@ -624,6 +622,52 @@ void UBGraphicsWidgetItem::mainFrameLoadFinished (bool ok)
update(boundingRect()); update(boundingRect());
} }
void UBGraphicsWidgetItem::wheelEvent(QGraphicsSceneWheelEvent *event)
{
if (Delegate()->weelEvent(event))
{
QGraphicsWebView::wheelEvent(event);
event->accept();
}
}
QVariant UBGraphicsWidgetItem::itemChange(GraphicsItemChange change, const QVariant &value)
{
if ((change == QGraphicsItem::ItemSelectedHasChanged) && scene()) {
if (isSelected())
scene()->setActiveWindow(this);
else
if(scene()->activeWindow() == this)
scene()->setActiveWindow(0);
}
QVariant newValue = Delegate()->itemChange(change, value);
return QGraphicsWebView::itemChange(change, newValue);
}
void UBGraphicsWidgetItem::resize(qreal w, qreal h)
{
UBGraphicsWidgetItem::resize(QSizeF(w, h));
}
void UBGraphicsWidgetItem::resize(const QSizeF & pSize)
{
if (pSize != size()) {
QGraphicsWebView::setMaximumSize(pSize.width(), pSize.height());
QGraphicsWebView::resize(pSize.width(), pSize.height());
if (Delegate())
Delegate()->positionHandles();
if (scene())
scene()->setModified(true);
}
}
QSizeF UBGraphicsWidgetItem::size() const
{
return QGraphicsWebView::size();
}
UBGraphicsAppleWidgetItem::UBGraphicsAppleWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent) UBGraphicsAppleWidgetItem::UBGraphicsAppleWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent)
@ -881,21 +925,6 @@ UBItem* UBGraphicsW3CWidgetItem::deepCopy() const
return copy; return copy;
} }
void UBGraphicsW3CWidgetItem::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
{
UBGraphicsScene::RenderingContext rc = UBGraphicsScene::Screen;
if (scene())
rc = scene()->renderingContext();
if (rc == UBGraphicsScene::NonScreen || rc == UBGraphicsScene::PdfExport) {
if (!snapshot().isNull())
painter->drawPixmap(0, 0, snapshot());
}
else
UBGraphicsWidgetItem::paint(painter, option, widget);
}
QMap<QString, UBGraphicsW3CWidgetItem::PreferenceValue> UBGraphicsW3CWidgetItem::preferences() QMap<QString, UBGraphicsW3CWidgetItem::PreferenceValue> UBGraphicsW3CWidgetItem::preferences()
{ {
return mPreferences; return mPreferences;

@ -19,10 +19,11 @@
#include <QtWebKit> #include <QtWebKit>
#include <QDomElement> #include <QDomElement>
#include "UBGraphicsWebView.h"
#include "core/UB.h" #include "core/UB.h"
#include "UBItem.h"
#include "UBResizableGraphicsItem.h"
class UBWidgetUniboardAPI; class UBWidgetUniboardAPI;
class UBGraphicsScene; class UBGraphicsScene;
class UBW3CWidgetAPI; class UBW3CWidgetAPI;
@ -38,7 +39,7 @@ struct UBWidgetType
}; };
}; };
class UBGraphicsWidgetItem : public UBGraphicsWebView class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBResizableGraphicsItem, public UBGraphicsItem
{ {
Q_OBJECT Q_OBJECT
@ -52,6 +53,10 @@ class UBGraphicsWidgetItem : public UBGraphicsWebView
virtual void initialize(); virtual void initialize();
virtual void resize(qreal w, qreal h);
virtual void resize(const QSizeF & size);
virtual QSizeF size() const;
QUrl mainHtml(); QUrl mainHtml();
void loadMainHtml(); void loadMainHtml();
QUrl widgetUrl(); QUrl widgetUrl();
@ -75,9 +80,6 @@ class UBGraphicsWidgetItem : public UBGraphicsWebView
void removeDatastoreEntry(const QString& key); void removeDatastoreEntry(const QString& key);
void removeAllDatastoreEntries(); void removeAllDatastoreEntries();
virtual UBGraphicsItemDelegate* Delegate() const;
virtual void remove();
void removeScript(); void removeScript();
void processDropEvent(QGraphicsSceneDragDropEvent *event); void processDropEvent(QGraphicsSceneDragDropEvent *event);
@ -140,16 +142,18 @@ class UBGraphicsWidgetItem : public UBGraphicsWebView
QMap<QString, QString> mDatastore; QMap<QString, QString> mDatastore;
QMap<QString, QString> mPreferences; QMap<QString, QString> mPreferences;
virtual bool event(QEvent *event); virtual bool event(QEvent *event);
virtual void dropEvent(QGraphicsSceneDragDropEvent *event); virtual void dropEvent(QGraphicsSceneDragDropEvent *event);
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event); virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
virtual void sendJSEnterEvent(); virtual void sendJSEnterEvent();
virtual void sendJSLeaveEvent(); virtual void sendJSLeaveEvent();
virtual void injectInlineJavaScript(); virtual void injectInlineJavaScript();
virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
protected slots: protected slots:
@ -230,7 +234,6 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const; virtual void copyItemParameters(UBItem *copy) const;
virtual void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget );
QMap<QString, PreferenceValue> preferences(); QMap<QString, PreferenceValue> preferences();
Metadata metadatas() const; Metadata metadatas() const;

@ -38,6 +38,18 @@ UBItem::~UBItem()
// NOOP // NOOP
} }
UBGraphicsItem::~UBGraphicsItem()
{
if (mDelegate!=NULL)
delete mDelegate;
}
void UBGraphicsItem::setDelegate(UBGraphicsItemDelegate* delegate)
{
Q_ASSERT(mDelegate==NULL);
mDelegate = delegate;
}
void UBGraphicsItem::assignZValue(QGraphicsItem *item, qreal value) void UBGraphicsItem::assignZValue(QGraphicsItem *item, qreal value)
{ {
item->setZValue(value); item->setZValue(value);
@ -54,6 +66,18 @@ bool UBGraphicsItem::isRotatable(QGraphicsItem *item)
return item->data(UBGraphicsItemData::ItemRotatable).toBool(); return item->data(UBGraphicsItemData::ItemRotatable).toBool();
} }
QUuid UBGraphicsItem::getOwnUuid(QGraphicsItem *item)
{
QString idCandidate = item->data(UBGraphicsItemData::ItemUuid).toString();
return idCandidate == QUuid().toString() ? QUuid() : QUuid(idCandidate);
}
void UBGraphicsItem::remove(bool canUndo)
{
if (Delegate())
Delegate()->remove(canUndo);
}
UBGraphicsItemDelegate *UBGraphicsItem::Delegate(QGraphicsItem *pItem) UBGraphicsItemDelegate *UBGraphicsItem::Delegate(QGraphicsItem *pItem)
{ {
UBGraphicsItemDelegate *result = 0; UBGraphicsItemDelegate *result = 0;

@ -90,30 +90,30 @@ class UBItem
class UBGraphicsItem class UBGraphicsItem
{ {
protected: protected:
UBGraphicsItem() : mDelegate(NULL)
UBGraphicsItem() : mDelegate(0)
{
// NOOP
}
UBGraphicsItemDelegate* mDelegate;
virtual ~UBGraphicsItem()
{ {
// NOOP // NOOP
} }
virtual ~UBGraphicsItem();
void setDelegate(UBGraphicsItemDelegate* mDelegate);
public: public:
inline UBGraphicsItemDelegate *Delegate() const { return mDelegate; }
static void assignZValue(QGraphicsItem*, qreal value); static void assignZValue(QGraphicsItem*, qreal value);
static bool isRotatable(QGraphicsItem *item); static bool isRotatable(QGraphicsItem *item);
static bool isFlippable(QGraphicsItem *item); static bool isFlippable(QGraphicsItem *item);
static QUuid getOwnUuid(QGraphicsItem *item);
static UBGraphicsItemDelegate *Delegate(QGraphicsItem *pItem); static UBGraphicsItemDelegate *Delegate(QGraphicsItem *pItem);
virtual UBGraphicsItemDelegate *Delegate() const = 0;
virtual void remove() = 0; void remove(bool canUndo = true);
virtual void clearSource(){;} virtual void clearSource(){}
private:
UBGraphicsItemDelegate* mDelegate;
}; };
#endif // UBITEM_H #endif // UBITEM_H

@ -6,7 +6,6 @@ HEADERS += src/domain/UBGraphicsScene.h \
src/domain/UBDocumentUndoCommand.h \ src/domain/UBDocumentUndoCommand.h \
src/domain/UBPageSizeUndoCommand.h \ src/domain/UBPageSizeUndoCommand.h \
src/domain/UBGraphicsProxyWidget.h \ src/domain/UBGraphicsProxyWidget.h \
src/domain/UBGraphicsWebView.h \
src/domain/UBGraphicsSvgItem.h \ src/domain/UBGraphicsSvgItem.h \
src/domain/UBGraphicsPolygonItem.h \ src/domain/UBGraphicsPolygonItem.h \
src/domain/UBItem.h \ src/domain/UBItem.h \
@ -35,7 +34,6 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBDocumentUndoCommand.cpp \ src/domain/UBDocumentUndoCommand.cpp \
src/domain/UBPageSizeUndoCommand.cpp \ src/domain/UBPageSizeUndoCommand.cpp \
src/domain/UBGraphicsProxyWidget.cpp \ src/domain/UBGraphicsProxyWidget.cpp \
src/domain/UBGraphicsWebView.cpp \
src/domain/UBGraphicsSvgItem.cpp \ src/domain/UBGraphicsSvgItem.cpp \
src/domain/UBGraphicsPolygonItem.cpp \ src/domain/UBGraphicsPolygonItem.cpp \
src/domain/UBItem.cpp \ src/domain/UBItem.cpp \
@ -47,8 +45,8 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBGraphicsStroke.cpp \ src/domain/UBGraphicsStroke.cpp \
src/domain/UBGraphicsMediaItem.cpp \ src/domain/UBGraphicsMediaItem.cpp \
src/domain/UBAbstractUndoCommand.cpp \ src/domain/UBAbstractUndoCommand.cpp \
src/domain/ubgraphicsgroupcontaineritem.cpp \ src/domain/UBGraphicsGroupContainerItem.cpp \
src/domain/ubgraphicsgroupcontaineritemdelegate.cpp \ src/domain/UBGraphicsGroupContainerItemDelegate.cpp \
src/domain/UBGraphicsStrokesGroup.cpp \ src/domain/UBGraphicsStrokesGroup.cpp \
src/domain/UBGraphicsItemGroupUndoCommand.cpp \ src/domain/UBGraphicsItemGroupUndoCommand.cpp \
src/domain/UBGraphicsItemDelegate.cpp \ src/domain/UBGraphicsItemDelegate.cpp \

@ -69,6 +69,9 @@ UBDocumentNavigator::~UBDocumentNavigator()
} }
} }
#include "gui/UBDockTeacherGuideWidget.h"
#include "gui/UBTeacherGuideWidget.h"
/** /**
* \brief Generate the thumbnails * \brief Generate the thumbnails
*/ */
@ -84,9 +87,30 @@ void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source)
for(int i = 0; i < source->selectedDocument()->pageCount(); i++) for(int i = 0; i < source->selectedDocument()->pageCount(); i++)
{ {
const QPixmap* pix = source->pageAt(i); const QPixmap* pix = source->pageAt(i);
UBSceneThumbnailNavigPixmap* pixmapItem = new UBSceneThumbnailNavigPixmap(*pix, source->selectedDocument(), i); QPixmap result(pix->width(),pix->height());
int pageIndex = UBDocumentContainer::pageFromSceneIndex(i); int pageIndex = UBDocumentContainer::pageFromSceneIndex(i);
QPainter composePainter;
composePainter.begin(&result);
composePainter.drawPixmap(QPoint(0,0),*pix);
if(pageIndex == UBApplication::boardController->currentPage() &&
((pageIndex == 0 && UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()) ||
(pageIndex && UBSettings::settings()->teacherGuideLessonPagesActivated->get().toBool()))
) {
if(UBApplication::boardController->paletteManager()->teacherGuideDockWidget()->teacherGuideWidget()->isModified()){
QPixmap toque(":images/toque.png");
composePainter.setOpacity(0.6);
composePainter.drawPixmap(QPoint(pix->width() - toque.width(),0),toque);
}
}
composePainter.end();
UBSceneThumbnailNavigPixmap* pixmapItem = new UBSceneThumbnailNavigPixmap(result, source->selectedDocument(), i);
QString label = pageIndex == 0 ? tr("Title page") : tr("Page %0").arg(pageIndex); QString label = pageIndex == 0 ? tr("Title page") : tr("Page %0").arg(pageIndex);
UBThumbnailTextItem *labelItem = new UBThumbnailTextItem(label); UBThumbnailTextItem *labelItem = new UBThumbnailTextItem(label);
@ -104,7 +128,7 @@ void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source)
void UBDocumentNavigator::onScrollToSelectedPage(int index) void UBDocumentNavigator::onScrollToSelectedPage(int index)
{ {
qDebug() << "Selection in widet: " << index; qDebug() << "Selection in widget: " << index;
int c = 0; int c = 0;
foreach(UBImgTextThumbnailElement el, mThumbsWithLabels) foreach(UBImgTextThumbnailElement el, mThumbsWithLabels)
{ {
@ -118,7 +142,6 @@ void UBDocumentNavigator::onScrollToSelectedPage(int index)
} }
c++; c++;
} }
// centerOn(mThumbsWithLabels[index].getThumbnail());
} }
/** /**
@ -131,8 +154,7 @@ void UBDocumentNavigator::updateSpecificThumbnail(int iPage)
//UBGraphicsScene* pScene = UBApplication::boardController->activeScene(); //UBGraphicsScene* pScene = UBApplication::boardController->activeScene();
const QPixmap* pix = UBApplication::boardController->pageAt(iPage); const QPixmap* pix = UBApplication::boardController->pageAt(iPage);
UBSceneThumbnailNavigPixmap* newItem = new UBSceneThumbnailNavigPixmap(*pix, UBSceneThumbnailNavigPixmap* newItem = new UBSceneThumbnailNavigPixmap(*pix, UBApplication::boardController->selectedDocument(), iPage);
UBApplication::boardController->selectedDocument(), iPage);
// Get the old thumbnail // Get the old thumbnail
UBSceneThumbnailNavigPixmap* oldItem = mThumbsWithLabels.at(iPage).getThumbnail(); UBSceneThumbnailNavigPixmap* oldItem = mThumbsWithLabels.at(iPage).getThumbnail();

@ -20,7 +20,7 @@
#include <QTreeWidget> #include <QTreeWidget>
#include <QPushButton> #include <QPushButton>
#include <QDomDocument> #include <QDomDocument>
#include <QScrollArea>
#include "UBTeacherGuideWidget.h" #include "UBTeacherGuideWidget.h"
@ -163,6 +163,7 @@ UBTeacherGuideEditionWidget::~UBTeacherGuideEditionWidget()
void UBTeacherGuideEditionWidget::onSliderMoved(int size) void UBTeacherGuideEditionWidget::onSliderMoved(int size)
{ {
Q_UNUSED(size); Q_UNUSED(size);
if(mpAddAMediaItem)
mpAddAMediaItem->setExpanded(true); mpAddAMediaItem->setExpanded(true);
} }
#endif #endif
@ -491,6 +492,7 @@ UBTeacherGuidePresentationWidget::~UBTeacherGuidePresentationWidget()
void UBTeacherGuidePresentationWidget::onSliderMoved(int size) void UBTeacherGuidePresentationWidget::onSliderMoved(int size)
{ {
Q_UNUSED(size); Q_UNUSED(size);
if(mpMediaSwitchItem)
mpMediaSwitchItem->setExpanded(true); mpMediaSwitchItem->setExpanded(true);
} }
#endif #endif
@ -632,8 +634,11 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons
QWidget(parent) QWidget(parent)
, mpLayout(NULL) , mpLayout(NULL)
, mpButtonTitleLayout(NULL) , mpButtonTitleLayout(NULL)
, mpContainerWidgetLayout(NULL)
, mpModePushButton(NULL) , mpModePushButton(NULL)
, mpPageNumberLabel(NULL) , mpPageNumberLabel(NULL)
, mpScrollArea(NULL)
, mpContainerWidget(NULL)
, mpSessionTitle(NULL) , mpSessionTitle(NULL)
, mpSeparatorSessionTitle(NULL) , mpSeparatorSessionTitle(NULL)
, mpAuthorsLabel(NULL) , mpAuthorsLabel(NULL)
@ -673,6 +678,16 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons
mpPageNumberLabel->setText(tr("Title page")); mpPageNumberLabel->setText(tr("Title page"));
mpLayout->addWidget(mpPageNumberLabel); mpLayout->addWidget(mpPageNumberLabel);
mpScrollArea = new QScrollArea();
mpContainerWidget = new QWidget();
mpContainerWidgetLayout = new QVBoxLayout();
mpLayout->addWidget(mpScrollArea);
mpScrollArea->setWidget(mpContainerWidget);
mpScrollArea->setWidgetResizable(true);
mpScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
mpContainerWidget->setLayout(mpContainerWidgetLayout);
mpButtonTitleLayout = new QHBoxLayout(0); mpButtonTitleLayout = new QHBoxLayout(0);
mpModePushButton = new QPushButton(this); mpModePushButton = new QPushButton(this);
@ -684,132 +699,139 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons
mpSessionTitle = new UBTGAdaptableText(0, this, "UBTGSessionTitle"); mpSessionTitle = new UBTGAdaptableText(0, this, "UBTGSessionTitle");
mpSessionTitle->setPlaceHolderText(tr("Type session title here ...")); mpSessionTitle->setPlaceHolderText(tr("Type session title here ..."));
mpSessionTitle->setMaximumLength(1000);
mpButtonTitleLayout->addWidget(mpSessionTitle); mpButtonTitleLayout->addWidget(mpSessionTitle);
connect(this, SIGNAL(resized()), mpSessionTitle, SLOT(onTextChanged())); connect(this, SIGNAL(resized()), mpSessionTitle, SLOT(onTextChanged()));
mpLayout->addLayout(mpButtonTitleLayout); mpContainerWidgetLayout->addLayout(mpButtonTitleLayout);
mpSeparatorSessionTitle = new QFrame(this); mpSeparatorSessionTitle = new QFrame(this);
mpSeparatorSessionTitle->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT); mpSeparatorSessionTitle->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT);
mpSeparatorSessionTitle->setObjectName("UBTGSeparator"); mpSeparatorSessionTitle->setObjectName("UBTGSeparator");
mpLayout->addWidget(mpSeparatorSessionTitle); mpContainerWidgetLayout->addWidget(mpSeparatorSessionTitle);
mpAuthorsLabel = new QLabel(this); mpAuthorsLabel = new QLabel(this);
mpAuthorsLabel->setObjectName("UBTGZeroPageEditionModeTitle"); mpAuthorsLabel->setObjectName("UBTGZeroPageEditionModeTitle");
mpAuthorsLabel->setText(tr("Author(s)")); mpAuthorsLabel->setText(tr("Author(s)"));
mpAuthorsLabel->setStyleSheet(chapterStyle); mpAuthorsLabel->setStyleSheet(chapterStyle);
mpLayout->addWidget(mpAuthorsLabel); mpContainerWidgetLayout->addWidget(mpAuthorsLabel);
mpAuthors = new UBTGAdaptableText(0, this); mpAuthors = new UBTGAdaptableText(0, this);
mpAuthors->setObjectName("UBTGZeroPageInputText"); mpAuthors->setObjectName("UBTGZeroPageInputText");
mpAuthors->setPlaceHolderText(tr("Type authors here ...")); mpAuthors->setPlaceHolderText(tr("Type authors here ..."));
mpLayout->addWidget(mpAuthors); mpContainerWidgetLayout->addWidget(mpAuthors);
connect(this, SIGNAL(resized()), mpAuthors, SLOT(onTextChanged())); connect(this, SIGNAL(resized()), mpAuthors, SLOT(onTextChanged()));
mpCreationLabel = new QLabel(this); mpCreationLabel = new QLabel(this);
mpCreationLabel->setObjectName("UBTGZeroPageDateLabel"); mpCreationLabel->setObjectName("UBTGZeroPageDateLabel");
mpLayout->addWidget(mpCreationLabel); mpContainerWidgetLayout->addWidget(mpCreationLabel);
mpLastModifiedLabel = new QLabel(this); mpLastModifiedLabel = new QLabel(this);
mpLastModifiedLabel->setObjectName("UBTGZeroPageDateLabel"); mpLastModifiedLabel->setObjectName("UBTGZeroPageDateLabel");
mpLayout->addWidget(mpLastModifiedLabel); mpContainerWidgetLayout->addWidget(mpLastModifiedLabel);
mpSeparatorAuthors = new QFrame(this); mpSeparatorAuthors = new QFrame(this);
mpSeparatorAuthors->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT); mpSeparatorAuthors->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT);
mpSeparatorAuthors->setObjectName("UBTGSeparator"); mpSeparatorAuthors->setObjectName("UBTGSeparator");
mpLayout->addWidget(mpSeparatorAuthors); mpContainerWidgetLayout->addWidget(mpSeparatorAuthors);
mpObjectivesLabel = new QLabel(this); mpObjectivesLabel = new QLabel(this);
mpObjectivesLabel->setObjectName("UBTGZeroPageEditionModeTitle"); mpObjectivesLabel->setObjectName("UBTGZeroPageEditionModeTitle");
mpObjectivesLabel->setText(tr("Objective(s)")); mpObjectivesLabel->setText(tr("Objective(s)"));
mpObjectivesLabel->setStyleSheet(chapterStyle); mpObjectivesLabel->setStyleSheet(chapterStyle);
mpLayout->addWidget(mpObjectivesLabel); mpContainerWidgetLayout->addWidget(mpObjectivesLabel);
mpObjectives = new UBTGAdaptableText(0, this); mpObjectives = new UBTGAdaptableText(0, this);
mpObjectives->setObjectName("UBTGZeroPageInputText"); mpObjectives->setObjectName("UBTGZeroPageInputText");
mpObjectives->setPlaceHolderText(tr("Type objectives here...")); mpObjectives->setPlaceHolderText(tr("Type objectives here..."));
mpLayout->addWidget(mpObjectives); mpContainerWidgetLayout->addWidget(mpObjectives);
connect(this, SIGNAL(resized()), mpObjectives, SLOT(onTextChanged())); connect(this, SIGNAL(resized()), mpObjectives, SLOT(onTextChanged()));
mpSeparatorObjectives = new QFrame(this); mpSeparatorObjectives = new QFrame(this);
mpSeparatorObjectives->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT); mpSeparatorObjectives->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT);
mpSeparatorObjectives->setObjectName("UBTGSeparator"); mpSeparatorObjectives->setObjectName("UBTGSeparator");
mpLayout->addWidget(mpSeparatorObjectives); mpContainerWidgetLayout->addWidget(mpSeparatorObjectives);
mpIndexLabel = new QLabel(this); mpIndexLabel = new QLabel(this);
mpIndexLabel->setObjectName("UBTGZeroPageEditionModeTitle"); mpIndexLabel->setObjectName("UBTGZeroPageEditionModeTitle");
mpIndexLabel->setText(tr("Resource indexing")); mpIndexLabel->setText(tr("Resource indexing"));
mpIndexLabel->setStyleSheet(chapterStyle); mpIndexLabel->setStyleSheet(chapterStyle);
mpLayout->addWidget(mpIndexLabel); mpContainerWidgetLayout->addWidget(mpIndexLabel);
mpKeywordsLabel = new QLabel(this); mpKeywordsLabel = new QLabel(this);
mpKeywordsLabel->setObjectName("UBTGZeroPageItemLabel"); mpKeywordsLabel->setObjectName("UBTGZeroPageItemLabel");
mpKeywordsLabel->setText(tr("Keywords:")); mpKeywordsLabel->setText(tr("Keywords:"));
mpKeywordsLabel->setStyleSheet(chapterStyle); mpKeywordsLabel->setStyleSheet(chapterStyle);
mpLayout->addWidget(mpKeywordsLabel); mpContainerWidgetLayout->addWidget(mpKeywordsLabel);
mpKeywords = new UBTGAdaptableText(0, this); mpKeywords = new UBTGAdaptableText(0, this);
mpKeywords->setPlaceHolderText(tr("Type keywords here ...")); mpKeywords->setPlaceHolderText(tr("Type keywords here ..."));
mpLayout->addWidget(mpKeywords); mpContainerWidgetLayout->addWidget(mpKeywords);
connect(this, SIGNAL(resized()), mpKeywords, SLOT(onTextChanged())); connect(this, SIGNAL(resized()), mpKeywords, SLOT(onTextChanged()));
mpSchoolLevelItemLabel = new QLabel(this); mpSchoolLevelItemLabel = new QLabel(this);
mpSchoolLevelItemLabel->setObjectName("UBTGZeroPageItemLabel"); mpSchoolLevelItemLabel->setObjectName("UBTGZeroPageItemLabel");
mpSchoolLevelItemLabel->setText(tr("Level:")); mpSchoolLevelItemLabel->setText(tr("Level:"));
mpSchoolLevelItemLabel->setStyleSheet(chapterStyle); mpSchoolLevelItemLabel->setStyleSheet(chapterStyle);
mpLayout->addWidget(mpSchoolLevelItemLabel); mpContainerWidgetLayout->addWidget(mpSchoolLevelItemLabel);
mpSchoolLevelBox = new QComboBox(this); mpSchoolLevelBox = new QComboBox(this);
mpSchoolLevelBox->setMinimumHeight(22); mpSchoolLevelBox->setMinimumHeight(22);
mpSchoolLevelBox->setMinimumWidth(LOWER_RESIZE_WIDTH);
mpSchoolLevelBox->setObjectName("DockPaletteWidgetComboBox"); mpSchoolLevelBox->setObjectName("DockPaletteWidgetComboBox");
connect(mpSchoolLevelBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(onSchoolLevelChanged(QString))); connect(mpSchoolLevelBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(onSchoolLevelChanged(QString)));
mpLayout->addWidget(mpSchoolLevelBox); mpContainerWidgetLayout->addWidget(mpSchoolLevelBox);
mpSchoolLevelValueLabel = new QLabel(this); mpSchoolLevelValueLabel = new QLabel(this);
mpLayout->addWidget(mpSchoolLevelValueLabel); mpContainerWidgetLayout->addWidget(mpSchoolLevelValueLabel);
mpSchoolSubjectsItemLabel = new QLabel(this); mpSchoolSubjectsItemLabel = new QLabel(this);
mpSchoolSubjectsItemLabel->setObjectName("UBTGZeroPageItemLabel"); mpSchoolSubjectsItemLabel->setObjectName("UBTGZeroPageItemLabel");
mpSchoolSubjectsItemLabel->setText(tr("Subjects:")); mpSchoolSubjectsItemLabel->setText(tr("Subjects:"));
mpSchoolSubjectsItemLabel->setStyleSheet(chapterStyle); mpSchoolSubjectsItemLabel->setStyleSheet(chapterStyle);
mpLayout->addWidget(mpSchoolSubjectsItemLabel); mpContainerWidgetLayout->addWidget(mpSchoolSubjectsItemLabel);
mpSchoolSubjectsBox = new QComboBox(this); mpSchoolSubjectsBox = new QComboBox(this);
mpSchoolSubjectsBox->setMinimumHeight(22); mpSchoolSubjectsBox->setMinimumHeight(22);
mpSchoolSubjectsBox->setMinimumWidth(LOWER_RESIZE_WIDTH);
mpSchoolSubjectsBox->setObjectName("DockPaletteWidgetComboBox"); mpSchoolSubjectsBox->setObjectName("DockPaletteWidgetComboBox");
mpLayout->addWidget(mpSchoolSubjectsBox); mpContainerWidgetLayout->addWidget(mpSchoolSubjectsBox);
mpSchoolSubjectsValueLabel = new QLabel(this); mpSchoolSubjectsValueLabel = new QLabel(this);
mpLayout->addWidget(mpSchoolSubjectsValueLabel); mpContainerWidgetLayout->addWidget(mpSchoolSubjectsValueLabel);
mpSchoolTypeItemLabel = new QLabel(this); mpSchoolTypeItemLabel = new QLabel(this);
mpSchoolTypeItemLabel->setObjectName("UBTGZeroPageItemLabel"); mpSchoolTypeItemLabel->setObjectName("UBTGZeroPageItemLabel");
mpSchoolTypeItemLabel->setText(tr("Type:")); mpSchoolTypeItemLabel->setText(tr("Type:"));
mpSchoolTypeItemLabel->setStyleSheet(chapterStyle); mpSchoolTypeItemLabel->setStyleSheet(chapterStyle);
mpLayout->addWidget(mpSchoolTypeItemLabel); mpContainerWidgetLayout->addWidget(mpSchoolTypeItemLabel);
mpSchoolTypeBox = new QComboBox(this); mpSchoolTypeBox = new QComboBox(this);
mpSchoolTypeBox->setMinimumHeight(22); mpSchoolTypeBox->setMinimumHeight(22);
mpSchoolTypeBox->setMinimumWidth(LOWER_RESIZE_WIDTH);
mpSchoolTypeBox->setObjectName("DockPaletteWidgetComboBox"); mpSchoolTypeBox->setObjectName("DockPaletteWidgetComboBox");
mpLayout->addWidget(mpSchoolTypeBox); mpContainerWidgetLayout->addWidget(mpSchoolTypeBox);
mpSchoolTypeValueLabel = new QLabel(this); mpSchoolTypeValueLabel = new QLabel(this);
mpLayout->addWidget(mpSchoolTypeValueLabel); mpContainerWidgetLayout->addWidget(mpSchoolTypeValueLabel);
mpSeparatorIndex = new QFrame(this); mpSeparatorIndex = new QFrame(this);
mpSeparatorIndex->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT); mpSeparatorIndex->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT);
mpSeparatorIndex->setObjectName("UBTGSeparator"); mpSeparatorIndex->setObjectName("UBTGSeparator");
mpLayout->addWidget(mpSeparatorIndex); mpContainerWidgetLayout->addWidget(mpSeparatorIndex);
mpLicenceLabel = new QLabel(this); mpLicenceLabel = new QLabel(this);
mpLicenceLabel->setObjectName("UBTGZeroPageItemLabel"); mpLicenceLabel->setObjectName("UBTGZeroPageItemLabel");
mpLicenceLabel->setText(tr("Licence")); mpLicenceLabel->setText(tr("Licence"));
mpLicenceLabel->setStyleSheet(chapterStyle); mpLicenceLabel->setStyleSheet(chapterStyle);
mpLayout->addWidget(mpLicenceLabel); mpContainerWidgetLayout->addWidget(mpLicenceLabel);
mpLicenceBox = new QComboBox(this); mpLicenceBox = new QComboBox(this);
mpLicenceBox->setMinimumHeight(22); mpLicenceBox->setMinimumHeight(22);
mpLicenceBox->setMinimumWidth(LOWER_RESIZE_WIDTH);
mpLicenceBox->setObjectName("DockPaletteWidgetComboBox"); mpLicenceBox->setObjectName("DockPaletteWidgetComboBox");
mpLayout->addWidget(mpLicenceBox); mpContainerWidgetLayout->addWidget(mpLicenceBox);
mpLicenceLayout = new QHBoxLayout(0); mpLicenceLayout = new QHBoxLayout(0);
mpLicenceIcon = new QLabel(this); mpLicenceIcon = new QLabel(this);
mpLicenceIcon->setMinimumWidth(LOWER_RESIZE_WIDTH/2);
mpLicenceLayout->addWidget(mpLicenceIcon); mpLicenceLayout->addWidget(mpLicenceIcon);
mpLicenceValueLabel = new QLabel(this); mpLicenceValueLabel = new QLabel(this);
mpLicenceValueLabel->setMinimumWidth(LOWER_RESIZE_WIDTH/2);
mpLicenceLayout->addWidget(mpLicenceValueLabel); mpLicenceLayout->addWidget(mpLicenceValueLabel);
mpLayout->addLayout(mpLicenceLayout); mpContainerWidgetLayout->addLayout(mpLicenceLayout);
mpLayout->addStretch(1); mpContainerWidgetLayout->addStretch(1);
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged())); connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged()));
fillComboBoxes(); fillComboBoxes();
@ -845,6 +867,9 @@ UBTeacherGuidePageZeroWidget::~UBTeacherGuidePageZeroWidget()
DELETEPTR(mpModePushButton); DELETEPTR(mpModePushButton);
DELETEPTR(mpLicenceLayout); DELETEPTR(mpLicenceLayout);
DELETEPTR(mpButtonTitleLayout); DELETEPTR(mpButtonTitleLayout);
DELETEPTR(mpContainerWidgetLayout);
DELETEPTR(mpContainerWidget);
DELETEPTR(mpScrollArea);
DELETEPTR(mpLayout); DELETEPTR(mpLayout);
} }
@ -895,9 +920,9 @@ void UBTeacherGuidePageZeroWidget::fillComboBoxes()
parametersFile.close(); parametersFile.close();
QStringList licences; QStringList licences;
licences << tr("Attribution CC BY") licences << tr("Attribution-ShareAlike CC BY-SA")
<< tr("Attribution CC BY")
<< tr("Attribution-NoDerivs CC BY-ND") << tr("Attribution-NoDerivs CC BY-ND")
<< tr("Attribution-ShareAlike CC BY-SA")
<< tr("Attribution-NonCommercial CC BY-NC") << tr("Attribution-NonCommercial CC BY-NC")
<< tr("Attribution-NonCommercial-NoDerivs CC BY-NC-ND") << tr("Attribution-NonCommercial-NoDerivs CC BY-NC-ND")
<< tr("Attribution-NonCommercial-ShareAlike CC BY-NC-SA") << tr("Attribution-NonCommercial-ShareAlike CC BY-NC-SA")
@ -905,9 +930,9 @@ void UBTeacherGuidePageZeroWidget::fillComboBoxes()
<< tr("Copyright"); << tr("Copyright");
mpLicenceBox->addItems(licences); mpLicenceBox->addItems(licences);
QStringList licenceIconList; QStringList licenceIconList;
licenceIconList << ":images/licenses/ccby.png" licenceIconList << ":images/licenses/ccbysa.png"
<< ":images/licenses/ccby.png"
<< ":images/licenses/ccbynd.png" << ":images/licenses/ccbynd.png"
<< ":images/licenses/ccbysa.png"
<< ":images/licenses/ccbync.png" << ":images/licenses/ccbync.png"
<< ":images/licenses/ccbyncnd.png" << ":images/licenses/ccbyncnd.png"
<< ":images/licenses/ccbyncsa.png"; << ":images/licenses/ccbyncsa.png";
@ -923,7 +948,8 @@ void UBTeacherGuidePageZeroWidget::onSchoolLevelChanged(QString schoolLevel)
mpSchoolSubjectsItemLabel->setEnabled(true); mpSchoolSubjectsItemLabel->setEnabled(true);
mpSchoolSubjectsBox->setEnabled(true); mpSchoolSubjectsBox->setEnabled(true);
mpSchoolSubjectsBox->addItems(subjects); mpSchoolSubjectsBox->addItems(subjects);
} else { }
else {
mpSchoolSubjectsItemLabel->setDisabled(true); mpSchoolSubjectsItemLabel->setDisabled(true);
mpSchoolSubjectsBox->setDisabled(true); mpSchoolSubjectsBox->setDisabled(true);
} }
@ -1126,9 +1152,9 @@ bool UBTeacherGuidePageZeroWidget::isModified()
return result; return result;
} }
void UBTeacherGuidePageZeroWidget::resizeEvent(QResizeEvent* ev){ void UBTeacherGuidePageZeroWidget::resizeEvent(QResizeEvent* ev)
{
emit resized(); emit resized();
QWidget::resizeEvent(ev); QWidget::resizeEvent(ev);
} }

@ -23,7 +23,7 @@ class QVBoxLayout;
class QPushButton; class QPushButton;
class UBDocumentProxy; class UBDocumentProxy;
class UBGraphicsTextItem; class UBGraphicsTextItem;
class QScrollArea;
#include "UBTeacherGuideWidgetsTools.h" #include "UBTeacherGuideWidgetsTools.h"
@ -35,6 +35,8 @@ typedef enum
tUBTGZeroPageMode_PRESENTATION tUBTGZeroPageMode_PRESENTATION
}tUBTGZeroPageMode; }tUBTGZeroPageMode;
#define LOWER_RESIZE_WIDTH 50
/*************************************************************************** /***************************************************************************
* class UBTeacherGuideEditionWidget * * class UBTeacherGuideEditionWidget *
***************************************************************************/ ***************************************************************************/
@ -155,8 +157,13 @@ private:
QVBoxLayout* mpLayout; QVBoxLayout* mpLayout;
QHBoxLayout* mpButtonTitleLayout; QHBoxLayout* mpButtonTitleLayout;
QVBoxLayout* mpContainerWidgetLayout;
QPushButton* mpModePushButton; QPushButton* mpModePushButton;
QLabel* mpPageNumberLabel; QLabel* mpPageNumberLabel;
QScrollArea* mpScrollArea;
QWidget* mpContainerWidget;
UBTGAdaptableText* mpSessionTitle; UBTGAdaptableText* mpSessionTitle;
QFrame* mpSeparatorSessionTitle; QFrame* mpSeparatorSessionTitle;

@ -120,6 +120,7 @@ UBTGAdaptableText::UBTGAdaptableText(QTreeWidgetItem* widget, QWidget* parent, c
, mMinimumHeight(0) , mMinimumHeight(0)
, mHasPlaceHolder(false) , mHasPlaceHolder(false)
, mIsUpdatingSize(false) , mIsUpdatingSize(false)
, mMaximumLength(0)
{ {
setObjectName(name); setObjectName(name);
connect(this,SIGNAL(textChanged()),this,SLOT(onTextChanged())); connect(this,SIGNAL(textChanged()),this,SLOT(onTextChanged()));
@ -131,6 +132,11 @@ UBTGAdaptableText::UBTGAdaptableText(QTreeWidgetItem* widget, QWidget* parent, c
} }
void UBTGAdaptableText::setMaximumLength(int length)
{
mMaximumLength = length;
}
void UBTGAdaptableText::setPlaceHolderText(QString text) void UBTGAdaptableText::setPlaceHolderText(QString text)
{ {
mHasPlaceHolder = true; mHasPlaceHolder = true;
@ -166,6 +172,12 @@ void UBTGAdaptableText::keyReleaseEvent(QKeyEvent* e)
setTextColor(QColor(Qt::lightGray)); setTextColor(QColor(Qt::lightGray));
setPlainText(mPlaceHolderText); setPlainText(mPlaceHolderText);
} }
if(mMaximumLength && toPlainText().length()>mMaximumLength){
setPlainText(toPlainText().left(mMaximumLength));
QTextCursor tc(document());
tc.setPosition(mMaximumLength);
setTextCursor(tc);
}
} }
void UBTGAdaptableText::showEvent(QShowEvent* e) void UBTGAdaptableText::showEvent(QShowEvent* e)
@ -213,7 +225,9 @@ void UBTGAdaptableText::onTextChanged()
} }
mIsUpdatingSize = false; mIsUpdatingSize = false;
} }
void UBTGAdaptableText::setInitialText(const QString& text) void UBTGAdaptableText::setInitialText(const QString& text)
{ {
setText(text); setText(text);

@ -97,6 +97,7 @@ public:
void setPlaceHolderText(QString text); void setPlaceHolderText(QString text);
QString text(); QString text();
void setInitialText(const QString& text); void setInitialText(const QString& text);
void setMaximumLength(int length);
public slots: public slots:
void onTextChanged(); void onTextChanged();
@ -113,6 +114,7 @@ private:
bool mHasPlaceHolder; bool mHasPlaceHolder;
QString mPlaceHolderText; QString mPlaceHolderText;
bool mIsUpdatingSize; bool mIsUpdatingSize;
int mMaximumLength;
}; };

@ -14,6 +14,7 @@
*/ */
#include <QtGlobal> #include <QtGlobal>
#include <QString>
#include "Config.h" #include "Config.h"
#include "Utils.h" #include "Utils.h"
#include "Exception.h" #include "Exception.h"
@ -65,18 +66,12 @@ double Utils::stringToDouble(const std::string & s )
std::string Utils::uIntToStr(unsigned int integer) std::string Utils::uIntToStr(unsigned int integer)
{ {
char str[10]; return std::string(QString::number(integer).toAscii());
snprintf(str, sizeof(str), "%u", integer);
return std::string(str);
} }
std::string Utils::doubleToStr(double doubleValue) std::string Utils::doubleToStr(double doubleValue)
{ {
char str[16]; return std::string(QString::number(doubleValue).toAscii());
snprintf(str, sizeof(str), "%f", doubleValue);
return std::string(str);
} }
int Utils::_stringToInt(const std::string & str) //throw ConvertException int Utils::_stringToInt(const std::string & str) //throw ConvertException

@ -37,8 +37,9 @@ const QColor UBGraphicsCurtainItem::sDarkBackgroundOpaqueControlColor = QColor(6
UBGraphicsCurtainItem::UBGraphicsCurtainItem(QGraphicsItem* parent) UBGraphicsCurtainItem::UBGraphicsCurtainItem(QGraphicsItem* parent)
: QGraphicsRectItem(parent) : QGraphicsRectItem(parent)
{ {
mDelegate = new UBGraphicsCurtainItemDelegate(this, 0); UBGraphicsCurtainItemDelegate* delegate = new UBGraphicsCurtainItemDelegate(this, 0);
mDelegate->init(); delegate->init();
setDelegate(delegate);
setFlag(QGraphicsItem::ItemIsMovable, true); setFlag(QGraphicsItem::ItemIsMovable, true);
setFlag(QGraphicsItem::ItemIsSelectable, true); setFlag(QGraphicsItem::ItemIsSelectable, true);
@ -56,7 +57,6 @@ UBGraphicsCurtainItem::UBGraphicsCurtainItem(QGraphicsItem* parent)
UBGraphicsCurtainItem::~UBGraphicsCurtainItem() UBGraphicsCurtainItem::~UBGraphicsCurtainItem()
{ {
delete mDelegate;
} }
QVariant UBGraphicsCurtainItem::itemChange(GraphicsItemChange change, const QVariant &value) QVariant UBGraphicsCurtainItem::itemChange(GraphicsItemChange change, const QVariant &value)
@ -64,9 +64,9 @@ QVariant UBGraphicsCurtainItem::itemChange(GraphicsItemChange change, const QVar
QVariant newValue = value; QVariant newValue = value;
if (mDelegate) if (Delegate())
{ {
newValue = mDelegate->itemChange(change, value); newValue = Delegate()->itemChange(change, value);
} }
return QGraphicsRectItem::itemChange(change, newValue); return QGraphicsRectItem::itemChange(change, newValue);
@ -80,7 +80,7 @@ void UBGraphicsCurtainItem::setUuid(const QUuid &pUuid)
void UBGraphicsCurtainItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsCurtainItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mousePressEvent(event)) if (Delegate()->mousePressEvent(event))
{ {
//NOOP //NOOP
} }
@ -92,7 +92,7 @@ void UBGraphicsCurtainItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsCurtainItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsCurtainItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mouseMoveEvent(event)) if (Delegate()->mouseMoveEvent(event))
{ {
// NOOP; // NOOP;
} }
@ -104,7 +104,7 @@ void UBGraphicsCurtainItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsCurtainItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsCurtainItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
mDelegate->mouseReleaseEvent(event); Delegate()->mouseReleaseEvent(event);
QGraphicsRectItem::mouseReleaseEvent(event); QGraphicsRectItem::mouseReleaseEvent(event);
} }
@ -171,13 +171,6 @@ QColor UBGraphicsCurtainItem::opaqueControlColor() const
} }
void UBGraphicsCurtainItem::remove()
{
if (mDelegate)
mDelegate->remove(true);
}
void UBGraphicsCurtainItem::triggerRemovedSignal() void UBGraphicsCurtainItem::triggerRemovedSignal()
{ {
emit removed(); emit removed();

@ -44,11 +44,8 @@ class UBGraphicsCurtainItem : public QObject, public QGraphicsRectItem, public U
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const; virtual void copyItemParameters(UBItem *copy) const;
virtual void remove();
//TODO UB 4.x not nice ... //TODO UB 4.x not nice ...
void triggerRemovedSignal(); void triggerRemovedSignal();
virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate;}
virtual void clearSource(){;} virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);

@ -40,13 +40,12 @@ class UBGraphicsCurtainItemDelegate : public UBGraphicsItemDelegate
virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value); virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value);
virtual void positionHandles(); virtual void positionHandles();
virtual void init();
public slots: public slots:
virtual void remove(bool checked, bool canUndo = true); virtual void remove(bool checked, bool canUndo = true);
protected:
virtual void init();
}; };
#endif /* UBGRAPHICSCURTAINITEMDELEGATE_H_ */ #endif /* UBGRAPHICSCURTAINITEMDELEGATE_H_ */

Loading…
Cancel
Save