Presentation changes

preferencesAboutTextFull
Ilia Ryabokon 12 years ago
parent 2806b13562
commit a672c9bf1c
  1. 2
      Sankore_3.1.pro
  2. 272
      src/board/UBBoardView.cpp
  3. 70
      src/domain/UBGraphicsItemDelegate.cpp
  4. 7
      src/domain/UBGraphicsScene.cpp
  5. 1
      src/domain/UBGraphicsScene.h

@ -374,7 +374,7 @@ macx {
linux-g++* { linux-g++* {
CONFIG += link_prl CONFIG += link_prl
LIBS += -lcrypto LIBS += -lcrypto
LIBS += -lprofiler #LIBS += -lprofiler
LIBS += -lX11 LIBS += -lX11
QMAKE_CFLAGS += -fopenmp QMAKE_CFLAGS += -fopenmp
QMAKE_CXXFLAGS += -fopenmp QMAKE_CXXFLAGS += -fopenmp

@ -973,38 +973,36 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
} }
mMouseDownPos = event->pos (); mMouseDownPos = event->pos ();
movingItem = scene()->itemAt(this->mapToScene(event->posF().toPoint())); movingItem = scene()->itemAt(this->mapToScene(event->posF().toPoint()));
if (!movingItem) if (!movingItem)
emit clickOnBoard(); emit clickOnBoard();
if (event->button () == Qt::LeftButton && isInteractive ()) if (event->button () == Qt::LeftButton && isInteractive())
{ {
int currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool ();
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool ();
if (!mTabletStylusIsPressed) if (!mTabletStylusIsPressed)
mMouseButtonIsPressed = true; mMouseButtonIsPressed = true;
if (currentTool == UBStylusTool::ZoomIn) switch (currentTool) {
{ case UBStylusTool::ZoomIn :
mController->zoomIn (mapToScene (event->pos ())); mController->zoomIn (mapToScene (event->pos ()));
event->accept (); event->accept();
} break;
else if (currentTool == UBStylusTool::ZoomOut)
{ case UBStylusTool::ZoomOut :
mController->zoomOut (mapToScene (event->pos ())); mController->zoomOut (mapToScene (event->pos ()));
event->accept (); event->accept();
} break;
else if (currentTool == UBStylusTool::Hand)
{ case UBStylusTool::Hand :
viewport ()->setCursor (QCursor (Qt::ClosedHandCursor)); viewport()->setCursor(QCursor (Qt::ClosedHandCursor));
mPreviousPoint = event->posF (); mPreviousPoint = event->posF();
event->accept (); event->accept();
} break;
else if (currentTool == UBStylusTool::Selector || currentTool == UBStylusTool::Play)
{ case UBStylusTool::Selector :
case UBStylusTool::Play :
if (bIsDesktop) { if (bIsDesktop) {
event->ignore(); event->ignore();
return; return;
@ -1018,27 +1016,27 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
mLongPressTimer.start(); mLongPressTimer.start();
if (!movingItem) { if (!movingItem) {
// Rubberband selection implementation // Rubberband selection implementation
if (!mUBRubberBand) { // if (!mUBRubberBand) {
mUBRubberBand = new UBRubberBand(QRubberBand::Rectangle, this); // mUBRubberBand = new UBRubberBand(QRubberBand::Rectangle, this);
} // }
mUBRubberBand->setGeometry (QRect (mMouseDownPos, QSize ())); // mUBRubberBand->setGeometry (QRect (mMouseDownPos, QSize ()));
mUBRubberBand->show(); // mUBRubberBand->show();
scene()->setMultipleSelectionProcess(true); // scene()->updateMultipleSelectionFrame();
scene()->clearSelectionFrame();
} }
else
{ if(mUBRubberBand) {
if(mUBRubberBand) { mUBRubberBand->hide();
mUBRubberBand->hide(); scene()->setMultipleSelectionProcess(false);
scene()->setMultipleSelectionProcess(false);
}
} }
handleItemMousePress(event); handleItemMousePress(event);
event->accept(); event->accept();
} break;
else if (currentTool == UBStylusTool::Text)
{ case UBStylusTool::Text : {
int frameWidth = UBSettings::settings ()->objectFrameWidth; int frameWidth = UBSettings::settings ()->objectFrameWidth;
QRectF fuzzyRect (0, 0, frameWidth * 4, frameWidth * 4); QRectF fuzzyRect (0, 0, frameWidth * 4, frameWidth * 4);
fuzzyRect.moveCenter (mapToScene (mMouseDownPos)); fuzzyRect.moveCenter (mapToScene (mMouseDownPos));
@ -1058,20 +1056,19 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
} }
else else
{ {
scene ()->deselectAllItems (); scene()->deselectAllItems();
if (!mRubberBand) if (!mRubberBand)
mRubberBand = new UBRubberBand (QRubberBand::Rectangle, this); mRubberBand = new UBRubberBand (QRubberBand::Rectangle, this);
mRubberBand->setGeometry (QRect (mMouseDownPos, QSize ())); mRubberBand->setGeometry (QRect (mMouseDownPos, QSize ()));
mRubberBand->show (); mRubberBand->show();
mIsCreatingTextZone = true; mIsCreatingTextZone = true;
scene()->setMultipleSelectionProcess(true);
event->accept (); event->accept ();
} }
} } break;
else if (currentTool == UBStylusTool::Capture)
{ case UBStylusTool::Capture :
scene ()->deselectAllItems (); scene ()->deselectAllItems ();
if (!mRubberBand) if (!mRubberBand)
@ -1083,22 +1080,19 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
scene()->setMultipleSelectionProcess(true); scene()->setMultipleSelectionProcess(true);
event->accept (); event->accept ();
} break;
else
{ default:
if(UBDrawingController::drawingController()->mActiveRuler==NULL) if(UBDrawingController::drawingController()->mActiveRuler==NULL) {
{
viewport()->setCursor (QCursor (Qt::BlankCursor)); viewport()->setCursor (QCursor (Qt::BlankCursor));
} }
if (scene () && !mTabletStylusIsPressed) if (scene () && !mTabletStylusIsPressed) {
{ if (currentTool == UBStylusTool::Eraser) {
if (currentTool == UBStylusTool::Eraser)
{
connect(&mLongPressTimer, SIGNAL(timeout()), this, SLOT(longPressEvent())); connect(&mLongPressTimer, SIGNAL(timeout()), this, SLOT(longPressEvent()));
mLongPressTimer.start(); mLongPressTimer.start();
} }
scene ()->inputDevicePress (mapToScene (UBGeometryUtils::pointConstrainedInRect (event->pos (), rect ()))); scene()->inputDevicePress(mapToScene(UBGeometryUtils::pointConstrainedInRect(event->pos(), rect())));
} }
event->accept (); event->accept ();
} }
@ -1114,127 +1108,131 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
} }
QTime mouseMoveTime = QTime::currentTime(); QTime mouseMoveTime = QTime::currentTime();
if(!mIsDragInProgress && ((mapToScene(event->pos()) - mLastPressedMousePos).manhattanLength() < QApplication::startDragDistance())) if(!mIsDragInProgress
{ && ((mapToScene(event->pos()) - mLastPressedMousePos).manhattanLength() < QApplication::startDragDistance())) {
qDebug() << "mouse move event canceled";
return; return;
} }
mIsDragInProgress = true; mIsDragInProgress = true;
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); mWidgetMoved = true;
mLongPressTimer.stop(); mLongPressTimer.stop();
if (isAbsurdPoint (event->pos ())) if (isAbsurdPoint (event->pos ())) {
{
event->accept (); event->accept ();
return; return;
} }
if (currentTool == UBStylusTool::Hand && (mMouseButtonIsPressed || mTabletStylusIsPressed)) if ((UBDrawingController::drawingController()->isDrawingTool())
{ && !mMouseButtonIsPressed) {
QGraphicsView::mouseMoveEvent(event);
}
int currentTool = static_cast<int>(UBDrawingController::drawingController()->stylusTool());
switch (currentTool) {
case UBStylusTool::Hand : {
if (!mMouseButtonIsPressed && mTabletStylusIsPressed) {
break;
}
QPointF eventPosition = event->posF (); QPointF eventPosition = event->posF ();
qreal dx = eventPosition.x () - mPreviousPoint.x (); qreal dx = eventPosition.x () - mPreviousPoint.x ();
qreal dy = eventPosition.y () - mPreviousPoint.y (); qreal dy = eventPosition.y () - mPreviousPoint.y ();
mController->handScroll (dx, dy); mController->handScroll (dx, dy);
mPreviousPoint = eventPosition; mPreviousPoint = eventPosition;
event->accept (); event->accept ();
} } break;
else if (currentTool == UBStylusTool::Selector || currentTool == UBStylusTool::Play)
{
if((event->pos() - mLastPressedMousePos).manhattanLength() < QApplication::startDragDistance()) {
return;
}
case UBStylusTool::Selector :
case UBStylusTool::Play : {
if (bIsDesktop) { if (bIsDesktop) {
event->ignore(); event->ignore();
return; return;
} }
if (currentTool != UBStylusTool::Play || mRubberBandInPlayMode) { bool rubberMove = currentTool != (UBStylusTool::Play || mRubberBandInPlayMode)
&& (mMouseButtonIsPressed || mTabletStylusIsPressed)
&& !movingItem;
if (rubberMove) {
QRect bandRect(mMouseDownPos, event->pos());
bandRect = bandRect.normalized();
if (!movingItem && (mMouseButtonIsPressed || mTabletStylusIsPressed) && mUBRubberBand && mUBRubberBand->isVisible()) { if (!mUBRubberBand) {
mUBRubberBand = new UBRubberBand(QRubberBand::Rectangle, this);
}
// mUBRubberBand->setGeometry (QRect (mMouseDownPos, QSize ()));
mUBRubberBand->setGeometry(bandRect);
mUBRubberBand->show();
scene()->setMultipleSelectionProcess(true);
QTime startTime = QTime::currentTime();
QTime testTime = QTime::currentTime();
QList<QGraphicsItem *> rubberItems = items(bandRect);
qDebug() << "==================";
qDebug() << "| ====rubber items" << testTime.msecsTo(QTime::currentTime());
testTime = QTime::currentTime();
foreach (QGraphicsItem *item, mJustSelectedItems) {
if (!rubberItems.contains(item)) {
item->setSelected(false);
mJustSelectedItems.remove(item);
}
}
qDebug() << "| ===foreach length" << testTime.msecsTo(QTime::currentTime());
testTime = QTime::currentTime();
QRect bandRect(mMouseDownPos, event->pos()); int counter = 0;
if (currentTool == UBStylusTool::Selector) {
foreach (QGraphicsItem *item, items(bandRect)) {
bandRect = bandRect.normalized(); if (item->type() == UBGraphicsW3CWidgetItem::Type
|| item->type() == UBGraphicsPixmapItem::Type
|| item->type() == UBGraphicsMediaItem::Type
|| item->type() == UBGraphicsSvgItem::Type
|| item->type() == UBGraphicsTextItem::Type
|| item->type() == UBGraphicsStrokesGroup::Type
|| item->type() == UBGraphicsGroupContainerItem::Type) {
mUBRubberBand->setGeometry(bandRect);
QTime startTime = QTime::currentTime(); if (!mJustSelectedItems.contains(item)) {
QTime testTime = QTime::currentTime(); counter++;
QList<QGraphicsItem *> rubberItems = items(bandRect);
qDebug() << "==================";
qDebug() << "| ====rubber items" << testTime.msecsTo(QTime::currentTime());
testTime = QTime::currentTime();
foreach (QGraphicsItem *item, mJustSelectedItems) {
if (!rubberItems.contains(item)) {
item->setSelected(false);
mJustSelectedItems.remove(item);
}
}
qDebug() << "| ===foreach length" << testTime.msecsTo(QTime::currentTime());
testTime = QTime::currentTime();
int counter = 0;
if (currentTool == UBStylusTool::Selector) {
foreach (QGraphicsItem *item, items(bandRect)) {
if (item->type() == UBGraphicsW3CWidgetItem::Type
|| item->type() == UBGraphicsPixmapItem::Type
|| item->type() == UBGraphicsMediaItem::Type
|| item->type() == UBGraphicsSvgItem::Type
|| item->type() == UBGraphicsTextItem::Type
|| item->type() == UBGraphicsStrokesGroup::Type
|| item->type() == UBGraphicsGroupContainerItem::Type) {
if (!mJustSelectedItems.contains(item)) {
counter++;
item->setSelected(true);
mJustSelectedItems.insert(item);
}
item->setSelected(true); item->setSelected(true);
mJustSelectedItems.insert(item);
} }
item->setSelected(true);
} }
} }
qDebug() << "| ==selected items count" << counter << endl
<< "| ==selection time" << testTime.msecsTo(QTime::currentTime()) << endl
<< "| =elapsed time " << startTime.msecsTo(QTime::currentTime()) << endl
<< "==================";
} }
}
qDebug() << "| ==selected items count" << counter << endl
<< "| ==selection time" << testTime.msecsTo(QTime::currentTime()) << endl
<< "| =elapsed time " << startTime.msecsTo(QTime::currentTime()) << endl
<< "==================";
}
handleItemMouseMove(event); handleItemMouseMove(event);
} } break;
else if ((UBDrawingController::drawingController()->isDrawingTool())
&& !mMouseButtonIsPressed) case UBStylusTool::Text :
{ case UBStylusTool::Capture : {
QGraphicsView::mouseMoveEvent (event); if (mRubberBand
} && (mIsCreatingTextZone || mIsCreatingSceneGrabZone)) {
else if (currentTool == UBStylusTool::Text || currentTool == UBStylusTool::Capture) mRubberBand->setGeometry(QRect(mMouseDownPos, event->pos()).normalized());
{ event->accept();
if (mRubberBand && (mIsCreatingTextZone || mIsCreatingSceneGrabZone)) } else {
{
mRubberBand->setGeometry (QRect (mMouseDownPos, event->pos ()).normalized ());
event->accept ();
}
else
{
QGraphicsView::mouseMoveEvent (event); QGraphicsView::mouseMoveEvent (event);
} }
} } break;
else
{ default:
if (!mTabletStylusIsPressed && scene ()) if (!mTabletStylusIsPressed && scene()) {
{ scene()->inputDeviceMove(mapToScene(UBGeometryUtils::pointConstrainedInRect(event->pos(), rect()))
scene ()->inputDeviceMove (mapToScene (UBGeometryUtils::pointConstrainedInRect (event->pos (), rect ())), mMouseButtonIsPressed); , mMouseButtonIsPressed);
} }
event->accept (); event->accept ();
} }
if((event->pos() - mLastPressedMousePos).manhattanLength() < QApplication::startDragDistance())
mWidgetMoved = true;
qDebug() << "mouse move time" << mouseMoveTime.msecsTo(QTime::currentTime()); qDebug() << "mouse move time" << mouseMoveTime.msecsTo(QTime::currentTime());
lastCallTime = QTime::currentTime(); lastCallTime = QTime::currentTime();
} }

