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

preferencesAboutTextFull
Claudio Valerio 13 years ago
commit 44616b3491
  1. 6
      Sankore 3.1.iss
  2. 43
      release.linux.sh
  3. 2
      release.win7.vc9.64.bat
  4. 2
      release.win7.vc9.bat
  5. 15
      src/adaptors/UBSvgSubsetAdaptor.cpp
  6. 10
      src/board/UBBoardController.cpp
  7. 12
      src/board/UBBoardView.cpp
  8. 1
      src/board/UBBoardView.h
  9. 10
      src/board/UBDrawingController.cpp
  10. 2
      src/board/UBDrawingController.h
  11. 3
      src/core/UB.h
  12. 2
      src/domain/UBGraphicsDelegateFrame.cpp
  13. 56
      src/domain/UBGraphicsItemDelegate.cpp
  14. 7
      src/domain/UBGraphicsItemDelegate.h
  15. 23
      src/domain/UBGraphicsPolygonItem.cpp
  16. 6
      src/domain/UBGraphicsPolygonItem.h
  17. 333
      src/domain/UBGraphicsScene.cpp
  18. 4
      src/domain/UBGraphicsScene.h
  19. 5
      src/domain/UBGraphicsStrokesGroup.h
  20. 5
      src/domain/UBGraphicsWidgetItem.cpp
  21. 2
      src/domain/UBGraphicsWidgetItem.h
  22. 158
      src/domain/ubgraphicsgroupcontaineritem.cpp
  23. 18
      src/domain/ubgraphicsgroupcontaineritem.h
  24. 24
      src/domain/ubgraphicsgroupcontaineritemdelegate.cpp
  25. 6
      src/domain/ubgraphicsgroupcontaineritemdelegate.h
  26. 3
      src/frameworks/UBGeometryUtils.cpp
  27. 19
      src/gui/UBFeaturesActionBar.cpp
  28. 4
      src/gui/UBFeaturesActionBar.h
  29. 184
      src/gui/UBFeaturesWidget.cpp
  30. 13
      src/gui/UBFeaturesWidget.h
  31. 1
      src/tools/UBGraphicsCompass.cpp
  32. 1
      src/tools/UBGraphicsProtractor.cpp
  33. 2
      src/tools/UBGraphicsProtractor.h
  34. 3
      src/tools/UBGraphicsRuler.cpp
  35. 1
      src/tools/UBGraphicsTriangle.cpp

@ -45,7 +45,10 @@ Type: files ; Name: "{app}\*.dll"
[Files] [Files]
Source: "..\Sankore-ThirdParty\microsoft\vcredist_x86.exe"; DestDir:"{tmp}" Source: "..\Sankore-ThirdParty\microsoft\vcredist_x86.exe"; DestDir:"{tmp}"
Source: ".\build\win32\release\product\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "build\win32\release\product\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
;Sankore plugins
Source: "plugins\cffadaptor\build\win32\release\lib\CFF_Adaptor.dll"; DestDir: "{app}"; Flags: ignoreversion
;OpenSSL ;OpenSSL
Source: "..\Sankore-ThirdParty\openssl\win32\libeay32.dll"; DestDir:"{app}"; Flags: ignoreversion Source: "..\Sankore-ThirdParty\openssl\win32\libeay32.dll"; DestDir:"{app}"; Flags: ignoreversion
@ -60,6 +63,7 @@ Source: "..\Qt-sankore3.1\lib\QtWebKit4.dll"; DestDir: "{app}"; Flags: ignorever
Source: "..\Qt-sankore3.1\lib\phonon4.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\Qt-sankore3.1\lib\phonon4.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\Qt-sankore3.1\lib\QtNetwork4.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\Qt-sankore3.1\lib\QtNetwork4.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\Qt-sankore3.1\lib\QtSvg4.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\Qt-sankore3.1\lib\QtSvg4.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\Qt-sankore3.1\lib\QtOpenGL4.dll"; DestDir: "{app}"; Flags: ignoreversion
;Qt plugins ;Qt plugins
Source: "..\Qt-sankore3.1\plugins\accessible\qtaccessiblecompatwidgets4.dll"; DestDir: "{app}\accessible"; Flags: ignoreversion Source: "..\Qt-sankore3.1\plugins\accessible\qtaccessiblecompatwidgets4.dll"; DestDir: "{app}\accessible"; Flags: ignoreversion

