group fixes Uuid data

preferencesAboutTextFull
root 13 years ago
parent 2e3d33cc5c
commit 408811c5c5
  1. 29
      src/board/UBBoardController.cpp
  2. 1
      src/board/UBBoardController.h
  3. 3
      src/core/UBSettings.cpp
  4. 5
      src/core/UBSettings.h
  5. 6
      src/domain/UBGraphicsAudioItem.cpp
  6. 1
      src/domain/UBGraphicsAudioItem.h
  7. 2
      src/domain/UBGraphicsItemDelegate.h
  8. 5
      src/domain/UBGraphicsPDFItem.cpp
  9. 1
      src/domain/UBGraphicsPDFItem.h
  10. 6
      src/domain/UBGraphicsPixmapItem.cpp
  11. 2
      src/domain/UBGraphicsPixmapItem.h
  12. 5
      src/domain/UBGraphicsProxyWidget.cpp
  13. 1
      src/domain/UBGraphicsProxyWidget.h
  14. 102
      src/domain/UBGraphicsScene.cpp
  15. 6
      src/domain/UBGraphicsScene.h
  16. 6
      src/domain/UBGraphicsStrokesGroup.cpp
  17. 1
      src/domain/UBGraphicsStrokesGroup.h
  18. 6
      src/domain/UBGraphicsTextItem.cpp
  19. 1
      src/domain/UBGraphicsTextItem.h
  20. 6
      src/domain/UBGraphicsVideoItem.cpp
  21. 1
      src/domain/UBGraphicsVideoItem.h
  22. 17
      src/domain/UBGraphicsWidgetItem.cpp
  23. 3
      src/domain/UBGraphicsWidgetItem.h
  24. 6
      src/domain/ubgraphicsgroupcontaineritem.cpp
  25. 1
      src/domain/ubgraphicsgroupcontaineritem.h
  26. 6
      src/tools/UBGraphicsCurtainItem.cpp
  27. 4
      src/tools/UBGraphicsCurtainItem.h

@ -50,6 +50,7 @@
#include "domain/UBW3CWidget.h"
#include "domain/UBGraphicsTextItem.h"
#include "domain/UBPageSizeUndoCommand.h"
#include "domain/ubgraphicsgroupcontaineritem.h"
#include "tools/UBToolsManager.h"
@ -140,6 +141,8 @@ void UBBoardController::init()
setActiveDocumentScene(doc);
connect(UBApplication::mainWindow->actionGroupItems, SIGNAL(triggered()), this, SLOT(groupButtonClicked()));
undoRedoStateChange(true);
}
@ -760,6 +763,32 @@ void UBBoardController::lastScene()
emit pageChanged();
}
void UBBoardController::groupButtonClicked()
{
QAction *groupAction = UBApplication::mainWindow->actionGroupItems;
QList<QGraphicsItem*> selItems = activeScene()->selectedItems();
if (!selItems.count()) {
qDebug() << "Got grouping request when there is no any selected item on the scene";
return;
}
if (groupAction->text() == UBSettings::settings()->actionGroupText) { //The only way to get information from item, considering using smth else
UBGraphicsGroupContainerItem *groupItem = activeScene()->createGroup(selItems);
groupItem->setSelected(true);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
} else if (groupAction->text() == UBSettings::settings()->actionUngroupText) {
//Considering one selected item and it's a group
if (selItems.count() > 1) {
qDebug() << "can't make sense of ungrouping more then one item. Grouping action should be performed for that purpose";
return;
}
UBGraphicsGroupContainerItem *currentGroup = dynamic_cast<UBGraphicsGroupContainerItem*>(selItems.first());
if (currentGroup) {
currentGroup->destroy();
}
}
}
void UBBoardController::downloadURL(const QUrl& url, const QPointF& pPos, const QSize& pSize, bool isBackground)
{

@ -184,6 +184,7 @@ class UBBoardController : public QObject
void nextScene();
void firstScene();
void lastScene();
void groupButtonClicked();
void downloadURL(const QUrl& url, const QPointF& pPos = QPointF(0.0, 0.0), const QSize& pSize = QSize(), bool isBackground = false);
void downloadFinished(bool pSuccess, QUrl sourceUrl, QString pHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground = false);
void changeBackground(bool isDark, bool isCrossed);

@ -384,6 +384,9 @@ void UBSettings::init()
historyLimit = new UBSetting(this, "Web", "HistoryLimit", 15);
teacherGuidePageZeroActivated = new UBSetting(this,"DockPalette","TeacherGuideActivatePageZero",true);
teacherGuideLessonPagesActivated = new UBSetting(this,"DockPalette","TeacherGuideActivateLessonPages",true);
actionGroupText = "Group items";
actionUngroupText = "Ungroup items";
}