@ -158,6 +158,8 @@ UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObjec
, mDeleteButton(NULL) , mDeleteButton(NULL)
, mDuplicateButton(NULL) , mDuplicateButton(NULL)
, mMenuButton(NULL) , mMenuButton(NULL)
, mZOrderUpButton(0)
, mZOrderDownButton(0)
, mMenu(0) , mMenu(0)
, mLockAction(0) , mLockAction(0)
, mShowOnDisplayAction(0) , mShowOnDisplayAction(0)
@ -243,13 +245,10 @@ void UBGraphicsItemDelegate::createControls()
void UBGraphicsItemDelegate::freeControls() void UBGraphicsItemDelegate::freeControls()
{ {
QGraphicsScene *controlsScene = delegated()->scene(); QGraphicsScene *controlsScene = delegated()->scene();
Q_ASSERT(controlsScene);
UB_FREE_CONTROL(mFrame, controlsScene);
UB_FREE_CONTROL(mDeleteButton, controlsScene);
UB_FREE_CONTROL(mMenuButton, controlsScene);
UB_FREE_CONTROL(mZOrderUpButton, controlsScene);
UB_FREE_CONTROL(mZOrderDownButton, controlsScene);
UB_FREE_CONTROL(mFrame, controlsScene);
freeButtons(); freeButtons();
} }
@ -263,7 +262,6 @@ bool UBGraphicsItemDelegate::controlsExist() const
; ;
} }
UBGraphicsItemDelegate::~UBGraphicsItemDelegate() UBGraphicsItemDelegate::~UBGraphicsItemDelegate()
{ {
if (UBApplication::boardController) if (UBApplication::boardController)
@ -277,43 +275,34 @@ UBGraphicsItemDelegate::~UBGraphicsItemDelegate()
QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{ {
UBGraphicsScene *ubScene = castUBGraphicsScene(); UBGraphicsScene *ubScene = castUBGraphicsScene();
switch (static_cast<int>(change)) {
if (change == QGraphicsItem::ItemSelectedHasChanged) {
bool ok; case QGraphicsItem::ItemSelectedHasChanged : {
bool selected = value.toUInt(&ok); if (ubScene && !ubScene->multipleSelectionProcess()) {
if (value.toBool()) { //selected(true)
if (ok) { if (!controlsExist()) {
if (ubScene && !ubScene->multipleSelectionProcess()) { createControls();
if (selected) { mAntiScaleRatio = 1 / (UBApplication::boardController->systemScaleFactor() * UBApplication::boardController->currentZoom());
positionHandles();
ubScene->setSelectedZLevel(delegated()); ubScene->setSelectedZLevel(delegated());
} else {
ubScene->setOwnZlevel(delegated());
} }
} else {
ubScene->setOwnZlevel(delegated());
freeControls();
} }
} }
}
if ((change == QGraphicsItem::ItemSelectedHasChanged } break;
|| change == QGraphicsItem::ItemPositionHasChanged
|| change == QGraphicsItem::ItemTransformHasChanged) case QGraphicsItem::ItemPositionHasChanged :
&& ubScene case QGraphicsItem::ItemTransformHasChanged :
&& !ubScene->multipleSelectionProcess() case QGraphicsItem::ItemZValueHasChanged :
&& UBApplication::boardController)
{
if (!controlsExist()) {
createControls();
}
mAntiScaleRatio = 1 / (UBApplication::boardController->systemScaleFactor() * UBApplication::boardController->currentZoom()); mAntiScaleRatio = 1 / (UBApplication::boardController->systemScaleFactor() * UBApplication::boardController->currentZoom());
positionHandles(); positionHandles();
} if (ubScene) {
if (change == QGraphicsItem::ItemPositionHasChanged
|| change == QGraphicsItem::ItemTransformHasChanged
|| change == QGraphicsItem::ItemZValueHasChanged)
{
UBGraphicsScene* ubScene = qobject_cast<UBGraphicsScene*>(mDelegated->scene());
if(ubScene)
ubScene->setModified(true); ubScene->setModified(true);
}
break;
} }
return value; return value;
@ -425,6 +414,10 @@ QGraphicsItem *UBGraphicsItemDelegate::delegated()
void UBGraphicsItemDelegate::positionHandles() void UBGraphicsItemDelegate::positionHandles()
{ {
if (!controlsExist()) {
return;
}
if (mDelegated->isSelected()) { if (mDelegated->isSelected()) {
bool shownOnDisplay = mDelegated->data(UBGraphicsItemData::ItemLayerType).toInt() != UBItemLayerType::Control; bool shownOnDisplay = mDelegated->data(UBGraphicsItemData::ItemLayerType).toInt() != UBItemLayerType::Control;
showHide(shownOnDisplay); showHide(shownOnDisplay);
@ -644,6 +637,13 @@ void UBGraphicsItemDelegate::buildButtons()
} }
void UBGraphicsItemDelegate::freeButtons() void UBGraphicsItemDelegate::freeButtons()
{ {
//Previously deleted with the frame
// Rimplement for some specific behavior
mButtons.clear();
mDeleteButton = 0;
mMenuButton = 0;
mZOrderUpButton = 0;
mZOrderDownButton = 0;
} }
void UBGraphicsItemDelegate::decorateMenu(QMenu* menu) void UBGraphicsItemDelegate::decorateMenu(QMenu* menu)

@ -1034,6 +1034,13 @@ UBGraphicsPolygonItem* UBGraphicsScene::arcToPolygonItem(const QLineF& pStartRad
return polygonToPolygonItem(polygon); return polygonToPolygonItem(polygon);
} }
void UBGraphicsScene::clearSelectionFrame()
{
if (mSelectionFrame) {
mSelectionFrame->setEnclosedItems(QList<QGraphicsItem*>());
}
}
void UBGraphicsScene::updateMultipleSelectionFrame() void UBGraphicsScene::updateMultipleSelectionFrame()
{ {
qDebug() << "selected item count" << selectedItems().count(); qDebug() << "selected item count" << selectedItems().count();

@ -311,6 +311,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
UBGraphicsPolygonItem* polygonToPolygonItem(const QPolygonF pPolygon); UBGraphicsPolygonItem* polygonToPolygonItem(const QPolygonF pPolygon);
void setMultipleSelectionProcess(bool pEnabled) {mMultipleSelectionProcess = pEnabled;} void setMultipleSelectionProcess(bool pEnabled) {mMultipleSelectionProcess = pEnabled;}
bool multipleSelectionProcess() const {return mMultipleSelectionProcess;} bool multipleSelectionProcess() const {return mMultipleSelectionProcess;}
void clearSelectionFrame();
void updateMultipleSelectionFrame(); void updateMultipleSelectionFrame();
public slots: public slots:

Loading…
Cancel
Save