@ -39,14 +39,18 @@ checkDirectory(){
# path definition # # path definition #
####################################################################### #######################################################################
QT_PATH="/usr/local/Trolltech/Qt-4.7.3" QT_PATH="/usr/local/Trolltech/Qt-4.7.3"
PLUGINS_PATH="$QT_PATH/plugins" QT_PLUGINS_PATH="$QT_PATH/plugins"
RELEASE_DIR=build/linux/release RELEASE_DIR=build/linux/release
BUILD_DIR=$RELEASE_DIR/product BUILD_DIR=$RELEASE_DIR/product
GUI_TRANSLATIONS_DIRECTORY_PATH="../Qt-sankore3.1/translations" GUI_TRANSLATIONS_DIRECTORY_PATH="../Qt-sankore3.1/translations"
QT_LIBRARY_SOURCE_PATH="$QT_PATH/lib" QT_LIBRARY_SOURCE_PATH="$QT_PATH/lib"
SANKORE_SRC_PLUGINS_PATH="plugins"
SANKORE_DST_PLUGINS_PATH=build/linux/release/product/plugins
CFF_ADAPTOR_SRC_PLUGIN_PATH=$SANKORE_SRC_PLUGINS_PATH/cffadaptor/build/linux/release/lib
QMAKE_PATH="$QT_PATH/bin/qmake" QMAKE_PATH="$QT_PATH/bin/qmake"
LRELEASE="/usr/local/Trolltech/Qt-4.7.3/bin/lrelease" LRELEASE="../Qt-sankore3.1/bin/lrelease"
#LRELEASE="/usr/local/Trolltech/Qt-4.7.3/bin/lrelease"
ARCHITECTURE=`uname -m` ARCHITECTURE=`uname -m`
@ -57,13 +61,15 @@ checkExecutable $QMAKE_PATH
checkExecutable $LRELEASE checkExecutable $LRELEASE
checkDirectory $GUI_TRANSLATIONS_DIRECTORY_PATH checkDirectory $GUI_TRANSLATIONS_DIRECTORY_PATH
checkDirectory $PLUGINS_PATH checkDirectory $QT_PLUGINS_PATH
checkDirectory $QT_LIBRARY_SOURCE_PATH checkDirectory $QT_LIBRARY_SOURCE_PATH
checkDirectory $CFF_ADAPTOR_PLUGIN_PATH
####################################################################### #######################################################################
# cleaning # # cleaning #
####################################################################### #######################################################################
rm -rf $RELEASE_DIR #rm -rf $RELEASE_DIR
####################################################################### #######################################################################
@ -126,21 +132,26 @@ cp -R resources/linux/qtlinux/* $BUILD_DIR
cp -R resources/customizations $BUILD_DIR cp -R resources/customizations $BUILD_DIR
notify-send "Sankore" "Copying plugins..."
mkdir "$SANKORE_DST_PLUGINS_PATH"
mkdir "$SANKORE_DST_PLUGINS_PATH/cffadaptor"
cp -R $CFF_ADAPTOR_SRC_PLUGIN_PATH/*.so* "$SANKORE_DST_PLUGINS_PATH/cffadaptor"
notify-send "QT" "Coping plugins and library ..." notify-send "QT" "Coping plugins and library ..."
cp -R $PLUGINS_PATH $BUILD_DIR cp -R $QT_PLUGINS_PATH $BUILD_DIR
#copying custom qt library #copying custom qt library
QT_LIBRARY_DEST_PATH="$BUILD_DIR/qtlib" QT_LIBRARY_DEST_PATH="$BUILD_DIR/qtlib"
mkdir $QT_LIBRARY_DEST_PATH mkdir $QT_LIBRARY_DEST_PATH
copyQtLibrary(){ copyQtLibrary(){
if [ ! -e "$QT_LIBRARY_SOURCE_PATH/$1.so.4.7.3" ]; then if [ ! -e "$QT_LIBRARY_SOURCE_PATH/$1.so.4" ]; then
notifyError "$1 library not found in path: $QT_LIBRARY_SOURCE_PATH" notifyError "$1 library not found in path: $QT_LIBRARY_SOURCE_PATH"
fi fi
cp "$QT_LIBRARY_SOURCE_PATH/$1.so.4" "$QT_LIBRARY_DEST_PATH/" cp $QT_LIBRARY_SOURCE_PATH/$1.so.4.* $QT_LIBRARY_DEST_PATH/
cp "$QT_LIBRARY_SOURCE_PATH/$1.so.4.7.3" "$QT_LIBRARY_DEST_PATH/"
} }
copyQtLibrary libphonon
copyQtLibrary libQtWebKit copyQtLibrary libQtWebKit
copyQtLibrary libQtDBus copyQtLibrary libQtDBus
copyQtLibrary libQtScript copyQtLibrary libQtScript
@ -150,14 +161,8 @@ copyQtLibrary libQtNetwork
copyQtLibrary libQtXml copyQtLibrary libQtXml
copyQtLibrary libQtGui copyQtLibrary libQtGui
copyQtLibrary libQtCore copyQtLibrary libQtCore
# uncomment for Qt 4.8
if [ ! -e "$QT_LIBRARY_SOURCE_PATH/libphonon.so.4.4.0" ]; then #copyQtLibrary libQtOpenGL
notifyError "phonon library not found in path: $QT_LIBRARY_SOURCE_PATH"
else
cp "$QT_LIBRARY_SOURCE_PATH/libphonon.so.4" "$QT_LIBRARY_DEST_PATH/"
cp "$QT_LIBRARY_SOURCE_PATH/libphonon.so.4.4.0" "$QT_LIBRARY_DEST_PATH/"
fi
####################################################################### #######################################################################
# Removing unwanted files # # Removing unwanted files #
@ -279,7 +284,7 @@ echo "Priority: optional" >> "$CONTROL_FILE"
echo "Architecture: $ARCHITECTURE" >> "$CONTROL_FILE" echo "Architecture: $ARCHITECTURE" >> "$CONTROL_FILE"
echo "Essential: no" >> "$CONTROL_FILE" echo "Essential: no" >> "$CONTROL_FILE"
echo "Installed-Size: `du -s $SANKORE_PACKAGE_DIRECTORY | awk '{ print $1 }'`" >> "$CONTROL_FILE" echo "Installed-Size: `du -s $SANKORE_PACKAGE_DIRECTORY | awk '{ print $1 }'`" >> "$CONTROL_FILE"
echo "Maintainer: Open-Sankoré Developers team <dev@open-sankore.org>" >> "$CONTROL_FILE" echo "Maintainer: Open-Sankore Developers team <dev@open-sankore.org>" >> "$CONTROL_FILE"
echo "Homepage: http://dev.open-sankore.org" >> "$CONTROL_FILE" echo "Homepage: http://dev.open-sankore.org" >> "$CONTROL_FILE"
echo -n "Depends: " >> "$CONTROL_FILE" echo -n "Depends: " >> "$CONTROL_FILE"
unset tab unset tab
@ -318,7 +323,7 @@ echo "Version=$VERSION" >> $SANKORE_SHORTCUT
echo "Encoding=UTF-8" >> $SANKORE_SHORTCUT echo "Encoding=UTF-8" >> $SANKORE_SHORTCUT
echo "Name=Open-Sankore ($VERSION)" >> $SANKORE_SHORTCUT echo "Name=Open-Sankore ($VERSION)" >> $SANKORE_SHORTCUT
echo "GenericName=Open-Sankore" >> $SANKORE_SHORTCUT echo "GenericName=Open-Sankore" >> $SANKORE_SHORTCUT
echo "Comment=Logiciel de création de présentations pour tableau numérique interactif (TNI)" >> $SANKORE_SHORTCUT echo "Comment=Logiciel de creation de presentations pour tableau numerique interactif (TNI)" >> $SANKORE_SHORTCUT
echo "Exec=/usr/local/$SANKORE_DIRECTORY_NAME/run.sh" >> $SANKORE_SHORTCUT echo "Exec=/usr/local/$SANKORE_DIRECTORY_NAME/run.sh" >> $SANKORE_SHORTCUT
echo "Icon=/usr/local/$SANKORE_DIRECTORY_NAME/sankore.png" >> $SANKORE_SHORTCUT echo "Icon=/usr/local/$SANKORE_DIRECTORY_NAME/sankore.png" >> $SANKORE_SHORTCUT
echo "StartupNotify=true" >> $SANKORE_SHORTCUT echo "StartupNotify=true" >> $SANKORE_SHORTCUT
@ -353,4 +358,4 @@ cd $RELEASE_DIR
rm ../../../install/linux/Open-Sankore.tar.gz rm ../../../install/linux/Open-Sankore.tar.gz
tar cvzf ../../../install/linux/Open-Sankore.tar.gz Open-Sankore.$VERSION -C . tar cvzf ../../../install/linux/Open-Sankore.tar.gz Open-Sankore.$VERSION -C .
notify-send "Open-Sankore" "tar.gz Build done" notify-send "Open-Sankore" "tar.gz Build done"

@ -62,7 +62,7 @@ nmake release-install
copy %BASE_QT_TRANSLATIONS_DIRECTORY%\qt_*.qm build\win32\release\product\i18n\ copy %BASE_QT_TRANSLATIONS_DIRECTORY%\qt_*.qm build\win32\release\product\i18n\
del build\win32\release\product\i18n\qt_help* del build\win32\release\product\i18n\qt_help*
del ".\build\win32\release\product\Sankore.pdb" del "build\win32\release\product\Sankore.pdb"
set INSTALLER_NAME=Open-Sankore set INSTALLER_NAME=Open-Sankore

@ -66,7 +66,7 @@ copy resources\customizations build\win32\release\product\
del build\win32\release\product\i18n\qt_help* del build\win32\release\product\i18n\qt_help*
del ".\build\win32\release\product\Sankore.pdb" del "build\win32\release\product\Sankore.pdb"
set INSTALLER_NAME=Open-Sankore set INSTALLER_NAME=Open-Sankore

@ -30,6 +30,7 @@
#include "domain/UBAbstractWidget.h" #include "domain/UBAbstractWidget.h"
#include "domain/UBGraphicsStroke.h" #include "domain/UBGraphicsStroke.h"
#include "domain/UBGraphicsStrokesGroup.h" #include "domain/UBGraphicsStrokesGroup.h"
#include "domain/ubgraphicsgroupcontaineritem.h"
#include "domain/UBItem.h" #include "domain/UBItem.h"
#include "tools/UBGraphicsRuler.h" #include "tools/UBGraphicsRuler.h"
@ -1004,8 +1005,13 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::writeSvgElement()
bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex) bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
{ {
if (mScene->isModified()) if (mScene->isModified())
{ {
static int i = 0;
qDebug() << "persist call no is " << ++i;
QBuffer buffer; QBuffer buffer;
buffer.open(QBuffer::WriteOnly); buffer.open(QBuffer::WriteOnly);
mXmlWriter.setDevice(&buffer); mXmlWriter.setDevice(&buffer);
@ -1218,6 +1224,14 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
triangleToSvg(triangle); triangleToSvg(triangle);
continue; continue;
} }
UBGraphicsGroupContainerItem *groupItem = qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(item);
if (groupItem && groupItem->isVisible())
{
qDebug() << "came across the group during the parsing";
continue;
}
} }
if (openStroke) if (openStroke)
@ -1269,7 +1283,6 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
return true; return true;
} }
void UBSvgSubsetAdaptor::UBSvgSubsetWriter::polygonItemToSvgLine(UBGraphicsPolygonItem* polygonItem, bool groupHoldsInfo) void UBSvgSubsetAdaptor::UBSvgSubsetWriter::polygonItemToSvgLine(UBGraphicsPolygonItem* polygonItem, bool groupHoldsInfo)
{ {
mXmlWriter.writeStartElement("line"); mXmlWriter.writeStartElement("line");

@ -1259,10 +1259,12 @@ void UBBoardController::ClearUndoStack()
while (itUniq.hasNext()) while (itUniq.hasNext())
{ {
QGraphicsItem* item = itUniq.next(); QGraphicsItem* item = itUniq.next();
UBGraphicsScene *scene = dynamic_cast<UBGraphicsScene*>(item->scene()); if (item->scene()) {
if(!scene) UBGraphicsScene *scene = dynamic_cast<UBGraphicsScene*>(item->scene());
{ if(!scene)
mActiveScene->deleteItem(item); {
mActiveScene->deleteItem(item);
}
} }
} }

@ -50,6 +50,8 @@
#include "domain/UBGraphicsVideoItem.h" #include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsAudioItem.h" #include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsSvgItem.h" #include "domain/UBGraphicsSvgItem.h"
#include "domain/ubgraphicsgroupcontaineritem.h"
#include "domain/UBGraphicsStrokesGroup.h"
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"
@ -435,8 +437,8 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
|| movingItem->type() == UBGraphicsCache::Type || movingItem->type() == UBGraphicsCache::Type
|| movingItem->type() == UBGraphicsTriangle::Type || movingItem->type() == UBGraphicsTriangle::Type
|| movingItem == this->scene()->backgroundObject() || movingItem == this->scene()->backgroundObject()
|| movingItem->group()) || (movingItem->parentItem() && movingItem->parentItem()->type() == UBGraphicsGroupContainerItem::Type))
{ {
movingItem = NULL; movingItem = NULL;
QGraphicsView::mousePressEvent (event); QGraphicsView::mousePressEvent (event);
@ -515,8 +517,6 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
} }
} }
QSet<QGraphicsItem*> mJustSelectedItems;
void void
UBBoardView::mouseMoveEvent (QMouseEvent *event) UBBoardView::mouseMoveEvent (QMouseEvent *event)
{ {
@ -562,7 +562,9 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
|| item->type() == UBGraphicsPixmapItem::Type || item->type() == UBGraphicsPixmapItem::Type
|| item->type() == UBGraphicsVideoItem::Type || item->type() == UBGraphicsVideoItem::Type
|| item->type() == UBGraphicsAudioItem::Type || item->type() == UBGraphicsAudioItem::Type
|| item->type() == UBGraphicsSvgItem::Type) { || item->type() == UBGraphicsSvgItem::Type
|| item->type() == UBGraphicsTextItem::Type
|| item->type() == UBGraphicsStrokesGroup::Type) {
if (!mJustSelectedItems.contains(item)) { if (!mJustSelectedItems.contains(item)) {
item->setSelected(true); item->setSelected(true);

@ -125,6 +125,7 @@ class UBBoardView : public QGraphicsView
QMouseEvent *suspendedMousePressEvent; QMouseEvent *suspendedMousePressEvent;
UBRubberBand *mUBRubberBand; UBRubberBand *mUBRubberBand;
QSet<QGraphicsItem*> mJustSelectedItems;
private slots: private slots:

@ -45,7 +45,7 @@ UBDrawingController::UBDrawingController(QObject * parent)
, mActiveRuler(NULL) , mActiveRuler(NULL)
, mStylusTool((UBStylusTool::Enum)-1) , mStylusTool((UBStylusTool::Enum)-1)
, mLatestDrawingTool((UBStylusTool::Enum)-1) , mLatestDrawingTool((UBStylusTool::Enum)-1)
//, mDrawingMode(eDrawingMode_Vector) , mDrawingMode(/*DRAWING_MODE*/eDrawingMode_Vector)
{ {
connect(UBSettings::settings(), SIGNAL(colorContextChanged()), this, SIGNAL(colorPaletteChanged())); connect(UBSettings::settings(), SIGNAL(colorContextChanged()), this, SIGNAL(colorPaletteChanged()));
@ -106,10 +106,16 @@ void UBDrawingController::setStylusTool(int tool)
mStylusTool = (UBStylusTool::Enum)tool; mStylusTool = (UBStylusTool::Enum)tool;
if(eDrawingMode_Vector == DRAWING_MODE){
mDrawingMode = eDrawingMode_Vector;
}
if (mStylusTool == UBStylusTool::Pen) if (mStylusTool == UBStylusTool::Pen)
UBApplication::mainWindow->actionPen->setChecked(true); UBApplication::mainWindow->actionPen->setChecked(true);
else if (mStylusTool == UBStylusTool::Eraser) else if (mStylusTool == UBStylusTool::Eraser){
UBApplication::mainWindow->actionEraser->setChecked(true); UBApplication::mainWindow->actionEraser->setChecked(true);
//mDrawingMode = eDrawingMode_Artistic;
}
else if (mStylusTool == UBStylusTool::Marker) else if (mStylusTool == UBStylusTool::Marker)
UBApplication::mainWindow->actionMarker->setChecked(true); UBApplication::mainWindow->actionMarker->setChecked(true);
else if (mStylusTool == UBStylusTool::Selector) else if (mStylusTool == UBStylusTool::Selector)

@ -27,6 +27,8 @@ typedef enum{
eDrawingMode_Vector eDrawingMode_Vector
}eDrawingMode; }eDrawingMode;
#define DRAWING_MODE eDrawingMode_Vector
class UBDrawingController : public QObject class UBDrawingController : public QObject
{ {
Q_OBJECT; Q_OBJECT;

@ -123,7 +123,8 @@ struct UBGraphicsItemType
StrokeItemType, StrokeItemType,
TriangleItemType, TriangleItemType,
MagnifierItemType, MagnifierItemType,
cacheItemType cacheItemType,
groupContainerType
}; };
}; };