@ -18,7 +18,7 @@
class UBSettings : public QObject
{
Q_OBJECT;
Q_OBJECT
public:
@ -206,6 +206,9 @@ class UBSettings : public QObject
QString softwareHomeUrl;
QString actionGroupText;
QString actionUngroupText;
UBSetting* appToolBarPositionedAtTop;
UBSetting* appToolBarDisplayText;
UBSetting* appEnableAutomaticSoftwareUpdates;

@ -118,3 +118,9 @@ void UBGraphicsAudioItem::tick ( qint64 time )
mTimeLcd->display ( displayTime.toString ( "mm:ss" ) );
}
void UBGraphicsAudioItem::setUuid(const QUuid &pUuid)
{
UBItem::setUuid(pUuid);
setData(UBGraphicsItemData::ItemUuid, QVariant(pUuid));
}

@ -45,6 +45,7 @@ public:
{
UBGraphicsMediaItem::clearSource();
}
void setUuid(const QUuid &pUuid);
private slots:

@ -74,7 +74,7 @@ class UBGraphicsToolBarItem : public QGraphicsRectItem, public QObject
{
public:
UBGraphicsToolBarItem(QGraphicsItem * parent = 0);
virtual ~UBGraphicsToolBarItem() {};
virtual ~UBGraphicsToolBarItem() {;}
bool isVisibleOnBoard() const { return mVisible; }
void setVisibleOnBoard(bool visible) { mVisible = visible; }

@ -46,6 +46,11 @@ QVariant UBGraphicsPDFItem::itemChange(GraphicsItemChange change, const QVariant
return GraphicsPDFItem::itemChange(change, newValue);
}
void UBGraphicsPDFItem::setUuid(const QUuid &pUuid)
{
UBItem::setUuid(pUuid);
setData(UBGraphicsItemData::ItemUuid, QVariant(pUuid));
}
void UBGraphicsPDFItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{

@ -51,6 +51,7 @@ class UBGraphicsPDFItem: public GraphicsPDFItem, public UBItem, public UBGraphic
virtual UBGraphicsItemDelegate *Delegate() const {return mDelegate;}
virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid);
protected:

@ -52,6 +52,12 @@ QVariant UBGraphicsPixmapItem::itemChange(GraphicsItemChange change, const QVari
return QGraphicsPixmapItem::itemChange(change, newValue);
}
void UBGraphicsPixmapItem::setUuid(const QUuid &pUuid)
{
UBItem::setUuid(pUuid);
setData(UBGraphicsItemData::ItemUuid, QVariant(pUuid));
}
void UBGraphicsPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
QMimeData* pMime = new QMimeData();

@ -52,6 +52,8 @@ class UBGraphicsPixmapItem : public QObject, public QGraphicsPixmapItem, public
virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate;}
virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid);
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);

@ -67,6 +67,11 @@ QVariant UBGraphicsProxyWidget::itemChange(GraphicsItemChange change, const QVar
return QGraphicsProxyWidget::itemChange(change, newValue);
}
void UBGraphicsProxyWidget::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 UBGraphicsProxyWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
{

@ -44,6 +44,7 @@ class UBGraphicsProxyWidget: public QGraphicsProxyWidget, public UBItem, public
virtual UBGraphicsItemDelegate* Delegate() const { return mDelegate;}
virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid);
protected:

