From 93f69f80aa115305430d8cde05e78eaf1d3865f5 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Tue, 10 Apr 2012 15:49:09 +0200 Subject: [PATCH 01/15] first new teacher guide implementation --- plugins/cffadaptor/src/UBCFFAdaptor.cpp | 42 +- src/board/UBBoardPaletteManager.cpp | 17 +- src/board/UBBoardPaletteManager.h | 4 + src/board/UBBoardView.cpp | 162 ++++--- src/board/UBBoardView.h | 1 + src/customWidgets/UBActionableWidget.cpp | 15 + src/customWidgets/UBActionableWidget.h | 15 + src/customWidgets/UBDraggableLabel.cpp | 39 -- src/customWidgets/UBDraggableLabel.h | 23 - src/customWidgets/UBDraggableMedia.cpp | 42 -- src/customWidgets/UBDraggableMedia.h | 19 - src/customWidgets/customWidgets.pri | 7 +- src/desktop/UBDesktopAnnotationController.cpp | 38 -- src/domain/UBGraphicsItemDelegate.cpp | 10 +- src/gui/UBActionPalette.cpp | 1 + src/gui/UBActionPalette.h | 2 + src/gui/UBDockTeacherGuideWidget.cpp | 45 ++ src/gui/UBDockTeacherGuideWidget.h | 39 ++ src/gui/UBMediaPlayer.cpp | 166 +------ src/gui/UBMediaPlayer.h | 31 +- src/gui/UBTeacherGuideDelegate.cpp | 5 + src/gui/UBTeacherGuideDelegate.h | 10 + src/gui/UBTeacherGuideWidget.cpp | 404 ++++++++++++++++++ src/gui/UBTeacherGuideWidget.h | 114 +++++ src/gui/UBTeacherGuideWidgetsTools.cpp | 361 ++++++++++++++++ src/gui/UBTeacherGuideWidgetsTools.h | 144 +++++++ src/gui/gui.pri | 24 +- 27 files changed, 1318 insertions(+), 462 deletions(-) delete mode 100644 src/customWidgets/UBDraggableLabel.cpp delete mode 100644 src/customWidgets/UBDraggableLabel.h delete mode 100644 src/customWidgets/UBDraggableMedia.cpp delete mode 100644 src/customWidgets/UBDraggableMedia.h create mode 100644 src/gui/UBDockTeacherGuideWidget.cpp create mode 100644 src/gui/UBDockTeacherGuideWidget.h create mode 100644 src/gui/UBTeacherGuideDelegate.cpp create mode 100644 src/gui/UBTeacherGuideDelegate.h create mode 100644 src/gui/UBTeacherGuideWidget.cpp create mode 100644 src/gui/UBTeacherGuideWidget.h create mode 100644 src/gui/UBTeacherGuideWidgetsTools.cpp create mode 100644 src/gui/UBTeacherGuideWidgetsTools.h diff --git a/plugins/cffadaptor/src/UBCFFAdaptor.cpp b/plugins/cffadaptor/src/UBCFFAdaptor.cpp index 6de92d92..5ac124f5 100644 --- a/plugins/cffadaptor/src/UBCFFAdaptor.cpp +++ b/plugins/cffadaptor/src/UBCFFAdaptor.cpp @@ -639,29 +639,30 @@ QDomElement UBCFFAdaptor::UBToCFFConverter::parseSvgPageSection(const QDomElemen void UBCFFAdaptor::UBToCFFConverter::writeQDomElementToXML(const QDomNode &node) { - if (!node.isNull()) - if (node.isText()) - { - mIWBContentWriter->writeCharacters(node.nodeValue()); - } - else - { - mIWBContentWriter->writeStartElement(node.namespaceURI(), node.toElement().tagName()); - - for (int i = 0; i < node.toElement().attributes().count(); i++) + if (!node.isNull()){ + if (node.isText()) { - QDomAttr attr = node.toElement().attributes().item(i).toAttr(); - mIWBContentWriter->writeAttribute(attr.name(), attr.value()); + mIWBContentWriter->writeCharacters(node.nodeValue()); } - QDomNode child = node.firstChild(); - while(!child.isNull()) + else { - writeQDomElementToXML(child); - child = child.nextSibling(); - } + mIWBContentWriter->writeStartElement(node.namespaceURI(), node.toElement().tagName()); - mIWBContentWriter->writeEndElement(); - } + for (int i = 0; i < node.toElement().attributes().count(); i++) + { + QDomAttr attr = node.toElement().attributes().item(i).toAttr(); + mIWBContentWriter->writeAttribute(attr.name(), attr.value()); + } + QDomNode child = node.firstChild(); + while(!child.isNull()) + { + writeQDomElementToXML(child); + child = child.nextSibling(); + } + + mIWBContentWriter->writeEndElement(); + } + } } bool UBCFFAdaptor::UBToCFFConverter::writeExtendedIwbSection() @@ -1322,7 +1323,7 @@ QDomNode UBCFFAdaptor::UBToCFFConverter::findNodeByTagName(const QDomNode &node, if (!iterNode.firstChildElement().isNull()) { QDomNode foundNode = findNodeByTagName(iterNode.firstChildElement(), tagName); - if (!foundNode.isNull()) + if (!foundNode.isNull()){ if (foundNode.isElement()) { if (tagName == foundNode.toElement().tagName()) @@ -1330,6 +1331,7 @@ QDomNode UBCFFAdaptor::UBToCFFConverter::findNodeByTagName(const QDomNode &node, } else break; + } } } diff --git a/src/board/UBBoardPaletteManager.cpp b/src/board/UBBoardPaletteManager.cpp index 1585df84..f21c089b 100644 --- a/src/board/UBBoardPaletteManager.cpp +++ b/src/board/UBBoardPaletteManager.cpp @@ -31,6 +31,7 @@ #include "gui/UBZoomPalette.h" #include "gui/UBActionPalette.h" #include "gui/UBFavoriteToolPalette.h" +#include "gui/UBDockTeacherGuideWidget.h" #include "web/UBWebPage.h" @@ -84,6 +85,7 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll , mpCachePropWidget(NULL) , mpDownloadWidget(NULL) , mpDesktopLibWidget(NULL) + , mpTeacherGuideWidget(NULL) , mDownloadInProgress(false) { setupPalettes(); @@ -135,6 +137,7 @@ void UBBoardPaletteManager::setupDockPaletteWidgets() mpCachePropWidget = new UBCachePropertiesWidget(); mpDownloadWidget = new UBDockDownloadWidget(); + mpTeacherGuideWidget = new UBDockTeacherGuideWidget(); // Add the dock palettes mLeftPalette = new UBLeftPalette(mContainer); @@ -143,6 +146,9 @@ void UBBoardPaletteManager::setupDockPaletteWidgets() mLeftPalette->registerWidget(mpPageNavigWidget); mLeftPalette->addTab(mpPageNavigWidget); + mLeftPalette->registerWidget(mpTeacherGuideWidget); + mLeftPalette->addTab(mpTeacherGuideWidget); + mLeftPalette->connectSignals(); mRightPalette = new UBRightPalette(mContainer); @@ -170,7 +176,7 @@ void UBBoardPaletteManager::slot_changeMainMode(UBApplicationController::MainMod switch( mainMode ) { - case UBApplicationController::Board: + case UBApplicationController::Board: { // call changeMode only when switch NOT from desktop mode if(!UBApplication::applicationController->isShowingDesktop()) @@ -205,7 +211,7 @@ void UBBoardPaletteManager::slot_changeMainMode(UBApplicationController::MainMod void UBBoardPaletteManager::slot_changeDesktopMode(bool isDesktop) { UBApplicationController::MainMode currMode = UBApplication::applicationController->displayMode(); - if(!isDesktop) + if(!isDesktop) { switch( currMode ) { @@ -232,6 +238,7 @@ void UBBoardPaletteManager::setupPalettes() #endif } + setupDockPaletteWidgets(); @@ -735,8 +742,8 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is mKeyboardPalette->show(); } else - mKeyboardPalette->setParent(UBApplication::documentController->controlView()); - } + mKeyboardPalette->setParent(UBApplication::documentController->controlView()); + } } break; @@ -787,7 +794,7 @@ void UBBoardPaletteManager::addItem(const QPixmap& pPixmap, const QPointF& pos, void UBBoardPaletteManager::addItemToCurrentPage() { - UBApplication::applicationController->showBoard(); + UBApplication::applicationController->showBoard(); mAddItemPalette->hide(); if(mPixmap.isNull()) UBApplication::boardController->downloadURL(mItemUrl); diff --git a/src/board/UBBoardPaletteManager.h b/src/board/UBBoardPaletteManager.h index e90e9ed5..4e5e5d99 100644 --- a/src/board/UBBoardPaletteManager.h +++ b/src/board/UBBoardPaletteManager.h @@ -40,6 +40,7 @@ class UBServerXMLHttpRequest; class UBKeyboardPalette; class UBMainWindow; class UBApplicationController; +class UBDockTeacherGuideWidget; class UBBoardPaletteManager : public QObject { @@ -52,6 +53,7 @@ class UBBoardPaletteManager : public QObject void setupLayout(); UBLeftPalette* leftPalette(){return mLeftPalette;} UBRightPalette* rightPalette(){return mRightPalette;} + UBStylusPalette* stylusPalette(){return mStylusPalette;} void showVirtualKeyboard(bool show = true); void initPalettesPosAtStartup(); void connectToDocumentController(); @@ -134,6 +136,8 @@ class UBBoardPaletteManager : public QObject // lib widget! UBLibWidget* mpDesktopLibWidget; + UBDockTeacherGuideWidget* mpTeacherGuideWidget; + bool mDownloadInProgress; private slots: diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp index e9ffde4d..83104c5d 100644 --- a/src/board/UBBoardView.cpp +++ b/src/board/UBBoardView.cpp @@ -49,9 +49,6 @@ #include "document/UBDocumentProxy.h" -#include "customWidgets/UBDraggableLabel.h" -#include "customWidgets/UBDraggableMedia.h" - #include "tools/UBGraphicsCompass.h" #include "tools/UBGraphicsCache.h" @@ -378,60 +375,62 @@ void UBBoardView::tabletEvent (QTabletEvent * event) } -void -UBBoardView::mousePressEvent (QMouseEvent *event) +void UBBoardView::mousePressEvent (QMouseEvent *event) { - if (isAbsurdPoint (event->pos ())) + if (isAbsurdPoint (event->pos ())) { - event->accept (); - return; + event->accept (); + return; } - mMouseDownPos = event->pos (); + mMouseDownPos = event->pos (); + + emit clickOnBoard(); - if (event->button () == Qt::LeftButton && isInteractive ()) + if (event->button () == Qt::LeftButton && isInteractive ()) { - UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); - if (!mTabletStylusIsPressed) - mMouseButtonIsPressed = true; + UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); - if (currentTool == UBStylusTool::ZoomIn) + if (!mTabletStylusIsPressed) + mMouseButtonIsPressed = true; + + if (currentTool == UBStylusTool::ZoomIn) { - mController->zoomIn (mapToScene (event->pos ())); - event->accept (); + mController->zoomIn (mapToScene (event->pos ())); + event->accept (); } - else if (currentTool == UBStylusTool::ZoomOut) + else if (currentTool == UBStylusTool::ZoomOut) { - mController->zoomOut (mapToScene (event->pos ())); - event->accept (); + mController->zoomOut (mapToScene (event->pos ())); + event->accept (); } - else if (currentTool == UBStylusTool::Hand) + else if (currentTool == UBStylusTool::Hand) { - viewport ()->setCursor (QCursor (Qt::ClosedHandCursor)); - mPreviousPoint = event->posF (); - event->accept (); + viewport ()->setCursor (QCursor (Qt::ClosedHandCursor)); + mPreviousPoint = event->posF (); + event->accept (); } - else if (currentTool == UBStylusTool::Selector) + else if (currentTool == UBStylusTool::Selector) { QSet existingTools = scene()->tools(); movingItem = scene()->itemAt(this->mapToScene(event->posF().toPoint())); - if (!movingItem - || movingItem->isSelected() - || movingItem->type() == UBGraphicsDelegateFrame::Type - || movingItem->type() == DelegateButton::Type - || movingItem->type() == UBGraphicsCompass::Type - || movingItem->type() == UBGraphicsPDFItem::Type - || movingItem->type() == UBGraphicsPolygonItem::Type - || movingItem->type() == UBGraphicsCache::Type) - { - movingItem = NULL; - QGraphicsView::mousePressEvent (event); + if (!movingItem + || movingItem->isSelected() + || movingItem->type() == UBGraphicsDelegateFrame::Type + || movingItem->type() == DelegateButton::Type + || movingItem->type() == UBGraphicsCompass::Type + || movingItem->type() == UBGraphicsPDFItem::Type + || movingItem->type() == UBGraphicsPolygonItem::Type + || movingItem->type() == UBGraphicsCache::Type) + { + movingItem = NULL; + QGraphicsView::mousePressEvent (event); - } - else + } + else { mLastPressedMousePos = mapToScene(event->pos()); if (suspendedMousePressEvent) @@ -440,67 +439,67 @@ UBBoardView::mousePressEvent (QMouseEvent *event) } suspendedMousePressEvent = new QMouseEvent(event->type(), event->pos(), event->button(), event->buttons(), event->modifiers()); // удалить } - + event->accept(); } - else if (currentTool == UBStylusTool::Text) + else if (currentTool == UBStylusTool::Text) { - int frameWidth = UBSettings::settings ()->objectFrameWidth; - QRectF fuzzyRect (0, 0, frameWidth * 4, frameWidth * 4); - fuzzyRect.moveCenter (mapToScene (mMouseDownPos)); + int frameWidth = UBSettings::settings ()->objectFrameWidth; + QRectF fuzzyRect (0, 0, frameWidth * 4, frameWidth * 4); + fuzzyRect.moveCenter (mapToScene (mMouseDownPos)); - UBGraphicsTextItem* foundTextItem = 0; - QListIterator it (scene ()->items (fuzzyRect)); + UBGraphicsTextItem* foundTextItem = 0; + QListIterator it (scene ()->items (fuzzyRect)); - while (it.hasNext () && !foundTextItem) + while (it.hasNext () && !foundTextItem) { - foundTextItem = qgraphicsitem_cast(it.next ()); + foundTextItem = qgraphicsitem_cast(it.next ()); } - if (foundTextItem) + if (foundTextItem) { - mIsCreatingTextZone = false; - QGraphicsView::mousePressEvent (event); + mIsCreatingTextZone = false; + QGraphicsView::mousePressEvent (event); } - else + else { - scene ()->deselectAllItems (); + scene ()->deselectAllItems (); - if (!mRubberBand) - mRubberBand = new UBRubberBand (QRubberBand::Rectangle, this); + if (!mRubberBand) + mRubberBand = new UBRubberBand (QRubberBand::Rectangle, this); - mRubberBand->setGeometry (QRect (mMouseDownPos, QSize ())); - mRubberBand->show (); - mIsCreatingTextZone = true; + mRubberBand->setGeometry (QRect (mMouseDownPos, QSize ())); + mRubberBand->show (); + mIsCreatingTextZone = true; - event->accept (); + event->accept (); } } - else if (currentTool == UBStylusTool::Capture) + else if (currentTool == UBStylusTool::Capture) { - scene ()->deselectAllItems (); + scene ()->deselectAllItems (); - if (!mRubberBand) - mRubberBand = new UBRubberBand (QRubberBand::Rectangle, this); + if (!mRubberBand) + mRubberBand = new UBRubberBand (QRubberBand::Rectangle, this); - mRubberBand->setGeometry (QRect (mMouseDownPos, QSize ())); - mRubberBand->show (); - mIsCreatingSceneGrabZone = true; + mRubberBand->setGeometry (QRect (mMouseDownPos, QSize ())); + mRubberBand->show (); + mIsCreatingSceneGrabZone = true; - event->accept (); + event->accept (); } - else + else + { + if(UBDrawingController::drawingController()->mActiveRuler==NULL) { - if(UBDrawingController::drawingController()->mActiveRuler==NULL) - { - viewport()->setCursor (QCursor (Qt::BlankCursor)); - } + viewport()->setCursor (QCursor (Qt::BlankCursor)); + } - if (scene () && !mTabletStylusIsPressed) - { - scene ()->inputDevicePress (mapToScene (UBGeometryUtils::pointConstrainedInRect (event->pos (), rect ()))); - } - event->accept (); + if (scene () && !mTabletStylusIsPressed) + { + scene ()->inputDevicePress (mapToScene (UBGeometryUtils::pointConstrainedInRect (event->pos (), rect ()))); + } + event->accept (); } } } @@ -530,7 +529,7 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event) if((event->pos() - mLastPressedMousePos).manhattanLength() < QApplication::startDragDistance()) { return; } - + if (movingItem && (mMouseButtonIsPressed || mTabletStylusIsPressed)) { QPointF scenePos = mapToScene(event->pos()); @@ -588,7 +587,7 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event) mWidgetMoved = false; movingItem = NULL; } - else if (movingItem && suspendedMousePressEvent) + else if (movingItem && suspendedMousePressEvent) { QGraphicsView::mousePressEvent(suspendedMousePressEvent); // suspendedMousePressEvent is deleted by old Qt event loop movingItem = NULL; @@ -700,7 +699,7 @@ UBBoardView::wheelEvent (QWheelEvent *wheelEvent) QList selItemsList = scene()->selectedItems(); // if NO have selected items, than no need process mouse wheel. just exist - if( selItemsList.count() > 0 ) + if( selItemsList.count() > 0 ) { // only one selected item possible, so we will work with first item only QGraphicsItem * selItem = selItemsList[0]; @@ -708,7 +707,7 @@ UBBoardView::wheelEvent (QWheelEvent *wheelEvent) // get items list under mouse cursor QPointF scenePos = mapToScene(wheelEvent->pos()); QList itemsList = scene()->items(scenePos); - + QBool isSlectedAndMouseHower = itemsList.contains(selItem); if(isSlectedAndMouseHower) { @@ -809,8 +808,7 @@ void UBBoardView::dropEvent (QDropEvent *event) event->acceptProposedAction(); } else if (!event->source() || dynamic_cast(event->source()) - || dynamic_cast(event->source()) || dynamic_cast(event->source()) - || dynamic_cast(event->source()) || dynamic_cast(event->source())) { + || dynamic_cast(event->source())) { mController->processMimeData (event->mimeData (), mapToScene (event->pos ())); event->acceptProposedAction(); @@ -963,7 +961,7 @@ UBBoardView::setToolCursor (int tool) controlViewport->setCursor (UBResources::resources ()->penCursor); break; case UBStylusTool::Eraser: - controlViewport->setCursor (UBResources::resources ()->eraserCursor); + controlViewport->setCursor (UBResources::resources ()->eraserCursor); break; case UBStylusTool::Marker: controlViewport->setCursor (UBResources::resources ()->markerCursor); diff --git a/src/board/UBBoardView.h b/src/board/UBBoardView.h index 16280790..1d54ed36 100644 --- a/src/board/UBBoardView.h +++ b/src/board/UBBoardView.h @@ -46,6 +46,7 @@ class UBBoardView : public QGraphicsView void resized(QResizeEvent* event); void hidden(); void shown(); + void clickOnBoard(); protected: diff --git a/src/customWidgets/UBActionableWidget.cpp b/src/customWidgets/UBActionableWidget.cpp index 65e440a3..78d8ea6b 100644 --- a/src/customWidgets/UBActionableWidget.cpp +++ b/src/customWidgets/UBActionableWidget.cpp @@ -1,3 +1,18 @@ +/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include #include diff --git a/src/customWidgets/UBActionableWidget.h b/src/customWidgets/UBActionableWidget.h index 683463df..23a2478c 100644 --- a/src/customWidgets/UBActionableWidget.h +++ b/src/customWidgets/UBActionableWidget.h @@ -1,3 +1,18 @@ +/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #ifndef UBACTIONABLEWIDGET_H #define UBACTIONABLEWIDGET_H diff --git a/src/customWidgets/UBDraggableLabel.cpp b/src/customWidgets/UBDraggableLabel.cpp deleted file mode 100644 index 200205b9..00000000 --- a/src/customWidgets/UBDraggableLabel.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -#include - -#include "UBDraggableLabel.h" - - -UBDraggableLabel::UBDraggableLabel(QWidget *parent) : - QLabel(parent) -{ -} - -UBDraggableLabel::~UBDraggableLabel() -{ - //NOOP -} - -void UBDraggableLabel::loadImage(QString imagePath) -{ - mSourcePath = imagePath; - QPixmap pix = QPixmap(mSourcePath); - setPixmap(pix); - setScaledContents(true); -} - -void UBDraggableLabel::mousePressEvent(QMouseEvent *event) -{ - Q_UNUSED(event); - QMimeData *mimeData = new QMimeData; - QList urls; - urls << QUrl::fromLocalFile(mSourcePath); - mimeData->setUrls(urls); - mimeData->setText(mSourcePath); - - - QDrag *drag = new QDrag(this); - drag->setMimeData(mimeData); - drag->start(); -} diff --git a/src/customWidgets/UBDraggableLabel.h b/src/customWidgets/UBDraggableLabel.h deleted file mode 100644 index 384b313e..00000000 --- a/src/customWidgets/UBDraggableLabel.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef UBDRAGGABLELABEL_H -#define UBDRAGGABLELABEL_H - -#include - -class UBDraggableLabel : public QLabel -{ - Q_OBJECT -public: - UBDraggableLabel(QWidget *parent = 0); - ~UBDraggableLabel(); - void loadImage(QString imagePath); -signals: - -public slots: - -protected: - QString mSourcePath; - void mousePressEvent(QMouseEvent *event); - -}; - -#endif // UBDRAGGABLELABEL_H diff --git a/src/customWidgets/UBDraggableMedia.cpp b/src/customWidgets/UBDraggableMedia.cpp deleted file mode 100644 index 4136f742..00000000 --- a/src/customWidgets/UBDraggableMedia.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include - -#include "UBDraggableMedia.h" - -UBDraggableMedia::UBDraggableMedia(eMediaType type, QWidget *parent, const char *name):UBMediaWidget(type, parent, name) -{ - removeAllActions(); -} - -UBDraggableMedia::~UBDraggableMedia() -{ - -} - -void UBDraggableMedia::mousePressEvent(QMouseEvent* ev) -{ - if(Qt::LeftButton == ev->button()){ - mDragStartPos = ev->pos(); - } -} - -void UBDraggableMedia::mouseMoveEvent(QMouseEvent* ev) -{ - if(!(ev->buttons() & Qt::LeftButton)){ - return; - } - if((ev->pos() - mDragStartPos).manhattanLength() < QApplication::startDragDistance()){ - return; - } - QDrag *drag = new QDrag(this); - QMimeData *mimeData = new QMimeData; - - QList urls; - urls << QUrl(mFilePath); - mimeData->setText(mFilePath); - mimeData->setUrls(urls); - - drag->setMimeData(mimeData); - - drag->exec(Qt::CopyAction | Qt::MoveAction); -} diff --git a/src/customWidgets/UBDraggableMedia.h b/src/customWidgets/UBDraggableMedia.h deleted file mode 100644 index b45c9391..00000000 --- a/src/customWidgets/UBDraggableMedia.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef UBDRAGGABLEMEDIA_H -#define UBDRAGGABLEMEDIA_H - -#include "UBMediaWidget.h" - -class UBDraggableMedia : public UBMediaWidget -{ -public: - UBDraggableMedia(eMediaType type = eMediaType_Video, QWidget* parent=0, const char* name="UBDraggableMedia"); - ~UBDraggableMedia(); -protected: - void mousePressEvent(QMouseEvent* ev); - void mouseMoveEvent(QMouseEvent* ev); - -private: - QPoint mDragStartPos; -}; - -#endif // UBDRAGGABLEMEDIA_H diff --git a/src/customWidgets/customWidgets.pri b/src/customWidgets/customWidgets.pri index c531d4b3..0d730437 100644 --- a/src/customWidgets/customWidgets.pri +++ b/src/customWidgets/customWidgets.pri @@ -1,13 +1,8 @@ HEADERS += src/customWidgets/UBWidgetList.h \ - src/customWidgets/UBDraggableLabel.h \ src/customWidgets/UBMediaWidget.h \ - src/globals/UBGlobals.h \ - src/customWidgets/UBDraggableMedia.h \ src/customWidgets/UBActionableWidget.h - + SOURCES += src/customWidgets/UBWidgetList.cpp \ - src/customWidgets/UBDraggableLabel.cpp \ src/customWidgets/UBMediaWidget.cpp \ - src/customWidgets/UBDraggableMedia.cpp \ src/customWidgets/UBActionableWidget.cpp diff --git a/src/desktop/UBDesktopAnnotationController.cpp b/src/desktop/UBDesktopAnnotationController.cpp index 9cb92e4b..8a3321d3 100644 --- a/src/desktop/UBDesktopAnnotationController.cpp +++ b/src/desktop/UBDesktopAnnotationController.cpp @@ -761,21 +761,6 @@ void UBDesktopAnnotationController::togglePropertyPalette(UBActionPalette *palet void UBDesktopAnnotationController::switchCursor(const int tool) { -// enum Enum -// { -// Pen = 0, -// Eraser, -// Marker, -// Selector, -// Hand, -// ZoomIn, -// ZoomOut, -// Pointer, -// Line, -// Text, -// Capture -// }; - mTransparentDrawingScene->setToolCursor(tool); mTransparentDrawingView->setToolCursor(tool); } @@ -825,17 +810,6 @@ void UBDesktopAnnotationController::onDesktopPaletteMaximized() connect(pPointerButton, SIGNAL(pressed()), this, SLOT(pointerActionPressed())); connect(pPointerButton, SIGNAL(released()), this, SLOT(pointerActionReleased())); } - - // enum Enum - // { - // Hand, - // ZoomIn, - // ZoomOut, - // Line, - // Text, - // Capture - // }; - } /** @@ -871,16 +845,6 @@ void UBDesktopAnnotationController::onDesktopPaletteMinimize() void UBDesktopAnnotationController::TransparentWidgetResized() { -/* - int rW = UBApplication::boardController->paletteManager()->rightPalette()->width(); - int rH_ = UBApplication::boardController->paletteManager()->rightPalette()->height(); - int rH = mTransparentDrawingView->height(); - - UBApplication::boardController->paletteManager()->rightPalette()->resize(rW+1, rH); - - // UBApplication::boardController->paletteManager()->rightPalette()->resize(500, 500); -*/ - onTransparentWidgetResized(); } @@ -899,8 +863,6 @@ void UBDesktopAnnotationController::onTransparentWidgetResized() UBApplication::boardController->paletteManager()->leftPalette()->resize(lW+1, rH); UBApplication::boardController->paletteManager()->leftPalette()->resize(lW, rH); - -// mRightPalette->resize(mRightPalette->width(), mTransparentDrawingView->height()); } void UBDesktopAnnotationController::updateMask(bool bTransparent) diff --git a/src/domain/UBGraphicsItemDelegate.cpp b/src/domain/UBGraphicsItemDelegate.cpp index 3d233923..f91a5452 100644 --- a/src/domain/UBGraphicsItemDelegate.cpp +++ b/src/domain/UBGraphicsItemDelegate.cpp @@ -322,16 +322,8 @@ void UBGraphicsItemDelegate::duplicate() } void UBGraphicsItemDelegate::increaseZLevel(int delta) { + Q_UNUSED(delta) qDebug() << delegated()->scene()->items().count(); - -// UBGraphicsItem::assignZValue(delegated(), ) - -// int valueCandidate = delegated()->data(UBGraphicsItemData::ItemOwnZValue).toInt(); -// if (delta < 0) { - -// } else if (delta > 0) { - -// } } void UBGraphicsItemDelegate::lock(bool locked) diff --git a/src/gui/UBActionPalette.cpp b/src/gui/UBActionPalette.cpp index 304f8ec2..96d9395e 100644 --- a/src/gui/UBActionPalette.cpp +++ b/src/gui/UBActionPalette.cpp @@ -231,6 +231,7 @@ void UBActionPalette::mouseReleaseEvent(QMouseEvent * event) void UBActionPalette::actionChanged() { + emit itemOnActionPaletteChanged(); for(int i = 0; i < mActions.length() && i < mButtons.length(); i++) { mButtons.at(i)->setVisible(mActions.at(i)->isVisible()); diff --git a/src/gui/UBActionPalette.h b/src/gui/UBActionPalette.h index dc64a408..5e5604a8 100644 --- a/src/gui/UBActionPalette.h +++ b/src/gui/UBActionPalette.h @@ -56,10 +56,12 @@ class UBActionPalette : public UBFloatingPalette public slots: void close(); + signals: void closed(); void buttonGroupClicked(int id); void customMouseReleased(); + void itemOnActionPaletteChanged(); protected: virtual void paintEvent(QPaintEvent *event); diff --git a/src/gui/UBDockTeacherGuideWidget.cpp b/src/gui/UBDockTeacherGuideWidget.cpp new file mode 100644 index 00000000..27842025 --- /dev/null +++ b/src/gui/UBDockTeacherGuideWidget.cpp @@ -0,0 +1,45 @@ +/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "core/UBApplication.h" +#include "globals/UBGlobals.h" + +#include "UBDockTeacherGuideWidget.h" +#include "UBTeacherGuideWidget.h" + + +UBDockTeacherGuideWidget::UBDockTeacherGuideWidget(QWidget* parent, const char* name): + UBDockPaletteWidget(parent,name) + , mpTeacherGuideWidget(NULL) +{ + mName = "TeacherGuide"; + + setAttribute(Qt::WA_StyledBackground, true); + setStyleSheet(UBApplication::globalStyleSheet()); + + mIconToLeft = QPixmap(":images/teacher_open.png"); + mIconToRight = QPixmap(":images/teacher_close.png"); + + mpLayout = new QVBoxLayout(this); + setLayout(mpLayout); + mpTeacherGuideWidget = new UBTeacherGuideWidget(this); + mpLayout->addWidget(mpTeacherGuideWidget); +} + +UBDockTeacherGuideWidget::~UBDockTeacherGuideWidget() +{ + DELETEPTR(mpTeacherGuideWidget); + DELETEPTR(mpLayout); +} diff --git a/src/gui/UBDockTeacherGuideWidget.h b/src/gui/UBDockTeacherGuideWidget.h new file mode 100644 index 00000000..ee2d4268 --- /dev/null +++ b/src/gui/UBDockTeacherGuideWidget.h @@ -0,0 +1,39 @@ +/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef UBDOCKTEACHERGUIDEWIDGET_H +#define UBDOCKTEACHERGUIDEWIDGET_H + +class QVBoxLayout; +class UBTeacherGuideWidget; + +#include "UBDockPaletteWidget.h" + + +class UBDockTeacherGuideWidget : public UBDockPaletteWidget +{ + Q_OBJECT +public: + UBDockTeacherGuideWidget(QWidget* parent=0, const char* name="UBDockTeacherGuideWidget"); + ~UBDockTeacherGuideWidget(); + + bool visibleInMode(eUBDockPaletteWidgetMode mode){ return mode == eUBDockPaletteWidget_BOARD; } + +private: + QVBoxLayout* mpLayout; + UBTeacherGuideWidget* mpTeacherGuideWidget; +}; + +#endif // UBDOCKTEACHERGUIDEWIDGET_H diff --git a/src/gui/UBMediaPlayer.cpp b/src/gui/UBMediaPlayer.cpp index b3ed29b8..0a203ae6 100644 --- a/src/gui/UBMediaPlayer.cpp +++ b/src/gui/UBMediaPlayer.cpp @@ -1,22 +1,29 @@ -#include "UBMediaPlayer.h" - - +/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #include +#include "UBMediaPlayer.h" + #define SLIDER_RANGE 8 MediaVideoWidget::MediaVideoWidget(UBMediaPlayer *player, QWidget *parent) : Phonon::VideoWidget(parent), m_player(player)/*, m_action(this)*/ { -// m_action.setCheckable(true); -// m_action.setChecked(false); -// m_action.setShortcut(QKeySequence( Qt::AltModifier + Qt::Key_Return)); -// m_action.setShortcutContext(Qt::WindowShortcut); -// connect(&m_action, SIGNAL(toggled(bool)), SLOT(setFullScreen(bool))); -// addAction(&m_action); -// setAcceptDrops(true); + //NOOP } void MediaVideoWidget::timerEvent(QTimerEvent *e) @@ -41,23 +48,6 @@ UBMediaPlayer::UBMediaPlayer() : QSize buttonSize(26, 20); -// QPushButton *openButton = new QPushButton(this); - -//// openButton->setIcon(style()->standardIcon(QStyle::SP_DialogOpenButton)); -//// QPalette bpal; -//// QColor arrowcolor = bpal.buttonText().color(); -//// if (arrowcolor == Qt::black) -//// arrowcolor = QColor(80, 80, 80); -//// bpal.setBrush(QPalette::ButtonText, arrowcolor); -//// openButton->setPalette(bpal); - -// rewindButton = new QPushButton(this); -// rewindButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipBackward)); - -// forwardButton = new QPushButton(this); -// forwardButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipForward)); -// forwardButton->setEnabled(false); - playButton = new QPushButton(this); playIcon = style()->standardIcon(QStyle::SP_MediaPlay); pauseIcon = style()->standardIcon(QStyle::SP_MediaPause); @@ -69,53 +59,18 @@ UBMediaPlayer::UBMediaPlayer() : QVBoxLayout *vLayout = new QVBoxLayout(this); vLayout->setContentsMargins(1, 1, 1, 1); -// QHBoxLayout *layout = new QHBoxLayout(); - -// info = new QLabel(this); -// info->setMinimumHeight(70); -// info->setAcceptDrops(false); -// info->setMargin(2); -// info->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); -// info->setLineWidth(2); -// info->setAutoFillBackground(true); - -// QPalette palette; -// palette.setBrush(QPalette::WindowText, Qt::white); -#ifndef Q_WS_MAC -// rewindButton->setMinimumSize(buttonSize); -// forwardButton->setMinimumSize(buttonSize); - playButton->setMinimumSize(buttonSize); -#endif -// info->setStyleSheet("border-image:url(:/images/screen.png) ; border-width:3px"); -// info->setPalette(palette); -// info->setText(tr("
No media
")); - - -// layout->addWidget(rewindButton); -// layout->addWidget(playButton); -// layout->addWidget(forwardButton); -// layout->addStretch(); - -// vLayout->addWidget(info); initVideoWindow(); vLayout->addWidget(&m_videoWindow); -// m_videoWidget->setStyleSheet(QString("background:red;")); QVBoxLayout *buttonPanelLayout = new QVBoxLayout(); #ifndef Q_WS_WIN m_videoWindow.hide(); #endif -// buttonPanelLayout->addLayout(layout); - -// timeLabel = new QLabel(this); progressLabel = new QLabel(this); QWidget *sliderPanel = new QWidget(this); -// sliderPanel->setStyleSheet(QString("background:green;")); QHBoxLayout *sliderLayout = new QHBoxLayout(); -// playButton->setStyleSheet(QString("background:yellow;")); sliderLayout->addWidget(playButton); sliderLayout->addWidget(slider); -// sliderLayout->addWidget(timeLabel); sliderLayout->addWidget(progressLabel); sliderLayout->setContentsMargins(0, 0, 0, 0); sliderPanel->setLayout(sliderLayout); @@ -123,11 +78,7 @@ UBMediaPlayer::UBMediaPlayer() : buttonPanelLayout->addWidget(sliderPanel); buttonPanelLayout->setContentsMargins(0, 0, 0, 0); #ifdef Q_OS_MAC -// layout->setSpacing(4); buttonPanelLayout->setSpacing(0); -// info->setMinimumHeight(100); -// info->setFont(QFont("verdana", 15)); -// openButton->setFocusPolicy(Qt::NoFocus); #endif QWidget *buttonPanelWidget = new QWidget(this); buttonPanelWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); @@ -138,23 +89,13 @@ UBMediaPlayer::UBMediaPlayer() : vLayout->addLayout(labelLayout); setLayout(vLayout); - - // Setup signal connections: -// connect(rewindButton, SIGNAL(clicked()), this, SLOT(rewind())); - connect(playButton, SIGNAL(clicked()), this, SLOT(playPause())); -// connect(forwardButton, SIGNAL(clicked()), this, SLOT(forward())); - -// connect(&m_MediaObject, SIGNAL(totalTimeChanged(qint64)), this, SLOT(updateTime())); -// connect(&m_MediaObject, SIGNAL(tick(qint64)), this, SLOT(updateTime())); connect(&m_MediaObject, SIGNAL(finished()), this, SLOT(finished())); connect(&m_MediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(stateChanged(Phonon::State,Phonon::State))); connect(&m_MediaObject, SIGNAL(bufferStatus(int)), this, SLOT(bufferStatus(int))); connect(&m_MediaObject, SIGNAL(hasVideoChanged(bool)), this, SLOT(hasVideoChanged(bool))); -// rewindButton->setEnabled(false); playButton->setEnabled(false); -// setAcceptDrops(true); m_audioOutputPath = Phonon::createPath(&m_MediaObject, &m_AudioOutput); Phonon::createPath(&m_MediaObject, m_videoWidget); @@ -180,7 +121,6 @@ void UBMediaPlayer::stateChanged(Phonon::State newstate, Phonon::State oldstate) case Phonon::ErrorState: if (m_MediaObject.errorType() == Phonon::FatalError) { playButton->setEnabled(false); -// rewindButton->setEnabled(false); } else { m_MediaObject.pause(); } @@ -188,16 +128,13 @@ void UBMediaPlayer::stateChanged(Phonon::State newstate, Phonon::State oldstate) break; case Phonon::StoppedState: -// m_videoWidget-> (false); // Fall through case Phonon::PausedState: playButton->setIcon(playIcon); if (m_MediaObject.currentSource().type() != Phonon::MediaSource::Invalid){ playButton->setEnabled(true); -// rewindButton->setEnabled(true); } else { playButton->setEnabled(false); -// rewindButton->setEnabled(false); } break; case Phonon::PlayingState: @@ -207,10 +144,8 @@ void UBMediaPlayer::stateChanged(Phonon::State newstate, Phonon::State oldstate) m_videoWindow.show(); // Fall through case Phonon::BufferingState: -// rewindButton->setEnabled(true); break; case Phonon::LoadingState: -// rewindButton->setEnabled(false); break; } @@ -280,35 +215,6 @@ void UBMediaPlayer::bufferStatus(int percent) } } -//void UBMediaPlayer::updateTime() -//{ -// long len = m_MediaObject.totalTime(); -// long pos = m_MediaObject.currentTime(); -// QString timeString; -// if (pos || len) -// { -// int sec = pos/1000; -// int min = sec/60; -// int hour = min/60; -// int msec = pos; - -// QTime playTime(hour%60, min%60, sec%60, msec%1000); -// sec = len / 1000; -// min = sec / 60; -// hour = min / 60; -// msec = len; - -// QTime stopTime(hour%60, min%60, sec%60, msec%1000); -// QString timeFormat = "m:ss"; -// if (hour > 0) -// timeFormat = "h:mm:ss"; -// timeString = playTime.toString(timeFormat); -// if (len) -// timeString += " / " + stopTime.toString(timeFormat); -// } -// timeLabel->setText(timeString); -//} - void UBMediaPlayer::rewind() { m_MediaObject.seek(0); @@ -319,7 +225,6 @@ void UBMediaPlayer::forward() QList queue = m_MediaObject.queue(); if (queue.size() > 0) { m_MediaObject.setCurrentSource(queue[0]); -// forwardButton->setEnabled(queue.size() > 1); m_MediaObject.play(); } } @@ -343,47 +248,10 @@ void UBMediaPlayer::finished() void UBMediaPlayer::hasVideoChanged(bool bHasVideo) { -// info->setVisible(!bHasVideo); m_videoWindow.setVisible(bHasVideo); } void UBMediaPlayer::resizeEvent(QResizeEvent* pEvent) { Q_UNUSED(pEvent); -// int origWidth = m_videoWindow.width(); -// int origHeight = m_videoWindow.height(); - -// float scaleFactor = (float)origWidth / (float)width(); -// int newWidth = width(); -// int newHeigth = origHeight/scaleFactor; - -// m_videoWindow.resize(newWidth, newHeigth); -} - -//************************************************************************* -UBDraggableMediaPlayer::UBDraggableMediaPlayer():UBMediaPlayer() -{ -// setAcceptDrops(true); -} - -void UBDraggableMediaPlayer::setFile(const QString &text) -{ - mSourcePath = text; - UBMediaPlayer::setFile(text); -} - -void UBDraggableMediaPlayer::mousePressEvent(QMouseEvent *event) -{ - Q_UNUSED(event); - QMimeData *mimeData = new QMimeData; - QList urls; - urls << QUrl::fromLocalFile(mSourcePath); - mimeData->setUrls(urls); - mimeData->setText(mSourcePath); - - - QDrag *drag = new QDrag(this); - drag->setMimeData(mimeData); - drag->start(); } - diff --git a/src/gui/UBMediaPlayer.h b/src/gui/UBMediaPlayer.h index 9e5e0e1a..d8501bd8 100644 --- a/src/gui/UBMediaPlayer.h +++ b/src/gui/UBMediaPlayer.h @@ -1,3 +1,18 @@ +/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #ifndef UBUBMediaPlayer_H #define UBUBMediaPlayer_H @@ -41,7 +56,6 @@ protected: private: UBMediaPlayer* m_player; QBasicTimer m_timer; -// QAction m_action; }; class UBMediaPlayer : public QWidget @@ -58,7 +72,6 @@ public slots: void openFile(); void rewind(); void forward(); -// void updateTime(); void finished(); void playPause(); @@ -78,12 +91,8 @@ private: QIcon playIcon; QIcon pauseIcon; QPushButton *playButton; -// QPushButton *rewindButton; -// QPushButton *forwardButton; Phonon::SeekSlider *slider; -// QLabel *timeLabel; QLabel *progressLabel; -// QLabel *info; QWidget m_videoWindow; Phonon::MediaObject m_MediaObject; @@ -92,16 +101,6 @@ private: Phonon::Path m_audioOutputPath; }; -class UBDraggableMediaPlayer : public UBMediaPlayer -{ - Q_OBJECT -public: - UBDraggableMediaPlayer(); - void setFile(const QString &text); -protected: - QString mSourcePath; - void mousePressEvent(QMouseEvent *event); -}; #endif // UBUBMediaPlayer_H diff --git a/src/gui/UBTeacherGuideDelegate.cpp b/src/gui/UBTeacherGuideDelegate.cpp new file mode 100644 index 00000000..33dba6fe --- /dev/null +++ b/src/gui/UBTeacherGuideDelegate.cpp @@ -0,0 +1,5 @@ +#include "UBTeacherGuideDelegate.h" + +UBTeacherGuideDelegate::UBTeacherGuideDelegate() +{ +} diff --git a/src/gui/UBTeacherGuideDelegate.h b/src/gui/UBTeacherGuideDelegate.h new file mode 100644 index 00000000..1c1134f5 --- /dev/null +++ b/src/gui/UBTeacherGuideDelegate.h @@ -0,0 +1,10 @@ +#ifndef UBTEACHERGUIDEDELEGATE_H +#define UBTEACHERGUIDEDELEGATE_H + +class UBTeacherGuideDelegate +{ +public: + UBTeacherGuideDelegate(); +}; + +#endif // UBTEACHERGUIDEDELEGATE_H diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp new file mode 100644 index 00000000..1af075da --- /dev/null +++ b/src/gui/UBTeacherGuideWidget.cpp @@ -0,0 +1,404 @@ +/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include + +#include "UBTeacherGuideWidget.h" + +#include "core/UBApplication.h" + +#include "globals/UBGlobals.h" + +#include "board/UBBoardController.h" +#include "board/UBBoardView.h" +#include "board/UBBoardPaletteManager.h" + +#include "gui/UBStylusPalette.h" +#include "gui/UBActionPalette.h" + +#include "web/UBWebController.h" + +typedef enum +{ + eUBTGAddSubItemWidgetType_None, + eUBTGAddSubItemWidgetType_Action , + eUBTGAddSubItemWidgetType_Media, + eUBTGAddSubItemWidgetType_Url +}eUBTGAddSubItemWidgetType; + + +/*************************************************************************** + * class UBTeacherGuideEditionWidget * + ***************************************************************************/ + +UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const char* name) : + QWidget(parent) + , mpLayout(NULL) + , mpDocumentTitle(NULL) + , mpPageTitle(NULL) + , mpComment(NULL) + , mpTreeWidget(NULL) + , mpRootWidgetItem(NULL) + , mpAddAnActionItem(NULL) + , mpAddAMediaItem(NULL) + , mpAddALinkItem(NULL) +{ + setObjectName(name); + + mpLayout = new QVBoxLayout(this); + // tree basic configuration + mpDocumentTitle = new QLabel(this); + mpDocumentTitle->setText("title document"); + mpDocumentTitle->setStyleSheet( "QWidget {background-color: white}"); + mpLayout->addWidget(mpDocumentTitle); + + mpPageTitle = new UBTGAdaptableText(0,this); + mpLayout->addWidget(mpPageTitle); + + mpComment = new UBTGAdaptableText(0,this); + mpLayout->addWidget(mpComment); + + mpTreeWidget = new QTreeWidget(this); + mpLayout->addWidget(mpTreeWidget); + + mpRootWidgetItem = mpTreeWidget->invisibleRootItem(); + mpTreeWidget->setRootIsDecorated(false); + mpTreeWidget->setIndentation(0); + mpTreeWidget->setDropIndicatorShown(false); + mpTreeWidget->header()->close(); + mpTreeWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + connect(mpTreeWidget,SIGNAL(itemClicked(QTreeWidgetItem*,int)),this,SLOT(onAddItemClicked(QTreeWidgetItem*,int))); + + mpAddAnActionItem = new UBAddItem(tr("Add an action"),eUBTGAddSubItemWidgetType_Action,mpTreeWidget); + mpAddAMediaItem = new UBAddItem(tr("Add a media"),eUBTGAddSubItemWidgetType_Media,mpTreeWidget); + mpAddALinkItem = new UBAddItem(tr("Add a link"),eUBTGAddSubItemWidgetType_Url,mpTreeWidget); + + mpRootWidgetItem->addChild(mpAddAnActionItem); + mpRootWidgetItem->addChild(mpAddAMediaItem); + mpRootWidgetItem->addChild(mpAddALinkItem); +} + +UBTeacherGuideEditionWidget::~UBTeacherGuideEditionWidget() +{ + + DELETEPTR(mpDocumentTitle); + DELETEPTR(mpPageTitle); + DELETEPTR(mpComment); + DELETEPTR(mpAddAnActionItem); + DELETEPTR(mpAddAMediaItem); + DELETEPTR(mpAddALinkItem); + DELETEPTR(mpTreeWidget) + DELETEPTR(mpLayout); +} + + +void UBTeacherGuideEditionWidget::cleanData() +{ + mpPageTitle->setText(""); + mpComment->setText(""); + QList children = mpAddAnActionItem->takeChildren(); + children << mpAddAMediaItem->takeChildren(); + children << mpAddALinkItem->takeChildren(); + + foreach(QTreeWidgetItem* item, children){ + DELETEPTR(item); + } + +} + +QList UBTeacherGuideEditionWidget::getChildrenList(QTreeWidgetItem* widgetItem) +{ + QListresult; + for(int i=0;ichildCount();i+=1) + result << widgetItem->child(i); + return result; +} + +QVector UBTeacherGuideEditionWidget::getPageAndCommentData() +{ + QVectorresult; + tUBGEElementNode* pageTitle = new tUBGEElementNode(); + pageTitle->type = "pageTitle"; + pageTitle->attributes.insert("value",mpPageTitle->toPlainText()); + result << pageTitle; + + tUBGEElementNode* comment = new tUBGEElementNode(); + comment->type = "comment"; + comment->attributes.insert("value",mpComment->toPlainText()); + result << comment; + return result; +} + +QVector UBTeacherGuideEditionWidget::getData() +{ + QVectorresult; + QList children = getChildrenList(mpAddAnActionItem); + children << getChildrenList(mpAddAMediaItem); + children << getChildrenList(mpAddALinkItem); + result << getPageAndCommentData(); + foreach(QTreeWidgetItem* widgetItem, children){ + result << dynamic_cast(mpTreeWidget->itemWidget(widgetItem,0))->saveData(); + } + return result; +} + +void UBTeacherGuideEditionWidget::onAddItemClicked(QTreeWidgetItem* widget, int column) +{ + int addSubItemWidgetType = widget->data(column,Qt::UserRole).toInt(); + if(column == 0 && addSubItemWidgetType != eUBTGAddSubItemWidgetType_None){ + QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(widget); + newWidgetItem->setData(column,Qt::UserRole,eUBTGAddSubItemWidgetType_None); + switch(addSubItemWidgetType) + { + case eUBTGAddSubItemWidgetType_Action: + mpTreeWidget->setItemWidget(newWidgetItem,0,new UBTGActionWidget(widget)); + break; + case eUBTGAddSubItemWidgetType_Media: + mpTreeWidget->setItemWidget(newWidgetItem,0,new UBTGMediaWidget(widget)); + break; + case eUBTGAddSubItemWidgetType_Url: + mpTreeWidget->setItemWidget(newWidgetItem,0,new UBTGUrlWidget()); + break; + default: + qDebug() << "onAddItemClicked no action set"; + } + + if(addSubItemWidgetType != eUBTGAddSubItemWidgetType_None && !widget->isExpanded() ) + widget->setExpanded(true); + else{ + //to update the tree and subtrees + widget->setExpanded(false); + widget->setExpanded(true); + } + } +} + +/*************************************************************************** + * class UBTeacherGuidePresentationWidget * + ***************************************************************************/ +typedef enum +{ + tUBTGActionAssociateOnClickItem_NONE, + tUBTGActionAssociateOnClickItem_URL, + tUBTGActionAssociateOnClickItem_MEDIA, + tUBTGActionAssociateOnClickItem_EXPAND +}tUBTGActionAssociateOnClickItem; + +typedef enum +{ + tUBTGTreeWidgetItemRole_HasAnAction = Qt::UserRole, + tUBTGTreeWidgetItemRole_HasAnUrl +}tUBTGTreeWidgetItemRole; + + +UBTeacherGuidePresentationWidget::UBTeacherGuidePresentationWidget(QWidget *parent, const char *name) : QWidget(parent) + , mpPageTitle(NULL) + , mpComment(NULL) + , mpLayout(NULL) + , mpButtonTitleLayout(NULL) + , mpDocumentTile(NULL) + , mpModePushButton(NULL) + , mpTreeWidget(NULL) + , mpRootWidgetItem(NULL) + , mpMediaSwitchItem(NULL) +{ + setObjectName(name); + mpLayout = new QVBoxLayout(this); + mpButtonTitleLayout = new QHBoxLayout(0); + + mpModePushButton = new QPushButton(this); + mpModePushButton->setIcon(QIcon(":images/pencil.svg")); + connect(mpModePushButton,SIGNAL(clicked()),parentWidget(),SLOT(changeMode())); + + mpDocumentTile = new QLabel(this); + mpDocumentTile->setText("Document title"); + + mpButtonTitleLayout->addWidget(mpModePushButton); + mpButtonTitleLayout->addWidget(mpDocumentTile); + + mpLayout->addLayout(mpButtonTitleLayout); + + mpPageTitle = new UBTGAdaptableText(0,this); + mpPageTitle->setReadOnly(true); + mpLayout->addWidget(mpPageTitle); + + mpComment = new UBTGAdaptableText(0,this); + mpComment->setReadOnly(true); + mpLayout->addWidget(mpComment); + + mpTreeWidget = new QTreeWidget(this); + mpLayout->addWidget(mpTreeWidget); + + mpRootWidgetItem = mpTreeWidget->invisibleRootItem(); + mpTreeWidget->setRootIsDecorated(false); + mpTreeWidget->setIndentation(0); + mpTreeWidget->setDropIndicatorShown(false); + mpTreeWidget->header()->close(); + mpTreeWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + connect(mpTreeWidget,SIGNAL(itemClicked(QTreeWidgetItem*,int)),this,SLOT(onAddItemClicked(QTreeWidgetItem*,int))); + +} + +UBTeacherGuidePresentationWidget::~UBTeacherGuidePresentationWidget() +{ + DELETEPTR(mpComment); + DELETEPTR(mpPageTitle); + DELETEPTR(mpMediaSwitchItem); + DELETEPTR(mpModePushButton); + DELETEPTR(mpDocumentTile); + DELETEPTR(mpButtonTitleLayout); + DELETEPTR(mpTreeWidget); + DELETEPTR(mpLayout); +} + +void UBTeacherGuidePresentationWidget::createMediaButtonItem() +{ + if(!mpMediaSwitchItem){ + //create the media button + mpMediaSwitchItem = new QTreeWidgetItem(mpRootWidgetItem); + mpMediaSwitchItem->setIcon(0,QIcon(":images/plus.svg")); + mpMediaSwitchItem->setExpanded(false); + mpMediaSwitchItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_EXPAND); + mpRootWidgetItem->addChild(mpMediaSwitchItem); + } +} + + +void UBTeacherGuidePresentationWidget::showData(QVector data) +{ + //tree clean + QList itemToRemove = mpRootWidgetItem->takeChildren(); + foreach(QTreeWidgetItem* eachItem, itemToRemove){ + DELETEPTR(eachItem); + } + // the mpMediaSwitchItem is deleted by the previous loop but the pointer is not set to zero + mpMediaSwitchItem = NULL; + + foreach(tUBGEElementNode* element, data){ + if(element->type == "pageTitle") + mpPageTitle->showText(element->attributes.value("value")); + else if (element->type == "comment") + mpComment->showText(element->attributes.value("value")); + else if(element->type == "action"){ + QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(mpRootWidgetItem); + newWidgetItem->setText(0,element->attributes.value("task")); + QColor color = element->attributes.value("owner").toInt()?QColor().red():QColor().green(); + newWidgetItem->setTextColor(0,color); + newWidgetItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_NONE); + mpRootWidgetItem->addChild(newWidgetItem); + } + else if(element->type == "media"){ + createMediaButtonItem(); + QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(mpMediaSwitchItem); + newWidgetItem->setText(0,element->attributes.value("title")); + newWidgetItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_MEDIA); + mpRootWidgetItem->addChild(newWidgetItem); + + QTreeWidgetItem* mediaItem = new QTreeWidgetItem(newWidgetItem); + mediaItem->setText(0,element->attributes.value("title")); + mediaItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_NONE); + UBTGMediaWidget* mediaWidget = new UBTGMediaWidget(element->attributes.value("relativePath"),newWidgetItem); + newWidgetItem->setExpanded(false); + mpTreeWidget->setItemWidget(mediaItem,0,mediaWidget); + } + else if(element->type == "link"){ + createMediaButtonItem(); + QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(mpMediaSwitchItem); + newWidgetItem->setText(0,element->attributes.value("title")); + newWidgetItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_URL); + newWidgetItem->setData(0,tUBTGTreeWidgetItemRole_HasAnUrl,QVariant(element->attributes.value("url"))); + mpRootWidgetItem->addChild(newWidgetItem); + } + } + +} + +void UBTeacherGuidePresentationWidget::onAddItemClicked(QTreeWidgetItem* widget, int column) +{ + int associateAction = widget->data(column,tUBTGTreeWidgetItemRole_HasAnAction).toInt(); + if(column == 0 && associateAction != tUBTGActionAssociateOnClickItem_NONE){ + switch(associateAction) + { + case tUBTGActionAssociateOnClickItem_EXPAND: + widget->setExpanded(!widget->isExpanded()); + break; + case tUBTGActionAssociateOnClickItem_URL: + widget->data(column,tUBTGTreeWidgetItemRole_HasAnUrl).toString(); + UBApplication::webController->loadUrl(QUrl(widget->data(column,tUBTGTreeWidgetItemRole_HasAnUrl).toString())); + break; + case tUBTGActionAssociateOnClickItem_MEDIA: + widget->setExpanded(!widget->isExpanded()); + break; + default: + qDebug() << "associateAction no action set " << associateAction; + } + } +} + +/*************************************************************************** + * class UBTeacherGuideWidget * + ***************************************************************************/ +UBTeacherGuideWidget::UBTeacherGuideWidget(QWidget *parent, const char *name): QStackedWidget(parent) + , mpEditionWidget(NULL) + , mpPresentationWidget(NULL) +{ + setObjectName(name); + mpEditionWidget = new UBTeacherGuideEditionWidget(this); + addWidget(mpEditionWidget); + mpPresentationWidget = new UBTeacherGuidePresentationWidget(this); + addWidget(mpPresentationWidget); + + setCurrentWidget(mpEditionWidget); + connect(UBApplication::boardController->controlView(),SIGNAL(clickOnBoard()),this,SLOT(showPresentationMode())); + connectToStylusPalette(); +} + + +UBTeacherGuideWidget::~UBTeacherGuideWidget() +{ + DELETEPTR(mpEditionWidget); + DELETEPTR(mpPresentationWidget); +} + +void UBTeacherGuideWidget::connectToStylusPalette() +{ + if(UBApplication::boardController->paletteManager()) + connect(UBApplication::boardController->paletteManager()->stylusPalette(),SIGNAL(itemOnActionPaletteChanged()),this,SLOT(showPresentationMode())); + else + QTimer::singleShot(500,this,SLOT(connectToStylusPalette())); +} + +void UBTeacherGuideWidget::showPresentationMode() +{ + if(currentWidget()!=mpPresentationWidget){ + currentData = mpEditionWidget->getData(); + mpPresentationWidget->showData(currentData); + setCurrentWidget(mpPresentationWidget); + } +} + +void UBTeacherGuideWidget::changeMode() +{ + if(currentWidget() == mpEditionWidget) + setCurrentWidget(mpPresentationWidget); + else + setCurrentWidget(mpEditionWidget); + +} diff --git a/src/gui/UBTeacherGuideWidget.h b/src/gui/UBTeacherGuideWidget.h new file mode 100644 index 00000000..076d5d26 --- /dev/null +++ b/src/gui/UBTeacherGuideWidget.h @@ -0,0 +1,114 @@ +/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef UBTEACHERGUIDEWIDGET_H +#define UBTEACHERGUIDEWIDGET_H + +class QTreeWidget; +class QHeaderView; +class QLabel; +class QVBoxLayout; +class QPushButton; + +#include "UBTeacherGuideWidgetsTools.h" + + +/*************************************************************************** + * class UBTeacherGuideEditionWidget * + ***************************************************************************/ +class UBTeacherGuideEditionWidget : public QWidget +{ + Q_OBJECT +public: + explicit UBTeacherGuideEditionWidget(QWidget* parent = 0, const char* name="UBTeacherGuideEditionWidget"); + ~UBTeacherGuideEditionWidget(); + void cleanData(); + QVector getData(); + +public slots: + void onAddItemClicked(QTreeWidgetItem* widget, int column); + +private: + QList getChildrenList(QTreeWidgetItem* widgetItem); + QVector getPageAndCommentData(); + + QVBoxLayout* mpLayout; + QLabel* mpDocumentTitle; + UBTGAdaptableText* mpPageTitle; + UBTGAdaptableText* mpComment; + QTreeWidget* mpTreeWidget; + QTreeWidgetItem* mpRootWidgetItem; + UBAddItem* mpAddAnActionItem; + UBAddItem* mpAddAMediaItem; + UBAddItem* mpAddALinkItem; + +}; + + +/*************************************************************************** + * class UBTeacherGuidePresentationWidget * + ***************************************************************************/ +class UBTeacherGuidePresentationWidget : public QWidget +{ + Q_OBJECT +public: + explicit UBTeacherGuidePresentationWidget(QWidget* parent, const char* name = "UBTeacherGuidePresentationName"); + ~UBTeacherGuidePresentationWidget(); + void showData(QVectordata); + +public slots: + void onAddItemClicked(QTreeWidgetItem* widget, int column); + +private: + void createMediaButtonItem(); + + UBTGAdaptableText* mpPageTitle; + UBTGAdaptableText* mpComment; + QVBoxLayout* mpLayout; + QHBoxLayout* mpButtonTitleLayout; + QLabel* mpDocumentTile; + QPushButton* mpModePushButton; + QTreeWidget* mpTreeWidget; + QTreeWidgetItem* mpRootWidgetItem; + QTreeWidgetItem* mpMediaSwitchItem; + +}; + + + +/*************************************************************************** + * class UBTeacherGuideWidget * + ***************************************************************************/ + +class UBTeacherGuideWidget : public QStackedWidget +{ + Q_OBJECT +public: + explicit UBTeacherGuideWidget(QWidget* parent = 0, const char* name="UBTeacherGuideWidget"); + ~UBTeacherGuideWidget(); + +public slots: + void changeMode(); + void showPresentationMode(); + void connectToStylusPalette(); + +private: + UBTeacherGuideEditionWidget* mpEditionWidget; + UBTeacherGuidePresentationWidget* mpPresentationWidget; + QVectorcurrentData; + +}; + +#endif // UBTEACHERGUIDEWIDGET_H diff --git a/src/gui/UBTeacherGuideWidgetsTools.cpp b/src/gui/UBTeacherGuideWidgetsTools.cpp new file mode 100644 index 00000000..8c4aec55 --- /dev/null +++ b/src/gui/UBTeacherGuideWidgetsTools.cpp @@ -0,0 +1,361 @@ +/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "UBTeacherGuideWidgetsTools.h" + +#include "globals/UBGlobals.h" + +#include "frameworks/UBFileSystemUtils.h" + + +/*************************************************************************** + * class UBAddItem * + ***************************************************************************/ +UBAddItem::UBAddItem(const QString &string, int addSubItemWidgetType, QTreeWidget* parent): QTreeWidgetItem(parent) +{ + setIcon(0,QIcon(":images/increase.svg")); + setText(0,string); + setData(0,Qt::UserRole,QVariant(addSubItemWidgetType)); +} + +UBAddItem::~UBAddItem() +{ + //NOOP +} + +/*************************************************************************** + * class UBTGActionWidget * + ***************************************************************************/ +UBTGActionWidget::UBTGActionWidget(QTreeWidgetItem* widget, QWidget* parent, const char* name) : QWidget(parent) + , mpLayout(NULL) + , mpOwner(NULL) + , mpTask(NULL) +{ + setObjectName(name); + mpLayout = new QVBoxLayout(this); + mpOwner = new QComboBox(this); + QStringList qslOwner; + qslOwner << tr("Teacher") << tr("Student"); + mpOwner->insertItems(0,qslOwner); + mpOwner->setCurrentIndex(0); + connect(mpOwner,SIGNAL(currentIndexChanged(int)),this,SLOT(onOwnerChange(int))); + mpTask = new UBTGAdaptableText(widget,this); + mpTask->setAcceptRichText(true); + mpTask->setTextColor(QColor().green()); + mpTask->setObjectName("ActionWidgetTaskTextEdit"); + mpLayout->addWidget(mpOwner,0); + mpLayout->addWidget(mpTask,1); + setStyleSheet( "QWidget {background-color: white}"); +} + +UBTGActionWidget::~UBTGActionWidget() +{ + DELETEPTR(mpOwner); + DELETEPTR(mpTask); + DELETEPTR(mpLayout); +} + +void UBTGActionWidget::onOwnerChange(int ownerId) +{ + if(ownerId == 0) + mpTask->setTextColor(QColor().red()); + else + mpTask->setTextColor(QColor().green()); +} + +tUBGEElementNode* UBTGActionWidget::saveData() +{ + tUBGEElementNode* result = new tUBGEElementNode(); + result->type = "action"; + result->attributes.insert("owner",QString(mpOwner->currentIndex())); + result->attributes.insert("task",mpTask->toPlainText()); + return result; +} + +/*************************************************************************** + * class UBTGAdaptableText * + ***************************************************************************/ +UBTGAdaptableText::UBTGAdaptableText(QTreeWidgetItem* widget, QWidget* parent, const char* name):QTextEdit(parent) + , mBottomMargin(5) + , mpTreeWidgetItem(widget) +{ + setObjectName(name); + setStyleSheet( "QWidget {background-color: white}"); + connect(this,SIGNAL(textChanged()),this,SLOT(onTextChanged())); + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); +} + +void UBTGAdaptableText::onTextChanged() +{ + setFixedHeight(document()->size().height()+mBottomMargin); + updateGeometry(); + //to trig the widget item to resize it + if(mpTreeWidgetItem){ + mpTreeWidgetItem->setExpanded(false); + mpTreeWidgetItem->setExpanded(true); + setFocus(); + } + +} + +void UBTGAdaptableText::showText(const QString & text) +{ + setText(text); + //A first rendering has to be done to calculate the text's size. + show(); + hide(); + setReadOnly(true); + onTextChanged(); +} + +void UBTGAdaptableText::bottomMargin(int newValue) +{ + mBottomMargin = newValue; + onTextChanged(); +} + +/*************************************************************************** + * class UBTGMediaWidget * + ***************************************************************************/ +UBTGMediaWidget::UBTGMediaWidget(QTreeWidgetItem* widget, QWidget* parent,const char* name): QStackedWidget(parent) + , mpTreeWidgetItem(widget) + , mpDropMeWidget(NULL) + , mpWorkWidget(NULL) + , mpLayout(NULL) + , mpTitle(NULL) + , mpMediaLabelWidget(NULL) + , mpMediaWidget(NULL) + , mpWebView(NULL) + , mRelativePath(QString("")) + , mIsPresentationMode(false) +{ + setObjectName(name); + setStyleSheet( "QWidget {background-color: white}"); + mpDropMeWidget = new QLabel(); + mpDropMeWidget->setText(tr("drop media here ...")); + mpDropMeWidget->setAlignment(Qt::AlignCenter); + setAcceptDrops(true); + addWidget(mpDropMeWidget); + + setMinimumHeight(40); +} + +UBTGMediaWidget::UBTGMediaWidget(QString relativePath, QTreeWidgetItem* widget, QWidget* parent,const char* name): QStackedWidget(parent) + , mpTreeWidgetItem(widget) + , mpDropMeWidget(NULL) + , mpWorkWidget(NULL) + , mpLayout(NULL) + , mpTitle(NULL) + , mpMediaLabelWidget(NULL) + , mpMediaWidget(NULL) + , mpWebView(NULL) + , mRelativePath(relativePath) + , mIsPresentationMode(true) +{ + setObjectName(name); + setAcceptDrops(false); + createWorkWidget(mRelativePath); +} + +UBTGMediaWidget::~UBTGMediaWidget() +{ + DELETEPTR(mpTitle); + DELETEPTR(mpMediaLabelWidget); + DELETEPTR(mpMediaWidget); + DELETEPTR(mpWebView); + DELETEPTR(mpLayout); + + removeWidget(mpDropMeWidget); + DELETEPTR(mpDropMeWidget); + removeWidget(mpWorkWidget); + DELETEPTR(mpWorkWidget); +} + +tUBGEElementNode* UBTGMediaWidget::saveData() +{ + tUBGEElementNode* result = new tUBGEElementNode(); + result->type = "media"; + result->attributes.insert("title",mpTitle->toPlainText()); + result->attributes.insert("relativePath",mRelativePath); + return result; +} + +void UBTGMediaWidget::dragEnterEvent(QDragEnterEvent *event) +{ + event->accept(); +} + +void UBTGMediaWidget::createWorkWidget(QString& path) +{ + QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(path); + qDebug() << mimeType; + bool setMedia = true; + if(mimeType.contains("audio") || mimeType.contains("video")){ + mpMediaWidget = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); + mpMediaWidget->setFile(path); + } + else if(mimeType.contains("image")){ + mpMediaLabelWidget = new QLabel(); + mpMediaLabelWidget->setPixmap(QPixmap(QUrl(path).toLocalFile())); + mpMediaLabelWidget->setScaledContents(true); + } + else if(mimeType.contains("application")){ + mpWebView = new QWebView(0); + mpWebView->setAcceptDrops(false); + mpWebView->settings()->setAttribute(QWebSettings::JavaEnabled, true); + mpWebView->settings()->setAttribute(QWebSettings::PluginsEnabled, true); + mpWebView->settings()->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, true); + mpWebView->settings()->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true); + mpWebView->settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); + mpWebView->settings()->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true); + mpWebView->settings()->setAttribute(QWebSettings::DnsPrefetchEnabled, true); + mpWebView->load(QUrl(path)); + mpWebView->show(); + } + else{ + qDebug() << "createWorkWidget mime type not handled" << mimeType; + setMedia=false; + } + + if(setMedia){ + mRelativePath = path; + setAcceptDrops(false); + mpWorkWidget = new QWidget(this); + mpLayout = new QVBoxLayout(mpWorkWidget); + if(!mIsPresentationMode){ + mpTitle = new UBTGAdaptableText(mpTreeWidgetItem,mpWorkWidget); + mpLayout->addWidget(mpTitle); + } + if(mpMediaLabelWidget){ + mpMediaLabelWidget->setParent(mpWorkWidget); + mpLayout->addWidget(mpMediaLabelWidget); + } + else if (mpMediaWidget){ + mpMediaWidget->setParent(mpWorkWidget); + mpLayout->addWidget(mpMediaWidget); + } + else if (mpWebView){ + mpWebView->setParent(mpWorkWidget); + mpLayout->addWidget(mpWebView); + } + addWidget(mpWorkWidget); + setCurrentWidget(mpWorkWidget); + updateSize(); + } +} + +void UBTGMediaWidget::parseMimeData(const QMimeData* pMimeData) +{ + QString path; + if(pMimeData){ + if(pMimeData->hasText()){ + path = QUrl::fromLocalFile(pMimeData->text()).toString(); + } + else if(pMimeData->hasUrls()){ + path = pMimeData->urls().at(0).toString(); + } + else if(pMimeData->hasImage()){ + qDebug() << "Not yet implemented"; + } + } + else + qDebug() << "No mime data present"; + + createWorkWidget(path); + QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(path); + qDebug() << mimeType; +} + +void UBTGMediaWidget::dropEvent(QDropEvent* event) +{ + parseMimeData(event->mimeData()); + event->accept(); +} + +void UBTGMediaWidget::mousePressEvent(QMouseEvent *event) +{ + if (!mIsPresentationMode) + event->ignore(); + else{ + + QDrag *drag = new QDrag(this); + QMimeData *mimeData = new QMimeData; + QList urlList; + urlList << QUrl::fromLocalFile(mRelativePath); + mimeData->setUrls(urlList); + drag->setMimeData(mimeData); + + drag->exec(); + event->accept(); + } +} + +void UBTGMediaWidget::updateSize() +{ + if(mpTreeWidgetItem){ + mpTreeWidgetItem->setExpanded(false); + mpTreeWidgetItem->setExpanded(true); + if(!mIsPresentationMode) + mpTitle->setFocus(); + } +} + + +/*************************************************************************** + * class UBTGUrlWdiget * + ***************************************************************************/ +UBTGUrlWidget::UBTGUrlWidget(QWidget* parent, const char* name ):QWidget(parent) + , mpLayout(NULL) + , mpTitle(NULL) + , mpUrl(NULL) +{ + setObjectName(name); + setStyleSheet( "QWidget {background-color: white}"); + + mpLayout = new QVBoxLayout(this); + mpTitle = new QLineEdit("title",this); + mpUrl = new QLineEdit("url",this); + + mpLayout->addWidget(mpTitle); + mpLayout->addWidget(mpUrl); +} + +UBTGUrlWidget::~UBTGUrlWidget() +{ + DELETEPTR(mpTitle); + DELETEPTR(mpUrl); + DELETEPTR(mpLayout); +} + +tUBGEElementNode* UBTGUrlWidget::saveData() +{ + tUBGEElementNode* result = new tUBGEElementNode(); + result->type = "link"; + result->attributes.insert("title",mpTitle->text()); + result->attributes.insert("url",mpUrl->text()); + return result; +} diff --git a/src/gui/UBTeacherGuideWidgetsTools.h b/src/gui/UBTeacherGuideWidgetsTools.h new file mode 100644 index 00000000..40da7b1d --- /dev/null +++ b/src/gui/UBTeacherGuideWidgetsTools.h @@ -0,0 +1,144 @@ +/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef UBTEACHERGUIDEWIDGETSTOOLS_H +#define UBTEACHERGUIDEWIDGETSTOOLS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "customWidgets/UBMediaWidget.h" + +class QTreeWidget; +class QVBoxLayout; +class QComboBox; +class QTextEdit; +class QWidget; +class UBTGAdaptableText; +class QDomElement; + +typedef struct +{ + QString type; + QMap attributes; +}tUBGEElementNode; + + +class iUBTGSavableData +{ +public: + virtual tUBGEElementNode* saveData() = 0; +}; + + +class UBAddItem : public QTreeWidgetItem +{ +public: + explicit UBAddItem(const QString &strings, int addSubItemWidgetType, QTreeWidget* parent = 0); + ~UBAddItem(); + +signals: + +public slots: +}; + +class UBTGActionWidget : public QWidget, public iUBTGSavableData +{ + Q_OBJECT +public: + explicit UBTGActionWidget(QTreeWidgetItem* widget, QWidget* parent = 0,const char* name = "UBActionWidget"); + ~UBTGActionWidget(); + void update(); + tUBGEElementNode* saveData(); +public slots: + void onOwnerChange(int ownerId); +private: + QVBoxLayout* mpLayout; + QComboBox* mpOwner; + UBTGAdaptableText* mpTask; +protected: + QTreeWidgetItem* mpTreeWidgetItem; +}; + + +class UBTGAdaptableText : public QTextEdit +{ + Q_OBJECT +public: + explicit UBTGAdaptableText(QTreeWidgetItem* widget = 0, QWidget *parent = 0, const char* name = "UBTGAdaptableText"); + void showText(const QString & text); + void bottomMargin(int newValue); +signals: + +public slots: + void onTextChanged(); +private: + int mBottomMargin; + QTreeWidgetItem* mpTreeWidgetItem; +}; + + +class UBTGMediaWidget : public QStackedWidget , public iUBTGSavableData +{ + Q_OBJECT +public: + UBTGMediaWidget(QTreeWidgetItem* widget = 0, QWidget* parent = 0, const char* name = "UBTGMediaWidget"); + UBTGMediaWidget(QString relativePath, QTreeWidgetItem* widget = 0, QWidget* parent = 0, const char* name = "UBTGMediaWidget"); + ~UBTGMediaWidget(); + tUBGEElementNode* saveData(); +protected: + void dragEnterEvent(QDragEnterEvent* event); + void dropEvent(QDropEvent* event); + void mousePressEvent(QMouseEvent* event); +private: + void parseMimeData(const QMimeData* pMimeData); + void createWorkWidget(QString& path); + void updateSize(); + + QTreeWidgetItem* mpTreeWidgetItem; + QLabel* mpDropMeWidget; + QWidget* mpWorkWidget; + QVBoxLayout* mpLayout; + UBTGAdaptableText* mpTitle; + QLabel* mpMediaLabelWidget; + UBMediaWidget* mpMediaWidget; + QWebView* mpWebView; + QString mRelativePath; + bool mIsPresentationMode; +}; + +class UBTGUrlWidget : public QWidget , public iUBTGSavableData +{ + Q_OBJECT +public: + UBTGUrlWidget(QWidget* parent = 0, const char* name = "UBTGUrlWidget"); + ~UBTGUrlWidget(); + tUBGEElementNode* saveData(); +private: + QVBoxLayout* mpLayout; + QLineEdit* mpTitle; + QLineEdit* mpUrl; +}; + + +#endif // UBTEACHERGUIDEWIDGETSTOOLS_H diff --git a/src/gui/gui.pri b/src/gui/gui.pri index ed0c9c4c..9191c598 100644 --- a/src/gui/gui.pri +++ b/src/gui/gui.pri @@ -46,7 +46,11 @@ HEADERS += src/gui/UBThumbnailView.h \ src/gui/UBLibWebView.h \ src/gui/UBDownloadWidget.h \ src/gui/UBDockDownloadWidget.h \ - src/gui/UBMediaPlayer.h + src/gui/UBMediaPlayer.h \ + src/gui/UBDockTeacherGuideWidget.h \ + src/gui/UBTeacherGuideWidget.h \ + src/gui/UBTeacherGuideWidgetsTools.h \ + src/gui/UBTeacherGuideDelegate.h SOURCES += src/gui/UBThumbnailView.cpp \ src/gui/UBFloatingPalette.cpp \ @@ -95,7 +99,11 @@ SOURCES += src/gui/UBThumbnailView.cpp \ src/gui/UBLibWebView.cpp \ src/gui/UBDownloadWidget.cpp \ src/gui/UBDockDownloadWidget.cpp \ - src/gui/UBMediaPlayer.cpp + src/gui/UBMediaPlayer.cpp \ + src/gui/UBDockTeacherGuideWidget.cpp \ + src/gui/UBTeacherGuideWidget.cpp \ + src/gui/UBTeacherGuideWidgetsTools.cpp \ + src/gui/UBTeacherGuideDelegate.cpp win32 { @@ -123,15 +131,3 @@ linux-g++-64 { SOURCES += src/gui/UBKeyboardPalette_linux.cpp } - - - - - - - - - - - - From 5a6de660d29d33275f1baf3edf98d5ec5aea4c88 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Tue, 10 Apr 2012 17:38:16 +0200 Subject: [PATCH 02/15] teacher bar behaves correctly --- src/board/UBBoardView.cpp | 18 ++++++++---------- src/gui/UBTeacherGuideWidget.cpp | 18 ++++++++++++++++-- src/gui/UBTeacherGuideWidgetsTools.cpp | 3 ++- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp index e1d49a40..1e493cc2 100644 --- a/src/board/UBBoardView.cpp +++ b/src/board/UBBoardView.cpp @@ -35,8 +35,8 @@ #include "gui/UBToolWidget.h" #include "gui/UBResources.h" #include "gui/UBMainWindow.h" -#include "gui/UBMediaPlayer.h" #include "gui/UBThumbnailWidget.h" +#include "gui/UBTeacherGuideWidgetsTools.h" #include "board/UBBoardController.h" @@ -764,11 +764,6 @@ UBBoardView::drawItems (QPainter *painter, int numItems, } } -//void UBBoardView::dragEnterEvent (QDragEnterEvent *event) -//{ -// // TODO UB 4.x be smarter with drag accept code .... we cannot handle everything ... -// event->acceptProposedAction (); -//} void UBBoardView::dragMoveEvent (QDragMoveEvent *event) { @@ -805,14 +800,17 @@ void UBBoardView::dropEvent (QDropEvent *event) QGraphicsItem* graphicsItemAtPos = itemAt(event->pos().x(),event->pos().y()); UBGraphicsWidgetItem* graphicsWidget = dynamic_cast(graphicsItemAtPos); - if (graphicsWidget && graphicsWidget->acceptDrops()) { + qDebug() << event->source(); + if (graphicsWidget && graphicsWidget->acceptDrops()) { graphicsWidget->processDropEvent(event); event->acceptProposedAction(); - } else if (!event->source() || dynamic_cast(event->source()) - || dynamic_cast(event->source())) { - + } + else if (!event->source() + || dynamic_cast(event->source()) + || dynamic_cast(event->source()) + || dynamic_cast(event->source())) { mController->processMimeData (event->mimeData (), mapToScene (event->pos ())); event->acceptProposedAction(); } diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp index 1af075da..940297fe 100644 --- a/src/gui/UBTeacherGuideWidget.cpp +++ b/src/gui/UBTeacherGuideWidget.cpp @@ -84,6 +84,11 @@ UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const mpTreeWidget->setDropIndicatorShown(false); mpTreeWidget->header()->close(); mpTreeWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + mpTreeWidget->setColumnCount(2); + mpTreeWidget->header()->setStretchLastSection(false); + mpTreeWidget->header()->setResizeMode(0, QHeaderView::Stretch); + mpTreeWidget->header()->setResizeMode(1, QHeaderView::Custom); + connect(mpTreeWidget,SIGNAL(itemClicked(QTreeWidgetItem*,int)),this,SLOT(onAddItemClicked(QTreeWidgetItem*,int))); mpAddAnActionItem = new UBAddItem(tr("Add an action"),eUBTGAddSubItemWidgetType_Action,mpTreeWidget); @@ -97,7 +102,6 @@ UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const UBTeacherGuideEditionWidget::~UBTeacherGuideEditionWidget() { - DELETEPTR(mpDocumentTitle); DELETEPTR(mpPageTitle); DELETEPTR(mpComment); @@ -165,6 +169,8 @@ void UBTeacherGuideEditionWidget::onAddItemClicked(QTreeWidgetItem* widget, int if(column == 0 && addSubItemWidgetType != eUBTGAddSubItemWidgetType_None){ QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(widget); newWidgetItem->setData(column,Qt::UserRole,eUBTGAddSubItemWidgetType_None); + newWidgetItem->setData(1,Qt::UserRole,eUBTGAddSubItemWidgetType_None); + newWidgetItem->setIcon(1,QIcon(":images/close.svg")); switch(addSubItemWidgetType) { case eUBTGAddSubItemWidgetType_Action: @@ -177,7 +183,9 @@ void UBTeacherGuideEditionWidget::onAddItemClicked(QTreeWidgetItem* widget, int mpTreeWidget->setItemWidget(newWidgetItem,0,new UBTGUrlWidget()); break; default: - qDebug() << "onAddItemClicked no action set"; + delete newWidgetItem; + qCritical() << "onAddItemClicked no action set"; + return; } if(addSubItemWidgetType != eUBTGAddSubItemWidgetType_None && !widget->isExpanded() ) @@ -188,6 +196,11 @@ void UBTeacherGuideEditionWidget::onAddItemClicked(QTreeWidgetItem* widget, int widget->setExpanded(true); } } + else if(column == 1 && addSubItemWidgetType == eUBTGAddSubItemWidgetType_None){ + int index = mpTreeWidget->currentIndex().row(); + QTreeWidgetItem* toBeDeletedWidgetItem = widget->parent()->takeChild(index); + delete toBeDeletedWidgetItem; + } } /*************************************************************************** @@ -252,6 +265,7 @@ UBTeacherGuidePresentationWidget::UBTeacherGuidePresentationWidget(QWidget *pare mpTreeWidget->setDropIndicatorShown(false); mpTreeWidget->header()->close(); mpTreeWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); +// mpTreeWidget->setColumnCount(1); connect(mpTreeWidget,SIGNAL(itemClicked(QTreeWidgetItem*,int)),this,SLOT(onAddItemClicked(QTreeWidgetItem*,int))); } diff --git a/src/gui/UBTeacherGuideWidgetsTools.cpp b/src/gui/UBTeacherGuideWidgetsTools.cpp index 8c4aec55..2134f8f6 100644 --- a/src/gui/UBTeacherGuideWidgetsTools.cpp +++ b/src/gui/UBTeacherGuideWidgetsTools.cpp @@ -39,6 +39,7 @@ UBAddItem::UBAddItem(const QString &string, int addSubItemWidgetType, QTreeWidge setIcon(0,QIcon(":images/increase.svg")); setText(0,string); setData(0,Qt::UserRole,QVariant(addSubItemWidgetType)); + setData(1,Qt::UserRole,QVariant(addSubItemWidgetType)); } UBAddItem::~UBAddItem() @@ -305,7 +306,7 @@ void UBTGMediaWidget::mousePressEvent(QMouseEvent *event) QDrag *drag = new QDrag(this); QMimeData *mimeData = new QMimeData; QList urlList; - urlList << QUrl::fromLocalFile(mRelativePath); + urlList << QUrl(mRelativePath); mimeData->setUrls(urlList); drag->setMimeData(mimeData); From a9ba75acbb6337f29964ca11803e5afd49d7b57b Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Wed, 11 Apr 2012 09:48:39 +0200 Subject: [PATCH 03/15] removed globalStyleSheet() --- src/core/UBApplication.cpp | 26 ++++--------------- src/core/UBApplication.h | 1 - src/customWidgets/UBMediaWidget.cpp | 3 +-- src/globals/UBGlobals.h | 35 +++++++++++++++++++++++--- src/gui/UBCachePropertiesWidget.cpp | 9 ++++--- src/gui/UBDockDownloadWidget.cpp | 5 ++-- src/gui/UBDockTeacherGuideWidget.cpp | 3 +-- src/gui/UBDownloadWidget.cpp | 7 +++--- src/gui/UBLibItemProperties.cpp | 7 +++--- src/gui/UBLibNavigatorWidget.cpp | 7 +++--- src/gui/UBLibWebView.cpp | 9 ++++--- src/gui/UBLibWidget.cpp | 7 +++--- src/gui/UBPageNavigationWidget.cpp | 9 ++++--- src/gui/UBTeacherGuideWidget.cpp | 7 ++++-- src/gui/UBTeacherGuideWidgetsTools.cpp | 2 ++ 15 files changed, 81 insertions(+), 56 deletions(-) diff --git a/src/core/UBApplication.cpp b/src/core/UBApplication.cpp index b8a3e257..05e5f8fb 100644 --- a/src/core/UBApplication.cpp +++ b/src/core/UBApplication.cpp @@ -257,10 +257,10 @@ int UBApplication::exec(const QString& pFileToImport) applicationController = new UBApplicationController(boardController->controlView(), boardController->displayView(), mainWindow, staticMemoryCleaner); - connect(applicationController, SIGNAL(mainModeChanged(UBApplicationController::MainMode)), + connect(applicationController, SIGNAL(mainModeChanged(UBApplicationController::MainMode)), boardController->paletteManager(), SLOT(slot_changeMainMode(UBApplicationController::MainMode))); - connect(applicationController, SIGNAL(desktopMode(bool)), + connect(applicationController, SIGNAL(desktopMode(bool)), boardController->paletteManager(), SLOT(slot_changeDesktopMode(bool))); @@ -283,8 +283,8 @@ int UBApplication::exec(const QString& pFileToImport) connect(mainWindow->actionSankoreEditor, SIGNAL(triggered()), applicationController, SLOT(showSankoreEditor())); connect(mainWindow->actionCheckUpdate, SIGNAL(triggered()), applicationController, SLOT(checkUpdateRequest())); - - + + toolBarPositionChanged(UBSettings::settings()->appToolBarPositionedAtTop->get()); bool bUseMultiScreen = UBSettings::settings()->appUseMultiscreen->get().toBool(); @@ -645,29 +645,13 @@ void UBStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, painter->setPen(savedPen); } -QString UBApplication::globalStyleSheet() -{ - QString style; - - QFile f(":style.qss"); - if(f.exists()) - { - if(f.open(QIODevice::ReadOnly)) - { - style = QString(f.readAll()); - } - } - - return style; -} - QString UBApplication::urlFromHtml(QString html) { QString _html; QRegExp comments("\\"); QString url; QDomDocument domDoc; - + // We remove all the comments & CRLF of this html _html = html.remove(comments); domDoc.setContent(_html.remove(QRegExp("[\\0]"))); diff --git a/src/core/UBApplication.h b/src/core/UBApplication.h index 0ca7ac37..ee4dba22 100644 --- a/src/core/UBApplication.h +++ b/src/core/UBApplication.h @@ -78,7 +78,6 @@ class UBApplication : public QtSingleApplication static void setDisabled(bool disable); static QObject* staticMemoryCleaner; - static QString globalStyleSheet(); void decorateActionMenu(QAction* action); void insertSpaceToToolbarBeforeAction(QToolBar* toolbar, QAction* action, int width = -1); diff --git a/src/customWidgets/UBMediaWidget.cpp b/src/customWidgets/UBMediaWidget.cpp index 4bef693b..fe96d6e9 100644 --- a/src/customWidgets/UBMediaWidget.cpp +++ b/src/customWidgets/UBMediaWidget.cpp @@ -35,8 +35,7 @@ UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name) , mpMediaContainer(NULL) , mpCover(NULL) { - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); + SET_STYLE_SHEET(); addAction(eAction_Close); mType = type; diff --git a/src/globals/UBGlobals.h b/src/globals/UBGlobals.h index 5a98fd10..93ebcb84 100644 --- a/src/globals/UBGlobals.h +++ b/src/globals/UBGlobals.h @@ -1,11 +1,38 @@ +/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #ifndef UBGLOBALS_H #define UBGLOBALS_H +#include +#include + #define DELETEPTR(ptr) if(NULL != ptr){ \ delete ptr; \ ptr = NULL; \ } +#define SET_STYLE_SHEET() {\ + setAttribute(Qt::WA_StyledBackground, true);\ + QString style;\ + QFile f(":style.qss");\ + if(f.exists() && f.open(QIODevice::ReadOnly))\ + style = QString(f.readAll());\ + setStyleSheet(style);\ +} + #ifdef Q_WS_WIN #define WARNINGS_DISABLE __pragma(warning(push, 0)); @@ -14,7 +41,7 @@ #ifdef NO_THIRD_PARTY_WARNINGS // disabling warning level to 0 and save old state #define THIRD_PARTY_WARNINGS_DISABLE WARNINGS_DISABLE -#else +#else // just save old state (needs for not empty define) #define THIRD_PARTY_WARNINGS_DISABLE __pragma(warning(push)); #endif //#ifdef NO_THIRD_PARTY_WARNINGS @@ -24,9 +51,9 @@ #define WARNINGS_DISABLE _Pragma("GCC diagnostic push"); \ _Pragma("GCC diagnostic ignored \"-Wunused-parameter\""); \ _Pragma("GCC diagnostic ignored \"-Wunused-variable\""); \ -_Pragma("GCC diagnostic ignored \"-Wsign-compare\""); +_Pragma("GCC diagnostic ignored \"-Wsign-compare\""); -#define WARNINGS_ENABLE _Pragma("GCC diagnostic pop"); +#define WARNINGS_ENABLE _Pragma("GCC diagnostic pop"); #ifdef NO_THIRD_PARTY_WARNINGS //disabling some warnings @@ -43,4 +70,4 @@ _Pragma("GCC diagnostic ignored \"-Wsign-compare\""); #define THIRD_PARTY_WARNINGS_ENABLE WARNINGS_ENABLE #endif // UBGLOBALS_H - + diff --git a/src/gui/UBCachePropertiesWidget.cpp b/src/gui/UBCachePropertiesWidget.cpp index e0c74986..ada7f785 100644 --- a/src/gui/UBCachePropertiesWidget.cpp +++ b/src/gui/UBCachePropertiesWidget.cpp @@ -7,6 +7,7 @@ #include "core/UBApplication.h" #include "core/UBApplicationController.h" +#include "globals/UBGlobals.h" #include "board/UBBoardController.h" #include "domain/UBGraphicsScene.h" @@ -34,8 +35,8 @@ UBCachePropertiesWidget::UBCachePropertiesWidget(QWidget *parent, const char *na , mpCurrentCache(NULL) { setObjectName(name); - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); + + SET_STYLE_SHEET(); mName = "CachePropWidget"; mVisibleState = false; @@ -283,7 +284,7 @@ void UBCachePropertiesWidget::updateCurrentCache() if( UBApplication::applicationController != NULL ) { // if app controller is available, and current mode is Board, and no show desktop, than all ok, just process - if( UBApplication::applicationController->displayMode() == UBApplicationController::Board && + if( UBApplication::applicationController->displayMode() == UBApplicationController::Board && !UBApplication::applicationController->isShowingDesktop()) isBoardMode = true; } @@ -348,4 +349,4 @@ void UBCachePropertiesWidget::onCacheEnabled() { emit showTab(this); } - + diff --git a/src/gui/UBDockDownloadWidget.cpp b/src/gui/UBDockDownloadWidget.cpp index 01b5d0ac..4ce9d07e 100644 --- a/src/gui/UBDockDownloadWidget.cpp +++ b/src/gui/UBDockDownloadWidget.cpp @@ -15,6 +15,8 @@ #include "UBDockDownloadWidget.h" #include "core/UBApplication.h" +#include "globals/UBGlobals.h" + UBDockDownloadWidget::UBDockDownloadWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent, name) , mpLayout(NULL) , mpDLWidget(NULL) @@ -22,8 +24,7 @@ UBDockDownloadWidget::UBDockDownloadWidget(QWidget *parent, const char *name):UB mName = "DownloadWidget"; mVisibleState = false; - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); + SET_STYLE_SHEET(); mIconToLeft = QPixmap(":images/download_open.png"); mIconToRight = QPixmap(":images/download_close.png"); diff --git a/src/gui/UBDockTeacherGuideWidget.cpp b/src/gui/UBDockTeacherGuideWidget.cpp index 27842025..f8ad4f43 100644 --- a/src/gui/UBDockTeacherGuideWidget.cpp +++ b/src/gui/UBDockTeacherGuideWidget.cpp @@ -26,8 +26,7 @@ UBDockTeacherGuideWidget::UBDockTeacherGuideWidget(QWidget* parent, const char* { mName = "TeacherGuide"; - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); + SET_STYLE_SHEET(); mIconToLeft = QPixmap(":images/teacher_open.png"); mIconToRight = QPixmap(":images/teacher_close.png"); diff --git a/src/gui/UBDownloadWidget.cpp b/src/gui/UBDownloadWidget.cpp index 286b9f20..00da5b01 100644 --- a/src/gui/UBDownloadWidget.cpp +++ b/src/gui/UBDownloadWidget.cpp @@ -18,8 +18,10 @@ #include #include "UBDownloadWidget.h" -#include "core/UBApplication.h" +#include "globals/UBGlobals.h" + +#include "core/UBApplication.h" #include "core/memcheck.h" /** @@ -36,8 +38,7 @@ UBDownloadWidget::UBDownloadWidget(QWidget *parent, const char *name):QWidget(pa { setObjectName(name); setWindowTitle(tr("Downloading files")); - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); + SET_STYLE_SHEET(); resize(400, 300); mpLayout = new QVBoxLayout(this); diff --git a/src/gui/UBLibItemProperties.cpp b/src/gui/UBLibItemProperties.cpp index b37747ff..4d2eada3 100644 --- a/src/gui/UBLibItemProperties.cpp +++ b/src/gui/UBLibItemProperties.cpp @@ -18,10 +18,12 @@ #include "core/UBApplication.h" #include "core/UBDownloadManager.h" +#include "core/memcheck.h" #include "frameworks/UBFileSystemUtils.h" -#include "core/memcheck.h" +#include "globals/UBGlobals.h" + /** * \brief Constructor @@ -43,8 +45,7 @@ UBLibItemProperties::UBLibItemProperties(QWidget *parent, const char *name):QWid { setObjectName(name); - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); + SET_STYLE_SHEET(); // Create the GUI mpLayout = new QVBoxLayout(this); diff --git a/src/gui/UBLibNavigatorWidget.cpp b/src/gui/UBLibNavigatorWidget.cpp index 8b36dd07..5974c4ea 100644 --- a/src/gui/UBLibNavigatorWidget.cpp +++ b/src/gui/UBLibNavigatorWidget.cpp @@ -18,6 +18,8 @@ #include "core/UBApplication.h" #include "core/memcheck.h" +#include "globals/UBGlobals.h" + static int lowBoundForSlider = 40; static int topBoundForSlider = 120; static int tickIntervalForSlider = 10; @@ -35,8 +37,7 @@ UBLibNavigatorWidget::UBLibNavigatorWidget(QWidget *parent, const char *name):QW { setObjectName(name); - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); + SET_STYLE_SHEET(); setAcceptDrops(true); @@ -62,7 +63,7 @@ UBLibNavigatorWidget::UBLibNavigatorWidget(QWidget *parent, const char *name):QW connect(mLibWidget, SIGNAL(propertiesRequested(UBLibElement*)), this, SLOT(onPropertiesRequested(UBLibElement*))); - connect(mLibWidget, SIGNAL(displaySearchEngine(UBLibElement*)), this, SLOT(onDisplaySearchEngine(UBLibElement*))); + connect(mLibWidget, SIGNAL(displaySearchEngine(UBLibElement*)), this, SLOT(onDisplaySearchEngine(UBLibElement*))); connect(mSlider,SIGNAL(valueChanged(int)),this,SLOT(updateThumbnailsSize(int))); connect(libWidget->pathViewer(), SIGNAL(mouseClick(UBChainedLibElement*)), this, SLOT(onPathItemClicked(UBChainedLibElement*))); connect(libWidget->pathViewer(), SIGNAL(elementsDropped(QList,UBLibElement*)), mLibWidget, SLOT(onElementsDropped(QList,UBLibElement*))); diff --git a/src/gui/UBLibWebView.cpp b/src/gui/UBLibWebView.cpp index b02af11d..ac6e11a5 100644 --- a/src/gui/UBLibWebView.cpp +++ b/src/gui/UBLibWebView.cpp @@ -1,11 +1,15 @@ #include #include "core/UBApplication.h" +#include "core/memcheck.h" + #include "board/UBBoardController.h" +#include "globals/UBGlobals.h" + #include "UBLibWebView.h" -#include "core/memcheck.h" + UBLibWebView::UBLibWebView(QWidget* parent, const char* name):QWidget(parent) , mpView(NULL) @@ -15,8 +19,7 @@ UBLibWebView::UBLibWebView(QWidget* parent, const char* name):QWidget(parent) { setObjectName(name); - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); + SET_STYLE_SHEET(); mpLayout = new QVBoxLayout(); setLayout(mpLayout); diff --git a/src/gui/UBLibWidget.cpp b/src/gui/UBLibWidget.cpp index 4e8ffc08..9765bae4 100644 --- a/src/gui/UBLibWidget.cpp +++ b/src/gui/UBLibWidget.cpp @@ -15,10 +15,12 @@ #include #include "UBLibWidget.h" -#include "core/UBApplication.h" +#include "core/UBApplication.h" #include "core/memcheck.h" +#include "globals/UBGlobals.h" + /** * \brief Constructor * @param parent as the parent widget @@ -37,8 +39,7 @@ UBLibWidget::UBLibWidget(QWidget *parent, const char *name):UBDockPaletteWidget( mName = "LibWidget"; mVisibleState = true; - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); + SET_STYLE_SHEET(); mIconToLeft = QPixmap(":images/library_open.png"); mIconToRight = QPixmap(":images/library_close.png"); diff --git a/src/gui/UBPageNavigationWidget.cpp b/src/gui/UBPageNavigationWidget.cpp index 77c378c2..6ff72dd8 100644 --- a/src/gui/UBPageNavigationWidget.cpp +++ b/src/gui/UBPageNavigationWidget.cpp @@ -14,9 +14,12 @@ */ #include "UBPageNavigationWidget.h" #include "core/UBApplication.h" -#include "board/UBBoardController.h" #include "core/memcheck.h" +#include "board/UBBoardController.h" + +#include "globals/UBGlobals.h" + /** * \brief Constructor * @param parent as the parent widget @@ -32,8 +35,8 @@ UBPageNavigationWidget::UBPageNavigationWidget(QWidget *parent, const char *name setObjectName(name); mName = "PageNavigator"; mVisibleState = true; - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); + + SET_STYLE_SHEET(); mIconToRight = QPixmap(":images/pages_open.png"); mIconToLeft = QPixmap(":images/pages_close.png"); diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp index 940297fe..f67c8d54 100644 --- a/src/gui/UBTeacherGuideWidget.cpp +++ b/src/gui/UBTeacherGuideWidget.cpp @@ -87,7 +87,8 @@ UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const mpTreeWidget->setColumnCount(2); mpTreeWidget->header()->setStretchLastSection(false); mpTreeWidget->header()->setResizeMode(0, QHeaderView::Stretch); - mpTreeWidget->header()->setResizeMode(1, QHeaderView::Custom); + mpTreeWidget->header()->setResizeMode(1, QHeaderView::Fixed); + mpTreeWidget->header()->setDefaultSectionSize(32); connect(mpTreeWidget,SIGNAL(itemClicked(QTreeWidgetItem*,int)),this,SLOT(onAddItemClicked(QTreeWidgetItem*,int))); @@ -158,7 +159,9 @@ QVector UBTeacherGuideEditionWidget::getData() children << getChildrenList(mpAddALinkItem); result << getPageAndCommentData(); foreach(QTreeWidgetItem* widgetItem, children){ - result << dynamic_cast(mpTreeWidget->itemWidget(widgetItem,0))->saveData(); + tUBGEElementNode* node = dynamic_cast(mpTreeWidget->itemWidget(widgetItem,0))->saveData(); + if(node) + result << node; } return result; } diff --git a/src/gui/UBTeacherGuideWidgetsTools.cpp b/src/gui/UBTeacherGuideWidgetsTools.cpp index 2134f8f6..60c9f89b 100644 --- a/src/gui/UBTeacherGuideWidgetsTools.cpp +++ b/src/gui/UBTeacherGuideWidgetsTools.cpp @@ -198,6 +198,8 @@ UBTGMediaWidget::~UBTGMediaWidget() tUBGEElementNode* UBTGMediaWidget::saveData() { + if(!mpTitle) + return 0; tUBGEElementNode* result = new tUBGEElementNode(); result->type = "media"; result->attributes.insert("title",mpTitle->toPlainText()); From 9444787bd3036a84401031cccaddc00023add005 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Wed, 11 Apr 2012 09:54:37 +0200 Subject: [PATCH 04/15] remove UBWidgetList class --- resources/style.qss | 70 +-------- src/customWidgets/UBWidgetList.cpp | 229 ---------------------------- src/customWidgets/UBWidgetList.h | 69 --------- src/customWidgets/customWidgets.pri | 4 +- 4 files changed, 3 insertions(+), 369 deletions(-) delete mode 100644 src/customWidgets/UBWidgetList.cpp delete mode 100644 src/customWidgets/UBWidgetList.h diff --git a/resources/style.qss b/resources/style.qss index c542d934..e68f1f66 100644 --- a/resources/style.qss +++ b/resources/style.qss @@ -3,23 +3,13 @@ QWidget#documentNavigator, QWidget#UBLibPathViewer, QWidget#UBLibNavigatorWidget, QWidget#UBLibItemProperties, -QWidget#UBDownloadWidget, -QWidget#UBWidgetList, -QWidget#UBTeacherBarDropMediaZone, -QWidget#UBTBMediaContainer +QWidget#UBDownloadWidget { background: #EEEEEE; border-radius: 10px; border: 2px solid #999999; } -QFrame#UBTBSeparator -{ - background: #DDDDDD; - border-radius: 2px; - border: 1px solid #DDDDDD; -} - QWidget#UBMediaVideoContainer { background: #000000; @@ -27,40 +17,6 @@ QWidget#UBMediaVideoContainer border: 2px solid #999999; } - -QWidget#UBTBPreviewWidget -{ - background: #FFFFFF; - border-radius: 10px; - border: 2px solid #999999; -} - -QLabel#UBTBPreviewSessionTitle -{ - font-size: 12px; -} - -QLabel#UBTeacherBarPreviewTitle -{ - color: #555555; - font-size : 20px; - font-weight:bold; - padding-left:5px; -} - -QLabel#UBMediaPlayerButton -{ - padding: 0px 0px 0px 0px; -} - -QLabel#UBTeacherBarPreviewSubtitle -{ - color: #555555; - font-size : 15px; - font-weight:bold; - padding-left:5px; -} - QWidget#UBLibWebView { background: #EEEEEE; @@ -68,30 +24,6 @@ QWidget#UBLibWebView border: 2px solid #999999; } -QWidget#UBActionPreviewOwner -{ - color: #555555; - font-size : 12px; - font-weight: bold; -} - -QWidget#UBTeacherBarPreviewComments, -QWidget#UBTeacherBarTargetBox -{ - border-radius: 10px; - border: white 2px solid; - padding: 5px 5px 5px 5px; - background-color: white; -} - -QWidget#UBActionPreviewContent, -QTextEdit#UBCommentPreview -{ - border-radius : 10px; - border: 2px solid #999999; - padding: 5px 5px 5px 5px; -} - QWebView#SearchEngineView { background:white; diff --git a/src/customWidgets/UBWidgetList.cpp b/src/customWidgets/UBWidgetList.cpp deleted file mode 100644 index a9e9a305..00000000 --- a/src/customWidgets/UBWidgetList.cpp +++ /dev/null @@ -1,229 +0,0 @@ -#include -#include -#include -#include - -#include "globals/UBGlobals.h" -#include "UBWidgetList.h" - -UBWidgetList::UBWidgetList(QWidget* parent, eWidgetListOrientation orientation, const char* name):QScrollArea(parent) - , mCanRemove(true) - , mpLayout(NULL) - , mpContainer(NULL) - , mMargin(10) - , mListElementsSpacing(10) - , mpEmptyLabel(NULL) - , mpCurrentWidget(NULL) -{ - setObjectName(name); - mOrientation = orientation; - mpContainer = new QWidget(this); - mpEmptyLabel = new QLabel(this); - mpEmptyLabel->setObjectName("emptyString"); - mpEmptyLabel->setWordWrap(true); - mpEmptyLabel->setAlignment(Qt::AlignCenter); - - if(eWidgetListOrientation_Vertical == orientation){ - setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - mpLayout = new QVBoxLayout(mpContainer); - } - else{ - setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - mpLayout = new QHBoxLayout(mpContainer); - } - mpLayout->setContentsMargins(margin(), margin(), margin(), margin()); - mpContainer->setLayout(mpLayout); - setWidget(mpContainer); -} - -UBWidgetList::~UBWidgetList() -{ - DELETEPTR(mpEmptyLabel); - DELETEPTR(mpLayout); - DELETEPTR(mpContainer); -} - -void UBWidgetList::addWidget(QWidget *widget) -{ - if(NULL != mpLayout && NULL != widget){ - widget->setParent(mpContainer); - mpEmptyLabel->setVisible(false); - mWidgetInfo[widget] = widget->size(); - updateView(size()); - mpLayout->addWidget(widget); - - // This call is used only to refresh the size of the widgets - updateSizes(); - } -} - -void UBWidgetList::removeWidget(QWidget *widget) -{ - if(NULL != mpLayout && NULL != widget){ - mpLayout->removeWidget(widget); - mWidgetInfo.remove(widget); - widget->setVisible(false); - updateView(size()); - if(0 == mpLayout->count()){ - mpEmptyLabel->setVisible(true); - } - if(mpCurrentWidget == widget){ - mpCurrentWidget = NULL; - } - } -} - - -int UBWidgetList::scaleWidgets(QSize pSize) -{ - // to remove the first spacing that shouldn't be there. - int result = -mListElementsSpacing; - foreach(QWidget* eachWidget, mWidgetInfo.keys()){ - qreal scaleFactor = 0; - int newWidgetWidth = pSize.width(); - int newWidgetHeight = pSize.height(); - if(eWidgetListOrientation_Vertical == mOrientation){ - scaleFactor = (float)mWidgetInfo[eachWidget].width() / (float)pSize.width(); - newWidgetHeight = mWidgetInfo[eachWidget].height()/scaleFactor; - result += newWidgetHeight; - eachWidget->setMinimumHeight(newWidgetHeight- 1); - eachWidget->setMaximumHeight(newWidgetHeight); - } - else{ - scaleFactor = (float)mWidgetInfo[eachWidget].height() / (float)pSize.height(); - newWidgetWidth = mWidgetInfo[eachWidget].width()/scaleFactor; - result += newWidgetWidth; - eachWidget->setMinimumWidth(newWidgetWidth - 1); - eachWidget->setMaximumWidth(newWidgetWidth); - } - //Adding a vertical/horizontal space between each element of the list - result += mListElementsSpacing; - } - return result; -} - -void UBWidgetList::scaleContainer(QSize pSize, int updateValue) -{ - if(eWidgetListOrientation_Vertical == mOrientation) - mpContainer->resize(pSize.width(), updateValue); - else - mpContainer->resize(updateValue, pSize.height()); -} - - -void UBWidgetList::updateView(QSize pSize) -{ - // Widgets on list are resized automatically to fit the mpcontainer. - // so if you want to keep the aspect ratio you have to calculate - // the sum of the new widget height and give it to the mpContainer. - // The container resize will trig the widgets resize and the good - // height permits to respect the aspect ratio. - int updatedValue = scaleWidgets(pSize); - scaleContainer(pSize,updatedValue); -} - - - -void UBWidgetList::resizeEvent(QResizeEvent *ev) -{ - Q_UNUSED(ev); - mpEmptyLabel->setGeometry((width() - mpEmptyLabel->width()) / 2, - (height() - mpEmptyLabel->height()) /2, - mpEmptyLabel->width(), - mpEmptyLabel->height()); - updateView(size()); - updateSizes(); -} - -void UBWidgetList::mousePressEvent(QMouseEvent *ev) -{ - Q_UNUSED(ev); - if(mCanRemove){ - QWidget* pWAt = widgetAt(ev->pos()); - if(NULL != mpCurrentWidget){ - if(pWAt != mpCurrentWidget){ - mpCurrentWidget->setActionsVisible(false); - update(); - } - } - mpCurrentWidget = dynamic_cast(pWAt); - if(NULL != mpCurrentWidget){ - mpCurrentWidget->setActionsVisible(true); - update(); - } - } - update(); -} - -QWidget* UBWidgetList::widgetAt(QPoint p) -{ - QWidget* pW = NULL; - pW = childAt(p); - if(NULL != pW){ - do{ - if( "UBTeacherStudentAction" == pW->objectName() || - "UBUrlWidget" == pW->objectName() || - "UBTBMediaPicture" == pW->objectName() || - "UBMediaWidget" == pW->objectName()){ - return pW; - }else{ - pW = pW->parentWidget(); - } - }while(NULL != pW && this != pW); - } - - return pW; -} - -void UBWidgetList::updateSizes() -{ - // Resize all the widgets - foreach(QWidget* eachWidget, mWidgetInfo.keys()){ - if(NULL != eachWidget){ - QSize originalSize = mWidgetInfo[eachWidget]; - int currentWidth = mpContainer->width(); - int currentHeight = mpContainer->height(); - if(eWidgetListOrientation_Vertical == mOrientation){ - if(verticalScrollBar()->isVisible()){ - currentWidth -= verticalScrollBar()->width(); - eachWidget->setStyleSheet(QString("margin-right:%0;").arg(verticalScrollBar()->width())); - } - float scaleFactor = (float)currentWidth/(float)originalSize.width(); - currentHeight = originalSize.height()*scaleFactor; - }else{ - if(horizontalScrollBar()->isVisible()){ - currentHeight -= horizontalScrollBar()->height(); - eachWidget->setStyleSheet(QString("padding-bottom:%0;").arg(horizontalScrollBar()->height())); - } - float scaleFactor = (float)currentHeight/(float)originalSize.height(); - currentWidth = originalSize.width()*scaleFactor; - } - - eachWidget->resize(currentWidth, currentHeight); - } - } -} - -void UBWidgetList::setMargin(int margin) -{ - mMargin = margin; -} - -int UBWidgetList::margin() -{ - return mMargin; -} - -void UBWidgetList::setEmptyText(const QString &text) -{ - if(NULL != mpEmptyLabel){ - mpEmptyLabel->setText(text); - } -} - -bool UBWidgetList::empty() -{ - return mWidgetInfo.empty(); -} diff --git a/src/customWidgets/UBWidgetList.h b/src/customWidgets/UBWidgetList.h deleted file mode 100644 index d2cd3a6c..00000000 --- a/src/customWidgets/UBWidgetList.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef UBWIDGETLIST_H -#define UBWIDGETLIST_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "interfaces/IResizeable.h" -#include "customWidgets/UBActionableWidget.h" - -typedef enum{ - eWidgetListOrientation_Vertical, - eWidgetListOrientation_Horizontal -}eWidgetListOrientation; - - -class UBWidgetList : public QScrollArea -{ - Q_OBJECT - - typedef struct - { - QSize size; - bool isResizable; - } sWidgetProperties; - -public: - UBWidgetList(QWidget* parent=0, eWidgetListOrientation orientation = eWidgetListOrientation_Vertical, const char* name = "UBWidgetList"); - ~UBWidgetList(); - void addWidget(QWidget* widget); - void removeWidget(QWidget* widget); - void setMargin(int margin); - void setEmptyText(const QString& text); - int margin(); - bool empty(); - void setListElementSpacing(int margin) { mListElementsSpacing = margin; } - int listElementsSpacing() {return mListElementsSpacing; } - -signals: - void closeWidget(QWidget* w); - -protected: - bool mCanRemove; - - void resizeEvent(QResizeEvent* ev); - void mousePressEvent(QMouseEvent* ev); - -private: - QWidget* widgetAt(QPoint p); - int scaleWidgets(QSize pSize); - void scaleContainer(QSize pSize, int updateValue); - void updateView(QSize pSize); - void updateSizes(); - QBoxLayout* mpLayout; - QWidget* mpContainer; - eWidgetListOrientation mOrientation; - int mMargin; - int mListElementsSpacing; - QMap mWidgetInfo; - QLabel* mpEmptyLabel; - UBActionableWidget* mpCurrentWidget; -}; - -#endif // UBWIDGETLIST_H diff --git a/src/customWidgets/customWidgets.pri b/src/customWidgets/customWidgets.pri index 0d730437..a3c64030 100644 --- a/src/customWidgets/customWidgets.pri +++ b/src/customWidgets/customWidgets.pri @@ -1,8 +1,8 @@ -HEADERS += src/customWidgets/UBWidgetList.h \ +HEADERS += \ src/customWidgets/UBMediaWidget.h \ src/customWidgets/UBActionableWidget.h -SOURCES += src/customWidgets/UBWidgetList.cpp \ +SOURCES += \ src/customWidgets/UBMediaWidget.cpp \ src/customWidgets/UBActionableWidget.cpp From e6f84716f0409293e69bde5d1fffbbd1196e0d62 Mon Sep 17 00:00:00 2001 From: Anatoly Mihalchenko Date: Thu, 12 Apr 2012 13:43:47 +0300 Subject: [PATCH 05/15] PDF view performance:multiple pages selection --- src/gui/UBThumbnailWidget.cpp | 1742 +++++++++++++++++---------------- src/gui/UBThumbnailWidget.h | 844 ++++++++-------- 2 files changed, 1302 insertions(+), 1284 deletions(-) diff --git a/src/gui/UBThumbnailWidget.cpp b/src/gui/UBThumbnailWidget.cpp index 302c6a23..cd0ebec3 100644 --- a/src/gui/UBThumbnailWidget.cpp +++ b/src/gui/UBThumbnailWidget.cpp @@ -1,863 +1,879 @@ -/* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#include -#include - -#include "UBThumbnailWidget.h" -#include "UBRubberBand.h" - -#include "core/UBSettings.h" -#include "core/UBApplication.h" - -#include "document/UBDocumentProxy.h" -#include "document/UBDocumentController.h" - -#include "core/memcheck.h" - -UBThumbnailWidget::UBThumbnailWidget(QWidget* parent) - : QGraphicsView(parent) - , mThumbnailWidth(UBSettings::defaultThumbnailWidth) - , mSpacing(UBSettings::thumbnailSpacing) - , mLastSelectedThumbnail(0) - , mSelectionSpan(0) - , mLassoRectItem(0) -{ - // By default, the drag is possible - bCanDrag = true; - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing); - setFrameShape(QFrame::NoFrame); - setScene(&mThumbnailsScene); - - setAlignment(Qt::AlignLeft | Qt::AlignTop); - - connect(&mThumbnailsScene, SIGNAL(selectionChanged()), this, SLOT(sceneSelectionChanged())); -} - - -UBThumbnailWidget::~UBThumbnailWidget() -{ - disconnect(&mThumbnailsScene, SIGNAL(selectionChanged())); -} - - -void UBThumbnailWidget::setThumbnailWidth(qreal pThumbnailWidth) -{ - mThumbnailWidth = pThumbnailWidth; - - refreshScene(); -} - - -void UBThumbnailWidget::setSpacing(qreal pSpacing) -{ - mSpacing = pSpacing; - - refreshScene(); -} - - -void UBThumbnailWidget::setGraphicsItems(const QList& pGraphicsItems - , const QList& pItemsPaths - , const QStringList pLabels - , const QString& pMimeType) -{ - mGraphicItems = pGraphicsItems; - mItemsPaths = pItemsPaths; - mMimeType = pMimeType; - mLabels = pLabels; - - foreach(QGraphicsItem* it, mThumbnailsScene.items()) - { - mThumbnailsScene.removeItem(it, true); - } - - // set lasso to 0 as it has been cleared as well - mLassoRectItem = 0; - - foreach (QGraphicsItem* item, pGraphicsItems) - { - if (item->scene() != &mThumbnailsScene) - { - mThumbnailsScene.addItem(item); - } - } - - mLabelsItems.clear(); - - foreach (const QString label, pLabels) - { - QFontMetrics fm(font()); - UBThumbnailTextItem *labelItem = - new UBThumbnailTextItem(label); // deleted while replace or by the scene destruction - - mThumbnailsScene.addItem(labelItem); - mLabelsItems << labelItem; - } - - refreshScene(); - - mLastSelectedThumbnail = 0; -} - - -void UBThumbnailWidget::refreshScene() -{ - int nbColumns = (geometry().width() - mSpacing) / (mThumbnailWidth + mSpacing); - - int labelSpacing = 0; - - if (mLabelsItems.size() > 0) - { - QFontMetrics fm(mLabelsItems.at(0)->font()); - labelSpacing = UBSettings::thumbnailSpacing + fm.height(); // TODO UB 4.x where is 20 from ??? configure ?? compute based on mSpacing ?? JBA Is it the font height? - } - nbColumns = qMax(nbColumns, 1); - - qreal thumbnailHeight = mThumbnailWidth / UBSettings::minScreenRatio; - - for (int i = 0; i < mGraphicItems.size(); i++) - { - QGraphicsItem* item = mGraphicItems.at(i); - - qreal scaleWidth = mThumbnailWidth / item->boundingRect().width(); - qreal scaleHeight = thumbnailHeight / item->boundingRect().height(); - - qreal scaleFactor = qMin(scaleWidth, scaleHeight); - - //bitmap should not be stretched - UBThumbnail* pix = dynamic_cast(item); - if (pix) - scaleFactor = qMin(scaleFactor, 1.0); - - QTransform transform; - transform.scale(scaleFactor, scaleFactor); - - item->setTransform(transform); - - item->setFlag(QGraphicsItem::ItemIsSelectable, true); - - int columnIndex = i % nbColumns; - int rowIndex = i / nbColumns; - - if (pix) - { - pix->setColumn(columnIndex); - pix->setRow(rowIndex); - } - - int w = item->boundingRect().width(); - int h = item->boundingRect().height(); - QPointF pos( - mSpacing + (mThumbnailWidth - w * scaleFactor) / 2 + columnIndex * (mThumbnailWidth + mSpacing), - mSpacing + rowIndex * (thumbnailHeight + mSpacing + labelSpacing) + (thumbnailHeight - h * scaleFactor) / 2); - - item->setPos(pos); - - if (mLabelsItems.size() > i) - { - QFontMetrics fm(mLabelsItems.at(i)->font(), this); - QString elidedText = fm.elidedText(mLabels.at(i), Qt::ElideRight, mThumbnailWidth); - - mLabelsItems.at(i)->setPlainText(elidedText); - mLabelsItems.at(i)->setWidth(fm.width(elidedText) + 2 * mLabelsItems.at(i)->document()->documentMargin()); - - pos.setY(pos.y() + (thumbnailHeight + h * scaleFactor) / 2 + 5); - qreal labelWidth = fm.width(elidedText); - pos.setX(mSpacing + (mThumbnailWidth - labelWidth) / 2 + columnIndex * (mThumbnailWidth + mSpacing)); - mLabelsItems.at(i)->setPos(pos); - } - } - - QScrollBar *vertScrollBar = verticalScrollBar(); - int scrollBarThickness = 0; - if (vertScrollBar && vertScrollBar->isVisible()) - scrollBarThickness = vertScrollBar->width(); - - setSceneRect(0, 0, - geometry().width() - scrollBarThickness, - mSpacing + ((((mGraphicItems.size() - 1) / nbColumns) + 1) * (thumbnailHeight + mSpacing + labelSpacing))); -} - - -QList UBThumbnailWidget::selectedItems() -{ - QList sortedSelectedItems = mThumbnailsScene.selectedItems(); - qSort(sortedSelectedItems.begin(), sortedSelectedItems.end(), thumbnailLessThan); - return sortedSelectedItems; -} - - -void UBThumbnailWidget::mousePressEvent(QMouseEvent *event) -{ - mClickTime = QTime::currentTime(); - mMousePressPos = event->pos(); - mMousePressScenePos = mapToScene(mMousePressPos); - QGraphicsItem* underlyingItem = itemAt(mMousePressPos); - - UBThumbnail *previousSelectedThumbnail = mLastSelectedThumbnail; - - if (!dynamic_cast(underlyingItem)) - { - deleteLasso(); - - UBRubberBand rubberBand(QRubberBand::Rectangle); - QStyleOption option; - option.initFrom(&rubberBand); - - mLassoRectItem = new QGraphicsRectItem(0, scene()); - -#ifdef Q_WS_MAC - // The following code must stay in synch with \src\gui\styles\qmacstyle_mac.mm - QColor strokeColor; - strokeColor.setHsvF(0, 0, 0.86, 1.0); - mLassoRectItem->setPen(QPen(strokeColor)); - QColor fillColor(option.palette.color(QPalette::Disabled, QPalette::Highlight)); - fillColor.setHsvF(0, 0, 0.53, 0.25); - mLassoRectItem->setBrush(fillColor); -#else - // The following code must stay in synch with \src\gui\styles\qwindowsxpstyle.cpp - QColor highlight = option.palette.color(QPalette::Active, QPalette::Highlight); - mLassoRectItem->setPen(highlight.darker(120)); - QColor dimHighlight(qMin(highlight.red() / 2 + 110, 255), - qMin(highlight.green() / 2 + 110, 255), - qMin(highlight.blue() / 2 + 110, 255), - 127); - mLassoRectItem->setBrush(dimHighlight); -#endif - - mLassoRectItem->setZValue(10000); - mLassoRectItem->setRect(QRectF(mMousePressScenePos, QSizeF())); - - if (Qt::ControlModifier & event->modifiers() || Qt::ShiftModifier & event->modifiers()) - { - mSelectedThumbnailItems = selectedItems(); - return; - } - - mSelectedThumbnailItems.clear(); - QGraphicsView::mousePressEvent(event); - } - else if (Qt::ShiftModifier & event->modifiers()) - { - if (previousSelectedThumbnail) - { - QGraphicsItem* previousSelectedItem = dynamic_cast(previousSelectedThumbnail); - if (previousSelectedItem) - { - int index1 = mGraphicItems.indexOf(previousSelectedItem); - int index2 = mGraphicItems.indexOf(underlyingItem); - if (-1 == index2) - { - mSelectedThumbnailItems = selectedItems(); - return; - } - mSelectionSpan = index2 - index1; - selectItems(qMin(index1, index2), mSelectionSpan < 0 ? - mSelectionSpan + 1 : mSelectionSpan + 1); - return; - } - } - } - else - { - mLastSelectedThumbnail = dynamic_cast(underlyingItem); - if (!underlyingItem->isSelected()) - { - int index = mGraphicItems.indexOf(underlyingItem); - selectItemAt(index, Qt::ControlModifier & event->modifiers()); - } - else - { - QGraphicsView::mousePressEvent(event); - } - if (!mLastSelectedThumbnail && mGraphicItems.count() > 0) - mLastSelectedThumbnail = dynamic_cast(mGraphicItems.at(0)); - mSelectionSpan = 0; - return; - } -} - - -void UBThumbnailWidget::mouseMoveEvent(QMouseEvent *event) -{ - int distance = (mMousePressPos - event->pos()).manhattanLength(); - - if (0 == (event->buttons() & Qt::LeftButton) || distance < QApplication::startDragDistance()) - return; - - if (mLassoRectItem) - { - bSelectionInProgress = true; - QPointF currentScenePos = mapToScene(event->pos()); - QRectF lassoRect( - qMin(mMousePressScenePos.x(), currentScenePos.x()), qMin(mMousePressScenePos.y(), currentScenePos.y()), - qAbs(mMousePressScenePos.x() - currentScenePos.x()), qAbs(mMousePressScenePos.y() - currentScenePos.y())); - mLassoRectItem->setRect(lassoRect); - - QList lassoSelectedItems = scene()->items(lassoRect, Qt::IntersectsItemBoundingRect); - QList lassoSelectedThumbnailItems; - foreach (QGraphicsItem *lassoSelectedItem, lassoSelectedItems) - { - UBThumbnail *thumbnailItem = dynamic_cast(lassoSelectedItem); - if (thumbnailItem) - lassoSelectedThumbnailItems.append(lassoSelectedItems); - } - - unselectAll(); - foreach (QGraphicsItem *lassoSelectedItem, lassoSelectedThumbnailItems) - { - if (Qt::ControlModifier & event->modifiers()) - { - if (!mSelectedThumbnailItems.contains(lassoSelectedItem)) - selectItemAt(mGraphicItems.indexOf(lassoSelectedItem), true); - } - else - { - selectItemAt(mGraphicItems.indexOf(lassoSelectedItem), true); - } - } - if (Qt::ControlModifier & event->modifiers()) - { - foreach (QGraphicsItem *selectedItem, mSelectedThumbnailItems) - { - if (!lassoSelectedThumbnailItems.contains(selectedItem)) - selectItemAt(mGraphicItems.indexOf(selectedItem), true); - } - } - } - else - { - bSelectionInProgress = false; - if (0 == selectedItems().size()) - return; - - if(bCanDrag) - { - QDrag *drag = new QDrag(this); - QMimeData *mime = new QMimeData(); - - if (mMimeType.length() > 0) - mime->setData(mMimeType, QByteArray()); // trick the d&d system to register our own mime type - - drag->setMimeData(mime); - - QList qlElements; - - foreach (QGraphicsItem* item, selectedItems()) - { - if (mGraphicItems.contains(item)) - { - if (mGraphicItems.indexOf(item) <= mItemsPaths.size()){ - qlElements << mItemsPaths.at(mGraphicItems.indexOf(item)); - } - } - } - - if (qlElements.size() > 0){ - mime->setUrls(qlElements); - drag->setMimeData(mime); - drag->exec(Qt::CopyAction); - } - } - } - - QGraphicsView::mouseMoveEvent(event); -} - - -void UBThumbnailWidget::mouseReleaseEvent(QMouseEvent *event) -{ - int elapsedTimeSincePress = mClickTime.elapsed(); - deleteLasso(); - QGraphicsView::mouseReleaseEvent(event); - - if(elapsedTimeSincePress < STARTDRAGTIME) { - emit mouseClick(itemAt(event->pos()), 0); - } -} - - -void UBThumbnailWidget::keyPressEvent(QKeyEvent *event) -{ - if (mLastSelectedThumbnail) - { - QGraphicsItem *lastSelectedGraphicsItem = dynamic_cast(mLastSelectedThumbnail); - if (!lastSelectedGraphicsItem) return; - int startSelectionIndex = mGraphicItems.indexOf(lastSelectedGraphicsItem); - int previousSelectedThumbnailIndex = startSelectionIndex + mSelectionSpan; - - switch (event->key()) - { - case Qt::Key_Down: - case Qt::Key_Up: - { - if (rowCount() <= 1) break; - if (Qt::ShiftModifier & event->modifiers()) - { - int endSelectionIndex; - if (Qt::Key_Down == event->key()) - { - endSelectionIndex = previousSelectedThumbnailIndex + columnCount(); - if (endSelectionIndex >= mGraphicItems.count()) break; - } - else - { - endSelectionIndex = previousSelectedThumbnailIndex - columnCount(); - if (endSelectionIndex < 0) break; - } - - int startIndex = startSelectionIndex < endSelectionIndex ? startSelectionIndex : endSelectionIndex; - int count = startSelectionIndex < endSelectionIndex ? endSelectionIndex - startSelectionIndex + 1 : startSelectionIndex - endSelectionIndex + 1; - mSelectionSpan = startSelectionIndex < endSelectionIndex ? (count - 1) : - (count - 1); - selectItems(startIndex, count); - } - else - { - int toSelectIndex; - if (Qt::Key_Down == event->key()) - { - toSelectIndex = previousSelectedThumbnailIndex + columnCount(); - if (toSelectIndex >= mGraphicItems.count()) break; - } - else - { - toSelectIndex = previousSelectedThumbnailIndex - columnCount(); - if (toSelectIndex < 0) break; - } - - selectItemAt(toSelectIndex, Qt::ControlModifier & event->modifiers()); - mSelectionSpan = 0; - } - } - break; - - case Qt::Key_Left: - case Qt::Key_Right: - { - QGraphicsItem *previousSelectedItem = mGraphicItems.at(previousSelectedThumbnailIndex); - UBThumbnail *previousSelectedThumbnail = dynamic_cast(previousSelectedItem); - if (!previousSelectedThumbnail) break; - - if (Qt::Key_Left == event->key()) - { - if (0 == previousSelectedThumbnail->column()) break; - } - else - { - if (previousSelectedThumbnail->column() == columnCount() - 1 || - previousSelectedThumbnailIndex == mGraphicItems.count() - 1) break; - } - - if (Qt::ShiftModifier & event->modifiers()) - { - int endSelectionIndex; - if (Qt::Key_Left == event->key()) - { - endSelectionIndex = previousSelectedThumbnailIndex - 1; - if (endSelectionIndex < 0) break; - } - else - { - endSelectionIndex = previousSelectedThumbnailIndex + 1; - if (endSelectionIndex >= mGraphicItems.count()) break; - } - - int startIndex = startSelectionIndex < endSelectionIndex ? startSelectionIndex : endSelectionIndex; - int count = startSelectionIndex < endSelectionIndex ? endSelectionIndex - startSelectionIndex + 1 : startSelectionIndex - endSelectionIndex + 1; - mSelectionSpan = startSelectionIndex < endSelectionIndex ? (count - 1) : - (count - 1); - selectItems(startIndex, count); - } - else - { - if (Qt::Key_Left == event->key()) - selectItemAt(previousSelectedThumbnailIndex - 1, Qt::ControlModifier & event->modifiers()); - else - selectItemAt(previousSelectedThumbnailIndex + 1, Qt::ControlModifier & event->modifiers()); - - mSelectionSpan = 0; - } - } - break; - - case Qt::Key_Home: - { - if (Qt::ShiftModifier & event->modifiers()) - { - mSelectionSpan = - startSelectionIndex; - selectItems(0, startSelectionIndex + 1); - } - else - { - selectItemAt(0, Qt::ControlModifier & event->modifiers()); - mSelectionSpan = 0; - } - } - break; - - case Qt::Key_End: - { - if (Qt::ShiftModifier & event->modifiers()) - { - mSelectionSpan = mGraphicItems.count() - startSelectionIndex - 1; - selectItems(startSelectionIndex, mSelectionSpan + 1); - } - else - { - selectItemAt(mGraphicItems.count() - 1, Qt::ControlModifier & event->modifiers()); - mSelectionSpan = 0; - } - } - break; - case Qt::Key_A: - { - if (Qt::ControlModifier & event->modifiers()) - selectAll(); - } - break; - } - } - QGraphicsView::keyPressEvent(event); -} - - -void UBThumbnailWidget::focusInEvent(QFocusEvent *event) -{ - Q_UNUSED(event); - - if (0 == selectedItems().count() && mGraphicItems.count() > 0 && Qt::TabFocusReason == event->reason()) - { - selectItemAt(0); - mSelectionSpan = 0; - } -} - - -void UBThumbnailWidget::resizeEvent(QResizeEvent *event) -{ - Q_UNUSED(event); - - refreshScene(); - - emit resized(); -} - - -void UBThumbnailWidget::sceneSelectionChanged() -{ - emit selectionChanged(); -} - - -void UBThumbnailWidget::selectItemAt(int pIndex, bool extend) -{ - QGraphicsItem* itemToSelect = 0; - - if (pIndex >= 0 && pIndex < mGraphicItems.size()) - itemToSelect = mGraphicItems.at(pIndex); - - foreach (QGraphicsItem* item, items()) - { - if (item == itemToSelect) - { - mLastSelectedThumbnail = dynamic_cast(item); - item->setSelected(true); - ensureVisible(item); - } - else if (!extend) - { - item->setSelected(false); - } - } -} - -void UBThumbnailWidget::unselectItemAt(int pIndex) -{ - if (pIndex >= 0 && pIndex < mGraphicItems.size()) - { - QGraphicsItem *itemToUnselect = mGraphicItems.at(pIndex); - itemToUnselect->setSelected(false); - } -} - - -void UBThumbnailWidget::selectItems(int startIndex, int count) -{ - for (int i = 0; i < mGraphicItems.count(); i++) - { - mGraphicItems.at(i)->setSelected(i >= startIndex && i < startIndex + count); - } -} - - -void UBThumbnailWidget::selectAll() -{ - foreach (QGraphicsItem* item, mGraphicItems) - { - item->setSelected(true); - } -} - -void UBThumbnailWidget::unselectAll() -{ - foreach (QGraphicsItem* item, mGraphicItems) - { - item->setSelected(false); - } -} - -int UBThumbnailWidget::rowCount() const -{ - UBThumbnail *lastThumbnail = dynamic_cast(mGraphicItems.last()); - return lastThumbnail ? lastThumbnail->row() + 1 : 0; -} - -int UBThumbnailWidget::columnCount() const -{ - UBThumbnail *lastThumbnail = dynamic_cast(mGraphicItems.last()); - if (!lastThumbnail) return 0; - int lastRow = lastThumbnail->row(); - int lastColumn = lastThumbnail->column(); - return lastRow > 0 ? (mGraphicItems.count() - lastColumn - 1) / lastRow : mGraphicItems.count(); -} - - -void UBThumbnailWidget::mouseDoubleClickEvent(QMouseEvent * event) -{ - QGraphicsItem* item = itemAt(event->pos()); - - if (item) - { - int index = mGraphicItems.indexOf(item); - emit mouseDoubleClick(item, index); - } -} - - -bool UBThumbnailWidget::thumbnailLessThan(QGraphicsItem* item1, QGraphicsItem* item2) -{ - UBThumbnail *thumbnail1 = dynamic_cast(item1); - UBThumbnail *thumbnail2 = dynamic_cast(item2); - if (thumbnail1 && thumbnail2) - { - if (thumbnail1->row() != thumbnail2->row()) - return thumbnail1->row() < thumbnail2->row(); - else - return thumbnail1->column() < thumbnail2->column(); - } - return false; -} - -void UBThumbnailWidget::deleteLasso() -{ - if (mLassoRectItem && scene()) - { - scene()->removeItem(mLassoRectItem); - delete mLassoRectItem; - mLassoRectItem = 0; - } -} - - -UBThumbnail::UBThumbnail() - : mAddedToScene(false) -{ - mSelectionItem = new QGraphicsRectItem(0, 0, 0, 0); - mSelectionItem->setPen(QPen(UBSettings::treeViewBackgroundColor, 8)); - // TODO UB 4.x fix nasty dependencies : 8 is a bit less than half of UBThumbnailWidget.mSpacing -} - -UBThumbnail::~UBThumbnail() -{ - if (mSelectionItem && !mAddedToScene) - delete mSelectionItem; -} - - -UBSceneThumbnailNavigPixmap::UBSceneThumbnailNavigPixmap(const QPixmap& pix, UBDocumentProxy* proxy, int pSceneIndex) - : UBSceneThumbnailPixmap(pix, proxy, pSceneIndex) - , bButtonsVisible(false) - , bCanDelete(false) - , bCanMoveUp(false) - , bCanMoveDown(false) -{ - setAcceptsHoverEvents(true); - setFlag(QGraphicsItem::ItemIsSelectable, true); -} - -UBSceneThumbnailNavigPixmap::~UBSceneThumbnailNavigPixmap() -{ - -} - -void UBSceneThumbnailNavigPixmap::hoverEnterEvent(QGraphicsSceneHoverEvent *event) -{ - event->accept(); - updateButtonsState(); - update(); -} - -void UBSceneThumbnailNavigPixmap::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - event->accept(); - bButtonsVisible = false; - update(); -} - -void UBSceneThumbnailNavigPixmap::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - Q_UNUSED(option); - Q_UNUSED(widget); - - UBSceneThumbnailPixmap::paint(painter, option, widget); - if(bButtonsVisible) - { - if(bCanDelete) - painter->drawPixmap(0, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/close.svg")); - else - painter->drawPixmap(0, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/closeDisabled.svg")); - if(bCanMoveUp) - painter->drawPixmap(BUTTONSIZE + BUTTONSPACING, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/moveUp.svg")); - else - painter->drawPixmap(BUTTONSIZE + BUTTONSPACING, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/moveUpDisabled.svg")); - if(bCanMoveDown) - painter->drawPixmap(2*(BUTTONSIZE + BUTTONSPACING), 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/menu.svg")); - else - painter->drawPixmap(2*(BUTTONSIZE + BUTTONSPACING), 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/menuDisabled.svg")); - } -} - -void UBSceneThumbnailNavigPixmap::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - QPointF p = event->pos(); - - // Here we check the position of the click and verify if it has to trig an action or not. - if(bCanDelete && p.x() >= 0 && p.x() <= BUTTONSIZE && p.y() >= 0 && p.y() <= BUTTONSIZE) - { - deletePage(); - } - if(bCanMoveUp && p.x() >= BUTTONSIZE + BUTTONSPACING && p.x() <= 2*BUTTONSIZE + BUTTONSPACING && p.y() >= 0 && p.y() <= BUTTONSIZE) - { - moveUpPage(); - } - if(bCanMoveDown && p.x() >= 2*(BUTTONSIZE + BUTTONSPACING) && p.x() <= 2*(BUTTONSIZE + BUTTONSPACING) + BUTTONSIZE && p.y() >= 0 && p.y() <= BUTTONSIZE) - { - moveDownPage(); - } - event->accept(); -} - -void UBSceneThumbnailNavigPixmap::updateButtonsState() -{ - bCanDelete = false; - bCanMoveUp = false; - bCanMoveDown = false; - - UBDocumentProxy* p = proxy(); - if(NULL != p) - { - int iNbPages = p->pageCount(); - if(1 < iNbPages) - { - bCanDelete = true; - if(sceneIndex() > 0) - { - bCanMoveUp = true; - } - if(sceneIndex() != iNbPages - 1) - { - bCanMoveDown = true; - } - } - } - - if(bCanDelete || bCanMoveUp || bCanMoveDown) - { - bButtonsVisible = true; - } -} - -void UBSceneThumbnailNavigPixmap::deletePage() -{ - QList itemsToDelete; - itemsToDelete << this; - - UBApplication::documentController->deletePages(itemsToDelete); -} - -void UBSceneThumbnailNavigPixmap::moveUpPage() -{ - UBApplication::documentController->moveSceneToIndex(proxy(), sceneIndex(), sceneIndex() - 1); -} - -void UBSceneThumbnailNavigPixmap::moveDownPage() -{ - UBApplication::documentController->moveSceneToIndex(proxy(), sceneIndex(), sceneIndex() + 1); -} - -void UBImgTextThumbnailElement::Place(int row, int col, qreal width, qreal height) -{ - int labelSpacing = 0; - if(this->caption) - { - QFontMetrics fm(this->caption->font()); - labelSpacing = UBSettings::thumbnailSpacing + fm.height(); - } - if(this->thumbnail) - { - int w = this->thumbnail->boundingRect().width(); - int h = this->thumbnail->boundingRect().height(); - - qreal scaleWidth = width / w; - qreal scaleHeight = height / h; - qreal scaleFactor = qMin(scaleWidth, scaleHeight); - UBThumbnail* pix = dynamic_cast(this->thumbnail); - - if(pix) - { - scaleFactor = qMin(scaleFactor, 1.0); - } - - QTransform transform; - transform.scale(scaleFactor, scaleFactor); - - // Apply the scaling - this->thumbnail->setTransform(transform); - this->thumbnail->setFlag(QGraphicsItem::ItemIsSelectable, true); - - if(pix) - { - pix->setColumn(col); - pix->setRow(row); - } - - QPointF pos(border + (width - w * scaleFactor) / 2 + col * (width + border), - border + row * (height + border + labelSpacing) + (height - h * scaleFactor) / 2); - - this->thumbnail->setPos(pos); - - if(this->caption) - { - QFontMetrics fm(this->caption->font()); - QString elidedText = fm.elidedText(this->caption->toPlainText(), Qt::ElideRight, width); - - this->caption->setPlainText(elidedText); - this->caption->setWidth(fm.width(elidedText) + 2 * this->caption->document()->documentMargin()); - pos.setY(pos.y() + (height + h * scaleFactor) / 2 + 5); // What is this 5 ?? - qreal labelWidth = fm.width(elidedText); - pos.setX(border + (width - labelWidth) / 2 + col * (width + border)); - this->caption->setPos(pos); - } - } -} +/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include +#include + +#include "UBThumbnailWidget.h" +#include "UBRubberBand.h" + +#include "core/UBSettings.h" +#include "core/UBApplication.h" + +#include "document/UBDocumentProxy.h" +#include "document/UBDocumentController.h" + +#include "core/memcheck.h" + +UBThumbnailWidget::UBThumbnailWidget(QWidget* parent) + : QGraphicsView(parent) + , mThumbnailWidth(UBSettings::defaultThumbnailWidth) + , mSpacing(UBSettings::thumbnailSpacing) + , mLastSelectedThumbnail(0) + , mSelectionSpan(0) + , mLassoRectItem(0) +{ + // By default, the drag is possible + bCanDrag = true; + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing); + setFrameShape(QFrame::NoFrame); + setScene(&mThumbnailsScene); + + setAlignment(Qt::AlignLeft | Qt::AlignTop); + + connect(&mThumbnailsScene, SIGNAL(selectionChanged()), this, SLOT(sceneSelectionChanged())); +} + + +UBThumbnailWidget::~UBThumbnailWidget() +{ + disconnect(&mThumbnailsScene, SIGNAL(selectionChanged())); +} + + +void UBThumbnailWidget::setThumbnailWidth(qreal pThumbnailWidth) +{ + mThumbnailWidth = pThumbnailWidth; + + refreshScene(); +} + + +void UBThumbnailWidget::setSpacing(qreal pSpacing) +{ + mSpacing = pSpacing; + + refreshScene(); +} + + +void UBThumbnailWidget::setGraphicsItems(const QList& pGraphicsItems + , const QList& pItemsPaths + , const QStringList pLabels + , const QString& pMimeType) +{ + mGraphicItems = pGraphicsItems; + mItemsPaths = pItemsPaths; + mMimeType = pMimeType; + mLabels = pLabels; + + foreach(QGraphicsItem* it, mThumbnailsScene.items()) + { + mThumbnailsScene.removeItem(it, true); + } + + // set lasso to 0 as it has been cleared as well + mLassoRectItem = 0; + + foreach (QGraphicsItem* item, pGraphicsItems) + { + if (item->scene() != &mThumbnailsScene) + { + mThumbnailsScene.addItem(item); + } + } + + mLabelsItems.clear(); + + foreach (const QString label, pLabels) + { + QFontMetrics fm(font()); + UBThumbnailTextItem *labelItem = + new UBThumbnailTextItem(label); // deleted while replace or by the scene destruction + + mThumbnailsScene.addItem(labelItem); + mLabelsItems << labelItem; + } + + refreshScene(); + + mLastSelectedThumbnail = 0; +} + + +void UBThumbnailWidget::refreshScene() +{ + int nbColumns = (geometry().width() - mSpacing) / (mThumbnailWidth + mSpacing); + + int labelSpacing = 0; + + if (mLabelsItems.size() > 0) + { + QFontMetrics fm(mLabelsItems.at(0)->font()); + labelSpacing = UBSettings::thumbnailSpacing + fm.height(); // TODO UB 4.x where is 20 from ??? configure ?? compute based on mSpacing ?? JBA Is it the font height? + } + nbColumns = qMax(nbColumns, 1); + + qreal thumbnailHeight = mThumbnailWidth / UBSettings::minScreenRatio; + + for (int i = 0; i < mGraphicItems.size(); i++) + { + QGraphicsItem* item = mGraphicItems.at(i); + + qreal scaleWidth = mThumbnailWidth / item->boundingRect().width(); + qreal scaleHeight = thumbnailHeight / item->boundingRect().height(); + + qreal scaleFactor = qMin(scaleWidth, scaleHeight); + + //bitmap should not be stretched + UBThumbnail* pix = dynamic_cast(item); + if (pix) + scaleFactor = qMin(scaleFactor, 1.0); + + QTransform transform; + transform.scale(scaleFactor, scaleFactor); + + item->setTransform(transform); + + item->setFlag(QGraphicsItem::ItemIsSelectable, true); + + int columnIndex = i % nbColumns; + int rowIndex = i / nbColumns; + + if (pix) + { + pix->setColumn(columnIndex); + pix->setRow(rowIndex); + } + + int w = item->boundingRect().width(); + int h = item->boundingRect().height(); + QPointF pos( + mSpacing + (mThumbnailWidth - w * scaleFactor) / 2 + columnIndex * (mThumbnailWidth + mSpacing), + mSpacing + rowIndex * (thumbnailHeight + mSpacing + labelSpacing) + (thumbnailHeight - h * scaleFactor) / 2); + + item->setPos(pos); + + if (mLabelsItems.size() > i) + { + QFontMetrics fm(mLabelsItems.at(i)->font(), this); + QString elidedText = fm.elidedText(mLabels.at(i), Qt::ElideRight, mThumbnailWidth); + + mLabelsItems.at(i)->setPlainText(elidedText); + mLabelsItems.at(i)->setWidth(fm.width(elidedText) + 2 * mLabelsItems.at(i)->document()->documentMargin()); + + pos.setY(pos.y() + (thumbnailHeight + h * scaleFactor) / 2 + 5); + qreal labelWidth = fm.width(elidedText); + pos.setX(mSpacing + (mThumbnailWidth - labelWidth) / 2 + columnIndex * (mThumbnailWidth + mSpacing)); + mLabelsItems.at(i)->setPos(pos); + } + } + + QScrollBar *vertScrollBar = verticalScrollBar(); + int scrollBarThickness = 0; + if (vertScrollBar && vertScrollBar->isVisible()) + scrollBarThickness = vertScrollBar->width(); + + setSceneRect(0, 0, + geometry().width() - scrollBarThickness, + mSpacing + ((((mGraphicItems.size() - 1) / nbColumns) + 1) * (thumbnailHeight + mSpacing + labelSpacing))); +} + + +QList UBThumbnailWidget::selectedItems() +{ + QList sortedSelectedItems = mThumbnailsScene.selectedItems(); + qSort(sortedSelectedItems.begin(), sortedSelectedItems.end(), thumbnailLessThan); + return sortedSelectedItems; +} + + +void UBThumbnailWidget::mousePressEvent(QMouseEvent *event) +{ + mClickTime = QTime::currentTime(); + mMousePressPos = event->pos(); + mMousePressScenePos = mapToScene(mMousePressPos); + QGraphicsItem* underlyingItem = itemAt(mMousePressPos); + + UBThumbnail *previousSelectedThumbnail = mLastSelectedThumbnail; + + if (!dynamic_cast(underlyingItem)) + { + deleteLasso(); + + UBRubberBand rubberBand(QRubberBand::Rectangle); + QStyleOption option; + option.initFrom(&rubberBand); + + mLassoRectItem = new QGraphicsRectItem(0, scene()); + +#ifdef Q_WS_MAC + // The following code must stay in synch with \src\gui\styles\qmacstyle_mac.mm + QColor strokeColor; + strokeColor.setHsvF(0, 0, 0.86, 1.0); + mLassoRectItem->setPen(QPen(strokeColor)); + QColor fillColor(option.palette.color(QPalette::Disabled, QPalette::Highlight)); + fillColor.setHsvF(0, 0, 0.53, 0.25); + mLassoRectItem->setBrush(fillColor); +#else + // The following code must stay in synch with \src\gui\styles\qwindowsxpstyle.cpp + QColor highlight = option.palette.color(QPalette::Active, QPalette::Highlight); + mLassoRectItem->setPen(highlight.darker(120)); + QColor dimHighlight(qMin(highlight.red() / 2 + 110, 255), + qMin(highlight.green() / 2 + 110, 255), + qMin(highlight.blue() / 2 + 110, 255), + 127); + mLassoRectItem->setBrush(dimHighlight); +#endif + + mLassoRectItem->setZValue(10000); + mLassoRectItem->setRect(QRectF(mMousePressScenePos, QSizeF())); + + if (Qt::ControlModifier & event->modifiers() || Qt::ShiftModifier & event->modifiers()) + { + // mSelectedThumbnailItems = selectedItems().toSet(); + return; + } + + mSelectedThumbnailItems.clear(); + QGraphicsView::mousePressEvent(event); + } + else if (Qt::ShiftModifier & event->modifiers()) + { + if (previousSelectedThumbnail) + { + QGraphicsItem* previousSelectedItem = dynamic_cast(previousSelectedThumbnail); + if (previousSelectedItem) + { + int index1 = mGraphicItems.indexOf(previousSelectedItem); + int index2 = mGraphicItems.indexOf(underlyingItem); + if (-1 == index2) + { + mSelectedThumbnailItems = selectedItems().toSet(); + return; + } + mSelectionSpan = index2 - index1; + selectItems(qMin(index1, index2), mSelectionSpan < 0 ? - mSelectionSpan + 1 : mSelectionSpan + 1); + return; + } + } + } + else + { + mLastSelectedThumbnail = dynamic_cast(underlyingItem); + if (!underlyingItem->isSelected()) + { + int index = mGraphicItems.indexOf(underlyingItem); + selectItemAt(index, Qt::ControlModifier & event->modifiers()); + } + else + { + QGraphicsView::mousePressEvent(event); + } + if (!mLastSelectedThumbnail && mGraphicItems.count() > 0) + mLastSelectedThumbnail = dynamic_cast(mGraphicItems.at(0)); + mSelectionSpan = 0; + return; + } +} + + +void UBThumbnailWidget::mouseMoveEvent(QMouseEvent *event) +{ + int distance = (mMousePressPos - event->pos()).manhattanLength(); + + if (0 == (event->buttons() & Qt::LeftButton) || distance < QApplication::startDragDistance()) + return; + + if (mLassoRectItem) + { + bSelectionInProgress = true; + int incrementLassoMinWidth = 2; + QPointF currentScenePos = mapToScene(event->pos()); + QRectF lassoRect( + qMin(mMousePressScenePos.x(), currentScenePos.x()), qMin(mMousePressScenePos.y(), currentScenePos.y()), + qAbs(mMousePressScenePos.x() - currentScenePos.x()), qAbs(mMousePressScenePos.y() - currentScenePos.y())); + QRectF incrementXSelection( + qMin(prevMoveMousePos.x(), currentScenePos.x()), qMin(mMousePressScenePos.y(), currentScenePos.y()), + qAbs(prevMoveMousePos.x() - currentScenePos.x())+incrementLassoMinWidth, qAbs(mMousePressScenePos.y() - currentScenePos.y())); + QRectF incrementYSelection( + qMin(mMousePressScenePos.x(), currentScenePos.x()), qMin(prevMoveMousePos.y(), currentScenePos.y()), + qAbs(mMousePressScenePos.x() - currentScenePos.x()), qAbs(prevMoveMousePos.y() - currentScenePos.y())+incrementLassoMinWidth); + + prevMoveMousePos = currentScenePos; + mLassoRectItem->setRect(lassoRect); + + + QSet incSelectedItems = scene()->items(incrementXSelection, Qt::IntersectsItemBoundingRect).toSet() + + scene()->items(incrementYSelection, Qt::IntersectsItemBoundingRect).toSet(); + + mPreviouslyIncrementalSelectedItems = incSelectedItems; + QSet lassoSelectedItems; + QSet lassoSelectedThumbnailItems; + foreach (QGraphicsItem *lassoSelectedItem, incSelectedItems) + { + if (lassoSelectedItem) + { + UBSceneThumbnailPixmap *thumbnailItem = dynamic_cast(lassoSelectedItem); + + if (thumbnailItem) + { + lassoSelectedItem->setSelected(true); + lassoSelectedThumbnailItems += lassoSelectedItem; + } + } + } + + QSet toUnset; + toUnset = mSelectedThumbnailItems - lassoSelectedThumbnailItems; + foreach(QGraphicsItem* item, toUnset) + { + item->setSelected(false); + } + + + mSelectedThumbnailItems += lassoSelectedItems; + // foreach (QGraphicsItem *lassoSelectedItem, lassoSelectedThumbnailItems) + { + + } + if (Qt::ControlModifier & event->modifiers()) + { + for (int i = 0; i < mSelectedThumbnailItems.count()-1; i++) + { + mSelectedThumbnailItems.values().at(i)->setSelected(true); + } + // foreach (QGraphicsItem *selectedItem, mSelectedThumbnailItems) + { + // selectedItem->setSelected(true); + } + } + } + else + { + bSelectionInProgress = false; + if (0 == selectedItems().size()) + return; + + if(bCanDrag) + { + QDrag *drag = new QDrag(this); + QMimeData *mime = new QMimeData(); + + if (mMimeType.length() > 0) + mime->setData(mMimeType, QByteArray()); // trick the d&d system to register our own mime type + + drag->setMimeData(mime); + + QList qlElements; + + foreach (QGraphicsItem* item, selectedItems()) + { + if (mGraphicItems.contains(item)) + { + if (mGraphicItems.indexOf(item) <= mItemsPaths.size()){ + qlElements << mItemsPaths.at(mGraphicItems.indexOf(item)); + } + } + } + + if (qlElements.size() > 0){ + mime->setUrls(qlElements); + drag->setMimeData(mime); + drag->exec(Qt::CopyAction); + } + } + } + + QGraphicsView::mouseMoveEvent(event); +} + + +void UBThumbnailWidget::mouseReleaseEvent(QMouseEvent *event) +{ + int elapsedTimeSincePress = mClickTime.elapsed(); + deleteLasso(); + QGraphicsView::mouseReleaseEvent(event); + + if(elapsedTimeSincePress < STARTDRAGTIME) { + emit mouseClick(itemAt(event->pos()), 0); + } +} + + +void UBThumbnailWidget::keyPressEvent(QKeyEvent *event) +{ + if (mLastSelectedThumbnail) + { + QGraphicsItem *lastSelectedGraphicsItem = dynamic_cast(mLastSelectedThumbnail); + if (!lastSelectedGraphicsItem) return; + int startSelectionIndex = mGraphicItems.indexOf(lastSelectedGraphicsItem); + int previousSelectedThumbnailIndex = startSelectionIndex + mSelectionSpan; + + switch (event->key()) + { + case Qt::Key_Down: + case Qt::Key_Up: + { + if (rowCount() <= 1) break; + if (Qt::ShiftModifier & event->modifiers()) + { + int endSelectionIndex; + if (Qt::Key_Down == event->key()) + { + endSelectionIndex = previousSelectedThumbnailIndex + columnCount(); + if (endSelectionIndex >= mGraphicItems.count()) break; + } + else + { + endSelectionIndex = previousSelectedThumbnailIndex - columnCount(); + if (endSelectionIndex < 0) break; + } + + int startIndex = startSelectionIndex < endSelectionIndex ? startSelectionIndex : endSelectionIndex; + int count = startSelectionIndex < endSelectionIndex ? endSelectionIndex - startSelectionIndex + 1 : startSelectionIndex - endSelectionIndex + 1; + mSelectionSpan = startSelectionIndex < endSelectionIndex ? (count - 1) : - (count - 1); + selectItems(startIndex, count); + } + else + { + int toSelectIndex; + if (Qt::Key_Down == event->key()) + { + toSelectIndex = previousSelectedThumbnailIndex + columnCount(); + if (toSelectIndex >= mGraphicItems.count()) break; + } + else + { + toSelectIndex = previousSelectedThumbnailIndex - columnCount(); + if (toSelectIndex < 0) break; + } + + selectItemAt(toSelectIndex, Qt::ControlModifier & event->modifiers()); + mSelectionSpan = 0; + } + } + break; + + case Qt::Key_Left: + case Qt::Key_Right: + { + QGraphicsItem *previousSelectedItem = mGraphicItems.at(previousSelectedThumbnailIndex); + UBThumbnail *previousSelectedThumbnail = dynamic_cast(previousSelectedItem); + if (!previousSelectedThumbnail) break; + + if (Qt::Key_Left == event->key()) + { + if (0 == previousSelectedThumbnail->column()) break; + } + else + { + if (previousSelectedThumbnail->column() == columnCount() - 1 || + previousSelectedThumbnailIndex == mGraphicItems.count() - 1) break; + } + + if (Qt::ShiftModifier & event->modifiers()) + { + int endSelectionIndex; + if (Qt::Key_Left == event->key()) + { + endSelectionIndex = previousSelectedThumbnailIndex - 1; + if (endSelectionIndex < 0) break; + } + else + { + endSelectionIndex = previousSelectedThumbnailIndex + 1; + if (endSelectionIndex >= mGraphicItems.count()) break; + } + + int startIndex = startSelectionIndex < endSelectionIndex ? startSelectionIndex : endSelectionIndex; + int count = startSelectionIndex < endSelectionIndex ? endSelectionIndex - startSelectionIndex + 1 : startSelectionIndex - endSelectionIndex + 1; + mSelectionSpan = startSelectionIndex < endSelectionIndex ? (count - 1) : - (count - 1); + selectItems(startIndex, count); + } + else + { + if (Qt::Key_Left == event->key()) + selectItemAt(previousSelectedThumbnailIndex - 1, Qt::ControlModifier & event->modifiers()); + else + selectItemAt(previousSelectedThumbnailIndex + 1, Qt::ControlModifier & event->modifiers()); + + mSelectionSpan = 0; + } + } + break; + + case Qt::Key_Home: + { + if (Qt::ShiftModifier & event->modifiers()) + { + mSelectionSpan = - startSelectionIndex; + selectItems(0, startSelectionIndex + 1); + } + else + { + selectItemAt(0, Qt::ControlModifier & event->modifiers()); + mSelectionSpan = 0; + } + } + break; + + case Qt::Key_End: + { + if (Qt::ShiftModifier & event->modifiers()) + { + mSelectionSpan = mGraphicItems.count() - startSelectionIndex - 1; + selectItems(startSelectionIndex, mSelectionSpan + 1); + } + else + { + selectItemAt(mGraphicItems.count() - 1, Qt::ControlModifier & event->modifiers()); + mSelectionSpan = 0; + } + } + break; + case Qt::Key_A: + { + if (Qt::ControlModifier & event->modifiers()) + selectAll(); + } + break; + } + } + QGraphicsView::keyPressEvent(event); +} + + +void UBThumbnailWidget::focusInEvent(QFocusEvent *event) +{ + Q_UNUSED(event); + + if (0 == selectedItems().count() && mGraphicItems.count() > 0 && Qt::TabFocusReason == event->reason()) + { + selectItemAt(0); + mSelectionSpan = 0; + } +} + + +void UBThumbnailWidget::resizeEvent(QResizeEvent *event) +{ + Q_UNUSED(event); + + refreshScene(); + + emit resized(); +} + + +void UBThumbnailWidget::sceneSelectionChanged() +{ + emit selectionChanged(); +} + + +void UBThumbnailWidget::selectItemAt(int pIndex, bool extend) +{ + QGraphicsItem* itemToSelect = 0; + + if (pIndex >= 0 && pIndex < mGraphicItems.size()) + itemToSelect = mGraphicItems.at(pIndex); + + foreach (QGraphicsItem* item, items()) + { + if (item == itemToSelect) + { + mLastSelectedThumbnail = dynamic_cast(item); + item->setSelected(true); + ensureVisible(item); + } + else if (!extend) + { + item->setSelected(false); + } + } +} + +void UBThumbnailWidget::unselectItemAt(int pIndex) +{ + if (pIndex >= 0 && pIndex < mGraphicItems.size()) + { + QGraphicsItem *itemToUnselect = mGraphicItems.at(pIndex); + itemToUnselect->setSelected(false); + } +} + + +void UBThumbnailWidget::selectItems(int startIndex, int count) +{ + for (int i = 0; i < mGraphicItems.count(); i++) + { + mGraphicItems.at(i)->setSelected(i >= startIndex && i < startIndex + count); + } +} + + +void UBThumbnailWidget::selectAll() +{ + foreach (QGraphicsItem* item, mGraphicItems) + { + item->setSelected(true); + } +} + +int UBThumbnailWidget::rowCount() const +{ + UBThumbnail *lastThumbnail = dynamic_cast(mGraphicItems.last()); + return lastThumbnail ? lastThumbnail->row() + 1 : 0; +} + +int UBThumbnailWidget::columnCount() const +{ + UBThumbnail *lastThumbnail = dynamic_cast(mGraphicItems.last()); + if (!lastThumbnail) return 0; + int lastRow = lastThumbnail->row(); + int lastColumn = lastThumbnail->column(); + return lastRow > 0 ? (mGraphicItems.count() - lastColumn - 1) / lastRow : mGraphicItems.count(); +} + + +void UBThumbnailWidget::mouseDoubleClickEvent(QMouseEvent * event) +{ + QGraphicsItem* item = itemAt(event->pos()); + + if (item) + { + int index = mGraphicItems.indexOf(item); + emit mouseDoubleClick(item, index); + } +} + + +bool UBThumbnailWidget::thumbnailLessThan(QGraphicsItem* item1, QGraphicsItem* item2) +{ + UBThumbnail *thumbnail1 = dynamic_cast(item1); + UBThumbnail *thumbnail2 = dynamic_cast(item2); + if (thumbnail1 && thumbnail2) + { + if (thumbnail1->row() != thumbnail2->row()) + return thumbnail1->row() < thumbnail2->row(); + else + return thumbnail1->column() < thumbnail2->column(); + } + return false; +} + +void UBThumbnailWidget::deleteLasso() +{ + if (mLassoRectItem && scene()) + { + scene()->removeItem(mLassoRectItem); + delete mLassoRectItem; + mLassoRectItem = 0; + } +} + + +UBThumbnail::UBThumbnail() + : mAddedToScene(false) +{ + mSelectionItem = new QGraphicsRectItem(0, 0, 0, 0); + mSelectionItem->setPen(QPen(UBSettings::treeViewBackgroundColor, 8)); + // TODO UB 4.x fix nasty dependencies : 8 is a bit less than half of UBThumbnailWidget.mSpacing +} + +UBThumbnail::~UBThumbnail() +{ + if (mSelectionItem && !mAddedToScene) + delete mSelectionItem; +} + + +UBSceneThumbnailNavigPixmap::UBSceneThumbnailNavigPixmap(const QPixmap& pix, UBDocumentProxy* proxy, int pSceneIndex) + : UBSceneThumbnailPixmap(pix, proxy, pSceneIndex) + , bButtonsVisible(false) + , bCanDelete(false) + , bCanMoveUp(false) + , bCanMoveDown(false) +{ + setAcceptsHoverEvents(true); + setFlag(QGraphicsItem::ItemIsSelectable, true); +} + +UBSceneThumbnailNavigPixmap::~UBSceneThumbnailNavigPixmap() +{ + +} + +void UBSceneThumbnailNavigPixmap::hoverEnterEvent(QGraphicsSceneHoverEvent *event) +{ + event->accept(); + updateButtonsState(); + update(); +} + +void UBSceneThumbnailNavigPixmap::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +{ + event->accept(); + bButtonsVisible = false; + update(); +} + +void UBSceneThumbnailNavigPixmap::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + Q_UNUSED(option); + Q_UNUSED(widget); + + UBSceneThumbnailPixmap::paint(painter, option, widget); + if(bButtonsVisible) + { + if(bCanDelete) + painter->drawPixmap(0, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/close.svg")); + else + painter->drawPixmap(0, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/closeDisabled.svg")); + if(bCanMoveUp) + painter->drawPixmap(BUTTONSIZE + BUTTONSPACING, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/moveUp.svg")); + else + painter->drawPixmap(BUTTONSIZE + BUTTONSPACING, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/moveUpDisabled.svg")); + if(bCanMoveDown) + painter->drawPixmap(2*(BUTTONSIZE + BUTTONSPACING), 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/menu.svg")); + else + painter->drawPixmap(2*(BUTTONSIZE + BUTTONSPACING), 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/menuDisabled.svg")); + } +} + +void UBSceneThumbnailNavigPixmap::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + QPointF p = event->pos(); + + // Here we check the position of the click and verify if it has to trig an action or not. + if(bCanDelete && p.x() >= 0 && p.x() <= BUTTONSIZE && p.y() >= 0 && p.y() <= BUTTONSIZE) + { + deletePage(); + } + if(bCanMoveUp && p.x() >= BUTTONSIZE + BUTTONSPACING && p.x() <= 2*BUTTONSIZE + BUTTONSPACING && p.y() >= 0 && p.y() <= BUTTONSIZE) + { + moveUpPage(); + } + if(bCanMoveDown && p.x() >= 2*(BUTTONSIZE + BUTTONSPACING) && p.x() <= 2*(BUTTONSIZE + BUTTONSPACING) + BUTTONSIZE && p.y() >= 0 && p.y() <= BUTTONSIZE) + { + moveDownPage(); + } + event->accept(); +} + +void UBSceneThumbnailNavigPixmap::updateButtonsState() +{ + bCanDelete = false; + bCanMoveUp = false; + bCanMoveDown = false; + + UBDocumentProxy* p = proxy(); + if(NULL != p) + { + int iNbPages = p->pageCount(); + if(1 < iNbPages) + { + bCanDelete = true; + if(sceneIndex() > 0) + { + bCanMoveUp = true; + } + if(sceneIndex() != iNbPages - 1) + { + bCanMoveDown = true; + } + } + } + + if(bCanDelete || bCanMoveUp || bCanMoveDown) + { + bButtonsVisible = true; + } +} + +void UBSceneThumbnailNavigPixmap::deletePage() +{ + QList itemsToDelete; + itemsToDelete << this; + + UBApplication::documentController->deletePages(itemsToDelete); +} + +void UBSceneThumbnailNavigPixmap::moveUpPage() +{ + UBApplication::documentController->moveSceneToIndex(proxy(), sceneIndex(), sceneIndex() - 1); +} + +void UBSceneThumbnailNavigPixmap::moveDownPage() +{ + UBApplication::documentController->moveSceneToIndex(proxy(), sceneIndex(), sceneIndex() + 1); +} + +void UBImgTextThumbnailElement::Place(int row, int col, qreal width, qreal height) +{ + int labelSpacing = 0; + if(this->caption) + { + QFontMetrics fm(this->caption->font()); + labelSpacing = UBSettings::thumbnailSpacing + fm.height(); + } + if(this->thumbnail) + { + int w = this->thumbnail->boundingRect().width(); + int h = this->thumbnail->boundingRect().height(); + + qreal scaleWidth = width / w; + qreal scaleHeight = height / h; + qreal scaleFactor = qMin(scaleWidth, scaleHeight); + UBThumbnail* pix = dynamic_cast(this->thumbnail); + + if(pix) + { + scaleFactor = qMin(scaleFactor, 1.0); + } + + QTransform transform; + transform.scale(scaleFactor, scaleFactor); + + // Apply the scaling + this->thumbnail->setTransform(transform); + this->thumbnail->setFlag(QGraphicsItem::ItemIsSelectable, true); + + if(pix) + { + pix->setColumn(col); + pix->setRow(row); + } + + QPointF pos(border + (width - w * scaleFactor) / 2 + col * (width + border), + border + row * (height + border + labelSpacing) + (height - h * scaleFactor) / 2); + + this->thumbnail->setPos(pos); + + if(this->caption) + { + QFontMetrics fm(this->caption->font()); + QString elidedText = fm.elidedText(this->caption->toPlainText(), Qt::ElideRight, width); + + this->caption->setPlainText(elidedText); + this->caption->setWidth(fm.width(elidedText) + 2 * this->caption->document()->documentMargin()); + pos.setY(pos.y() + (height + h * scaleFactor) / 2 + 5); // What is this 5 ?? + qreal labelWidth = fm.width(elidedText); + pos.setX(border + (width - labelWidth) / 2 + col * (width + border)); + this->caption->setPos(pos); + } + } +} diff --git a/src/gui/UBThumbnailWidget.h b/src/gui/UBThumbnailWidget.h index e00029c5..2ad70c37 100644 --- a/src/gui/UBThumbnailWidget.h +++ b/src/gui/UBThumbnailWidget.h @@ -1,421 +1,423 @@ -/* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef UBTHUMBNAILWIDGET_H_ -#define UBTHUMBNAILWIDGET_H_ - -#include -#include -#include -#include - -#include "frameworks/UBCoreGraphicsScene.h" -#include "core/UBSettings.h" -#include "domain/UBItem.h" - -#define STARTDRAGTIME 1000000 -#define BUTTONSIZE 48 -#define BUTTONSPACING 5 - -class UBDocumentProxy; -class UBThumbnailTextItem; -class UBThumbnail; - -class UBThumbnailWidget : public QGraphicsView -{ - Q_OBJECT; - - public: - UBThumbnailWidget(QWidget* parent); - virtual ~UBThumbnailWidget(); - - QList selectedItems(); - void selectItemAt(int pIndex, bool extend = false); - void unselectItemAt(int pIndex); - - qreal thumbnailWidth() - { - return mThumbnailWidth; - } - - void setBackgroundBrush(const QBrush& brush) - { - mThumbnailsScene.setBackgroundBrush(brush); - } - - public slots: - void setThumbnailWidth(qreal pThumbnailWidth); - void setSpacing(qreal pSpacing); - virtual void setGraphicsItems(const QList& pGraphicsItems, const QList& pItemPaths, const QStringList pLabels = QStringList(), const QString& pMimeType = QString("")); - void refreshScene(); - void sceneSelectionChanged(); - - signals: - void resized(); - void selectionChanged(); - void mouseDoubleClick(QGraphicsItem* item, int index); - void mouseClick(QGraphicsItem* item, int index); - - - protected: - virtual void mousePressEvent(QMouseEvent *event); - virtual void mouseMoveEvent(QMouseEvent *event); - virtual void mouseReleaseEvent(QMouseEvent *event); - virtual void resizeEvent(QResizeEvent * event); - void mouseDoubleClickEvent(QMouseEvent * event); - - virtual void keyPressEvent(QKeyEvent *event); - virtual void focusInEvent(QFocusEvent *event); - - QList mGraphicItems; - QList mLabelsItems; - QPointF mMousePressScenePos; - QPoint mMousePressPos; - - protected: - qreal spacing() { return mSpacing; } - QList mItemsPaths; - QStringList mLabels; - bool bSelectionInProgress; - bool bCanDrag; - - private: - void selectAll(); - void unselectAll(); - void selectItems(int startIndex, int count); - int rowCount() const; - int columnCount() const; - - static bool thumbnailLessThan(QGraphicsItem* item1, QGraphicsItem* item2); - - void deleteLasso(); - - UBCoreGraphicsScene mThumbnailsScene; - - QString mMimeType; - - qreal mThumbnailWidth; - qreal mThumbnailHeight; - qreal mSpacing; - - UBThumbnail *mLastSelectedThumbnail; - int mSelectionSpan; - QGraphicsRectItem *mLassoRectItem; - QList mSelectedThumbnailItems; - QTime mClickTime; -}; - - -class UBThumbnail -{ - public: - UBThumbnail(); - - virtual ~UBThumbnail(); - - QStyleOptionGraphicsItem muteStyleOption(const QStyleOptionGraphicsItem *option) - { - // Never draw the rubber band, we draw our custom selection with the DelegateFrame - QStyleOptionGraphicsItem styleOption = QStyleOptionGraphicsItem(*option); - styleOption.state &= ~QStyle::State_Selected; - - return styleOption; - } - - virtual void itemChange(QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const QVariant &value) - { - Q_UNUSED(value); - - if ((change == QGraphicsItem::ItemSelectedHasChanged - || change == QGraphicsItem::ItemTransformHasChanged - || change == QGraphicsItem::ItemPositionHasChanged) - && item->scene()) - { - if (item->isSelected()) - { - if (!mSelectionItem->scene()) - { - item->scene()->addItem(mSelectionItem); - mSelectionItem->setZValue(item->zValue() - 1); -// UBGraphicsItem::assignZValue(mSelectionItem, item->zValue() - 1); - mAddedToScene = true; - } - - mSelectionItem->setRect( - item->sceneBoundingRect().x() - 5, - item->sceneBoundingRect().y() - 5, - item->sceneBoundingRect().width() + 10, - item->sceneBoundingRect().height() + 10); - - mSelectionItem->show(); - - } - else - { - mSelectionItem->hide(); - } - } - } - - int column() { return mColumn; } - void setColumn(int column) { mColumn = column; } - int row() { return mRow; } - void setRow(int row) { mRow = row; } - - protected: - QGraphicsRectItem *mSelectionItem; - private: - bool mAddedToScene; - - int mColumn; - int mRow; -}; - - -class UBThumbnailSvg : public QGraphicsSvgItem, public UBThumbnail -{ - public: - UBThumbnailSvg(const QString& path) - : QGraphicsSvgItem(path) - { - setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); - } - - virtual ~UBThumbnailSvg() - { - // NOOP - } - - virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) - { - QStyleOptionGraphicsItem styleOption = UBThumbnail::muteStyleOption(option); - QGraphicsSvgItem::paint(painter, &styleOption, widget); - } - - virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) - { - UBThumbnail::itemChange(this, change, value); - return QGraphicsSvgItem::itemChange(change, value); - } - -}; - - -class UBThumbnailPixmap : public QGraphicsPixmapItem, public UBThumbnail -{ - public: - UBThumbnailPixmap(const QPixmap& pix) - : QGraphicsPixmapItem(pix) - { - setTransformationMode(Qt::SmoothTransformation); // UB 4.3 may be expensive -- make configurable - setShapeMode(QGraphicsPixmapItem::BoundingRectShape); - setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); - } - - virtual ~UBThumbnailPixmap() - { - // NOOP - } - - virtual QPainterPath shape () const - { - QPainterPath path; - path.addRect(boundingRect()); - return path; - } - - - virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) - { - QStyleOptionGraphicsItem styleOption = UBThumbnail::muteStyleOption(option); - QGraphicsPixmapItem::paint(painter, &styleOption, widget); - } - - virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) - { - UBThumbnail::itemChange(this, change, value); - return QGraphicsPixmapItem::itemChange(change, value); - } -}; - - -class UBSceneThumbnailPixmap : public UBThumbnailPixmap -{ - public: - UBSceneThumbnailPixmap(const QPixmap& pix, UBDocumentProxy* proxy, int pSceneIndex) - : UBThumbnailPixmap(pix) - , mProxy(proxy) - , mSceneIndex(pSceneIndex) - { - // NOOP - } - - virtual ~UBSceneThumbnailPixmap() - { - // NOOP - } - - UBDocumentProxy* proxy() - { - return mProxy; - } - - int sceneIndex() - { - return mSceneIndex; - } - - void highlight() - { - //NOOP - } - - private: - UBDocumentProxy* mProxy; - int mSceneIndex; -}; - -class UBSceneThumbnailNavigPixmap : public UBSceneThumbnailPixmap -{ - public: - UBSceneThumbnailNavigPixmap(const QPixmap& pix, UBDocumentProxy* proxy, int pSceneIndex); - ~UBSceneThumbnailNavigPixmap(); - - protected: - void hoverEnterEvent(QGraphicsSceneHoverEvent *event); - void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - void mousePressEvent(QGraphicsSceneMouseEvent *event); - - private: - void updateButtonsState(); - void deletePage(); - void moveUpPage(); - void moveDownPage(); - - bool bButtonsVisible; - bool bCanDelete; - bool bCanMoveUp; - bool bCanMoveDown; -}; - -class UBThumbnailVideo : public UBThumbnailPixmap -{ - public: - UBThumbnailVideo(const QUrl &path) - : UBThumbnailPixmap(QPixmap(":/images/movie.svg")) - , mPath(path) - { - // NOOP - } - - virtual ~UBThumbnailVideo() - { - // NOOP - } - - QUrl path() - { - return mPath; - } - - private: - - QUrl mPath; -}; - -class UBThumbnailTextItem : public QGraphicsTextItem -{ - public: - UBThumbnailTextItem(const QString& text) - : QGraphicsTextItem(text) - , mUnelidedText(text) - , mIsHighlighted(false) - { - setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); - } - - QRectF boundingRect() const { return QRectF(QPointF(0.0, 0.0), QSize(mWidth, QFontMetricsF(font()).height() + 5));} - - void setWidth(qreal pWidth) - { - if (mWidth != pWidth) - { - prepareGeometryChange(); - mWidth = pWidth; - computeText(); - } - }; - - qreal width() {return mWidth;} - - void highlight() - { - if (!mIsHighlighted) - { - mIsHighlighted = true; - computeText(); - } - } - - void computeText() - { - QFontMetricsF fm(font()); - QString elidedText = fm.elidedText(mUnelidedText, Qt::ElideRight, mWidth); - - if (mIsHighlighted) - { - setHtml("" + elidedText + ""); - } - else - { - setPlainText(elidedText); - } - } - - private: - qreal mWidth; - QString mUnelidedText; - bool mIsHighlighted; -}; - -class UBImgTextThumbnailElement -{ -private: - QGraphicsItem* thumbnail; - UBThumbnailTextItem* caption; - int border; - -public: - UBImgTextThumbnailElement(QGraphicsItem* thumb, UBThumbnailTextItem* text): border(0) - { - this->thumbnail = thumb; - this->caption = text; - } - - QGraphicsItem* getThumbnail() const { return this->thumbnail; } - void setThumbnail(QGraphicsItem* newGItem) { this->thumbnail = newGItem; } - - UBThumbnailTextItem* getCaption() const { return this->caption; } - void setCaption(UBThumbnailTextItem* newcaption) { this->caption = newcaption; } - - void Place(int row, int col, qreal width, qreal height); - - int getBorder() const { return this->border; } - void setBorder(int newBorder) { this->border = newBorder; } -}; - - -#endif /* UBTHUMBNAILWIDGET_H_ */ +/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef UBTHUMBNAILWIDGET_H_ +#define UBTHUMBNAILWIDGET_H_ + +#include +#include +#include +#include + +#include "frameworks/UBCoreGraphicsScene.h" +#include "core/UBSettings.h" +#include "domain/UBItem.h" + +#define STARTDRAGTIME 1000000 +#define BUTTONSIZE 48 +#define BUTTONSPACING 5 + +class UBDocumentProxy; +class UBThumbnailTextItem; +class UBThumbnail; + +class UBThumbnailWidget : public QGraphicsView +{ + Q_OBJECT; + + public: + UBThumbnailWidget(QWidget* parent); + virtual ~UBThumbnailWidget(); + + QList selectedItems(); + void selectItemAt(int pIndex, bool extend = false); + void unselectItemAt(int pIndex); + + qreal thumbnailWidth() + { + return mThumbnailWidth; + } + + void setBackgroundBrush(const QBrush& brush) + { + mThumbnailsScene.setBackgroundBrush(brush); + } + + public slots: + void setThumbnailWidth(qreal pThumbnailWidth); + void setSpacing(qreal pSpacing); + virtual void setGraphicsItems(const QList& pGraphicsItems, const QList& pItemPaths, const QStringList pLabels = QStringList(), const QString& pMimeType = QString("")); + void refreshScene(); + void sceneSelectionChanged(); + + signals: + void resized(); + void selectionChanged(); + void mouseDoubleClick(QGraphicsItem* item, int index); + void mouseClick(QGraphicsItem* item, int index); + + + protected: + virtual void mousePressEvent(QMouseEvent *event); + virtual void mouseMoveEvent(QMouseEvent *event); + virtual void mouseReleaseEvent(QMouseEvent *event); + virtual void resizeEvent(QResizeEvent * event); + void mouseDoubleClickEvent(QMouseEvent * event); + + virtual void keyPressEvent(QKeyEvent *event); + virtual void focusInEvent(QFocusEvent *event); + + QList mGraphicItems; + QList mLabelsItems; + QPointF mMousePressScenePos; + QPoint mMousePressPos; + + protected: + qreal spacing() { return mSpacing; } + QList mItemsPaths; + QStringList mLabels; + bool bSelectionInProgress; + bool bCanDrag; + + private: + void selectAll(); + void selectItems(int startIndex, int count); + int rowCount() const; + int columnCount() const; + + static bool thumbnailLessThan(QGraphicsItem* item1, QGraphicsItem* item2); + + void deleteLasso(); + + UBCoreGraphicsScene mThumbnailsScene; + + QString mMimeType; + + QPointF prevMoveMousePos; + + qreal mThumbnailWidth; + qreal mThumbnailHeight; + qreal mSpacing; + + UBThumbnail *mLastSelectedThumbnail; + int mSelectionSpan; + QGraphicsRectItem *mLassoRectItem; + QSet mSelectedThumbnailItems; + QSet mPreviouslyIncrementalSelectedItems; + QTime mClickTime; +}; + + +class UBThumbnail +{ + public: + UBThumbnail(); + + virtual ~UBThumbnail(); + + QStyleOptionGraphicsItem muteStyleOption(const QStyleOptionGraphicsItem *option) + { + // Never draw the rubber band, we draw our custom selection with the DelegateFrame + QStyleOptionGraphicsItem styleOption = QStyleOptionGraphicsItem(*option); + styleOption.state &= ~QStyle::State_Selected; + + return styleOption; + } + + virtual void itemChange(QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const QVariant &value) + { + Q_UNUSED(value); + + if ((change == QGraphicsItem::ItemSelectedHasChanged + || change == QGraphicsItem::ItemTransformHasChanged + || change == QGraphicsItem::ItemPositionHasChanged) + && item->scene()) + { + if (item->isSelected()) + { + if (!mSelectionItem->scene()) + { + item->scene()->addItem(mSelectionItem); + mSelectionItem->setZValue(item->zValue() - 1); +// UBGraphicsItem::assignZValue(mSelectionItem, item->zValue() - 1); + mAddedToScene = true; + } + + mSelectionItem->setRect( + item->sceneBoundingRect().x() - 5, + item->sceneBoundingRect().y() - 5, + item->sceneBoundingRect().width() + 10, + item->sceneBoundingRect().height() + 10); + + mSelectionItem->show(); + + } + else + { + mSelectionItem->hide(); + } + } + } + + int column() { return mColumn; } + void setColumn(int column) { mColumn = column; } + int row() { return mRow; } + void setRow(int row) { mRow = row; } + + protected: + QGraphicsRectItem *mSelectionItem; + private: + bool mAddedToScene; + + int mColumn; + int mRow; +}; + + +class UBThumbnailSvg : public QGraphicsSvgItem, public UBThumbnail +{ + public: + UBThumbnailSvg(const QString& path) + : QGraphicsSvgItem(path) + { + setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); + } + + virtual ~UBThumbnailSvg() + { + // NOOP + } + + virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) + { + QStyleOptionGraphicsItem styleOption = UBThumbnail::muteStyleOption(option); + QGraphicsSvgItem::paint(painter, &styleOption, widget); + } + + virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) + { + UBThumbnail::itemChange(this, change, value); + return QGraphicsSvgItem::itemChange(change, value); + } + +}; + + +class UBThumbnailPixmap : public QGraphicsPixmapItem, public UBThumbnail +{ + public: + UBThumbnailPixmap(const QPixmap& pix) + : QGraphicsPixmapItem(pix) + { + setTransformationMode(Qt::SmoothTransformation); // UB 4.3 may be expensive -- make configurable + setShapeMode(QGraphicsPixmapItem::BoundingRectShape); + setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); + } + + virtual ~UBThumbnailPixmap() + { + // NOOP + } + + virtual QPainterPath shape () const + { + QPainterPath path; + path.addRect(boundingRect()); + return path; + } + + + virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) + { + QStyleOptionGraphicsItem styleOption = UBThumbnail::muteStyleOption(option); + QGraphicsPixmapItem::paint(painter, &styleOption, widget); + } + + virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) + { + UBThumbnail::itemChange(this, change, value); + return QGraphicsPixmapItem::itemChange(change, value); + } +}; + + +class UBSceneThumbnailPixmap : public UBThumbnailPixmap +{ + public: + UBSceneThumbnailPixmap(const QPixmap& pix, UBDocumentProxy* proxy, int pSceneIndex) + : UBThumbnailPixmap(pix) + , mProxy(proxy) + , mSceneIndex(pSceneIndex) + { + // NOOP + } + + virtual ~UBSceneThumbnailPixmap() + { + // NOOP + } + + UBDocumentProxy* proxy() + { + return mProxy; + } + + int sceneIndex() + { + return mSceneIndex; + } + + void highlight() + { + //NOOP + } + + private: + UBDocumentProxy* mProxy; + int mSceneIndex; +}; + +class UBSceneThumbnailNavigPixmap : public UBSceneThumbnailPixmap +{ + public: + UBSceneThumbnailNavigPixmap(const QPixmap& pix, UBDocumentProxy* proxy, int pSceneIndex); + ~UBSceneThumbnailNavigPixmap(); + + protected: + void hoverEnterEvent(QGraphicsSceneHoverEvent *event); + void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + void mousePressEvent(QGraphicsSceneMouseEvent *event); + + private: + void updateButtonsState(); + void deletePage(); + void moveUpPage(); + void moveDownPage(); + + bool bButtonsVisible; + bool bCanDelete; + bool bCanMoveUp; + bool bCanMoveDown; +}; + +class UBThumbnailVideo : public UBThumbnailPixmap +{ + public: + UBThumbnailVideo(const QUrl &path) + : UBThumbnailPixmap(QPixmap(":/images/movie.svg")) + , mPath(path) + { + // NOOP + } + + virtual ~UBThumbnailVideo() + { + // NOOP + } + + QUrl path() + { + return mPath; + } + + private: + + QUrl mPath; +}; + +class UBThumbnailTextItem : public QGraphicsTextItem +{ + public: + UBThumbnailTextItem(const QString& text) + : QGraphicsTextItem(text) + , mUnelidedText(text) + , mIsHighlighted(false) + { + setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); + } + + QRectF boundingRect() const { return QRectF(QPointF(0.0, 0.0), QSize(mWidth, QFontMetricsF(font()).height() + 5));} + + void setWidth(qreal pWidth) + { + if (mWidth != pWidth) + { + prepareGeometryChange(); + mWidth = pWidth; + computeText(); + } + }; + + qreal width() {return mWidth;} + + void highlight() + { + if (!mIsHighlighted) + { + mIsHighlighted = true; + computeText(); + } + } + + void computeText() + { + QFontMetricsF fm(font()); + QString elidedText = fm.elidedText(mUnelidedText, Qt::ElideRight, mWidth); + + if (mIsHighlighted) + { + setHtml("" + elidedText + ""); + } + else + { + setPlainText(elidedText); + } + } + + private: + qreal mWidth; + QString mUnelidedText; + bool mIsHighlighted; +}; + +class UBImgTextThumbnailElement +{ +private: + QGraphicsItem* thumbnail; + UBThumbnailTextItem* caption; + int border; + +public: + UBImgTextThumbnailElement(QGraphicsItem* thumb, UBThumbnailTextItem* text): border(0) + { + this->thumbnail = thumb; + this->caption = text; + } + + QGraphicsItem* getThumbnail() const { return this->thumbnail; } + void setThumbnail(QGraphicsItem* newGItem) { this->thumbnail = newGItem; } + + UBThumbnailTextItem* getCaption() const { return this->caption; } + void setCaption(UBThumbnailTextItem* newcaption) { this->caption = newcaption; } + + void Place(int row, int col, qreal width, qreal height); + + int getBorder() const { return this->border; } + void setBorder(int newBorder) { this->border = newBorder; } +}; + + +#endif /* UBTHUMBNAILWIDGET_H_ */ From 3af42770fa135b9032558f4492c822af6d9e33f4 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Thu, 12 Apr 2012 13:22:27 +0200 Subject: [PATCH 06/15] firsts guid improvements for the teacher guide --- resources/sankore.qrc | 5 + resources/style.qss | 64 ++++++++++- src/gui/UBTGWidgetTreeDelegate.cpp | 34 ++++++ src/gui/UBTGWidgetTreeDelegate.h | 35 ++++++ src/gui/UBTeacherGuideWidget.cpp | 147 +++++++++++++++++++------ src/gui/UBTeacherGuideWidget.h | 15 ++- src/gui/UBTeacherGuideWidgetsTools.cpp | 104 +++++++++++++---- src/gui/UBTeacherGuideWidgetsTools.h | 20 +++- src/gui/gui.pri | 6 +- 9 files changed, 361 insertions(+), 69 deletions(-) create mode 100644 src/gui/UBTGWidgetTreeDelegate.cpp create mode 100644 src/gui/UBTGWidgetTreeDelegate.h diff --git a/resources/sankore.qrc b/resources/sankore.qrc index d81ac808..f94729e7 100644 --- a/resources/sankore.qrc +++ b/resources/sankore.qrc @@ -347,5 +347,10 @@ images/licenses/ccbyncsa.png images/licenses/ccbynd.png images/licenses/ccbysa.png + images/teacherGuide/audio.png + images/teacherGuide/image.png + images/teacherGuide/link.png + images/teacherGuide/movie.png + images/teacherGuide/w3c.png diff --git a/resources/style.qss b/resources/style.qss index e68f1f66..38eeecbc 100644 --- a/resources/style.qss +++ b/resources/style.qss @@ -3,7 +3,8 @@ QWidget#documentNavigator, QWidget#UBLibPathViewer, QWidget#UBLibNavigatorWidget, QWidget#UBLibItemProperties, -QWidget#UBDownloadWidget +QWidget#UBDownloadWidget, +QWidget#UBTeacherGuideWidget { background: #EEEEEE; border-radius: 10px; @@ -41,9 +42,11 @@ QLabel#DockPaletteWidgetTitle font-weight:bold; } -QLineEdit#DockPaletteWidgetLineEdit +QLineEdit#UBTGLineEdit, +QLabel#UBTGMediaDropMeLabel { background: white; + border: 1 solid #999999; border-radius : 10px; padding: 2px; } @@ -200,4 +203,59 @@ QSlider::groove::horizontal height:10px; border-radius:5px; border:1px solid #555555; -} \ No newline at end of file +} + +QLabel#UBTGEditionDocumentTitle +{ + color: black; + font-size : 14px; + font-weight:bold; +} + +QLabel#UBTGPresentationDocumentTitle +{ + color: black; + font-size : 12px; + font-weight:bold; +} + +QLabel#UBTGEditionPageNumberLabel +{ + color: black; + font-size : 12px; + font-weight:bold; +} + +QLabel#UBTGPresentationPageNumberLabel +{ + color: black; + font-size : 12px; +} + +UBTGAdaptableText#UBTGEditionPageTitle, +UBTGAdaptableText#UBTGEditionComment +{ + color: black; + font-size : 12px; +} + +UBTGAdaptableText#UBTGPresentationPageTitle +{ + color: black; + font-size:16px; + font-weight:bold; + border : none; +} + +UBTGAdaptableText#UBTGPresentationComment +{ + color: black; + font-size:12px; + border : none; +} + +QFrame#UBTGEditionSeparator, +QFrame#UBTGPresentationSepartor +{ + background-color: #cccccc; +} diff --git a/src/gui/UBTGWidgetTreeDelegate.cpp b/src/gui/UBTGWidgetTreeDelegate.cpp new file mode 100644 index 00000000..928beac9 --- /dev/null +++ b/src/gui/UBTGWidgetTreeDelegate.cpp @@ -0,0 +1,34 @@ + +#include +#include +#include +#include +#include +#include +#include "UBTGWidgetTreeDelegate.h" + +UBTGWidgetTreeDelegate::UBTGWidgetTreeDelegate(QObject *parent) : + QStyledItemDelegate(parent) +{ + //NOOP +} + +void UBTGWidgetTreeDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const +{ + if(index.data(Qt::UserRole) != eUBTGAddSubItemWidgetType_None){ + painter->setBackgroundMode(Qt::OpaqueMode); + painter->setBackground(QBrush(QColor(Qt::red))); + QStyleOptionButton styleButton; + styleButton.text = "pipo"; + styleButton.rect = option.rect; + QApplication::style()->drawControl(QStyle::CE_PushButtonLabel,&styleButton,painter); + } + else + QStyledItemDelegate::paint(painter,option,index); +} + +QSize UBTGWidgetTreeDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + QSize size = QStyledItemDelegate::sizeHint(option,index); + return size; +} diff --git a/src/gui/UBTGWidgetTreeDelegate.h b/src/gui/UBTGWidgetTreeDelegate.h new file mode 100644 index 00000000..75343346 --- /dev/null +++ b/src/gui/UBTGWidgetTreeDelegate.h @@ -0,0 +1,35 @@ +#ifndef UBTGWIDGETTREEDELEGATE_H +#define UBTGWIDGETTREEDELEGATE_H + +class QPainter; +class QStyleOptionViewItem; +class QModelIndex; + +#include + + +typedef enum +{ + eUBTGAddSubItemWidgetType_None, + eUBTGAddSubItemWidgetType_Action , + eUBTGAddSubItemWidgetType_Media, + eUBTGAddSubItemWidgetType_Url +}eUBTGAddSubItemWidgetType; + + +class UBTGWidgetTreeDelegate : public QStyledItemDelegate +{ + Q_OBJECT +public: + explicit UBTGWidgetTreeDelegate(QObject *parent = 0); + + virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const; + virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; + +signals: + +public slots: + +}; + +#endif // UBTGWIDGETTREEDELEGATE_H diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp index f67c8d54..4fe76953 100644 --- a/src/gui/UBTeacherGuideWidget.cpp +++ b/src/gui/UBTeacherGuideWidget.cpp @@ -35,13 +35,7 @@ #include "web/UBWebController.h" -typedef enum -{ - eUBTGAddSubItemWidgetType_None, - eUBTGAddSubItemWidgetType_Action , - eUBTGAddSubItemWidgetType_Media, - eUBTGAddSubItemWidgetType_Url -}eUBTGAddSubItemWidgetType; +#define UBTG_SEPARATOR_FIXED_HEIGHT 3 /*************************************************************************** @@ -52,33 +46,52 @@ UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const QWidget(parent) , mpLayout(NULL) , mpDocumentTitle(NULL) + , mpPageNumberLabel(NULL) , mpPageTitle(NULL) , mpComment(NULL) + , mpSeparator(NULL) , mpTreeWidget(NULL) , mpRootWidgetItem(NULL) , mpAddAnActionItem(NULL) , mpAddAMediaItem(NULL) , mpAddALinkItem(NULL) + , mpTreeDelegate(NULL) { setObjectName(name); mpLayout = new QVBoxLayout(this); + mpPageNumberLabel = new QLabel(this); + mpPageNumberLabel->setAlignment(Qt::AlignRight); + mpPageNumberLabel->setObjectName("UBTGEditionPageNumberLabel"); + mpLayout->addWidget(mpPageNumberLabel); // tree basic configuration mpDocumentTitle = new QLabel(this); - mpDocumentTitle->setText("title document"); - mpDocumentTitle->setStyleSheet( "QWidget {background-color: white}"); + mpDocumentTitle->setText("Document title"); + mpDocumentTitle->setObjectName("UBTGEditionDocumentTitle"); mpLayout->addWidget(mpDocumentTitle); mpPageTitle = new UBTGAdaptableText(0,this); + mpPageTitle->setObjectName("UBTGEditionPageTitle"); + mpPageTitle->setPlaceHolderText(tr("Type title here ...")); mpLayout->addWidget(mpPageTitle); mpComment = new UBTGAdaptableText(0,this); + mpComment->setObjectName("UBTGEditionComment"); + mpComment->setPlaceHolderText(tr("Type comment here ...")); mpLayout->addWidget(mpComment); + mpSeparator = new QFrame(this); + mpSeparator->setObjectName("UBTGEditionSeparator"); + mpSeparator->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT); + mpLayout->addWidget(mpSeparator); + mpTreeWidget = new QTreeWidget(this); mpLayout->addWidget(mpTreeWidget); + mpTreeDelegate = new UBTGWidgetTreeDelegate(); + mpRootWidgetItem = mpTreeWidget->invisibleRootItem(); + //mpTreeWidget->setItemDelegate(mpTreeDelegate); mpTreeWidget->setRootIsDecorated(false); mpTreeWidget->setIndentation(0); mpTreeWidget->setDropIndicatorShown(false); @@ -88,9 +101,10 @@ UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const mpTreeWidget->header()->setStretchLastSection(false); mpTreeWidget->header()->setResizeMode(0, QHeaderView::Stretch); mpTreeWidget->header()->setResizeMode(1, QHeaderView::Fixed); - mpTreeWidget->header()->setDefaultSectionSize(32); + mpTreeWidget->header()->setDefaultSectionSize(18); connect(mpTreeWidget,SIGNAL(itemClicked(QTreeWidgetItem*,int)),this,SLOT(onAddItemClicked(QTreeWidgetItem*,int))); + connect(UBApplication::boardController,SIGNAL(activeSceneChanged()),this,SLOT(onActiveSceneChanged())); mpAddAnActionItem = new UBAddItem(tr("Add an action"),eUBTGAddSubItemWidgetType_Action,mpTreeWidget); mpAddAMediaItem = new UBAddItem(tr("Add a media"),eUBTGAddSubItemWidgetType_Media,mpTreeWidget); @@ -104,15 +118,31 @@ UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const UBTeacherGuideEditionWidget::~UBTeacherGuideEditionWidget() { DELETEPTR(mpDocumentTitle); + DELETEPTR(mpPageNumberLabel); DELETEPTR(mpPageTitle); DELETEPTR(mpComment); + DELETEPTR(mpSeparator); DELETEPTR(mpAddAnActionItem); DELETEPTR(mpAddAMediaItem); DELETEPTR(mpAddALinkItem); + DELETEPTR(mpTreeDelegate); DELETEPTR(mpTreeWidget) DELETEPTR(mpLayout); } +void UBTeacherGuideEditionWidget::showEvent(QShowEvent* event) +{ + mpPageTitle->setFocus(); + mpComment->setFocus(); + setFocus(); + QWidget::showEvent(event); +} + +void UBTeacherGuideEditionWidget::onActiveSceneChanged() +{ + cleanData(); + mpPageNumberLabel->setText(tr("Page: %0").arg(UBApplication::boardController->activeSceneIndex() + 1)); +} void UBTeacherGuideEditionWidget::cleanData() { @@ -141,12 +171,12 @@ QVector UBTeacherGuideEditionWidget::getPageAndCommentData() QVectorresult; tUBGEElementNode* pageTitle = new tUBGEElementNode(); pageTitle->type = "pageTitle"; - pageTitle->attributes.insert("value",mpPageTitle->toPlainText()); + pageTitle->attributes.insert("value",mpPageTitle->text()); result << pageTitle; tUBGEElementNode* comment = new tUBGEElementNode(); comment->type = "comment"; - comment->attributes.insert("value",mpComment->toPlainText()); + comment->attributes.insert("value",mpComment->text()); result << comment; return result; } @@ -229,36 +259,58 @@ UBTeacherGuidePresentationWidget::UBTeacherGuidePresentationWidget(QWidget *pare , mpComment(NULL) , mpLayout(NULL) , mpButtonTitleLayout(NULL) - , mpDocumentTile(NULL) + , mpDocumentTitle(NULL) + , mpPageNumberLabel(NULL) + , mpSeparator(NULL) , mpModePushButton(NULL) , mpTreeWidget(NULL) , mpRootWidgetItem(NULL) , mpMediaSwitchItem(NULL) { setObjectName(name); + mpLayout = new QVBoxLayout(this); + + mpPageNumberLabel = new QLabel(this); + mpPageNumberLabel->setAlignment(Qt::AlignRight); + mpPageNumberLabel->setObjectName("UBTGPresentationPageNumberLabel"); + + mpLayout->addWidget(mpPageNumberLabel); + mpButtonTitleLayout = new QHBoxLayout(0); mpModePushButton = new QPushButton(this); mpModePushButton->setIcon(QIcon(":images/pencil.svg")); + mpModePushButton->setMaximumWidth(32); + connect(mpModePushButton,SIGNAL(clicked()),parentWidget(),SLOT(changeMode())); - mpDocumentTile = new QLabel(this); - mpDocumentTile->setText("Document title"); + mpDocumentTitle = new QLabel(this); + mpDocumentTitle->setObjectName("UBTGPresentationDocumentTitle"); + mpDocumentTitle->setText("Document title"); mpButtonTitleLayout->addWidget(mpModePushButton); - mpButtonTitleLayout->addWidget(mpDocumentTile); + mpButtonTitleLayout->addWidget(mpDocumentTitle); mpLayout->addLayout(mpButtonTitleLayout); mpPageTitle = new UBTGAdaptableText(0,this); + mpPageTitle->setObjectName("UBTGPresentationPageTitle"); mpPageTitle->setReadOnly(true); + mpPageTitle->setStyleSheet("background-color:transparent"); mpLayout->addWidget(mpPageTitle); mpComment = new UBTGAdaptableText(0,this); + mpComment->setObjectName("UBTGPresentationComment"); mpComment->setReadOnly(true); + mpComment->setStyleSheet("background-color:transparent"); mpLayout->addWidget(mpComment); + mpSeparator = new QFrame(this); + mpSeparator->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT); + mpSeparator->setObjectName("UBTGPresentationSepartor"); + mpLayout->addWidget(mpSeparator); + mpTreeWidget = new QTreeWidget(this); mpLayout->addWidget(mpTreeWidget); @@ -268,31 +320,55 @@ UBTeacherGuidePresentationWidget::UBTeacherGuidePresentationWidget(QWidget *pare mpTreeWidget->setDropIndicatorShown(false); mpTreeWidget->header()->close(); mpTreeWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); -// mpTreeWidget->setColumnCount(1); connect(mpTreeWidget,SIGNAL(itemClicked(QTreeWidgetItem*,int)),this,SLOT(onAddItemClicked(QTreeWidgetItem*,int))); - + connect(UBApplication::boardController,SIGNAL(activeSceneChanged()),this,SLOT(onActiveSceneChanged())); } UBTeacherGuidePresentationWidget::~UBTeacherGuidePresentationWidget() { DELETEPTR(mpComment); DELETEPTR(mpPageTitle); + DELETEPTR(mpPageNumberLabel); + DELETEPTR(mpSeparator); DELETEPTR(mpMediaSwitchItem); DELETEPTR(mpModePushButton); - DELETEPTR(mpDocumentTile); + DELETEPTR(mpDocumentTitle); DELETEPTR(mpButtonTitleLayout); DELETEPTR(mpTreeWidget); DELETEPTR(mpLayout); } +void UBTeacherGuidePresentationWidget::cleanData() +{ + mpPageTitle->showText(""); + mpComment->showText(""); + //tree clean + QList itemToRemove = mpRootWidgetItem->takeChildren(); + foreach(QTreeWidgetItem* eachItem, itemToRemove){ + DELETEPTR(eachItem); + } + // the mpMediaSwitchItem is deleted by the previous loop but the pointer is not set to zero + mpMediaSwitchItem = NULL; +} + +void UBTeacherGuidePresentationWidget::onActiveSceneChanged() +{ + cleanData(); + mpPageNumberLabel->setText(tr("Page: %0").arg(UBApplication::boardController->activeSceneIndex() + 1)); +} + void UBTeacherGuidePresentationWidget::createMediaButtonItem() { if(!mpMediaSwitchItem){ //create the media button mpMediaSwitchItem = new QTreeWidgetItem(mpRootWidgetItem); - mpMediaSwitchItem->setIcon(0,QIcon(":images/plus.svg")); + //mpMediaSwitchItem->setIcon(0,QIcon(":images/plus.svg")); + mpMediaSwitchItem->setText(0,"+"); mpMediaSwitchItem->setExpanded(false); mpMediaSwitchItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_EXPAND); + mpMediaSwitchItem->setData(0,Qt::BackgroundRole,QVariant(QColor(200,200,200))); + mpMediaSwitchItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),16))); + mpMediaSwitchItem->setData(0,Qt::TextAlignmentRole,QVariant(Qt::AlignCenter)); mpRootWidgetItem->addChild(mpMediaSwitchItem); } } @@ -300,13 +376,7 @@ void UBTeacherGuidePresentationWidget::createMediaButtonItem() void UBTeacherGuidePresentationWidget::showData(QVector data) { - //tree clean - QList itemToRemove = mpRootWidgetItem->takeChildren(); - foreach(QTreeWidgetItem* eachItem, itemToRemove){ - DELETEPTR(eachItem); - } - // the mpMediaSwitchItem is deleted by the previous loop but the pointer is not set to zero - mpMediaSwitchItem = NULL; + cleanData(); foreach(tUBGEElementNode* element, data){ if(element->type == "pageTitle") @@ -316,20 +386,23 @@ void UBTeacherGuidePresentationWidget::showData(QVector data) else if(element->type == "action"){ QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(mpRootWidgetItem); newWidgetItem->setText(0,element->attributes.value("task")); - QColor color = element->attributes.value("owner").toInt()?QColor().red():QColor().green(); - newWidgetItem->setTextColor(0,color); + QColor color = element->attributes.value("owner").toInt() == 0 ? QColor(Qt::red):QColor(Qt::green); + newWidgetItem->setData(0,Qt::ForegroundRole,QBrush(color)); newWidgetItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_NONE); + newWidgetItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),11))); mpRootWidgetItem->addChild(newWidgetItem); } else if(element->type == "media"){ createMediaButtonItem(); QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(mpMediaSwitchItem); + newWidgetItem->setIcon(0,QIcon(":images/teacherGuide/"+ element->attributes.value("mediaType") +".png")); newWidgetItem->setText(0,element->attributes.value("title")); newWidgetItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_MEDIA); + newWidgetItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),11))); mpRootWidgetItem->addChild(newWidgetItem); QTreeWidgetItem* mediaItem = new QTreeWidgetItem(newWidgetItem); - mediaItem->setText(0,element->attributes.value("title")); + //mediaItem->setBackground(0,QBrush(QColor("#EEEEEF"))); mediaItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_NONE); UBTGMediaWidget* mediaWidget = new UBTGMediaWidget(element->attributes.value("relativePath"),newWidgetItem); newWidgetItem->setExpanded(false); @@ -338,13 +411,14 @@ void UBTeacherGuidePresentationWidget::showData(QVector data) else if(element->type == "link"){ createMediaButtonItem(); QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(mpMediaSwitchItem); + newWidgetItem->setIcon(0,QIcon(":images/teacherGuide/link.png")); newWidgetItem->setText(0,element->attributes.value("title")); newWidgetItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_URL); newWidgetItem->setData(0,tUBTGTreeWidgetItemRole_HasAnUrl,QVariant(element->attributes.value("url"))); + newWidgetItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),11))); mpRootWidgetItem->addChild(newWidgetItem); } } - } void UBTeacherGuidePresentationWidget::onAddItemClicked(QTreeWidgetItem* widget, int column) @@ -355,6 +429,10 @@ void UBTeacherGuidePresentationWidget::onAddItemClicked(QTreeWidgetItem* widget, { case tUBTGActionAssociateOnClickItem_EXPAND: widget->setExpanded(!widget->isExpanded()); + if(widget->isExpanded()) + mpMediaSwitchItem->setText(0,"-"); + else + mpMediaSwitchItem->setText(0,"+"); break; case tUBTGActionAssociateOnClickItem_URL: widget->data(column,tUBTGTreeWidgetItemRole_HasAnUrl).toString(); @@ -377,12 +455,13 @@ UBTeacherGuideWidget::UBTeacherGuideWidget(QWidget *parent, const char *name): Q , mpPresentationWidget(NULL) { setObjectName(name); + mpEditionWidget = new UBTeacherGuideEditionWidget(this); addWidget(mpEditionWidget); mpPresentationWidget = new UBTeacherGuidePresentationWidget(this); addWidget(mpPresentationWidget); - setCurrentWidget(mpEditionWidget); + setCurrentWidget(mpPresentationWidget); connect(UBApplication::boardController->controlView(),SIGNAL(clickOnBoard()),this,SLOT(showPresentationMode())); connectToStylusPalette(); } @@ -405,8 +484,8 @@ void UBTeacherGuideWidget::connectToStylusPalette() void UBTeacherGuideWidget::showPresentationMode() { if(currentWidget()!=mpPresentationWidget){ - currentData = mpEditionWidget->getData(); - mpPresentationWidget->showData(currentData); + mCurrentData = mpEditionWidget->getData(); + mpPresentationWidget->showData(mCurrentData); setCurrentWidget(mpPresentationWidget); } } diff --git a/src/gui/UBTeacherGuideWidget.h b/src/gui/UBTeacherGuideWidget.h index 076d5d26..fc984d4a 100644 --- a/src/gui/UBTeacherGuideWidget.h +++ b/src/gui/UBTeacherGuideWidget.h @@ -23,7 +23,7 @@ class QVBoxLayout; class QPushButton; #include "UBTeacherGuideWidgetsTools.h" - +#include "UBTGWidgetTreeDelegate.h" /*************************************************************************** * class UBTeacherGuideEditionWidget * @@ -39,6 +39,8 @@ public: public slots: void onAddItemClicked(QTreeWidgetItem* widget, int column); + void onActiveSceneChanged(); + void showEvent(QShowEvent* event); private: QList getChildrenList(QTreeWidgetItem* widgetItem); @@ -46,13 +48,16 @@ private: QVBoxLayout* mpLayout; QLabel* mpDocumentTitle; + QLabel* mpPageNumberLabel; UBTGAdaptableText* mpPageTitle; UBTGAdaptableText* mpComment; + QFrame* mpSeparator; QTreeWidget* mpTreeWidget; QTreeWidgetItem* mpRootWidgetItem; UBAddItem* mpAddAnActionItem; UBAddItem* mpAddAMediaItem; UBAddItem* mpAddALinkItem; + UBTGWidgetTreeDelegate* mpTreeDelegate; }; @@ -67,9 +72,11 @@ public: explicit UBTeacherGuidePresentationWidget(QWidget* parent, const char* name = "UBTeacherGuidePresentationName"); ~UBTeacherGuidePresentationWidget(); void showData(QVectordata); + void cleanData(); public slots: void onAddItemClicked(QTreeWidgetItem* widget, int column); + void onActiveSceneChanged(); private: void createMediaButtonItem(); @@ -78,7 +85,9 @@ private: UBTGAdaptableText* mpComment; QVBoxLayout* mpLayout; QHBoxLayout* mpButtonTitleLayout; - QLabel* mpDocumentTile; + QLabel* mpDocumentTitle; + QLabel* mpPageNumberLabel; + QFrame* mpSeparator; QPushButton* mpModePushButton; QTreeWidget* mpTreeWidget; QTreeWidgetItem* mpRootWidgetItem; @@ -107,7 +116,7 @@ public slots: private: UBTeacherGuideEditionWidget* mpEditionWidget; UBTeacherGuidePresentationWidget* mpPresentationWidget; - QVectorcurrentData; + QVectormCurrentData; }; diff --git a/src/gui/UBTeacherGuideWidgetsTools.cpp b/src/gui/UBTeacherGuideWidgetsTools.cpp index 60c9f89b..b101113b 100644 --- a/src/gui/UBTeacherGuideWidgetsTools.cpp +++ b/src/gui/UBTeacherGuideWidgetsTools.cpp @@ -23,8 +23,10 @@ #include #include #include +#include #include "UBTeacherGuideWidgetsTools.h" +#include "UBTGWidgetTreeDelegate.h" #include "globals/UBGlobals.h" @@ -40,6 +42,9 @@ UBAddItem::UBAddItem(const QString &string, int addSubItemWidgetType, QTreeWidge setText(0,string); setData(0,Qt::UserRole,QVariant(addSubItemWidgetType)); setData(1,Qt::UserRole,QVariant(addSubItemWidgetType)); + setData(0,Qt::BackgroundRole,QVariant(QColor(200,200,200))); + setData(1,Qt::BackgroundRole,QVariant(QColor(200,200,200))); + setData(0,Qt::FontRole,QVariant(QFont(QApplication::font().family(),12))); } UBAddItem::~UBAddItem() @@ -56,20 +61,21 @@ UBTGActionWidget::UBTGActionWidget(QTreeWidgetItem* widget, QWidget* parent, con , mpTask(NULL) { setObjectName(name); + SET_STYLE_SHEET(); mpLayout = new QVBoxLayout(this); mpOwner = new QComboBox(this); + mpOwner->setObjectName("DockPaletteWidgetComboBox"); + mpOwner->setMinimumHeight(22); QStringList qslOwner; qslOwner << tr("Teacher") << tr("Student"); mpOwner->insertItems(0,qslOwner); mpOwner->setCurrentIndex(0); - connect(mpOwner,SIGNAL(currentIndexChanged(int)),this,SLOT(onOwnerChange(int))); mpTask = new UBTGAdaptableText(widget,this); mpTask->setAcceptRichText(true); mpTask->setTextColor(QColor().green()); mpTask->setObjectName("ActionWidgetTaskTextEdit"); mpLayout->addWidget(mpOwner,0); mpLayout->addWidget(mpTask,1); - setStyleSheet( "QWidget {background-color: white}"); } UBTGActionWidget::~UBTGActionWidget() @@ -79,20 +85,12 @@ UBTGActionWidget::~UBTGActionWidget() DELETEPTR(mpLayout); } -void UBTGActionWidget::onOwnerChange(int ownerId) -{ - if(ownerId == 0) - mpTask->setTextColor(QColor().red()); - else - mpTask->setTextColor(QColor().green()); -} - tUBGEElementNode* UBTGActionWidget::saveData() { tUBGEElementNode* result = new tUBGEElementNode(); result->type = "action"; - result->attributes.insert("owner",QString(mpOwner->currentIndex())); - result->attributes.insert("task",mpTask->toPlainText()); + result->attributes.insert("owner",QString("%0").arg(mpOwner->currentIndex())); + result->attributes.insert("task",mpTask->text()); return result; } @@ -102,17 +100,66 @@ tUBGEElementNode* UBTGActionWidget::saveData() UBTGAdaptableText::UBTGAdaptableText(QTreeWidgetItem* widget, QWidget* parent, const char* name):QTextEdit(parent) , mBottomMargin(5) , mpTreeWidgetItem(widget) + , mMinimumHeight(20) + , mHasPlaceHolder(false) { setObjectName(name); - setStyleSheet( "QWidget {background-color: white}"); + setStyleSheet( "QWidget {background: white; border:1 solid #999999; border-radius : 10px; padding: 2px;}"); connect(this,SIGNAL(textChanged()),this,SLOT(onTextChanged())); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setMinimumHeight(mMinimumHeight); +} + +void UBTGAdaptableText::setPlaceHolderText(QString text) +{ + + // the space addition is to make this string unique and check against it to know + // if we are talking about a typed string or the placeholder string + mPlaceHolderText = text + " "; + setTextColor(QColor(Qt::lightGray)); + setText(mPlaceHolderText); + onTextChanged(); + if(isHidden()) + show(); + mHasPlaceHolder = true; +} + +void UBTGAdaptableText::focusInEvent(QFocusEvent *e) +{ + if(mHasPlaceHolder && toPlainText() == mPlaceHolderText){ + setText(""); + setTextColor(QColor(Qt::black)); + } + + e->accept(); +} + + +void UBTGAdaptableText::focusOutEvent(QFocusEvent *e) +{ + if(mHasPlaceHolder && toPlainText().length() == 0){ + setTextColor(QColor(Qt::lightGray)); + setText(mPlaceHolderText); + } + e->accept(); +} + +QString UBTGAdaptableText::text() +{ + QString result = toPlainText(); + if(mHasPlaceHolder && result == mPlaceHolderText) + return ""; + + return result; } void UBTGAdaptableText::onTextChanged() { - setFixedHeight(document()->size().height()+mBottomMargin); + if(document()->size().height() < mMinimumHeight) + setFixedHeight(mMinimumHeight); + else + setFixedHeight(document()->size().height()+mBottomMargin); updateGeometry(); //to trig the widget item to resize it if(mpTreeWidgetItem){ @@ -120,7 +167,6 @@ void UBTGAdaptableText::onTextChanged() mpTreeWidgetItem->setExpanded(true); setFocus(); } - } void UBTGAdaptableText::showText(const QString & text) @@ -131,6 +177,8 @@ void UBTGAdaptableText::showText(const QString & text) hide(); setReadOnly(true); onTextChanged(); + if(isHidden()) + show(); } void UBTGAdaptableText::bottomMargin(int newValue) @@ -155,8 +203,8 @@ UBTGMediaWidget::UBTGMediaWidget(QTreeWidgetItem* widget, QWidget* parent,const , mIsPresentationMode(false) { setObjectName(name); - setStyleSheet( "QWidget {background-color: white}"); mpDropMeWidget = new QLabel(); + mpDropMeWidget->setObjectName("UBTGMediaDropMeLabel"); mpDropMeWidget->setText(tr("drop media here ...")); mpDropMeWidget->setAlignment(Qt::AlignCenter); setAcceptDrops(true); @@ -176,6 +224,7 @@ UBTGMediaWidget::UBTGMediaWidget(QString relativePath, QTreeWidgetItem* widget, , mpWebView(NULL) , mRelativePath(relativePath) , mIsPresentationMode(true) + , mMediaType("") { setObjectName(name); setAcceptDrops(false); @@ -202,8 +251,9 @@ tUBGEElementNode* UBTGMediaWidget::saveData() return 0; tUBGEElementNode* result = new tUBGEElementNode(); result->type = "media"; - result->attributes.insert("title",mpTitle->toPlainText()); + result->attributes.insert("title",mpTitle->text()); result->attributes.insert("relativePath",mRelativePath); + result->attributes.insert("mediaType",mMediaType); return result; } @@ -218,15 +268,20 @@ void UBTGMediaWidget::createWorkWidget(QString& path) qDebug() << mimeType; bool setMedia = true; if(mimeType.contains("audio") || mimeType.contains("video")){ + mMediaType = mimeType.contains("audio")? "audio":"movie"; mpMediaWidget = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); mpMediaWidget->setFile(path); } else if(mimeType.contains("image")){ + mMediaType = "image"; mpMediaLabelWidget = new QLabel(); - mpMediaLabelWidget->setPixmap(QPixmap(QUrl(path).toLocalFile())); + QPixmap pixmap = QPixmap(QUrl(path).toLocalFile()); + pixmap = pixmap.scaledToWidth(mpTreeWidgetItem->treeWidget()->size().width()); + mpMediaLabelWidget->setPixmap(pixmap); mpMediaLabelWidget->setScaledContents(true); } else if(mimeType.contains("application")){ + mMediaType = "w3c"; mpWebView = new QWebView(0); mpWebView->setAcceptDrops(false); mpWebView->settings()->setAttribute(QWebSettings::JavaEnabled, true); @@ -258,6 +313,7 @@ void UBTGMediaWidget::createWorkWidget(QString& path) mpLayout->addWidget(mpMediaLabelWidget); } else if (mpMediaWidget){ + mpMediaWidget->setMaximumHeight(mpTreeWidgetItem->treeWidget()->size().width()); mpMediaWidget->setParent(mpWorkWidget); mpLayout->addWidget(mpMediaWidget); } @@ -337,12 +393,14 @@ UBTGUrlWidget::UBTGUrlWidget(QWidget* parent, const char* name ):QWidget(parent) , mpUrl(NULL) { setObjectName(name); - setStyleSheet( "QWidget {background-color: white}"); - + SET_STYLE_SHEET(); mpLayout = new QVBoxLayout(this); - mpTitle = new QLineEdit("title",this); - mpUrl = new QLineEdit("url",this); - + mpTitle = new QLineEdit(this); + mpTitle->setObjectName("UBTGLineEdit"); + mpTitle->setPlaceholderText(tr("Insert link title here...")); + mpUrl = new QLineEdit(this); + mpUrl->setObjectName("UBTGLineEdit"); + mpUrl->setPlaceholderText("http://"); mpLayout->addWidget(mpTitle); mpLayout->addWidget(mpUrl); } diff --git a/src/gui/UBTeacherGuideWidgetsTools.h b/src/gui/UBTeacherGuideWidgetsTools.h index 40da7b1d..1383b522 100644 --- a/src/gui/UBTeacherGuideWidgetsTools.h +++ b/src/gui/UBTeacherGuideWidgetsTools.h @@ -65,17 +65,18 @@ public slots: class UBTGActionWidget : public QWidget, public iUBTGSavableData { Q_OBJECT + public: - explicit UBTGActionWidget(QTreeWidgetItem* widget, QWidget* parent = 0,const char* name = "UBActionWidget"); + explicit UBTGActionWidget(QTreeWidgetItem* widget, QWidget* parent = 0,const char* name = "UBTGActionWidget"); ~UBTGActionWidget(); void update(); tUBGEElementNode* saveData(); -public slots: - void onOwnerChange(int ownerId); + private: QVBoxLayout* mpLayout; QComboBox* mpOwner; UBTGAdaptableText* mpTask; + protected: QTreeWidgetItem* mpTreeWidgetItem; }; @@ -88,13 +89,21 @@ public: explicit UBTGAdaptableText(QTreeWidgetItem* widget = 0, QWidget *parent = 0, const char* name = "UBTGAdaptableText"); void showText(const QString & text); void bottomMargin(int newValue); -signals: + void setPlaceHolderText(QString text); + QString text(); public slots: void onTextChanged(); + +protected: + void focusInEvent(QFocusEvent *e); + void focusOutEvent(QFocusEvent *e); private: int mBottomMargin; QTreeWidgetItem* mpTreeWidgetItem; + int mMinimumHeight; + bool mHasPlaceHolder; + QString mPlaceHolderText; }; @@ -106,10 +115,12 @@ public: UBTGMediaWidget(QString relativePath, QTreeWidgetItem* widget = 0, QWidget* parent = 0, const char* name = "UBTGMediaWidget"); ~UBTGMediaWidget(); tUBGEElementNode* saveData(); + protected: void dragEnterEvent(QDragEnterEvent* event); void dropEvent(QDropEvent* event); void mousePressEvent(QMouseEvent* event); + private: void parseMimeData(const QMimeData* pMimeData); void createWorkWidget(QString& path); @@ -125,6 +136,7 @@ private: QWebView* mpWebView; QString mRelativePath; bool mIsPresentationMode; + QString mMediaType; }; class UBTGUrlWidget : public QWidget , public iUBTGSavableData diff --git a/src/gui/gui.pri b/src/gui/gui.pri index 9191c598..264b9df3 100644 --- a/src/gui/gui.pri +++ b/src/gui/gui.pri @@ -50,7 +50,8 @@ HEADERS += src/gui/UBThumbnailView.h \ src/gui/UBDockTeacherGuideWidget.h \ src/gui/UBTeacherGuideWidget.h \ src/gui/UBTeacherGuideWidgetsTools.h \ - src/gui/UBTeacherGuideDelegate.h + src/gui/UBTeacherGuideDelegate.h \ + src/gui/UBTGWidgetTreeDelegate.h SOURCES += src/gui/UBThumbnailView.cpp \ src/gui/UBFloatingPalette.cpp \ @@ -103,7 +104,8 @@ SOURCES += src/gui/UBThumbnailView.cpp \ src/gui/UBDockTeacherGuideWidget.cpp \ src/gui/UBTeacherGuideWidget.cpp \ src/gui/UBTeacherGuideWidgetsTools.cpp \ - src/gui/UBTeacherGuideDelegate.cpp + src/gui/UBTeacherGuideDelegate.cpp \ + src/gui/UBTGWidgetTreeDelegate.cpp win32 { From 921953e06901d6bccce025ba9706e6c475573fca Mon Sep 17 00:00:00 2001 From: Anatoly Mihalchenko Date: Thu, 12 Apr 2012 15:56:17 +0300 Subject: [PATCH 07/15] PDF view: performance fix --- src/core/UBApplicationController.cpp | 3 ++ src/document/UBDocumentController.cpp | 44 +++++++++++++++++++++------ src/document/UBDocumentController.h | 4 ++- src/gui/UBDocumentNavigator.cpp | 1 - 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/src/core/UBApplicationController.cpp b/src/core/UBApplicationController.cpp index 0ee793e1..89af16fa 100644 --- a/src/core/UBApplicationController.cpp +++ b/src/core/UBApplicationController.cpp @@ -337,6 +337,9 @@ void UBApplicationController::showBoard() mMainWindow->tutorialToolBar->hide(); mMainWindow->boardToolBar->show(); + if (mMainMode == Document && UBApplication::documentController->getSelectedItemIndex() != -1) + UBApplication::boardController->setActiveDocumentScene(UBApplication::documentController->getCurrentDocument(), UBApplication::documentController->getSelectedItemIndex()); + mMainMode = Board; adaptToolBar(); diff --git a/src/document/UBDocumentController.cpp b/src/document/UBDocumentController.cpp index f75ccc4d..acc5495e 100644 --- a/src/document/UBDocumentController.cpp +++ b/src/document/UBDocumentController.cpp @@ -160,6 +160,9 @@ void UBDocumentController::selectDocument(UBDocumentProxy* proxy, bool setAsCurr mDocumentUI->documentTreeWidget->scrollToItem(selected); + mDocumentThumbs = UBThumbnailAdaptor::load(selectedDocumentProxy()); + refreshDocumentThumbnailsView(); + mSelectionType = Document; } } @@ -268,11 +271,10 @@ void UBDocumentController::refreshDocumentThumbnailsView() if (proxy) { mCurrentDocument = proxy; - QList thumbs = UBThumbnailAdaptor::load(proxy); - for (int i = 0; i < thumbs.count(); i++) + for (int i = 0; i < mDocumentThumbs.count(); i++) { - QPixmap pix = thumbs.at(i); + QPixmap pix = mDocumentThumbs.at(i); QGraphicsPixmapItem *pixmapItem = new UBSceneThumbnailPixmap(pix, proxy, i); // deleted by the tree widget if (proxy == mBoardController->activeDocument() && mBoardController->activeSceneIndex() == i) @@ -507,7 +509,7 @@ void UBDocumentController::openSelectedItem() if (proxy && isOKToOpenDocument(proxy)) { - mBoardController->setActiveDocumentScene(proxy, thumb->sceneIndex()); + //mBoardController->setActiveDocumentScene(proxy, thumb->sceneIndex()); UBApplication::applicationController->showBoard(); } } @@ -561,6 +563,7 @@ void UBDocumentController::duplicateSelectedItem() foreach (int sceneIndex, selectedSceneIndexes) { UBPersistenceManager::persistenceManager()->duplicateDocumentScene(proxy, sceneIndex + offset); + mDocumentThumbs.insert(sceneIndex + offset, mDocumentThumbs.at(sceneIndex + offset)); offset++; } } @@ -921,6 +924,7 @@ void UBDocumentController::itemClicked(QTreeWidgetItem * item, int column ) Q_UNUSED(item); Q_UNUSED(column); + selectDocument(selectedDocumentProxy(), false); itemSelectionChanged(); } @@ -1043,6 +1047,7 @@ void UBDocumentController::addFolderOfImages() { document->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); UBMetadataDcSubsetAdaptor::persist(document); + mDocumentThumbs = UBThumbnailAdaptor::load(selectedDocumentProxy()); refreshDocumentThumbnailsView(); } } @@ -1057,6 +1062,7 @@ void UBDocumentController::addFileToDocument() if (document) { addFileToDocument(document); + mDocumentThumbs = UBThumbnailAdaptor::load(document); refreshDocumentThumbnailsView(); } } @@ -1108,12 +1114,9 @@ void UBDocumentController::moveSceneToIndex(UBDocumentProxy* proxy, int source, proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); UBMetadataDcSubsetAdaptor::persist(proxy); + mDocumentThumbs.insert(target, mDocumentThumbs.takeAt(source)); refreshDocumentThumbnailsView(); - - // Notify the move to anyone interested in knowing it - emit movedToIndex(target); - - UBApplication::boardController->setActiveDocumentScene(proxy, target); + mDocumentUI->thumbnailWidget->hightlightItem(target); } @@ -1321,7 +1324,8 @@ void UBDocumentController::addToDocument() } int newActiveSceneIndex = selectedItems.count() == mBoardController->activeDocument()->pageCount() ? 0 : oldActiveSceneIndex + 1; - mBoardController->setActiveDocumentScene(mBoardController->activeDocument(), newActiveSceneIndex); + mDocumentUI->thumbnailWidget->selectItemAt(newActiveSceneIndex, false); + selectDocument(mBoardController->activeDocument()); mBoardController->activeDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); UBMetadataDcSubsetAdaptor::persist(mBoardController->activeDocument()); @@ -1495,6 +1499,7 @@ void UBDocumentController::addImages() { document->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); UBMetadataDcSubsetAdaptor::persist(document); + mDocumentThumbs = UBThumbnailAdaptor::load(selectedDocumentProxy()); refreshDocumentThumbnailsView(); } } @@ -1605,6 +1610,13 @@ void UBDocumentController::deletePages(QList itemsToDelete) UBPersistenceManager::persistenceManager()->deleteDocumentScenes(proxy, sceneIndexes); proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); UBMetadataDcSubsetAdaptor::persist(proxy); + + int offset = 0; + foreach(int index, sceneIndexes) + { + mDocumentThumbs.removeAt(index - offset); + offset++; + } refreshDocumentThumbnailsView(); int minIndex = proxy->pageCount() - 1; @@ -1616,3 +1628,15 @@ void UBDocumentController::deletePages(QList itemsToDelete) } } } + +int UBDocumentController::getSelectedItemIndex() +{ + QList selectedItems = mDocumentUI->thumbnailWidget->selectedItems(); + + if (selectedItems.count() > 0) + { + UBSceneThumbnailPixmap* thumb = dynamic_cast (selectedItems.last()); + return thumb->sceneIndex(); + } + else return -1; +} \ No newline at end of file diff --git a/src/document/UBDocumentController.h b/src/document/UBDocumentController.h index 4baf8b36..5b1daa2b 100644 --- a/src/document/UBDocumentController.h +++ b/src/document/UBDocumentController.h @@ -48,8 +48,9 @@ class UBDocumentController : public QObject QWidget* controlView(); UBDocumentProxyTreeItem* findDocument(UBDocumentProxy* proxy); bool addFileToDocument(UBDocumentProxy* document); - UBDocumentProxy* getCurrentDocument(); + UBDocumentProxy* getCurrentDocument() { return mCurrentDocument; }; void deletePages(QList itemsToDelete); + int getSelectedItemIndex(); signals: void refreshThumbnails(); @@ -111,6 +112,7 @@ class UBDocumentController : public QObject bool mToolsPalettePositionned; UBDocumentGroupTreeItem* mTrashTi; UBDocumentProxy* mCurrentDocument; + QList mDocumentThumbs; // UBKeyboardPalette *mKeyboardPalette; diff --git a/src/gui/UBDocumentNavigator.cpp b/src/gui/UBDocumentNavigator.cpp index 7abf129b..efb3e04a 100644 --- a/src/gui/UBDocumentNavigator.cpp +++ b/src/gui/UBDocumentNavigator.cpp @@ -56,7 +56,6 @@ UBDocumentNavigator::UBDocumentNavigator(QWidget *parent, const char *name):QGra setFrameShadow(QFrame::Plain); connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(addNewPage())); - connect(UBApplication::boardController, SIGNAL(setDocOnPageNavigator(UBDocumentProxy*)), this, SLOT(generateThumbnails())); connect(mScene, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); connect(UBApplication::boardController, SIGNAL(documentReorganized(int)), this, SLOT(onMovedToIndex(int))); } From edb3fd508688d14201ec29daa9290d3888d421c3 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Thu, 12 Apr 2012 15:26:51 +0200 Subject: [PATCH 08/15] new littles gui improvements on teacher guide --- src/customWidgets/UBMediaWidget.cpp | 37 +++- src/customWidgets/UBMediaWidget.h | 6 + src/gui/UBMediaPlayer.cpp | 257 ------------------------- src/gui/UBMediaPlayer.h | 106 ---------- src/gui/UBTeacherGuideWidget.cpp | 2 +- src/gui/UBTeacherGuideWidgetsTools.cpp | 7 +- src/gui/UBTeacherGuideWidgetsTools.h | 1 + src/gui/gui.pri | 2 - 8 files changed, 48 insertions(+), 370 deletions(-) delete mode 100644 src/gui/UBMediaPlayer.cpp delete mode 100644 src/gui/UBMediaPlayer.h diff --git a/src/customWidgets/UBMediaWidget.cpp b/src/customWidgets/UBMediaWidget.cpp index fe96d6e9..cbc0b842 100644 --- a/src/customWidgets/UBMediaWidget.cpp +++ b/src/customWidgets/UBMediaWidget.cpp @@ -34,6 +34,8 @@ UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name) , mBorder(5) , mpMediaContainer(NULL) , mpCover(NULL) +// , mpVideoStackedWidget(NULL) +// , mpSnapshotVideoWidget(NULL) { SET_STYLE_SHEET(); @@ -72,6 +74,8 @@ UBMediaWidget::~UBMediaWidget() DELETEPTR(mpPlayStopButton); DELETEPTR(mpAudioOutput); DELETEPTR(mpVideoWidget); +// DELETEPTR(mpVideoStackedWidget); +// DELETEPTR(mpSnapshotVideoWidget); DELETEPTR(mpMediaObject); DELETEPTR(mpCover); } @@ -117,6 +121,13 @@ void UBMediaWidget::showEvent(QShowEvent* event) QWidget::showEvent(event); } +void UBMediaWidget::hideEvent(QHideEvent* event) +{ + if(mpMediaObject->state() == Phonon::PlayingState) + mpMediaObject->stop(); + UBActionableWidget::hideEvent(event); +} + /** * \brief Create the media player */ @@ -127,10 +138,17 @@ void UBMediaWidget::createMediaPlayer() mpMediaContainer->setLayout(&mMediaLayout); if(eMediaType_Video == mType){ - mMediaLayout.setContentsMargins(10, 10, 25, 10); + mMediaLayout.setContentsMargins(10, 10, 10, 10); if(isVisible()){ mpVideoWidget = new Phonon::VideoWidget(this); mMediaLayout.addStretch(1); + +// mpVideoStackedWidget = new QStackedWidget(this); +// mpVideoStackedWidget->addWidget(mpVideoWidget); +// mpSnapshotVideoWidget = new QLabel(this); +// mpVideoStackedWidget->addWidget(mpSnapshotVideoWidget); +// mMediaLayout.addWidget(mpVideoStackedWidget,0); + mMediaLayout.addWidget(mpVideoWidget, 0); mMediaLayout.addStretch(1); Phonon::createPath(mpMediaObject, mpVideoWidget); @@ -170,6 +188,22 @@ void UBMediaWidget::adaptSizeToVideo() } } +//void UBMediaWidget::updateView(Phonon::State nextState) +//{ +// if(eMediaType_Video == mType){ +// if(nextState != Phonon::PlayingState){ +// const QPixmap& snapshot = QPixmap::grabWindow(mpVideoWidget->winId()); +// if(snapshot.size().width()!= 0){ +// mpSnapshotVideoWidget->setPixmap(snapshot); +// mpVideoStackedWidget->setCurrentWidget(mpSnapshotVideoWidget); +// } +// } +// else +// mpVideoStackedWidget->setCurrentWidget(mpVideoWidget); +// } + +//} + /** * \brief Handle the media state change notification * @param newState as the new state @@ -198,6 +232,7 @@ void UBMediaWidget::onStateChanged(Phonon::State newState, Phonon::State oldStat mpPauseButton->setEnabled(false); mpSlider->setValue(0); } + //updateView(newState); } } diff --git a/src/customWidgets/UBMediaWidget.h b/src/customWidgets/UBMediaWidget.h index dbc85b78..0d4db8f0 100644 --- a/src/customWidgets/UBMediaWidget.h +++ b/src/customWidgets/UBMediaWidget.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -75,6 +76,7 @@ public: protected: void resizeEvent(QResizeEvent* ev); void showEvent(QShowEvent* event); + void hideEvent(QHideEvent* event); /** The current media file path */ QString mFilePath; @@ -89,6 +91,7 @@ private slots: private: void createMediaPlayer(); void adaptSizeToVideo(); +// void updateView(Phonon::State nextState); /** The current media type */ eMediaType mType; @@ -122,6 +125,9 @@ private: QLabel* mpCover; /** The media url */ QString mUrl; + +// QStackedWidget* mpVideoStackedWidget; +// QLabel* mpSnapshotVideoWidget; }; #endif // UBMEDIAWIDGET_H diff --git a/src/gui/UBMediaPlayer.cpp b/src/gui/UBMediaPlayer.cpp deleted file mode 100644 index 0a203ae6..00000000 --- a/src/gui/UBMediaPlayer.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -#include "UBMediaPlayer.h" - -#define SLIDER_RANGE 8 - - -MediaVideoWidget::MediaVideoWidget(UBMediaPlayer *player, QWidget *parent) : - Phonon::VideoWidget(parent), m_player(player)/*, m_action(this)*/ -{ - //NOOP -} - -void MediaVideoWidget::timerEvent(QTimerEvent *e) -{ - if (e->timerId() == m_timer.timerId()) { - //let's store the cursor shape -#ifndef QT_NO_CURSOR - setCursor(Qt::BlankCursor); -#endif - } - Phonon::VideoWidget::timerEvent(e); -} - - -UBMediaPlayer::UBMediaPlayer() : - playButton(0), - m_AudioOutput(Phonon::VideoCategory), - m_videoWidget(new MediaVideoWidget(this)) -{ - setContextMenuPolicy(Qt::CustomContextMenu); - m_videoWidget->setContextMenuPolicy(Qt::CustomContextMenu); - - QSize buttonSize(26, 20); - - playButton = new QPushButton(this); - playIcon = style()->standardIcon(QStyle::SP_MediaPlay); - pauseIcon = style()->standardIcon(QStyle::SP_MediaPause); - playButton->setIcon(playIcon); - - slider = new Phonon::SeekSlider(this); - slider->setMediaObject(&m_MediaObject); - - QVBoxLayout *vLayout = new QVBoxLayout(this); - vLayout->setContentsMargins(1, 1, 1, 1); - - - initVideoWindow(); - vLayout->addWidget(&m_videoWindow); - QVBoxLayout *buttonPanelLayout = new QVBoxLayout(); -#ifndef Q_WS_WIN - m_videoWindow.hide(); -#endif - progressLabel = new QLabel(this); - QWidget *sliderPanel = new QWidget(this); - QHBoxLayout *sliderLayout = new QHBoxLayout(); - sliderLayout->addWidget(playButton); - sliderLayout->addWidget(slider); - sliderLayout->addWidget(progressLabel); - sliderLayout->setContentsMargins(0, 0, 0, 0); - sliderPanel->setLayout(sliderLayout); - - buttonPanelLayout->addWidget(sliderPanel); - buttonPanelLayout->setContentsMargins(0, 0, 0, 0); -#ifdef Q_OS_MAC - buttonPanelLayout->setSpacing(0); -#endif - QWidget *buttonPanelWidget = new QWidget(this); - buttonPanelWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - buttonPanelWidget->setLayout(buttonPanelLayout); - vLayout->addWidget(buttonPanelWidget); - - QHBoxLayout *labelLayout = new QHBoxLayout(); - vLayout->addLayout(labelLayout); - setLayout(vLayout); - - connect(playButton, SIGNAL(clicked()), this, SLOT(playPause())); - connect(&m_MediaObject, SIGNAL(finished()), this, SLOT(finished())); - connect(&m_MediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(stateChanged(Phonon::State,Phonon::State))); - connect(&m_MediaObject, SIGNAL(bufferStatus(int)), this, SLOT(bufferStatus(int))); - connect(&m_MediaObject, SIGNAL(hasVideoChanged(bool)), this, SLOT(hasVideoChanged(bool))); - - playButton->setEnabled(false); - - m_audioOutputPath = Phonon::createPath(&m_MediaObject, &m_AudioOutput); - Phonon::createPath(&m_MediaObject, m_videoWidget); - - resize(minimumSizeHint()); -} - -void UBMediaPlayer::stateChanged(Phonon::State newstate, Phonon::State oldstate) -{ - if (oldstate == Phonon::LoadingState) { - QRect videoHintRect = QRect(QPoint(0, 0), m_videoWindow.sizeHint()); - QApplication::desktop()->screenGeometry().intersected(videoHintRect); - - if (m_MediaObject.hasVideo()) { - qApp->processEvents(); - resize(sizeHint()); - } else - resize(minimumSize()); - - } - - switch (newstate) { - case Phonon::ErrorState: - if (m_MediaObject.errorType() == Phonon::FatalError) { - playButton->setEnabled(false); - } else { - m_MediaObject.pause(); - } - QMessageBox::warning(this, "Phonon UBMediaPlayer", m_MediaObject.errorString(), QMessageBox::Close); - break; - - case Phonon::StoppedState: - // Fall through - case Phonon::PausedState: - playButton->setIcon(playIcon); - if (m_MediaObject.currentSource().type() != Phonon::MediaSource::Invalid){ - playButton->setEnabled(true); - } else { - playButton->setEnabled(false); - } - break; - case Phonon::PlayingState: - playButton->setEnabled(true); - playButton->setIcon(pauseIcon); - if (m_MediaObject.hasVideo()) - m_videoWindow.show(); - // Fall through - case Phonon::BufferingState: - break; - case Phonon::LoadingState: - break; - } - -} - -void UBMediaPlayer::setVolume(qreal volume) -{ - m_AudioOutput.setVolume(volume); -} - - -void UBMediaPlayer::initVideoWindow() -{ - QVBoxLayout *videoLayout = new QVBoxLayout(); - videoLayout->addWidget(m_videoWidget); - videoLayout->setContentsMargins(0, 0, 0, 0); - m_videoWindow.setLayout(videoLayout); - m_videoWindow.setMinimumSize(60, 40); -} - -void UBMediaPlayer::playPause() -{ - if (m_MediaObject.state() == Phonon::PlayingState) - m_MediaObject.pause(); - else { - if (m_MediaObject.currentTime() == m_MediaObject.totalTime()) - m_MediaObject.seek(0); - m_MediaObject.play(); - } -} - -void UBMediaPlayer::setFile(const QString &fileName) -{ - setWindowTitle(fileName.right(fileName.length() - fileName.lastIndexOf('/') - 1)); - m_MediaObject.setCurrentSource(Phonon::MediaSource(fileName)); -} - -void UBMediaPlayer::setLocation(const QString& location) -{ - setWindowTitle(location.right(location.length() - location.lastIndexOf('/') - 1)); - m_MediaObject.setCurrentSource(Phonon::MediaSource(QUrl::fromEncoded(location.toUtf8()))); - m_MediaObject.play(); -} - - -void UBMediaPlayer::openFile() -{ - QStringList fileNames = QFileDialog::getOpenFileNames(this, QString(), QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); - - - m_MediaObject.clearQueue(); - if (fileNames.size() > 0) { - QString fileName = fileNames[0]; - setFile(fileName); - for (int i=1; isetText(QString()); - else { - QString str = QString::fromLatin1("(%1%)").arg(percent); - progressLabel->setText(str); - } -} - -void UBMediaPlayer::rewind() -{ - m_MediaObject.seek(0); -} - -void UBMediaPlayer::forward() -{ - QList queue = m_MediaObject.queue(); - if (queue.size() > 0) { - m_MediaObject.setCurrentSource(queue[0]); - m_MediaObject.play(); - } -} - -void UBMediaPlayer::openUrl() -{ - QSettings settings; - settings.beginGroup(QLatin1String("BrowserMainWindow")); - QString sourceURL = settings.value("location").toString(); - bool ok = false; - sourceURL = QInputDialog::getText(this, tr("Open Location"), tr("Please enter a valid address here:"), QLineEdit::Normal, sourceURL, &ok); - if (ok && !sourceURL.isEmpty()) { - setLocation(sourceURL); - settings.setValue("location", sourceURL); - } -} - -void UBMediaPlayer::finished() -{ -} - -void UBMediaPlayer::hasVideoChanged(bool bHasVideo) -{ - m_videoWindow.setVisible(bHasVideo); -} - -void UBMediaPlayer::resizeEvent(QResizeEvent* pEvent) -{ - Q_UNUSED(pEvent); -} diff --git a/src/gui/UBMediaPlayer.h b/src/gui/UBMediaPlayer.h deleted file mode 100644 index d8501bd8..00000000 --- a/src/gui/UBMediaPlayer.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef UBUBMediaPlayer_H -#define UBUBMediaPlayer_H - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE -class QPushButton; -class QLabel; -class QSlider; -class QTextEdit; -QT_END_NAMESPACE - -class UBMediaPlayer; - -class MediaVideoWidget : public Phonon::VideoWidget -{ - Q_OBJECT; - -public: - MediaVideoWidget(UBMediaPlayer *player, QWidget *parent = 0); - -protected: - void timerEvent(QTimerEvent *e); - -private: - UBMediaPlayer* m_player; - QBasicTimer m_timer; -}; - -class UBMediaPlayer : public QWidget -{ - Q_OBJECT -public: - UBMediaPlayer(); - - void setFile(const QString &text); - void setLocation(const QString &location); - void setVolume(qreal volume); - -public slots: - void openFile(); - void rewind(); - void forward(); - void finished(); - void playPause(); - -protected: - void resizeEvent(QResizeEvent* pEvent); - -private slots: - void stateChanged(Phonon::State newstate, Phonon::State oldstate); - void bufferStatus(int percent); - void openUrl(); - - void hasVideoChanged(bool); - -private: - void initVideoWindow(); - - QIcon playIcon; - QIcon pauseIcon; - QPushButton *playButton; - Phonon::SeekSlider *slider; - QLabel *progressLabel; - - QWidget m_videoWindow; - Phonon::MediaObject m_MediaObject; - Phonon::AudioOutput m_AudioOutput; - MediaVideoWidget *m_videoWidget; - Phonon::Path m_audioOutputPath; -}; - - - -#endif // UBUBMediaPlayer_H diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp index 4fe76953..62afccfc 100644 --- a/src/gui/UBTeacherGuideWidget.cpp +++ b/src/gui/UBTeacherGuideWidget.cpp @@ -287,7 +287,7 @@ UBTeacherGuidePresentationWidget::UBTeacherGuidePresentationWidget(QWidget *pare mpDocumentTitle = new QLabel(this); mpDocumentTitle->setObjectName("UBTGPresentationDocumentTitle"); - mpDocumentTitle->setText("Document title"); + mpDocumentTitle->setText(tr("Document title")); mpButtonTitleLayout->addWidget(mpModePushButton); mpButtonTitleLayout->addWidget(mpDocumentTitle); diff --git a/src/gui/UBTeacherGuideWidgetsTools.cpp b/src/gui/UBTeacherGuideWidgetsTools.cpp index b101113b..d63df4f3 100644 --- a/src/gui/UBTeacherGuideWidgetsTools.cpp +++ b/src/gui/UBTeacherGuideWidgetsTools.cpp @@ -210,7 +210,7 @@ UBTGMediaWidget::UBTGMediaWidget(QTreeWidgetItem* widget, QWidget* parent,const setAcceptDrops(true); addWidget(mpDropMeWidget); - setMinimumHeight(40); + setMinimumHeight(100); } UBTGMediaWidget::UBTGMediaWidget(QString relativePath, QTreeWidgetItem* widget, QWidget* parent,const char* name): QStackedWidget(parent) @@ -229,6 +229,7 @@ UBTGMediaWidget::UBTGMediaWidget(QString relativePath, QTreeWidgetItem* widget, setObjectName(name); setAcceptDrops(false); createWorkWidget(mRelativePath); + setMinimumHeight(200); } UBTGMediaWidget::~UBTGMediaWidget() @@ -306,7 +307,7 @@ void UBTGMediaWidget::createWorkWidget(QString& path) mpLayout = new QVBoxLayout(mpWorkWidget); if(!mIsPresentationMode){ mpTitle = new UBTGAdaptableText(mpTreeWidgetItem,mpWorkWidget); - mpLayout->addWidget(mpTitle); + mpLayout->addWidget(mpTitle,1); } if(mpMediaLabelWidget){ mpMediaLabelWidget->setParent(mpWorkWidget); @@ -321,6 +322,7 @@ void UBTGMediaWidget::createWorkWidget(QString& path) mpWebView->setParent(mpWorkWidget); mpLayout->addWidget(mpWebView); } + mpWorkWidget->setLayout(mpLayout); addWidget(mpWorkWidget); setCurrentWidget(mpWorkWidget); updateSize(); @@ -383,7 +385,6 @@ void UBTGMediaWidget::updateSize() } } - /*************************************************************************** * class UBTGUrlWdiget * ***************************************************************************/ diff --git a/src/gui/UBTeacherGuideWidgetsTools.h b/src/gui/UBTeacherGuideWidgetsTools.h index 1383b522..f098f0d2 100644 --- a/src/gui/UBTeacherGuideWidgetsTools.h +++ b/src/gui/UBTeacherGuideWidgetsTools.h @@ -139,6 +139,7 @@ private: QString mMediaType; }; + class UBTGUrlWidget : public QWidget , public iUBTGSavableData { Q_OBJECT diff --git a/src/gui/gui.pri b/src/gui/gui.pri index 264b9df3..a901409f 100644 --- a/src/gui/gui.pri +++ b/src/gui/gui.pri @@ -46,7 +46,6 @@ HEADERS += src/gui/UBThumbnailView.h \ src/gui/UBLibWebView.h \ src/gui/UBDownloadWidget.h \ src/gui/UBDockDownloadWidget.h \ - src/gui/UBMediaPlayer.h \ src/gui/UBDockTeacherGuideWidget.h \ src/gui/UBTeacherGuideWidget.h \ src/gui/UBTeacherGuideWidgetsTools.h \ @@ -100,7 +99,6 @@ SOURCES += src/gui/UBThumbnailView.cpp \ src/gui/UBLibWebView.cpp \ src/gui/UBDownloadWidget.cpp \ src/gui/UBDockDownloadWidget.cpp \ - src/gui/UBMediaPlayer.cpp \ src/gui/UBDockTeacherGuideWidget.cpp \ src/gui/UBTeacherGuideWidget.cpp \ src/gui/UBTeacherGuideWidgetsTools.cpp \ From 35467c4eaf125ff21a2f88a9ddaf6de0d133c7a4 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Thu, 12 Apr 2012 15:42:14 +0200 Subject: [PATCH 09/15] missing images --- resources/images/teacherGuide/audio.png | Bin 0 -> 3299 bytes resources/images/teacherGuide/image.png | Bin 0 -> 3349 bytes resources/images/teacherGuide/link.png | Bin 0 -> 3587 bytes resources/images/teacherGuide/movie.png | Bin 0 -> 3270 bytes resources/images/teacherGuide/w3c.png | Bin 0 -> 3325 bytes 5 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 resources/images/teacherGuide/audio.png create mode 100644 resources/images/teacherGuide/image.png create mode 100644 resources/images/teacherGuide/link.png create mode 100644 resources/images/teacherGuide/movie.png create mode 100644 resources/images/teacherGuide/w3c.png diff --git a/resources/images/teacherGuide/audio.png b/resources/images/teacherGuide/audio.png new file mode 100644 index 0000000000000000000000000000000000000000..ffb8fbf1d91b1909c5d7385d65f0381ccb739b95 GIT binary patch literal 3299 zcmV<93>@=`P)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0006GNkl!hJWq3WQEx)eKzRR_T-EfIo49a?n}Z6(H{Y5u(z-#zCzMAM?CJ|UZDyZ5{I$9K*> z_b3rTGee`v(R83`B;30@aNle&7Er7J2t)&l0jZl15fHH+9Gp7ySD-P1gNJ&~uJ1=- zCY74-<*-~?j^tOKLjXVksJgG(`bXqf-tX`QBxX&_n0~l0ySgh{Da9hS^pEv-?GqM% zHMEwDX9?CLGdwaE`&A#k(*44-gks4J`g&z%fh7iUgFe-pN|p#!*K6?w6k;vRVBtTX z5kMHQFq%-H-}<51IP7DL!jdnO>(UFX|N^0%*K)>Fx7yqt!*}-$#isBwN{2KzN;> za{JDOTk-hmcywDEK4zy;{pNw!T<~lqw3L1JKr4NUh46Y|8J(Sb(+z=N@~^tX;V$G0 zX{dmL>sqvjql-WFq08yR$+6utp^(9+TqUzLvghUbbK{p90^RaP_s!cBqR}m=x)!sk z51GEc(eb+O6injy&5KY#FxXy*Mt8mY?K7^Ohl@+|+pi~&K8{2-mr6xrPb7w~#$qR* h{L8da|KEW9J^(aA2^b;y4hsMP002ovPDHLkV1id*ENlP( literal 0 HcmV?d00001 diff --git a/resources/images/teacherGuide/image.png b/resources/images/teacherGuide/image.png new file mode 100644 index 0000000000000000000000000000000000000000..d07dda6d64253d7895a39c74a99a14e0c5a0f084 GIT binary patch literal 3349 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 literal 0 HcmV?d00001 diff --git a/resources/images/teacherGuide/link.png b/resources/images/teacherGuide/link.png new file mode 100644 index 0000000000000000000000000000000000000000..893643dbdf92eac00865ae108584ec971e482d39 GIT binary patch literal 3587 zcmV+e4*cKLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0009nNkl8QhWvvw=j$Y!&DO-@@qbh*)umFY{QfR)`RzjbgF6htBs4h{}*yWRBk z^e`|mPyj6g`u+YTm&-+6T^;Fknm`}`fX!yZ=kw9m*GE@Z7kC zXJktis6GMVJ@@iD({YHG^QD=I257z}v5UJ8Ihh|<>rU0q$hzCTV+Px<=wD?XnO zfQE(!Dl01seyCI`iN#`t4_lI?ACe>?gkWc92d!31d3iaTo0|n6zr4JV$z+hrfAvH< zokpkAQFLXEMgu@Dmt%c>9gRkV-EK#zROWM@o}O4+TjTET4uE((PBNLKs;a8E^;%k5 zxV*dsptZFXoleKe$w@(x06ZQK9*>8?!9kQtC4RpjtJV6WNTI{wxRl9cG&eUhIXOup zk;tq5UF`4gb8~Y;TU#6D<>kx3@>}4tR;&GQWMl-7$Ai!3!(cG5u&}_`*ce8mu?VQq zXvk)>I2?{|uY0n^#l^Qde;bX)L%m+#v$3&(TCK)xHd9?)jU-82Uti~|T3=s}BuUK9 z&VG^0<$*u-a^4^w9v+sqx3>ufgETfa5(T7?e=dfmFoLPZd2ri z;c(b_dwW|Ni^WhV6zKJOEEdb5TCG0(j353M{*keM2KcG?IRGw8Y&@X-%UJ*b002ov JPDHLkV1m12u#*4) literal 0 HcmV?d00001 diff --git a/resources/images/teacherGuide/movie.png b/resources/images/teacherGuide/movie.png new file mode 100644 index 0000000000000000000000000000000000000000..9150c659b7231a4095ffcf444b0c16d7a4dda005 GIT binary patch literal 3270 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 Ef)-^NB>(^b literal 0 HcmV?d00001 diff --git a/resources/images/teacherGuide/w3c.png b/resources/images/teacherGuide/w3c.png new file mode 100644 index 0000000000000000000000000000000000000000..028cd087de96abcf00f90513699b51efa18b0149 GIT binary patch literal 3325 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 Hu0mjfZu~IC literal 0 HcmV?d00001 From 71e8585b742a67ab2d1a8e24d9700b721e219583 Mon Sep 17 00:00:00 2001 From: Anatoly Mihalchenko Date: Thu, 12 Apr 2012 17:09:19 +0300 Subject: [PATCH 10/15] SANKORE-429 Document explorer(navigator): Imported ubz files are always imported into "Untitled Documents" folder --- src/adaptors/UBImportDocument.cpp | 2 +- src/core/UBPersistenceManager.cpp | 14 ++++++++++++-- src/core/UBPersistenceManager.h | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/adaptors/UBImportDocument.cpp b/src/adaptors/UBImportDocument.cpp index 7d43feee..27ba6673 100644 --- a/src/adaptors/UBImportDocument.cpp +++ b/src/adaptors/UBImportDocument.cpp @@ -191,7 +191,7 @@ UBDocumentProxy* UBImportDocument::importFile(const QFile& pFile, const QString& return 0; } else{ - UBDocumentProxy* newDocument = UBPersistenceManager::persistenceManager()->createDocumentFromDir(documentRootFolder); + UBDocumentProxy* newDocument = UBPersistenceManager::persistenceManager()->createDocumentFromDir(documentRootFolder, pGroup); UBApplication::showMessage(tr("Import successful.")); return newDocument; } diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index 23b5e3c3..8d0e1952 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -254,13 +254,23 @@ UBDocumentProxy* UBPersistenceManager::createDocument(const QString& pGroupName, return doc; } - -UBDocumentProxy* UBPersistenceManager::createDocumentFromDir(const QString& pDocumentDirectory) +UBDocumentProxy* UBPersistenceManager::createDocumentFromDir(const QString& pDocumentDirectory, const QString& pGroupName, const QString& pName, bool withEmptyPage) { checkIfDocumentRepositoryExists(); UBDocumentProxy* doc = new UBDocumentProxy(pDocumentDirectory); // deleted in UBPersistenceManager::destructor + if (pGroupName.length() > 0) + { + doc->setMetaData(UBSettings::documentGroupName, pGroupName); + } + + if (pName.length() > 0) + { + doc->setMetaData(UBSettings::documentName, pName); + } + if (withEmptyPage) createDocumentSceneAt(doc, 0); + QMap metadatas = UBMetadataDcSubsetAdaptor::load(pDocumentDirectory); foreach(QString key, metadatas.keys()) diff --git a/src/core/UBPersistenceManager.h b/src/core/UBPersistenceManager.h index 7a7bdd87..b9c53579 100644 --- a/src/core/UBPersistenceManager.h +++ b/src/core/UBPersistenceManager.h @@ -46,7 +46,7 @@ class UBPersistenceManager : public QObject static void destroy(); virtual UBDocumentProxy* createDocument(const QString& pGroupName = "", const QString& pName = "", bool withEmptyPage = true); - virtual UBDocumentProxy* createDocumentFromDir(const QString& pDocumentDirectory); + virtual UBDocumentProxy* createDocumentFromDir(const QString& pDocumentDirectory, const QString& pGroupName = "", const QString& pName = "", bool withEmptyPage = false); virtual UBDocumentProxy* persistDocumentMetadata(UBDocumentProxy* pDocumentProxy); From 368a4dc5a63d082e139ec9b8ef10c3ce6c6ef893 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Thu, 12 Apr 2012 16:33:36 +0200 Subject: [PATCH 11/15] Fixed the rotation issue --- src/domain/UBGraphicsDelegateFrame.cpp | 58 ++++++++++++++++++++------ 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/src/domain/UBGraphicsDelegateFrame.cpp b/src/domain/UBGraphicsDelegateFrame.cpp index c0e22a16..d6df2c62 100644 --- a/src/domain/UBGraphicsDelegateFrame.cpp +++ b/src/domain/UBGraphicsDelegateFrame.cpp @@ -254,10 +254,10 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) qreal moveY = -move.length() * sin((move.angle() - mAngle) * PI / 180); qreal width = delegated()->boundingRect().width() * mTotalScaleX; qreal height = delegated()->boundingRect().height() * mTotalScaleY; - mTranslateX = moveX; if(mOperationMode == Scaling) { + mTranslateX = moveX; // Perform the resize if (resizingBottomRight()) { @@ -353,6 +353,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) } else if (mOperationMode == Resizing) { + mTranslateX = moveX; UBResizableGraphicsItem* resizableItem = dynamic_cast(delegated()); if (resizableItem) @@ -390,12 +391,14 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) if (rotating()) { + mTranslateX = 0; + mTranslateY = 0; + QLineF startLine(sceneBoundingRect().center(), event->lastScenePos()); - QLineF currentLine(sceneBoundingRect().center(), event->scenePos()); + QLineF currentLine(sceneBoundingRect().center(), event->scenePos()); mAngle += startLine.angleTo(currentLine); - if ((int)mAngle % 45 >= 45 - mAngleTolerance - || (int)mAngle % 45 <= mAngleTolerance) + if ((int)mAngle % 45 >= 45 - mAngleTolerance || (int)mAngle % 45 <= mAngleTolerance) { mAngle = qRound(mAngle / 45) * 45; mAngleOffset += startLine.angleTo(currentLine); @@ -405,8 +408,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) mAngleOffset = 0; } } - else if ((int)mAngle % 30 >= 30 - mAngleTolerance - || (int)mAngle % 30 <= mAngleTolerance) + else if ((int)mAngle % 30 >= 30 - mAngleTolerance || (int)mAngle % 30 <= mAngleTolerance) { mAngle = qRound(mAngle / 30) * 30; mAngleOffset += startLine.angleTo(currentLine); @@ -498,10 +500,16 @@ QTransform UBGraphicsDelegateFrame::buildTransform() { QTransform tr; QPointF center = delegated()->boundingRect().center(); + + // Translate tr.translate(mTotalTranslateX + mTranslateX, mTotalTranslateY + mTranslateY); + + // Set angle tr.translate(center.x() * mTotalScaleX * mScaleX, center.y() * mTotalScaleY * mScaleY); tr.rotate(-mAngle); tr.translate(-center.x() * mTotalScaleX * mScaleX, -center.y() * mTotalScaleY * mScaleY); + + // Scale tr.scale(mTotalScaleX * mScaleX, mTotalScaleY * mScaleY); return tr; } @@ -565,35 +573,53 @@ void UBGraphicsDelegateFrame::setVisible(bool visible) void UBGraphicsDelegateFrame::positionHandles() { + // TODO: Check why the height is modified if the user rotates the item more than 90° + QRectF itemRect = delegated()->boundingRect(); QTransform itemTransform = delegated()->sceneTransform(); QPointF topLeft = itemTransform.map(itemRect.topLeft()); QPointF topRight = itemTransform.map(itemRect.topRight()); QPointF bottomLeft = itemTransform.map(itemRect.bottomLeft()); + QPointF bottomRight = itemTransform.map(itemRect.bottomRight()); QPointF center = itemTransform.map(itemRect.center()); + int rotateHeight = QLineF(topLeft, bottomLeft).length(); // Handle the mirroring if(topLeft.x() > topRight.x()){ - QPointF tmp = topRight; + QPointF topTmp = topRight; + QPointF bottomTmp = bottomRight; topRight = topLeft; - topLeft = tmp; - bottomLeft.setX(topLeft.x()); + topLeft = topTmp; + bottomRight = bottomLeft; + bottomLeft = bottomTmp; + } + + if(bottomLeft.y() > topLeft.y()){ + QPointF leftTmp = bottomLeft; + QPointF rightTmp = bottomRight; + bottomLeft = topLeft; + topLeft = leftTmp; + bottomRight = topRight; + topRight = rightTmp; } QLineF topLine(topLeft, topRight); qreal angle = topLine.angle(); qreal width = topLine.length(); + QLineF leftLine(topLeft, bottomLeft); qreal height = leftLine.length(); + int h = rotating()?rotateHeight:height; + if (mVisible) { - setRect(center.x() - mFrameWidth - width / 2, center.y() - mFrameWidth - height / 2, - width + 2 * mFrameWidth, height + 2 * mFrameWidth); + qDebug() << center.y(); + setRect(center.x() - mFrameWidth - width / 2, center.y() - mFrameWidth - h / 2, width + 2 * mFrameWidth, h + 2 * mFrameWidth); } else { - setRect(center.x() - width / 2, center.y() - height / 2, width, height); + setRect(center.x() - width / 2, center.y() - h / 2, width, h); } resetTransform(); @@ -680,30 +706,38 @@ UBGraphicsDelegateFrame::FrameTool UBGraphicsDelegateFrame::toolFromPos(QPointF return ResizeBottomRight; else if (bottomResizeGripRect().contains(pos)){ if(mMirrorY){ + qDebug() << "Top"; return ResizeTop; }else{ + qDebug() << "Bottom"; return ResizeBottom; } } else if (leftResizeGripRect().contains(pos)){ if(mMirrorX){ + qDebug() << "Right"; return ResizeRight; }else{ + qDebug() << "Left"; return ResizeLeft; } return ResizeLeft; } else if (rightResizeGripRect().contains(pos)){ if(mMirrorX){ + qDebug() << "Left"; return ResizeLeft; }else{ + qDebug() << "Right"; return ResizeRight; } } else if (topResizeGripRect().contains(pos)){ if(mMirrorY){ + qDebug() << "Bottom"; return ResizeBottom; }else{ + qDebug() << "Top"; return ResizeTop; } } From e36c0c8e488cbf75c3d0a75612abbd4005ac3882 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Thu, 12 Apr 2012 17:22:10 +0200 Subject: [PATCH 12/15] reworked the QTextEdit placeholder --- src/gui/UBTeacherGuideWidgetsTools.cpp | 42 +++++++++++++++----------- src/gui/UBTeacherGuideWidgetsTools.h | 7 +++-- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/gui/UBTeacherGuideWidgetsTools.cpp b/src/gui/UBTeacherGuideWidgetsTools.cpp index d63df4f3..ed39418f 100644 --- a/src/gui/UBTeacherGuideWidgetsTools.cpp +++ b/src/gui/UBTeacherGuideWidgetsTools.cpp @@ -71,6 +71,7 @@ UBTGActionWidget::UBTGActionWidget(QTreeWidgetItem* widget, QWidget* parent, con mpOwner->insertItems(0,qslOwner); mpOwner->setCurrentIndex(0); mpTask = new UBTGAdaptableText(widget,this); + mpTask->setPlaceHolderText(tr("Type task here ...")); mpTask->setAcceptRichText(true); mpTask->setTextColor(QColor().green()); mpTask->setObjectName("ActionWidgetTaskTextEdit"); @@ -102,6 +103,7 @@ UBTGAdaptableText::UBTGAdaptableText(QTreeWidgetItem* widget, QWidget* parent, c , mpTreeWidgetItem(widget) , mMinimumHeight(20) , mHasPlaceHolder(false) + , mIsUpdatingSize(false) { setObjectName(name); setStyleSheet( "QWidget {background: white; border:1 solid #999999; border-radius : 10px; padding: 2px;}"); @@ -113,36 +115,39 @@ UBTGAdaptableText::UBTGAdaptableText(QTreeWidgetItem* widget, QWidget* parent, c void UBTGAdaptableText::setPlaceHolderText(QString text) { + mHasPlaceHolder = true; // the space addition is to make this string unique and check against it to know // if we are talking about a typed string or the placeholder string mPlaceHolderText = text + " "; setTextColor(QColor(Qt::lightGray)); - setText(mPlaceHolderText); - onTextChanged(); - if(isHidden()) - show(); - mHasPlaceHolder = true; + setPlainText(mPlaceHolderText); } -void UBTGAdaptableText::focusInEvent(QFocusEvent *e) +void UBTGAdaptableText::keyPressEvent(QKeyEvent* e) { - if(mHasPlaceHolder && toPlainText() == mPlaceHolderText){ - setText(""); + if(toPlainText() == mPlaceHolderText){ setTextColor(QColor(Qt::black)); + setPlainText(""); } - - e->accept(); + QTextEdit::keyPressEvent(e); } - -void UBTGAdaptableText::focusOutEvent(QFocusEvent *e) +void UBTGAdaptableText::keyReleaseEvent(QKeyEvent* e) { - if(mHasPlaceHolder && toPlainText().length() == 0){ + QTextEdit::keyReleaseEvent(e); + + if(toPlainText().isEmpty()){ setTextColor(QColor(Qt::lightGray)); - setText(mPlaceHolderText); + setPlainText(mPlaceHolderText); } - e->accept(); +} + +void UBTGAdaptableText::showEvent(QShowEvent* e) +{ + Q_UNUSED(e); + if(!mIsUpdatingSize && mHasPlaceHolder && toPlainText().isEmpty()) + setPlainText(mPlaceHolderText); } QString UBTGAdaptableText::text() @@ -156,6 +161,7 @@ QString UBTGAdaptableText::text() void UBTGAdaptableText::onTextChanged() { + mIsUpdatingSize = true; if(document()->size().height() < mMinimumHeight) setFixedHeight(mMinimumHeight); else @@ -167,6 +173,7 @@ void UBTGAdaptableText::onTextChanged() mpTreeWidgetItem->setExpanded(true); setFocus(); } + mIsUpdatingSize = false; } void UBTGAdaptableText::showText(const QString & text) @@ -210,7 +217,7 @@ UBTGMediaWidget::UBTGMediaWidget(QTreeWidgetItem* widget, QWidget* parent,const setAcceptDrops(true); addWidget(mpDropMeWidget); - setMinimumHeight(100); + setMinimumHeight(200); } UBTGMediaWidget::UBTGMediaWidget(QString relativePath, QTreeWidgetItem* widget, QWidget* parent,const char* name): QStackedWidget(parent) @@ -307,6 +314,7 @@ void UBTGMediaWidget::createWorkWidget(QString& path) mpLayout = new QVBoxLayout(mpWorkWidget); if(!mIsPresentationMode){ mpTitle = new UBTGAdaptableText(mpTreeWidgetItem,mpWorkWidget); + mpTitle->setPlaceHolderText(tr("Type title here...")); mpLayout->addWidget(mpTitle,1); } if(mpMediaLabelWidget){ @@ -347,8 +355,6 @@ void UBTGMediaWidget::parseMimeData(const QMimeData* pMimeData) qDebug() << "No mime data present"; createWorkWidget(path); - QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(path); - qDebug() << mimeType; } void UBTGMediaWidget::dropEvent(QDropEvent* event) diff --git a/src/gui/UBTeacherGuideWidgetsTools.h b/src/gui/UBTeacherGuideWidgetsTools.h index f098f0d2..523aea08 100644 --- a/src/gui/UBTeacherGuideWidgetsTools.h +++ b/src/gui/UBTeacherGuideWidgetsTools.h @@ -96,14 +96,17 @@ public slots: void onTextChanged(); protected: - void focusInEvent(QFocusEvent *e); - void focusOutEvent(QFocusEvent *e); + void keyPressEvent(QKeyEvent* e); + void keyReleaseEvent(QKeyEvent* e); + void showEvent(QShowEvent* e); + private: int mBottomMargin; QTreeWidgetItem* mpTreeWidgetItem; int mMinimumHeight; bool mHasPlaceHolder; QString mPlaceHolderText; + bool mIsUpdatingSize; }; From c4a694e73ff1e491cc0ff809a6db918e73dd1a07 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Thu, 12 Apr 2012 18:08:40 +0200 Subject: [PATCH 13/15] fixed issue of multiple lines on the teacher bar on the presentation mode --- src/gui/UBTeacherGuideWidget.cpp | 12 ++++++++---- src/gui/UBTeacherGuideWidgetsTools.cpp | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp index 62afccfc..e4c85225 100644 --- a/src/gui/UBTeacherGuideWidget.cpp +++ b/src/gui/UBTeacherGuideWidget.cpp @@ -386,10 +386,14 @@ void UBTeacherGuidePresentationWidget::showData(QVector data) else if(element->type == "action"){ QTreeWidgetItem* newWidgetItem = new QTreeWidgetItem(mpRootWidgetItem); newWidgetItem->setText(0,element->attributes.value("task")); - QColor color = element->attributes.value("owner").toInt() == 0 ? QColor(Qt::red):QColor(Qt::green); - newWidgetItem->setData(0,Qt::ForegroundRole,QBrush(color)); - newWidgetItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_NONE); - newWidgetItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),11))); + QString colorString = element->attributes.value("owner").toInt() == 0 ? "red":"green"; + UBTGAdaptableText* textWidget = new UBTGAdaptableText(newWidgetItem,0); + textWidget->bottomMargin(15); + textWidget->setStyleSheet("QWidget {background: #EEEEEE; border:none; color:" + colorString + ";}"); + textWidget->showText(element->attributes.value("task")); + textWidget->document()->setDefaultFont(QFont(QApplication::font().family(),11)); + mpTreeWidget->setItemWidget(newWidgetItem,0,textWidget); + mpRootWidgetItem->addChild(newWidgetItem); } else if(element->type == "media"){ diff --git a/src/gui/UBTeacherGuideWidgetsTools.cpp b/src/gui/UBTeacherGuideWidgetsTools.cpp index ed39418f..c2b10990 100644 --- a/src/gui/UBTeacherGuideWidgetsTools.cpp +++ b/src/gui/UBTeacherGuideWidgetsTools.cpp @@ -327,6 +327,7 @@ void UBTGMediaWidget::createWorkWidget(QString& path) mpLayout->addWidget(mpMediaWidget); } else if (mpWebView){ + mpWebView->setMaximumHeight(mpTreeWidgetItem->treeWidget()->size().width()); mpWebView->setParent(mpWorkWidget); mpLayout->addWidget(mpWebView); } From a3582234785895c13697fa1b980164ff1eaa77d0 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Thu, 12 Apr 2012 18:15:26 +0200 Subject: [PATCH 14/15] UBTGAdaptableText handling the resize event --- src/gui/UBTeacherGuideWidget.cpp | 2 +- src/gui/UBTeacherGuideWidgetsTools.cpp | 6 ++++++ src/gui/UBTeacherGuideWidgetsTools.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp index e4c85225..8d770c64 100644 --- a/src/gui/UBTeacherGuideWidget.cpp +++ b/src/gui/UBTeacherGuideWidget.cpp @@ -388,7 +388,7 @@ void UBTeacherGuidePresentationWidget::showData(QVector data) newWidgetItem->setText(0,element->attributes.value("task")); QString colorString = element->attributes.value("owner").toInt() == 0 ? "red":"green"; UBTGAdaptableText* textWidget = new UBTGAdaptableText(newWidgetItem,0); - textWidget->bottomMargin(15); + textWidget->bottomMargin(14); textWidget->setStyleSheet("QWidget {background: #EEEEEE; border:none; color:" + colorString + ";}"); textWidget->showText(element->attributes.value("task")); textWidget->document()->setDefaultFont(QFont(QApplication::font().family(),11)); diff --git a/src/gui/UBTeacherGuideWidgetsTools.cpp b/src/gui/UBTeacherGuideWidgetsTools.cpp index c2b10990..66962bc4 100644 --- a/src/gui/UBTeacherGuideWidgetsTools.cpp +++ b/src/gui/UBTeacherGuideWidgetsTools.cpp @@ -194,6 +194,12 @@ void UBTGAdaptableText::bottomMargin(int newValue) onTextChanged(); } +void UBTGAdaptableText::resizeEvent(QResizeEvent* e) +{ + QTextEdit::resizeEvent(e); + onTextChanged(); +} + /*************************************************************************** * class UBTGMediaWidget * ***************************************************************************/ diff --git a/src/gui/UBTeacherGuideWidgetsTools.h b/src/gui/UBTeacherGuideWidgetsTools.h index 523aea08..fe1248d8 100644 --- a/src/gui/UBTeacherGuideWidgetsTools.h +++ b/src/gui/UBTeacherGuideWidgetsTools.h @@ -99,6 +99,7 @@ protected: void keyPressEvent(QKeyEvent* e); void keyReleaseEvent(QKeyEvent* e); void showEvent(QShowEvent* e); + void resizeEvent(QResizeEvent* e); private: int mBottomMargin; From d1f7f5f8f23456b7f77e7cc0370ec20764507907 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Thu, 12 Apr 2012 18:40:38 +0200 Subject: [PATCH 15/15] gui hack --- src/gui/UBTeacherGuideWidgetsTools.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/UBTeacherGuideWidgetsTools.cpp b/src/gui/UBTeacherGuideWidgetsTools.cpp index 66962bc4..73b89276 100644 --- a/src/gui/UBTeacherGuideWidgetsTools.cpp +++ b/src/gui/UBTeacherGuideWidgetsTools.cpp @@ -197,7 +197,7 @@ void UBTGAdaptableText::bottomMargin(int newValue) void UBTGAdaptableText::resizeEvent(QResizeEvent* e) { QTextEdit::resizeEvent(e); - onTextChanged(); + QTimer::singleShot(100,this,SLOT(onTextChanged())); } /***************************************************************************