@ -583,7 +583,7 @@ void UBGraphicsDelegateFrame::positionHandles()
{ {
QRectF itemRect = delegated()->boundingRect(); QRectF itemRect = delegated()->boundingRect();
if (mDelegate->getToolBarItem()->isVisibleOnBoard() if (mDelegate->getToolBarItem()->isVisibleOnBoard()
&& mDelegate->getToolBarItem()->isShifting()) && mDelegate->getToolBarItem()->isShifting())
itemRect.setHeight(itemRect.height() + mDelegate->getToolBarItem()->rect().height() * mDelegate->antiScaleRatio() * 1.1); itemRect.setHeight(itemRect.height() + mDelegate->getToolBarItem()->rect().height() * mDelegate->antiScaleRatio() * 1.1);

@ -40,6 +40,7 @@
#include "domain/UBGraphicsTextItem.h" #include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsAudioItem.h" #include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsVideoItem.h" #include "domain/UBGraphicsVideoItem.h"
#include "domain/ubgraphicsgroupcontaineritem.h"
#include "web/UBWebController.h" #include "web/UBWebController.h"
@ -167,7 +168,9 @@ UBGraphicsItemDelegate::~UBGraphicsItemDelegate()
QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{ {
if (change == QGraphicsItem::ItemSelectedHasChanged) { if(change == QGraphicsItem::ItemChildAddedChange){
}else if (change == QGraphicsItem::ItemSelectedHasChanged) {
bool ok; bool ok;
bool selected = value.toUInt(&ok); bool selected = value.toUInt(&ok);
if (ok) { if (ok) {
@ -217,10 +220,9 @@ bool UBGraphicsItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event)
startUndoStep(); startUndoStep();
if (!mDelegated->isSelected()) if (!delegated()->isSelected())
{ {
mDelegated->setSelected(true); delegated()->setSelected(true);
positionHandles();
return true; return true;
} }
else else
@ -236,33 +238,31 @@ void UBGraphicsItemDelegate::setMimeData(QMimeData *mimeData)
bool UBGraphicsItemDelegate::mouseMoveEvent(QGraphicsSceneMouseEvent *event) bool UBGraphicsItemDelegate::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if((NULL != mMimeData) && ((event->pos() - mDragStartPosition).manhattanLength() < QApplication::startDragDistance())) if(mMimeData) {
{ QDrag* mDrag = new QDrag(event->widget());
QDrag* mDrag = new QDrag(event->widget()); mDrag->setMimeData(mMimeData);
mDrag->setMimeData(mMimeData); if (!mDragPixmap.isNull()) {
if (!mDragPixmap.isNull()) { mDrag->setPixmap(mDragPixmap);
mDrag->setPixmap(mDragPixmap); mDrag->setHotSpot(mDragPixmap.rect().center());
mDrag->setHotSpot(mDragPixmap.rect().center());
}
mDrag->exec();
mDragPixmap = QPixmap();
return true;
} }
mDrag->exec();
mDragPixmap = QPixmap();
if(isLocked())
{
event->accept();
return true; return true;
} }
return true; if(isLocked()) {
event->accept();
return true;
} else {
return false;
}
} }
bool UBGraphicsItemDelegate::weelEvent(QGraphicsSceneWheelEvent *event) bool UBGraphicsItemDelegate::weelEvent(QGraphicsSceneWheelEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
if( mDelegated->isSelected() ) if( delegated()->isSelected() )
{ {
// event->accept(); // event->accept();
return true; return true;
@ -310,6 +310,18 @@ void UBGraphicsItemDelegate::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
// } // }
} }
QGraphicsItem *UBGraphicsItemDelegate::delegated()
{
QGraphicsItem *curDelegate = 0;
if (mDelegated->parentItem() && mDelegated->parentItem()->type() == UBGraphicsGroupContainerItem::Type) {
curDelegate = mDelegated->parentItem(); // considering delegated item as an item's group which contains everything
} else {
curDelegate = mDelegated;
}
return curDelegate;
}
void UBGraphicsItemDelegate::positionHandles() void UBGraphicsItemDelegate::positionHandles()
{ {
if (mDelegated->isSelected()) { if (mDelegated->isSelected()) {
@ -363,7 +375,7 @@ void UBGraphicsItemDelegate::setZOrderButtonsVisible(bool visible)
void UBGraphicsItemDelegate::remove(bool canUndo) void UBGraphicsItemDelegate::remove(bool canUndo)
{ {
// QGraphicsScene* scene = mDelegated->scene(); // QGraphicsScene* scene = mDelegated->scene();
UBGraphicsScene* scene = (UBGraphicsScene*)(mDelegated->scene()); UBGraphicsScene* scene = dynamic_cast<UBGraphicsScene*>(mDelegated->scene());
if (scene) if (scene)
{ {
foreach(DelegateButton* button, mButtons) foreach(DelegateButton* button, mButtons)

@ -4,7 +4,7 @@
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This prograscenem is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
@ -121,10 +121,7 @@ class UBGraphicsItemDelegate : public QObject
void printMessage(const QString &mess) {qDebug() << mess;} void printMessage(const QString &mess) {qDebug() << mess;}
QGraphicsItem* delegated() QGraphicsItem* delegated();
{
return mDelegated;
}
void setCanDuplicate(bool allow){ mCanDuplicate = allow; } void setCanDuplicate(bool allow){ mCanDuplicate = allow; }

@ -39,6 +39,7 @@ UBGraphicsPolygonItem::UBGraphicsPolygonItem (const QPolygonF & polygon, QGraphi
, mOriginalWidth(-1) , mOriginalWidth(-1)
, mIsNominalLine(false) , mIsNominalLine(false)
, mStroke(0) , mStroke(0)
, mpGroup(NULL)
{ {
// NOOP // NOOP
initialize(); initialize();
@ -77,6 +78,10 @@ UBGraphicsPolygonItem::~UBGraphicsPolygonItem()
clearStroke(); clearStroke();
} }
void UBGraphicsPolygonItem::setStrokesGroup(UBGraphicsStrokesGroup *group)
{
mpGroup = group;
}
void UBGraphicsPolygonItem::setStroke(UBGraphicsStroke* stroke) void UBGraphicsPolygonItem::setStroke(UBGraphicsStroke* stroke)
{ {
@ -156,7 +161,7 @@ UBGraphicsPolygonItem* UBGraphicsPolygonItem::deepCopy(const QPolygonF& pol) con
copy->mIsNominalLine = false; copy->mIsNominalLine = false;
copy->setStroke(this->stroke()); copy->setStroke(this->stroke());
copy->setGroup(this->group()); copy->setStrokesGroup(this->strokesGroup());
copy->setBrush(this->brush()); copy->setBrush(this->brush());
copy->setPen(this->pen()); copy->setPen(this->pen());
copy->mHasAlpha = this->mHasAlpha; copy->mHasAlpha = this->mHasAlpha;
@ -184,18 +189,18 @@ void UBGraphicsPolygonItem::paint ( QPainter * painter, const QStyleOptionGraphi
QGraphicsPolygonItem::paint(painter, option, widget); QGraphicsPolygonItem::paint(painter, option, widget);
} }
QPainterPath UBGraphicsPolygonItem::shape() const //QPainterPath UBGraphicsPolygonItem::shape() const
{ //{
QPainterPath path; // QPainterPath path;
path.addRect(boundingRect()); // path.addRect(boundingRect());
return path; // return path;
// static QPainterPath shapePath = QGraphicsPolygonItem::shape(); //// static QPainterPath shapePath = QGraphicsPolygonItem::shape();
// return shapePath; //// return shapePath;
} //}
UBGraphicsScene* UBGraphicsPolygonItem::scene() UBGraphicsScene* UBGraphicsPolygonItem::scene()

@ -19,6 +19,7 @@
#include "core/UB.h" #include "core/UB.h"
#include "UBItem.h" #include "UBItem.h"
#include "UBGraphicsStrokesGroup.h"
class UBItem; class UBItem;
class UBGraphicsScene; class UBGraphicsScene;
@ -37,6 +38,8 @@ class UBGraphicsPolygonItem : public QGraphicsPolygonItem, public UBItem
void initialize(); void initialize();
void setStrokesGroup(UBGraphicsStrokesGroup* group);
UBGraphicsStrokesGroup* strokesGroup() const{return mpGroup;}
void setColor(const QColor& color); void setColor(const QColor& color);
QColor color() const; QColor color() const;
@ -115,7 +118,7 @@ class UBGraphicsPolygonItem : public QGraphicsPolygonItem, public UBItem
protected: protected:
void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget); void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget);
QPainterPath shape () const; // QPainterPath shape () const;
private: private:
@ -132,6 +135,7 @@ class UBGraphicsPolygonItem : public QGraphicsPolygonItem, public UBItem
QColor mColorOnLightBackground; QColor mColorOnLightBackground;
UBGraphicsStroke* mStroke; UBGraphicsStroke* mStroke;
UBGraphicsStrokesGroup* mpGroup;
}; };

@ -65,6 +65,9 @@
#include "core/memcheck.h" #include "core/memcheck.h"
const QString groupText = "Group items";
const QString ungroupText = "Ungroup items";
qreal UBZLayerController::errorNumber = -20000001.0; qreal UBZLayerController::errorNumber = -20000001.0;
UBZLayerController::UBZLayerController(QGraphicsScene *scene) : UBZLayerController::UBZLayerController(QGraphicsScene *scene) :
@ -291,9 +294,15 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
} }
connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing())); connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing()));
connect(this, SIGNAL(selectionChanged()), this, SLOT(enableGroupingButton())); connect(this, SIGNAL(selectionChanged()), this, SLOT(updateGroupButtonState()));
connect(UBApplication::mainWindow->actionGroupItems, SIGNAL(triggered()), this, SLOT(processGroupItems())); // 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() UBGraphicsScene::~UBGraphicsScene()
@ -308,39 +317,78 @@ UBGraphicsScene::~UBGraphicsScene()
void UBGraphicsScene::selectionChangedProcessing() void UBGraphicsScene::selectionChangedProcessing()
{ {
if (selectedItems().count()) if (selectedItems().count()){
qDebug() << "Selected item bounding rect: " << selectedItems().first()->boundingRect();
UBApplication::showMessage("ZValue is " + QString::number(selectedItems().first()->zValue(), 'f') + "own z value is " UBApplication::showMessage("ZValue is " + QString::number(selectedItems().first()->zValue(), 'f') + "own z value is "
+ QString::number(selectedItems().first()->data(UBGraphicsItemData::ItemOwnZValue).toReal(), 'f')); + QString::number(selectedItems().first()->data(UBGraphicsItemData::ItemOwnZValue).toReal(), 'f'));
}
} }
void UBGraphicsScene::enableGroupingButton() void UBGraphicsScene::updateGroupButtonState()
{ {
QAction *groupAction = UBApplication::mainWindow->actionGroupItems; QAction *groupAction = UBApplication::mainWindow->actionGroupItems;
QList<QGraphicsItem*> selItems = selectedItems();
int selCount = selItems.count();
if (selectedItems().count() > 1) { if (selCount < 1) {
groupAction->setEnabled(true);
} else {
groupAction->setEnabled(false); groupAction->setEnabled(false);
groupAction->setText(groupText);
} else if (selCount == 1) {
if (selItems.first()->type() == UBGraphicsGroupContainerItem::Type) {
groupAction->setEnabled(true);
groupAction->setText(ungroupText);
} else {
groupAction->setEnabled(false);
}
} else if (selCount > 1) {
groupAction->setEnabled(true);
groupAction->setText(groupText);
} }
} }
void UBGraphicsScene::processGroupItems() void UBGraphicsScene::groupButtonClicked()
{ {
qDebug() << "processing grouping items"; 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;
}
UBGraphicsGroupContainerItem *groupItem = new UBGraphicsGroupContainerItem(); if (groupAction->text() == groupText) { //The only way to get information from item, considering using smth else
UBGraphicsGroupContainerItem *groupItem = new UBGraphicsGroupContainerItem();
foreach (QGraphicsItem *item, selectedItems()) { foreach (QGraphicsItem *item, selItems) {
item->setSelected(false); if (item->type() == UBGraphicsGroupContainerItem::Type) {
item->setFlag(QGraphicsItem::ItemIsSelectable, false); QList<QGraphicsItem*> childItems = item->childItems();
item->setFlag( QGraphicsItem::ItemIsMovable, false); UBGraphicsGroupContainerItem *currentGroup = dynamic_cast<UBGraphicsGroupContainerItem*>(item);
item->setFlag(QGraphicsItem::ItemIsFocusable); if (currentGroup) {
groupItem->addToGroup(item); 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();
}
} }
addItem(groupItem);
// groupItem->setPos(50, 50);
groupItem->setVisible(true);
groupItem->setFocus();
qDebug() << groupItem->boundingRect();
} }
// MARK: - // MARK: -
@ -432,7 +480,6 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
return accepted; return accepted;
} }
bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pressure) bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pressure)
{ {
bool accepted = false; bool accepted = false;
@ -567,7 +614,7 @@ bool UBGraphicsScene::inputDeviceRelease()
} }
}else if (mCurrentStroke) }else if (mCurrentStroke)
{ {
if(eDrawingMode_Vector == dc->drawingMode()){ if(eDrawingMode_Vector == DRAWING_MODE){
UBGraphicsStrokesGroup* pStrokes = new UBGraphicsStrokesGroup(); UBGraphicsStrokesGroup* pStrokes = new UBGraphicsStrokesGroup();
// Remove the strokes that were just drawn here and replace them by a stroke item // Remove the strokes that were just drawn here and replace them by a stroke item
@ -575,6 +622,7 @@ bool UBGraphicsScene::inputDeviceRelease()
mPreviousPolygonItems.removeAll(poly); mPreviousPolygonItems.removeAll(poly);
removeItem(poly); removeItem(poly);
UBCoreGraphicsScene::removeItemFromDeletion(poly); UBCoreGraphicsScene::removeItemFromDeletion(poly);
poly->setStrokesGroup(pStrokes);
pStrokes->addToGroup(poly); pStrokes->addToGroup(poly);
} }
@ -746,6 +794,8 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth,
void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
{ {
// QList<QGraphicsItem*> itemList;
const QLineF line(mPreviousPoint, pEndPoint); const QLineF line(mPreviousPoint, pEndPoint);
const QPolygonF eraserPolygon = UBGeometryUtils::lineToPolygon(line, pWidth); const QPolygonF eraserPolygon = UBGeometryUtils::lineToPolygon(line, pWidth);
@ -756,114 +806,208 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
eraserPathVar.addPolygon(eraserPolygon); eraserPathVar.addPolygon(eraserPolygon);
const QPainterPath eraserPath = eraserPathVar; const QPainterPath eraserPath = eraserPathVar;
// Get all the items that are intersecting with the eraser path
QList<QGraphicsItem*> collidItems = items(eraserBoundingRect, Qt::IntersectsItemBoundingRect); QList<QGraphicsItem*> collidItems = items(eraserBoundingRect, Qt::IntersectsItemBoundingRect);
QSet<QGraphicsItem*> toBeAddedItems; if(eDrawingMode_Vector == UBDrawingController::drawingController()->drawingMode()){
QSet<QGraphicsItem*> toBeRemovedItems; // NOTE: I decided to reuse the 'artistic' eraser all the time in order to have a better eraser
// For this reason, the following code is not used but we will keep it for now, in case of
int collidItemsSize = collidItems.size(); // futur requirements.
foreach(QGraphicsItem* poly, collidItems){
UBGraphicsStrokesGroup* pGroup = dynamic_cast<UBGraphicsStrokesGroup*>(poly);
if(NULL != pGroup){
// TODO: Ungroup the item, put back the polygons on the scene, deal with the
// eraser's bounding rect, remove the polygons that must be removed
// then create new groups.
// Get all substrokes and verify if they are part of the eraserpath then deal with it
foreach(QGraphicsItem* item, poly->childItems()){
UBGraphicsPolygonItem* polygon = dynamic_cast<UBGraphicsPolygonItem*>(item);
if(NULL != polygon){
if(eraserBoundingRect.intersects(polygon->boundingRect())){
pGroup->removeFromGroup(polygon);
removeItem(polygon);
}
}
}
}
}
toBeAddedItems.reserve(collidItemsSize); }else{
toBeRemovedItems.reserve(collidItemsSize); QSet<QGraphicsItem*> toBeAddedItems;
QSet<QGraphicsItem*> toBeRemovedItems;
int collidItemsSize = collidItems.size();
toBeAddedItems.reserve(collidItemsSize);
toBeRemovedItems.reserve(collidItemsSize);
if (mShouldUseOMP) if (mShouldUseOMP)
{
#pragma omp parallel for
for (int i = 0; i < collidItemsSize; i++)
{ {
UBGraphicsPolygonItem *collidingPolygonItem // #pragma omp parallel for
= qgraphicsitem_cast<UBGraphicsPolygonItem*> (collidItems.at(i)); for (int i = 0; i < collidItemsSize; i++)
if (collidingPolygonItem)
{ {
if(eraserInnerRect.contains(collidingPolygonItem->boundingRect())) UBGraphicsPolygonItem *collidingPolygonItem = qgraphicsitem_cast<UBGraphicsPolygonItem*>(collidItems.at(i));
{
#pragma omp critical if (NULL != collidingPolygonItem)
toBeRemovedItems << collidingPolygonItem;
}
else
{ {
QPolygonF collidingPolygon = collidingPolygonItem->polygon(); collidingPolygonItem->setColor(QColor(Qt::green));
QPainterPath collidingPath;
collidingPath.addPolygon(collidingPolygon);
QPainterPath croppedPath = collidingPath.subtracted(eraserPath); UBGraphicsStrokesGroup* pGroup = collidingPolygonItem->strokesGroup();
QPainterPath croppedPathSimplified = croppedPath.simplified();
if (croppedPath == collidingPath) if(eraserInnerRect.contains(collidingPolygonItem->boundingRect()))
{ {
// NOOP // #pragma omp critical
} qDebug() << "case 1";
else if (croppedPathSimplified.isEmpty()) // Put the entire polygon into the remove list
{ collidingPolygonItem->setColor(QColor(Qt::blue));
#pragma omp critical
toBeRemovedItems << collidingPolygonItem; toBeRemovedItems << collidingPolygonItem;
} }
else else
{ {
foreach(const QPolygonF &pol, croppedPathSimplified.toFillPolygons()) // Here we get the polygon of the colliding item
QPolygonF collidingPolygon = collidingPolygonItem->polygon();
QPainterPath collidingPath;
collidingPath.addPolygon(collidingPolygon);
// Then we substract the eraser path to the polygon and we simplify it
QPainterPath croppedPath = collidingPath.subtracted(eraserPath);
QPainterPath croppedPathSimplified = croppedPath.simplified();
/*if (croppedPath == collidingPath)
{ {
UBGraphicsPolygonItem* croppedPolygonItem = collidingPolygonItem->deepCopy(pol); // NOOP
#pragma omp critical qDebug() << "case 2";
toBeAddedItems << croppedPolygonItem; toBeRemovedItems << collidingPolygonItem;
}
else */if (croppedPathSimplified.isEmpty())
{
// #pragma omp critical
qDebug() << "case 3";
// Put the entire polygon into the remove list if the eraser removes all its visible content
collidingPolygonItem->setColor(QColor(Qt::blue));
toBeRemovedItems << collidingPolygonItem;
}
else
{
//qDebug() << "case 4";
// Then we convert the remaining path to a list of polygons that will be converted in
// UBGraphicsPolygonItems and added to the scene
foreach(const QPolygonF &pol, croppedPathSimplified.toFillPolygons())
{
UBGraphicsPolygonItem* croppedPolygonItem = collidingPolygonItem->deepCopy(pol);
croppedPolygonItem->setColor(QColor(Qt::black));
// #pragma omp critical
if(NULL != pGroup){
croppedPolygonItem->setStrokesGroup(pGroup);
// croppedPolygonItem->setTransform(pGroup->sceneTransform().inverted());
}
// Add this new polygon to the 'added' list
toBeAddedItems << croppedPolygonItem;
}
// #pragma omp critical
// Remove the original polygonitem because it has been replaced by many smaller polygons
collidingPolygonItem->setColor(QColor(Qt::blue));
toBeRemovedItems << collidingPolygonItem;
} }
#pragma omp critical
toBeRemovedItems << collidingPolygonItem;
} }
} }
} }
} }
} else
else
{
for (int i = 0; i < collidItemsSize; i++)
{ {
UBGraphicsPolygonItem *collidingPolygonItem for (int i = 0; i < collidItemsSize; i++)
= qgraphicsitem_cast<UBGraphicsPolygonItem*> (collidItems.at(i));
if (collidingPolygonItem)
{ {
if(eraserInnerRect.contains(collidingPolygonItem->boundingRect())) UBGraphicsPolygonItem *collidingPolygonItem = dynamic_cast<UBGraphicsPolygonItem*> (collidItems.at(i));
{
toBeRemovedItems << collidingPolygonItem;
}
else
{
QPolygonF collidingPolygon = collidingPolygonItem->polygon();
QPainterPath collidingPath;
collidingPath.addPolygon(collidingPolygon);
QPainterPath croppedPath = collidingPath.subtracted(eraserPath); if (collidingPolygonItem)
QPainterPath croppedPathSimplified = croppedPath.simplified(); {
UBGraphicsStrokesGroup* pGroup = collidingPolygonItem->strokesGroup();
if (croppedPath == collidingPath) if(eraserInnerRect.contains(collidingPolygonItem->boundingRect()))
{
// NOOP
}
else if (croppedPathSimplified.isEmpty())
{ {
toBeRemovedItems << collidingPolygonItem; toBeRemovedItems << collidingPolygonItem;
} }
else else
{ {
foreach(const QPolygonF &pol, croppedPathSimplified.toFillPolygons()) QPolygonF collidingPolygon = collidingPolygonItem->polygon();
QPainterPath collidingPath;
collidingPath.addPolygon(collidingPolygon);
QPainterPath croppedPath = collidingPath.subtracted(eraserPath);
QPainterPath croppedPathSimplified = croppedPath.simplified();
if (croppedPath == collidingPath)
{ {
UBGraphicsPolygonItem* croppedPolygonItem = collidingPolygonItem->deepCopy(pol); // NOOP
toBeAddedItems << croppedPolygonItem; }
else if (croppedPathSimplified.isEmpty())
{
toBeRemovedItems << collidingPolygonItem;
}
else
{
foreach(const QPolygonF &pol, croppedPathSimplified.toFillPolygons())
{
UBGraphicsPolygonItem* croppedPolygonItem = collidingPolygonItem->deepCopy(pol);
toBeAddedItems << croppedPolygonItem;
if(NULL != pGroup){
croppedPolygonItem->setStrokesGroup(pGroup);
}
}
toBeRemovedItems << collidingPolygonItem;
} }
toBeRemovedItems << collidingPolygonItem;
} }
} }
} }
} }
}
addItems(toBeAddedItems); if(eDrawingMode_Vector == DRAWING_MODE){
mAddedItems += toBeAddedItems; foreach(QGraphicsItem* item, toBeRemovedItems){
UBGraphicsPolygonItem* poly = dynamic_cast<UBGraphicsPolygonItem*>(item);
if(NULL != poly){
if(NULL != poly->strokesGroup()){
poly->strokesGroup()->removeFromGroup(poly);
removeItem(poly);
}else{
qDebug() << "No group present";
}
}
}
}else{
removeItems(toBeRemovedItems);
mRemovedItems += toBeRemovedItems;
}
removeItems(toBeRemovedItems); // bool hack = false;
mRemovedItems += toBeRemovedItems; // UBGraphicsStrokesGroup* pG = new UBGraphicsStrokesGroup();
if(eDrawingMode_Vector == DRAWING_MODE){
foreach(QGraphicsItem* item, toBeAddedItems){
UBGraphicsPolygonItem* poly = dynamic_cast<UBGraphicsPolygonItem*>(item);
if(NULL != poly && NULL != poly->strokesGroup()){
// if(!hack){
// itemList = poly->strokesGroup()->childItems();
// removeItem(poly->strokesGroup());
// foreach(QGraphicsItem* it, itemList){
// pG->addToGroup(it);
// }
// hack = true;
// }
qreal dx = -poly->strokesGroup()->sceneTransform().inverted().dx();
qreal dy = -poly->strokesGroup()->sceneTransform().inverted().dy();
//poly->setTransform(QTransform().translate(20, 0));
poly->setTransform(QTransform().translate(dx, dy));
poly->strokesGroup()/*pG*/->addToGroup(poly);
}
}
//addItem(pG);
}else{
addItems(toBeAddedItems);
mAddedItems += toBeAddedItems;
}
}
mPreviousPoint = pEndPoint; mPreviousPoint = pEndPoint;
} }
@ -1759,7 +1903,6 @@ QGraphicsItem* UBGraphicsScene::scaleToFitDocumentSize(QGraphicsItem* item, bool
return item; return item;
} }
void UBGraphicsScene::addRuler(QPointF center) void UBGraphicsScene::addRuler(QPointF center)
{ {
UBGraphicsRuler* ruler = new UBGraphicsRuler(); // mem : owned and destroyed by the scene UBGraphicsRuler* ruler = new UBGraphicsRuler(); // mem : owned and destroyed by the scene

@ -306,8 +306,8 @@ public slots:
void setToolCursor(int tool); void setToolCursor(int tool);
void selectionChangedProcessing(); void selectionChangedProcessing();
void enableGroupingButton(); void updateGroupButtonState();
void processGroupItems(); void groupButtonClicked();
void moveMagnifier(QPoint newPos); void moveMagnifier(QPoint newPos);
void closeMagnifier(); void closeMagnifier();

@ -16,6 +16,11 @@ public:
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
virtual void remove(); virtual void remove();
virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate;} virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate;}
enum { Type = UBGraphicsItemType::StrokeItemType };
virtual int type() const
{
return Type;
}
protected: protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);