@ -65,9 +65,6 @@
#include "core/memcheck.h"
const QString groupText = "Group items";
const QString ungroupText = "Ungroup items";
qreal UBZLayerController::errorNumber = -20000001.0;
UBZLayerController::UBZLayerController(QGraphicsScene *scene) :
@ -296,14 +293,6 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
// Just for debug. Do not delete please
// connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing()));
connect(this, SIGNAL(selectionChanged()), this, SLOT(updateGroupButtonState()));
// just a stub don't treat as a result code
// static int i = 0;
// i++;
// if (i == 1) {
connect(UBApplication::mainWindow->actionGroupItems, SIGNAL(triggered()), this, SLOT(groupButtonClicked()));
// qDebug() << "the connect is accepted";
// }
}
UBGraphicsScene::~UBGraphicsScene()
@ -332,64 +321,20 @@ void UBGraphicsScene::updateGroupButtonState()
if (selCount < 1) {
groupAction->setEnabled(false);
groupAction->setText(groupText);
groupAction->setText(UBSettings::settings()->actionGroupText);
} else if (selCount == 1) {
if (selItems.first()->type() == UBGraphicsGroupContainerItem::Type) {
groupAction->setEnabled(true);
groupAction->setText(ungroupText);
groupAction->setText(UBSettings::settings()->actionUngroupText);
} else {
groupAction->setEnabled(false);
}
} else if (selCount > 1) {
groupAction->setEnabled(true);
groupAction->setText(groupText);
}
}
void UBGraphicsScene::groupButtonClicked()
{
QAction *groupAction = UBApplication::mainWindow->actionGroupItems;
QList<QGraphicsItem*> selItems = selectedItems();
if (!selItems.count()) {
qDebug() << "Got grouping request when there is no any selected item on the scene";
return;
}
if (groupAction->text() == groupText) { //The only way to get information from item, considering using smth else
UBGraphicsGroupContainerItem *groupItem = new UBGraphicsGroupContainerItem();
foreach (QGraphicsItem *item, selItems) {
if (item->type() == UBGraphicsGroupContainerItem::Type) {
QList<QGraphicsItem*> childItems = item->childItems();
UBGraphicsGroupContainerItem *currentGroup = dynamic_cast<UBGraphicsGroupContainerItem*>(item);
if (currentGroup) {
currentGroup->destroy();
}
foreach (QGraphicsItem *chItem, childItems) {
groupItem->addToGroup(chItem);
}
} else {
groupItem->addToGroup(item);
}
}
addItem(groupItem);
groupItem->setVisible(true);
groupItem->setFocus();
} else if (groupAction->text() == ungroupText) {
//Considering one selected item and it's a group
if (selItems.count() > 1) {
qDebug() << "can't make sense of ungrouping more then one item. Grouping action should be performed for that purpose";
return;
}
UBGraphicsGroupContainerItem *currentGroup = dynamic_cast<UBGraphicsGroupContainerItem*>(selItems.first());
if (currentGroup) {
currentGroup->destroy();
groupAction->setText(UBSettings::settings()->actionGroupText);
}
}
}
// MARK: -
@ -1582,6 +1527,39 @@ UBGraphicsW3CWidgetItem* UBGraphicsScene::addOEmbed(const QUrl& pContentUrl, con
return widget;
}
UBGraphicsGroupContainerItem *UBGraphicsScene::createGroup(QList<QGraphicsItem *> items)
{
UBGraphicsGroupContainerItem *groupItem = new UBGraphicsGroupContainerItem();
foreach (QGraphicsItem *item, items) {
if (item->type() == UBGraphicsGroupContainerItem::Type) {
QList<QGraphicsItem*> childItems = item->childItems();
UBGraphicsGroupContainerItem *currentGroup = dynamic_cast<UBGraphicsGroupContainerItem*>(item);
if (currentGroup) {
currentGroup->destroy();
}
foreach (QGraphicsItem *chItem, childItems) {
groupItem->addToGroup(chItem);
}
} else {
groupItem->addToGroup(item);
}
}
addItem(groupItem);
groupItem->setVisible(true);
groupItem->setFocus();
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, groupItem);
UBApplication::undoStack->push(uc);
}
setDocumentUpdated();
return groupItem;
}
UBGraphicsSvgItem* UBGraphicsScene::addSvg(const QUrl& pSvgFileUrl, const QPointF& pPos)
{
QString path = pSvgFileUrl.toLocalFile();
@ -2188,14 +2166,6 @@ void UBGraphicsScene::setOwnZlevel(QGraphicsItem *item)
{
item->setZValue(item->data(UBGraphicsItemData::ItemOwnZValue).toReal());
}
void UBGraphicsScene::groupItems(QList<QGraphicsItem *> &itemList)
{
foreach (QGraphicsItem *item, itemList) {
qDebug() << "selected item found";
item->setSelected(false);
}
}
qreal UBGraphicsScene::changeZLevelTo(QGraphicsItem *item, UBZLayerController::moveDestination dest)
{

@ -46,6 +46,7 @@ class UBGraphicsStroke;
class UBMagnifierParams;
class UBMagnifier;
class UBGraphicsCache;
class UBGraphicsGroupContainerItem;
const double PI = 4.0 * atan(1.0);
@ -141,6 +142,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
UBGraphicsW3CWidgetItem* addOEmbed(const QUrl& pContentUrl, const QPointF& pPos = QPointF(0, 0));
UBGraphicsGroupContainerItem *createGroup(QList<QGraphicsItem*> items);
QGraphicsItem* setAsBackgroundObject(QGraphicsItem* item, bool pAdaptTransformation = false, bool expand = false);
QGraphicsItem* backgroundObject() const
@ -289,7 +292,6 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void setSelectedZLevel(QGraphicsItem *item);
void setOwnZlevel(QGraphicsItem *item);
void groupItems(QList<QGraphicsItem *> &itemList);
public slots:
void hideEraser();
@ -307,8 +309,6 @@ public slots:
void selectionChangedProcessing();
void updateGroupButtonState();
void groupButtonClicked();
void moveMagnifier(QPoint newPos);
void closeMagnifier();
void zoomInMagnifier();

@ -22,6 +22,12 @@ UBGraphicsStrokesGroup::~UBGraphicsStrokesGroup()
}
}
void UBGraphicsStrokesGroup::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 UBGraphicsStrokesGroup::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (mDelegate->mousePressEvent(event))