@ -91,6 +91,11 @@ void UBGraphicsWidgetItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
mDelegate->hoverLeaveEvent(event); mDelegate->hoverLeaveEvent(event);
UBGraphicsProxyWidget::hoverLeaveEvent(event); UBGraphicsProxyWidget::hoverLeaveEvent(event);
} }
void UBGraphicsWidgetItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
UBGraphicsProxyWidget::hoverMoveEvent(event);
}
bool UBGraphicsWidgetItem::eventFilter(QObject *obj, QEvent *event) bool UBGraphicsWidgetItem::eventFilter(QObject *obj, QEvent *event)
{ {

@ -87,6 +87,8 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
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 bool eventFilter(QObject *obj, QEvent *event); virtual bool eventFilter(QObject *obj, QEvent *event);

@ -9,7 +9,7 @@
#include "core/memcheck.h" #include "core/memcheck.h"
UBGraphicsGroupContainerItem::UBGraphicsGroupContainerItem(QGraphicsItem *parent) UBGraphicsGroupContainerItem::UBGraphicsGroupContainerItem(QGraphicsItem *parent)
: QGraphicsItemGroup(parent) : QGraphicsItem(parent)
{ {
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
@ -23,12 +23,137 @@ UBGraphicsGroupContainerItem::UBGraphicsGroupContainerItem(QGraphicsItem *parent
UBGraphicsGroupContainerItem::setAcceptHoverEvents(true); UBGraphicsGroupContainerItem::setAcceptHoverEvents(true);
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
}
void UBGraphicsGroupContainerItem::addToGroup(QGraphicsItem *item)
{
if (!item) {
qWarning("UBGraphicsGroupContainerItem::addToGroup: cannot add null item");
return;
}
if (item == this) {
qWarning("UBGraphicsGroupContainerItem::addToGroup: cannot add a group to itself");
return;
}
// COMBINE
bool ok;
QTransform itemTransform = item->itemTransform(this, &ok);
if (!ok) {
qWarning("UBGraphicsGroupContainerItem::addToGroup: could not find a valid transformation from item to group coordinates");
return;
}
//setting item flags to given item
item->setSelected(false);
item->setFlag(QGraphicsItem::ItemIsSelectable, false);
item->setFlag( QGraphicsItem::ItemIsMovable, false);
item->setFlag(QGraphicsItem::ItemIsFocusable, true);
QTransform newItemTransform(itemTransform);
item->setPos(mapFromItem(item, 0, 0));
item->setParentItem(this);
// removing position from translation component of the new transform
if (!item->pos().isNull())
newItemTransform *= QTransform::fromTranslate(-item->x(), -item->y());
// removing additional transformations properties applied with itemTransform()
QPointF origin = item->transformOriginPoint();
QMatrix4x4 m;
QList<QGraphicsTransform*> transformList = item->transformations();
for (int i = 0; i < transformList.size(); ++i)
transformList.at(i)->applyTo(&m);
newItemTransform *= m.toTransform().inverted();
newItemTransform.translate(origin.x(), origin.y());
newItemTransform.rotate(-item->rotation());
newItemTransform.scale(1/item->scale(), 1/item->scale());
newItemTransform.translate(-origin.x(), -origin.y());
// ### Expensive, we could maybe use dirtySceneTransform bit for optimization
item->setTransform(newItemTransform);
// item->d_func()->setIsMemberOfGroup(true);
prepareGeometryChange();
itemsBoundingRect |= itemTransform.mapRect(item->boundingRect() | item->childrenBoundingRect());
update();
}
void UBGraphicsGroupContainerItem::removeFromGroup(QGraphicsItem *item)
{
if (!item) {
qWarning("QGraphicsItemGroup::removeFromGroup: cannot remove null item");
return;
}
QGraphicsItem *newParent = parentItem();
// COMBINE
bool ok;
QTransform itemTransform;
if (newParent)
itemTransform = item->itemTransform(newParent, &ok);
else
itemTransform = item->sceneTransform();
QPointF oldPos = item->mapToItem(newParent, 0, 0);
item->setParentItem(newParent);
item->setPos(oldPos);
// removing position from translation component of the new transform
if (!item->pos().isNull())
itemTransform *= QTransform::fromTranslate(-item->x(), -item->y());
// removing additional transformations properties applied
// with itemTransform() or sceneTransform()
QPointF origin = item->transformOriginPoint();
QMatrix4x4 m;
QList<QGraphicsTransform*> transformList = item->transformations();
for (int i = 0; i < transformList.size(); ++i)
transformList.at(i)->applyTo(&m);
itemTransform *= m.toTransform().inverted();
itemTransform.translate(origin.x(), origin.y());
itemTransform.rotate(-item->rotation());
itemTransform.scale(1 / item->scale(), 1 / item->scale());
itemTransform.translate(-origin.x(), -origin.y());
// ### Expensive, we could maybe use dirtySceneTransform bit for optimization
item->setTransform(itemTransform);
// item->d_func()->setIsMemberOfGroup(item->group() != 0);
// ### Quite expensive. But removeFromGroup() isn't called very often.
prepareGeometryChange();
itemsBoundingRect = childrenBoundingRect();
} }
QRectF UBGraphicsGroupContainerItem::boundingRect() const
{
return itemsBoundingRect;
}
void UBGraphicsGroupContainerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget)
{
Q_UNUSED(widget);
Q_UNUSED(painter);
Q_UNUSED(option);
// we would not use paint smth for the moment
// if (option->state & QStyle::State_Selected) {
// painter->setBrush(Qt::NoBrush);
// QPen tmpPen;
// qreal tmpPenWidth = 1.0;
// tmpPen.setWidth(tmpPenWidth);
// tmpPen.setColor(Qt::lightGray);
// painter->setPen(tmpPen);
// painter->drawRect(itemsBoundingRect.adjusted(tmpPenWidth / 2, tmpPenWidth / 2, -tmpPenWidth / 2, -tmpPenWidth / 2));
// }
}
UBGraphicsScene *UBGraphicsGroupContainerItem::scene() UBGraphicsScene *UBGraphicsGroupContainerItem::scene()
{ {
UBGraphicsScene *castScene = dynamic_cast<UBGraphicsScene*>(scene()); UBGraphicsScene *castScene = dynamic_cast<UBGraphicsScene*>(QGraphicsItem::scene());
return castScene; return castScene;
} }
@ -55,15 +180,33 @@ void UBGraphicsGroupContainerItem::remove()
mDelegate->remove(); mDelegate->remove();
} }
void UBGraphicsGroupContainerItem::destroy() {
foreach (QGraphicsItem *item, childItems()) {
removeFromGroup(item);
item->setFlag(QGraphicsItem::ItemIsSelectable, true);
item->setFlag(QGraphicsItem::ItemIsFocusable, true);
}
remove();
if (scene()) {
qDebug() << "scene is well casted";
scene()->removeItem(this);
}
}
void UBGraphicsGroupContainerItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsGroupContainerItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mousePressEvent(event)) { if (mDelegate->mousePressEvent(event)) {
//NOOP //NOOP
} else { } else {
QGraphicsItemGroup::mousePressEvent(event);
QGraphicsItem::mousePressEvent(event);
setSelected(true); setSelected(true);
} }
} }
void UBGraphicsGroupContainerItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsGroupContainerItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
@ -71,18 +214,19 @@ void UBGraphicsGroupContainerItem::mouseMoveEvent(QGraphicsSceneMouseEvent *even
if (mDelegate->mouseMoveEvent(event)) { if (mDelegate->mouseMoveEvent(event)) {
// NOOP; // NOOP;
} else { } else {
QGraphicsItemGroup::mouseMoveEvent(event); QGraphicsItem::mouseMoveEvent(event);
} }
} }
void UBGraphicsGroupContainerItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsGroupContainerItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
mDelegate->mouseReleaseEvent(event); // mDelegate->mouseReleaseEvent(event);
QGraphicsItemGroup::mouseReleaseEvent(event); QGraphicsItem::mouseReleaseEvent(event);
} }
QVariant UBGraphicsGroupContainerItem::itemChange(GraphicsItemChange change, const QVariant &value) QVariant UBGraphicsGroupContainerItem::itemChange(GraphicsItemChange change, const QVariant &value)
{ {
QVariant newValue = mDelegate->itemChange(change, value); QVariant newValue = mDelegate->itemChange(change, value);
return QGraphicsItemGroup::itemChange(change, newValue); return QGraphicsItem::itemChange(change, newValue);
} }

@ -5,20 +5,33 @@
#include "domain/UBItem.h" #include "domain/UBItem.h"
class UBGraphicsGroupContainerItem : public QGraphicsItemGroup, public UBItem, public UBGraphicsItem class UBGraphicsGroupContainerItem : public QGraphicsItem, public UBItem, public UBGraphicsItem
{ {
public: public:
UBGraphicsGroupContainerItem (QGraphicsItem *parent = 0); UBGraphicsGroupContainerItem (QGraphicsItem *parent = 0);
void addToGroup(QGraphicsItem *item);
void removeFromGroup(QGraphicsItem *item);
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
virtual UBGraphicsItemDelegate* Delegate() const { return mDelegate;} virtual UBGraphicsItemDelegate* Delegate() const { return mDelegate;}
virtual UBGraphicsScene* scene(); virtual UBGraphicsScene* scene();
virtual UBGraphicsGroupContainerItem *deepCopy() const; virtual UBGraphicsGroupContainerItem *deepCopy() const;
virtual void remove(); virtual void remove();
enum { Type = UBGraphicsItemType::groupContainerType };
virtual int type() const
{
return Type;
}
protected: void destroy();
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
@ -26,6 +39,7 @@ protected:
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
private: private:
QRectF itemsBoundingRect;
}; };