@ -21,6 +21,7 @@ public:
{
return Type;
}
virtual void setUuid(const QUuid &pUuid);
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);

@ -296,6 +296,12 @@ QSizeF UBGraphicsTextItem::size() const
return QSizeF(textWidth(), textHeight());
}
void UBGraphicsTextItem::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 UBGraphicsTextItem::undoCommandAdded()
{

@ -81,6 +81,7 @@ class UBGraphicsTextItem : public QGraphicsTextItem, public UBItem, public UBRes
virtual UBGraphicsItemDelegate *Delegate() const {return mDelegate;}
virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid);
signals:
void textUndoCommandAdded(UBGraphicsTextItem *textItem);

@ -107,6 +107,12 @@ void UBGraphicsVideoItem::showOnDisplayChanged(bool shown)
vid->toggleMute();
}
void UBGraphicsVideoItem::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 UBGraphicsVideoItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
mShouldMove = (event->buttons() & Qt::LeftButton);

@ -48,6 +48,7 @@ public:
{
UBGraphicsMediaItem::clearSource();
}
virtual void setUuid(const QUuid &pUuid);
public slots:
void hasVideoChanged(bool hasVideo);

@ -58,6 +58,11 @@ void UBGraphicsWidgetItem::javaScriptWindowObjectCleared()
}
void UBGraphicsWidgetItem::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 UBGraphicsWidgetItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
@ -340,7 +345,11 @@ UBItem* UBGraphicsAppleWidgetItem::deepCopy() const
return appleWidget;
}
void UBGraphicsAppleWidgetItem::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
}
UBGraphicsW3CWidgetItem::UBGraphicsW3CWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent, int widgetType)
: UBGraphicsWidgetItem(parent, widgetType)
@ -389,6 +398,12 @@ void UBGraphicsW3CWidgetItem::paint(QPainter * painter, const QStyleOptionGraphi
}
}
void UBGraphicsW3CWidgetItem::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 UBGraphicsW3CWidgetItem::javaScriptWindowObjectCleared()
{
UBGraphicsWidgetItem::javaScriptWindowObjectCleared();

@ -78,6 +78,7 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
virtual QUrl getSnapshotPath(){return SnapshotFile;}
virtual void clearSource();
virtual void setUuid(const QUuid &pUuid);
protected:
@ -129,6 +130,7 @@ class UBGraphicsAppleWidgetItem : public UBGraphicsWidgetItem
}
virtual UBItem* deepCopy() const;
virtual void setUuid(const QUuid &pUuid);
};
@ -155,6 +157,7 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
UBW3CWidget* w3cWidget() const;
virtual void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget );
virtual void setUuid(const QUuid &pUuid);
private slots:

@ -180,6 +180,12 @@ void UBGraphicsGroupContainerItem::remove()
mDelegate->remove();
}
void UBGraphicsGroupContainerItem::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 UBGraphicsGroupContainerItem::destroy() {
foreach (QGraphicsItem *item, childItems()) {

@ -28,6 +28,7 @@ public:
return Type;
}
virtual void setUuid(const QUuid &pUuid);
void destroy();

@ -71,6 +71,12 @@ QVariant UBGraphicsCurtainItem::itemChange(GraphicsItemChange change, const QVar
return QGraphicsRectItem::itemChange(change, newValue);
}
void UBGraphicsCurtainItem::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 UBGraphicsCurtainItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (mDelegate->mousePressEvent(event))

@ -48,7 +48,9 @@ class UBGraphicsCurtainItem : public QObject, public QGraphicsRectItem, public U
//TODO UB 4.x not nice ...
void triggerRemovedSignal();
virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate;}
virtual void clearSource(){};
virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid);
signals:

Loading…
Cancel
Save