@ -45,21 +45,25 @@ void UBGraphicsGroupContainerItemDelegate::decorateMenu(QMenu *menu)
void UBGraphicsGroupContainerItemDelegate::buildButtons() void UBGraphicsGroupContainerItemDelegate::buildButtons()
{ {
UBGraphicsItemDelegate::buildButtons(); UBGraphicsItemDelegate::buildButtons();
}
mDestroyGroupButton = new DelegateButton(":/images/font.svg", mDelegated, mFrame, Qt::TopLeftSection); bool UBGraphicsGroupContainerItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_UNUSED(event)
mButtons << mDestroyGroupButton; return false;
}
bool UBGraphicsGroupContainerItemDelegate::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
Q_UNUSED(event)
connect(mDestroyGroupButton, SIGNAL(clicked()), (UBGraphicsGroupContainerItemDelegate*)this, SLOT(destroyGroup())); return false;
} }
void UBGraphicsGroupContainerItemDelegate::destroyGroup() bool UBGraphicsGroupContainerItemDelegate::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
qDebug() << "got an event"; Q_UNUSED(event)
foreach (QGraphicsItem *item, delegated()->childItems()) {
delegated()->removeFromGroup(item);
item->setFlag(QGraphicsItem::ItemIsSelectable, true);
}
remove(true); return false;
} }

@ -17,9 +17,9 @@ protected:
virtual void decorateMenu(QMenu *menu); virtual void decorateMenu(QMenu *menu);
virtual void buildButtons(); virtual void buildButtons();
virtual bool mousePressEvent(QGraphicsSceneMouseEvent *event);
private slots: virtual bool mouseMoveEvent(QGraphicsSceneMouseEvent *event);
void destroyGroup(); virtual bool mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
private: private:
DelegateButton *mDestroyGroupButton; DelegateButton *mDestroyGroupButton;

@ -198,8 +198,9 @@ QRectF UBGeometryUtils::lineToInnerRect(const QLineF& pLine, const qreal& pWidth
qreal centerX = (pLine.x1() + pLine.x2()) / 2; qreal centerX = (pLine.x1() + pLine.x2()) / 2;
qreal centerY = (pLine.y1() + pLine.y2()) / 2; qreal centerY = (pLine.y1() + pLine.y2()) / 2;
// Please put a fucking comment here
qreal side = sqrt((pWidth * pWidth) / 2); qreal side = sqrt((pWidth * pWidth) / 2);
qreal halfSide = side / 2; qreal halfSide = side / 2;
return QRectF(centerX - halfSide, centerY - halfSide, side, side); return QRectF(centerX - halfSide, centerY - halfSide, side, side);
} }

@ -66,8 +66,8 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
mButtonGroup->addButton(mpRemoveFavoriteBtn); mButtonGroup->addButton(mpRemoveFavoriteBtn);
mButtonGroup->addButton(mpNewFolderBtn); mButtonGroup->addButton(mpNewFolderBtn);
// Connect signals & slots // Connect signals & slots
connect(mpFavoriteAction,SIGNAL(triggered()), this, SLOT(onActionFavorite())); /*connect(mpFavoriteAction,SIGNAL(triggered()), this, SLOT(onActionFavorite()));
/*connect(mpSocialAction,SIGNAL(triggered()), this, SLOT(onActionSocial())); connect(mpSocialAction,SIGNAL(triggered()), this, SLOT(onActionSocial()));
connect(mpSearchAction,SIGNAL(triggered()), this, SLOT(onActionSearch())); connect(mpSearchAction,SIGNAL(triggered()), this, SLOT(onActionSearch()));
connect(mpDeleteAction,SIGNAL(triggered()), this, SLOT(onActionTrash())); connect(mpDeleteAction,SIGNAL(triggered()), this, SLOT(onActionTrash()));
connect(mpCloseAction, SIGNAL(triggered()), this, SLOT(onActionClose())); connect(mpCloseAction, SIGNAL(triggered()), this, SLOT(onActionClose()));
@ -75,8 +75,11 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
connect(mSearchBar, SIGNAL(textChanged(QString)), this, SLOT(onSearchTextChanged(QString))); connect(mSearchBar, SIGNAL(textChanged(QString)), this, SLOT(onSearchTextChanged(QString)));
connect(mpNewFolderAction, SIGNAL(triggered()), this, SLOT(onActionNewFolder()));*/ connect(mpNewFolderAction, SIGNAL(triggered()), this, SLOT(onActionNewFolder()));*/
connect(mpFavoriteAction,SIGNAL(triggered()), this, SLOT(onActionFavorite()));
connect(mSearchBar, SIGNAL(textChanged(QString)), this, SLOT(onSearchTextChanged(QString))); connect(mSearchBar, SIGNAL(textChanged(QString)), this, SLOT(onSearchTextChanged(QString)));
connect(mpNewFolderAction, SIGNAL(triggered()), this, SLOT(onActionNewFolder())); connect(mpNewFolderAction, SIGNAL(triggered()), this, SLOT(onActionNewFolder()));
connect(mpRemoveFavorite, SIGNAL(triggered()), this, SLOT(onActionRemoveFavorite()));
connect(mpDeleteAction,SIGNAL(triggered()), this, SLOT(onActionTrash()));
// Build the default toolbar // Build the default toolbar
mLayout->addWidget(mpFavoriteBtn); mLayout->addWidget(mpFavoriteBtn);
@ -148,6 +151,8 @@ void UBFeaturesActionBar::setButtons()
mpFavoriteBtn->hide(); mpFavoriteBtn->hide();
mpSocialBtn->hide(); mpSocialBtn->hide();
mSearchBar->show(); mSearchBar->show();
mpDeleteBtn->show();
mpDeleteBtn->setEnabled(true);
//mpSearchBtn->show(); //mpSearchBtn->show();
//mpDeleteBtn->hide(); //mpDeleteBtn->hide();
mpCloseBtn->hide(); mpCloseBtn->hide();
@ -175,6 +180,16 @@ void UBFeaturesActionBar::onActionFavorite()
emit addElementsToFavorite(); emit addElementsToFavorite();
} }
void UBFeaturesActionBar::onActionRemoveFavorite()
{
emit removeElementsFromFavorite();
}
void UBFeaturesActionBar::onActionTrash()
{
emit deleteSelectedElements();
}
/* /*
void UBFeaturesActionBar::dragMoveEvent(QDragMoveEvent *event) void UBFeaturesActionBar::dragMoveEvent(QDragMoveEvent *event)
{ {

@ -31,10 +31,14 @@ signals:
void addToFavorite( const QMimeData &data ); void addToFavorite( const QMimeData &data );
void removeFromFavorite( const QMimeData &data ); void removeFromFavorite( const QMimeData &data );
void addElementsToFavorite(); void addElementsToFavorite();
void removeElementsFromFavorite();
void deleteSelectedElements();
private slots: private slots:
void onSearchTextChanged(QString txt); void onSearchTextChanged(QString txt);
void onActionNewFolder(); void onActionNewFolder();
void onActionFavorite(); void onActionFavorite();
void onActionRemoveFavorite();
void onActionTrash();
protected: protected:
//void dragMoveEvent(QDragMoveEvent *event); //void dragMoveEvent(QDragMoveEvent *event);
void dragEnterEvent( QDragEnterEvent *event ); void dragEnterEvent( QDragEnterEvent *event );

@ -10,7 +10,7 @@
#include "globals/UBGlobals.h" #include "globals/UBGlobals.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent) UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent)
{ {
setObjectName(name); setObjectName(name);
mName = "FeaturesWidget"; mName = "FeaturesWidget";
@ -82,7 +82,6 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
//pathListView->setMovement( QListView::Static ); //pathListView->setMovement( QListView::Static );
pathListView->setDragDropMode( QAbstractItemView::DropOnly ); pathListView->setDragDropMode( QAbstractItemView::DropOnly );
pathScene = new QGraphicsScene(this);
//pathViewer = new UBFeaturesPathViewer( QPixmap(":images/libpalette/home.png"), controller->getRootPath(), pathScene, this ); //pathViewer = new UBFeaturesPathViewer( QPixmap(":images/libpalette/home.png"), controller->getRootPath(), pathScene, this );
featureProperties = new UBFeatureProperties(this); featureProperties = new UBFeatureProperties(this);
webView = new UBFeaturesWebView(this); webView = new UBFeaturesWebView(this);
@ -121,7 +120,9 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
connect( mActionBar, SIGNAL( deleteElements(const QMimeData &) ), this, SLOT( deleteElements(const QMimeData &) ) ); connect( mActionBar, SIGNAL( deleteElements(const QMimeData &) ), this, SLOT( deleteElements(const QMimeData &) ) );
connect( mActionBar, SIGNAL( addToFavorite(const QMimeData &) ), this, SLOT( addToFavorite(const QMimeData &) ) ); connect( mActionBar, SIGNAL( addToFavorite(const QMimeData &) ), this, SLOT( addToFavorite(const QMimeData &) ) );
connect( mActionBar, SIGNAL( removeFromFavorite(const QMimeData &) ), this, SLOT( removeFromFavorite(const QMimeData &) ) ); connect( mActionBar, SIGNAL( removeFromFavorite(const QMimeData &) ), this, SLOT( removeFromFavorite(const QMimeData &) ) );
connect ( mActionBar, SIGNAL( addElementsToFavorite() ), this, SLOT ( addElementsToFavorite() ) ); connect( mActionBar, SIGNAL( addElementsToFavorite() ), this, SLOT ( addElementsToFavorite() ) );
connect( mActionBar, SIGNAL( removeElementsFromFavorite() ), this, SLOT ( removeElementsFromFavorite() ) );
connect( mActionBar, SIGNAL( deleteSelectedElements() ), this, SLOT( deleteSelectedElements() ) );
connect( pathListView, SIGNAL(clicked( const QModelIndex & ) ), connect( pathListView, SIGNAL(clicked( const QModelIndex & ) ),
this, SLOT( currentPathChanged( const QModelIndex & ) ) ); this, SLOT( currentPathChanged( const QModelIndex & ) ) );
connect( thumbSlider, SIGNAL( sliderMoved(int) ), this, SLOT(thumbnailSizeChanged( int ) ) ); connect( thumbSlider, SIGNAL( sliderMoved(int) ), this, SLOT(thumbnailSizeChanged( int ) ) );
@ -131,6 +132,15 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
this, SLOT( onAddDownloadedFileToLibrary( bool, QUrl, QString,QByteArray ) ) ); this, SLOT( onAddDownloadedFileToLibrary( bool, QUrl, QString,QByteArray ) ) );
} }
UBFeaturesWidget::~UBFeaturesWidget()
{
if ( thumbSlider != NULL )
{
delete thumbSlider;
thumbSlider = NULL;
}
}
bool UBFeaturesWidget::eventFilter( QObject *target, QEvent *event ) bool UBFeaturesWidget::eventFilter( QObject *target, QEvent *event )
{ {
if ( target == featuresListView && event->type() == QEvent::Resize ) if ( target == featuresListView && event->type() == QEvent::Resize )
@ -277,6 +287,37 @@ void UBFeaturesWidget::deleteElements( const QMimeData & mimeData )
model->invalidate(); model->invalidate();
} }
void UBFeaturesWidget::deleteSelectedElements()
{
QModelIndexList selected = featuresListView->selectionModel()->selectedIndexes();
QList <QUrl> urls;
foreach ( QModelIndex sel, selected )
{
UBFeature feature = sel.data( Qt::UserRole + 1 ).value<UBFeature>();
if ( feature.isDeletable() )
urls.append( feature.getFullPath() );
}
foreach (QUrl url, urls)
{
if ( controller->isTrash( url ) )
{
controller->deleteItem( url );
}
else
{
UBFeature elem = controller->moveItemToFolder( url, controller->getTrashElement() );
controller->removeFromFavorite( url );
featuresModel->addItem( elem );
featuresModel->deleteFavoriteItem( url.toString() );
}
featuresModel->deleteItem( url.toString() );
}
QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( featuresListView->model() );
model->invalidate();
}
void UBFeaturesWidget::addToFavorite( const QMimeData & mimeData ) void UBFeaturesWidget::addToFavorite( const QMimeData & mimeData )
{ {
if ( !mimeData.hasUrls() ) if ( !mimeData.hasUrls() )
@ -335,14 +376,45 @@ void UBFeaturesWidget::onAddDownloadedFileToLibrary(bool pSuccess, QUrl sourceUr
} }
void UBFeaturesWidget::addElementsToFavorite() void UBFeaturesWidget::addElementsToFavorite()
{
if ( currentStackedWidget == ID_PROPERTIES )
{
UBFeature feature = featureProperties->getCurrentElement();
if ( feature != UBFeature() && !UBApplication::isFromWeb( feature.getFullPath().toString() ) )
{
UBFeature elem = controller->addToFavorite( feature.getFullPath() );
featuresModel->addItem( elem );
}
}
else if ( currentStackedWidget == ID_LISTVIEW )
{
QModelIndexList selected = featuresListView->selectionModel()->selectedIndexes();
for ( int i = 0; i < selected.size(); ++i )
{
UBFeature feature = selected.at(i).data( Qt::UserRole + 1 ).value<UBFeature>();
UBFeature elem = controller->addToFavorite( feature.getFullPath() );
if ( !elem.getVirtualPath().isEmpty() && !elem.getVirtualPath().isNull() )
featuresModel->addItem( elem );
}
}
QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( featuresListView->model() );
model->invalidate();
}
void UBFeaturesWidget::removeElementsFromFavorite()
{ {
QModelIndexList selected = featuresListView->selectionModel()->selectedIndexes(); QModelIndexList selected = featuresListView->selectionModel()->selectedIndexes();
//qSort( selected.begin(), selected.end(), qGreater<QModelIndex>() );
QList <QUrl> items;
for ( int i = 0; i < selected.size(); ++i ) for ( int i = 0; i < selected.size(); ++i )
{ {
UBFeature feature = selected.at(i).data( Qt::UserRole + 1 ).value<UBFeature>(); UBFeature feature = selected.at(i).data( Qt::UserRole + 1 ).value<UBFeature>();
UBFeature elem = controller->addToFavorite( feature.getFullPath() ); items.append( feature.getFullPath() );
if ( !elem.getVirtualPath().isEmpty() && !elem.getVirtualPath().isNull() ) }
featuresModel->addItem( elem ); foreach ( QUrl url, items )
{
controller->removeFromFavorite( url );
featuresModel->deleteFavoriteItem( url.toString() );
} }
QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( featuresListView->model() ); QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( featuresListView->model() );
model->invalidate(); model->invalidate();
@ -380,9 +452,7 @@ void UBFeaturesWidget::currentPathChanged(const QString &path)
*/ */
UBFeaturesWidget::~UBFeaturesWidget()
{
}
UBFeaturesListView::UBFeaturesListView( QWidget* parent, const char* name ) UBFeaturesListView::UBFeaturesListView( QWidget* parent, const char* name )
: QListView(parent) : QListView(parent)
@ -435,7 +505,7 @@ void UBFeaturesListView::dropEvent( QDropEvent *event )
{ {
event->setDropAction( Qt::MoveAction ); event->setDropAction( Qt::MoveAction );
} }
QListView::dropEvent( event ); QListView::dropEvent( event );
} }
@ -473,15 +543,18 @@ UBFeaturesWebView::UBFeaturesWebView(QWidget* parent, const char* name):QWidget(
UBFeaturesWebView::~UBFeaturesWebView() UBFeaturesWebView::~UBFeaturesWebView()
{ {
if(NULL != mpSankoreAPI){ if( NULL != mpSankoreAPI )
{
delete mpSankoreAPI; delete mpSankoreAPI;
mpSankoreAPI = NULL; mpSankoreAPI = NULL;
} }
if(NULL != mpView){ if( NULL != mpView )
{
delete mpView; delete mpView;
mpView = NULL; mpView = NULL;
} }
if(NULL != mpLayout){ if( NULL != mpLayout )
{
delete mpLayout; delete mpLayout;
mpLayout = NULL; mpLayout = NULL;
} }
@ -597,6 +670,55 @@ UBFeatureProperties::UBFeatureProperties( QWidget *parent, const char *name ) :
connect( mpAddToLibButton, SIGNAL( clicked() ), this, SLOT(onAddToLib() ) ); connect( mpAddToLibButton, SIGNAL( clicked() ), this, SLOT(onAddToLib() ) );
} }
UBFeatureProperties::~UBFeatureProperties()
{
if ( mpOrigPixmap )
{
delete mpOrigPixmap;
mpOrigPixmap = NULL;
}
if ( mpElement )
{
delete mpElement;
mpElement = NULL;
}
if ( mpThumbnail )
{
delete mpThumbnail;
mpThumbnail = NULL;
}
if ( mpButtonLayout )
{
delete mpButtonLayout;
mpButtonLayout = NULL;
}
if ( mpAddPageButton )
{
delete mpAddPageButton;
mpAddPageButton = NULL;
}
if ( mpSetAsBackgroundButton )
{
delete mpSetAsBackgroundButton;
mpSetAsBackgroundButton = NULL;
}
if ( mpAddToLibButton )
{
delete mpAddToLibButton;
mpAddToLibButton = NULL;
}
if ( mpObjInfoLabel )
{
delete mpObjInfoLabel;
mpObjInfoLabel = NULL;
}
if ( mpObjInfos )
{
delete mpObjInfos;
mpObjInfos = NULL;
}
}
void UBFeatureProperties::resizeEvent( QResizeEvent *event ) void UBFeatureProperties::resizeEvent( QResizeEvent *event )
{ {
Q_UNUSED(event); Q_UNUSED(event);
@ -609,6 +731,13 @@ void UBFeatureProperties::showEvent (QShowEvent *event )
adaptSize(); adaptSize();
} }
UBFeature UBFeatureProperties::getCurrentElement() const
{
if ( mpElement )
return *mpElement;
return UBFeature();
}
void UBFeatureProperties::adaptSize() void UBFeatureProperties::adaptSize()
{ {
if( NULL != mpOrigPixmap ) if( NULL != mpOrigPixmap )
@ -716,19 +845,7 @@ void UBFeatureProperties::onSetAsBackground()
featuresWidget->getFeaturesController()->addItemAsBackground( *mpElement ); featuresWidget->getFeaturesController()->addItemAsBackground( *mpElement );
} }
UBFeatureProperties::~UBFeatureProperties()
{
if ( mpOrigPixmap )
{
delete mpOrigPixmap;
mpOrigPixmap = NULL;
}
if ( mpElement )
{
delete mpElement;
mpElement = NULL;
}
}
UBFeatureItemButton::UBFeatureItemButton(QWidget *parent, const char *name):QPushButton(parent) UBFeatureItemButton::UBFeatureItemButton(QWidget *parent, const char *name):QPushButton(parent)
{ {
@ -854,7 +971,7 @@ void UBFeaturesModel::deleteFavoriteItem( const QString &path )
{ {
for ( int i = 0; i < featuresList->size(); ++i ) for ( int i = 0; i < featuresList->size(); ++i )
{ {
if ( !QString::compare( featuresList->at(i).getUrl(), path, Qt::CaseInsensitive ) && if ( !QString::compare( featuresList->at(i).getFullPath().toString(), path, Qt::CaseInsensitive ) &&
!QString::compare( featuresList->at(i).getVirtualPath(), "/root/favorites", Qt::CaseInsensitive ) ) !QString::compare( featuresList->at(i).getVirtualPath(), "/root/favorites", Qt::CaseInsensitive ) )
{ {
removeRow( i, QModelIndex() ); removeRow( i, QModelIndex() );
@ -863,6 +980,18 @@ void UBFeaturesModel::deleteFavoriteItem( const QString &path )
} }
} }
void UBFeaturesModel::deleteItem( const QString &path )
{
for ( int i = 0; i < featuresList->size(); ++i )
{
if ( !QString::compare( featuresList->at(i).getFullPath().toString(), path, Qt::CaseInsensitive ) )
{
removeRow( i, QModelIndex() );
return;
}
}
}
bool UBFeaturesModel::removeRows( int row, int count, const QModelIndex & parent ) bool UBFeaturesModel::removeRows( int row, int count, const QModelIndex & parent )
{ {
if ( row < 0 ) if ( row < 0 )
@ -889,6 +1018,7 @@ bool UBFeaturesModel::removeRow( int row, const QModelIndex & parent )
return true; return true;
} }
Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const
{ {
Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index); Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index);

@ -80,7 +80,7 @@ private:
QSlider *thumbSlider; QSlider *thumbSlider;
QVBoxLayout *layout; QVBoxLayout *layout;
//UBFeaturesPathViewer *pathViewer; //UBFeaturesPathViewer *pathViewer;
QGraphicsScene *pathScene; //QGraphicsScene *pathScene;
UBFeaturesActionBar *mActionBar; UBFeaturesActionBar *mActionBar;
UBFeatureProperties *featureProperties; UBFeatureProperties *featureProperties;
UBFeaturesWebView *webView; UBFeaturesWebView *webView;
@ -88,7 +88,6 @@ private:
int currentStackedWidget; int currentStackedWidget;
QModelIndex trashIndex;
private slots: private slots:
void currentSelected( const QModelIndex & ); void currentSelected( const QModelIndex & );
//void currentPathChanged(const QString &); //void currentPathChanged(const QString &);
@ -102,6 +101,8 @@ private slots:
void onDisplayMetadata( QMap<QString,QString> ); void onDisplayMetadata( QMap<QString,QString> );
void onAddDownloadedFileToLibrary(bool, QUrl, QString, QByteArray); void onAddDownloadedFileToLibrary(bool, QUrl, QString, QByteArray);
void addElementsToFavorite(); void addElementsToFavorite();
void removeElementsFromFavorite();
void deleteSelectedElements();
protected: protected:
bool eventFilter(QObject *target, QEvent *event); bool eventFilter(QObject *target, QEvent *event);
}; };
@ -129,7 +130,7 @@ class UBFeaturesWebView : public QWidget
Q_OBJECT Q_OBJECT
public: public:
UBFeaturesWebView(QWidget* parent = 0, const char* name = "UBFeaturesWebView"); UBFeaturesWebView(QWidget* parent = 0, const char* name = "UBFeaturesWebView");
~UBFeaturesWebView(); virtual ~UBFeaturesWebView();
void showElement(const UBFeature &elem); void showElement(const UBFeature &elem);
@ -151,8 +152,7 @@ public:
~UBFeatureProperties(); ~UBFeatureProperties();
void showElement(const UBFeature &elem); void showElement(const UBFeature &elem);
UBFeature getCurrentElement() const;
protected: protected:
void resizeEvent(QResizeEvent *event); void resizeEvent(QResizeEvent *event);
void showEvent(QShowEvent *event); void showEvent(QShowEvent *event);
@ -200,6 +200,7 @@ public:
void addItem( const UBFeature &item ); void addItem( const UBFeature &item );
void deleteFavoriteItem( const QString &path ); void deleteFavoriteItem( const QString &path );
void deleteItem( const QString &path );
QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const;
QMimeData *mimeData( const QModelIndexList &indexes ) const; QMimeData *mimeData( const QModelIndexList &indexes ) const;
@ -209,6 +210,8 @@ public:
bool dropMimeData(const QMimeData *mimeData, Qt::DropAction action, int row, int column, const QModelIndex &parent); bool dropMimeData(const QMimeData *mimeData, Qt::DropAction action, int row, int column, const QModelIndex &parent);
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
bool removeRow(int row, const QModelIndex &parent = QModelIndex()); bool removeRow(int row, const QModelIndex &parent = QModelIndex());
//bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
//bool insertRow(int row, const QModelIndex &parent = QModelIndex());
Qt::DropActions supportedDropActions() const { return Qt::MoveAction | Qt::CopyAction; } Qt::DropActions supportedDropActions() const { return Qt::MoveAction | Qt::CopyAction; }

@ -71,6 +71,7 @@ UBGraphicsCompass::UBGraphicsCompass()
unsetCursor(); unsetCursor();
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::CppTool)); //Necessary to set if we want z value to be assigned correctly setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::CppTool)); //Necessary to set if we want z value to be assigned correctly
setFlag(QGraphicsItem::ItemIsSelectable, false);
connect(UBApplication::boardController, SIGNAL(penColorChanged()), this, SLOT(penColorChanged())); connect(UBApplication::boardController, SIGNAL(penColorChanged()), this, SLOT(penColorChanged()));
connect(UBDrawingController::drawingController(), SIGNAL(lineWidthIndexChanged(int)), this, SLOT(lineWidthChanged())); connect(UBDrawingController::drawingController(), SIGNAL(lineWidthIndexChanged(int)), this, SLOT(lineWidthChanged()));

@ -64,6 +64,7 @@ UBGraphicsProtractor::UBGraphicsProtractor()
mRotateSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control)); mRotateSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::CppTool)); //Necessary to set if we want z value to be assigned correctly setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::CppTool)); //Necessary to set if we want z value to be assigned correctly
setFlag(QGraphicsItem::ItemIsSelectable, false);
scale(1.5, 1.5); scale(1.5, 1.5);
} }

@ -28,7 +28,7 @@ class UBGraphicsScene;
class UBGraphicsProtractor : public UBAbstractDrawRuler, public QGraphicsEllipseItem, public UBItem class UBGraphicsProtractor : public UBAbstractDrawRuler, public QGraphicsEllipseItem, public UBItem
{ {
Q_OBJECT; Q_OBJECT
public: public:
UBGraphicsProtractor (); UBGraphicsProtractor ();

@ -46,7 +46,8 @@ UBGraphicsRuler::UBGraphicsRuler()
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::CppTool)); //Necessary to set if we want z value to be assigned correctly setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::CppTool)); //Necessary to set if we want z value to be assigned correctly
updateResizeCursor(); setFlag(QGraphicsItem::ItemIsSelectable, false);
updateResizeCursor();
} }
void UBGraphicsRuler::updateResizeCursor() void UBGraphicsRuler::updateResizeCursor()

@ -55,6 +55,7 @@ UBGraphicsTriangle::UBGraphicsTriangle()
mRotateSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control)); mRotateSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::CppTool)); //Necessary to set if we want z value to be assigned correctly setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::CppTool)); //Necessary to set if we want z value to be assigned correctly
setFlag(QGraphicsItem::ItemIsSelectable, false);
updateResizeCursor(); updateResizeCursor();
} }

Loading…
Cancel
Save