diff --git a/Sankore 3.1.iss b/Sankore 3.1.iss index 553f777f..eaeacb68 100644 --- a/Sankore 3.1.iss +++ b/Sankore 3.1.iss @@ -45,7 +45,10 @@ Type: files ; Name: "{app}\*.dll" [Files] Source: "..\Sankore-ThirdParty\microsoft\vcredist_x86.exe"; DestDir:"{tmp}" -Source: ".\build\win32\release\product\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs +Source: "build\win32\release\product\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs + +;Sankore plugins +Source: "plugins\cffadaptor\build\win32\release\lib\CFF_Adaptor.dll"; DestDir: "{app}"; Flags: ignoreversion ;OpenSSL Source: "..\Sankore-ThirdParty\openssl\win32\libeay32.dll"; DestDir:"{app}"; Flags: ignoreversion @@ -60,6 +63,7 @@ Source: "..\Qt-sankore3.1\lib\QtWebKit4.dll"; DestDir: "{app}"; Flags: ignorever Source: "..\Qt-sankore3.1\lib\phonon4.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\Qt-sankore3.1\lib\QtNetwork4.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\Qt-sankore3.1\lib\QtSvg4.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "..\Qt-sankore3.1\lib\QtOpenGL4.dll"; DestDir: "{app}"; Flags: ignoreversion ;Qt plugins Source: "..\Qt-sankore3.1\plugins\accessible\qtaccessiblecompatwidgets4.dll"; DestDir: "{app}\accessible"; Flags: ignoreversion diff --git a/release.linux.sh b/release.linux.sh index 79bdc17c..313ac7dc 100755 --- a/release.linux.sh +++ b/release.linux.sh @@ -39,14 +39,18 @@ checkDirectory(){ # path definition # ####################################################################### QT_PATH="/usr/local/Trolltech/Qt-4.7.3" -PLUGINS_PATH="$QT_PATH/plugins" +QT_PLUGINS_PATH="$QT_PATH/plugins" RELEASE_DIR=build/linux/release BUILD_DIR=$RELEASE_DIR/product GUI_TRANSLATIONS_DIRECTORY_PATH="../Qt-sankore3.1/translations" QT_LIBRARY_SOURCE_PATH="$QT_PATH/lib" +SANKORE_SRC_PLUGINS_PATH="plugins" +SANKORE_DST_PLUGINS_PATH=build/linux/release/product/plugins +CFF_ADAPTOR_SRC_PLUGIN_PATH=$SANKORE_SRC_PLUGINS_PATH/cffadaptor/build/linux/release/lib QMAKE_PATH="$QT_PATH/bin/qmake" -LRELEASE="/usr/local/Trolltech/Qt-4.7.3/bin/lrelease" +LRELEASE="../Qt-sankore3.1/bin/lrelease" +#LRELEASE="/usr/local/Trolltech/Qt-4.7.3/bin/lrelease" ARCHITECTURE=`uname -m` @@ -57,13 +61,15 @@ checkExecutable $QMAKE_PATH checkExecutable $LRELEASE checkDirectory $GUI_TRANSLATIONS_DIRECTORY_PATH -checkDirectory $PLUGINS_PATH +checkDirectory $QT_PLUGINS_PATH checkDirectory $QT_LIBRARY_SOURCE_PATH +checkDirectory $CFF_ADAPTOR_PLUGIN_PATH + ####################################################################### # cleaning # ####################################################################### -rm -rf $RELEASE_DIR +#rm -rf $RELEASE_DIR ####################################################################### @@ -126,21 +132,26 @@ cp -R resources/linux/qtlinux/* $BUILD_DIR cp -R resources/customizations $BUILD_DIR +notify-send "Sankore" "Copying plugins..." +mkdir "$SANKORE_DST_PLUGINS_PATH" +mkdir "$SANKORE_DST_PLUGINS_PATH/cffadaptor" +cp -R $CFF_ADAPTOR_SRC_PLUGIN_PATH/*.so* "$SANKORE_DST_PLUGINS_PATH/cffadaptor" + notify-send "QT" "Coping plugins and library ..." -cp -R $PLUGINS_PATH $BUILD_DIR +cp -R $QT_PLUGINS_PATH $BUILD_DIR #copying custom qt library QT_LIBRARY_DEST_PATH="$BUILD_DIR/qtlib" mkdir $QT_LIBRARY_DEST_PATH copyQtLibrary(){ - if [ ! -e "$QT_LIBRARY_SOURCE_PATH/$1.so.4.7.3" ]; then + if [ ! -e "$QT_LIBRARY_SOURCE_PATH/$1.so.4" ]; then notifyError "$1 library not found in path: $QT_LIBRARY_SOURCE_PATH" fi - cp "$QT_LIBRARY_SOURCE_PATH/$1.so.4" "$QT_LIBRARY_DEST_PATH/" - cp "$QT_LIBRARY_SOURCE_PATH/$1.so.4.7.3" "$QT_LIBRARY_DEST_PATH/" + cp $QT_LIBRARY_SOURCE_PATH/$1.so.4.* $QT_LIBRARY_DEST_PATH/ } +copyQtLibrary libphonon copyQtLibrary libQtWebKit copyQtLibrary libQtDBus copyQtLibrary libQtScript @@ -150,14 +161,8 @@ copyQtLibrary libQtNetwork copyQtLibrary libQtXml copyQtLibrary libQtGui copyQtLibrary libQtCore - -if [ ! -e "$QT_LIBRARY_SOURCE_PATH/libphonon.so.4.4.0" ]; then - notifyError "phonon library not found in path: $QT_LIBRARY_SOURCE_PATH" -else - cp "$QT_LIBRARY_SOURCE_PATH/libphonon.so.4" "$QT_LIBRARY_DEST_PATH/" - cp "$QT_LIBRARY_SOURCE_PATH/libphonon.so.4.4.0" "$QT_LIBRARY_DEST_PATH/" -fi - +# uncomment for Qt 4.8 +#copyQtLibrary libQtOpenGL ####################################################################### # Removing unwanted files # @@ -279,7 +284,7 @@ echo "Priority: optional" >> "$CONTROL_FILE" echo "Architecture: $ARCHITECTURE" >> "$CONTROL_FILE" echo "Essential: no" >> "$CONTROL_FILE" echo "Installed-Size: `du -s $SANKORE_PACKAGE_DIRECTORY | awk '{ print $1 }'`" >> "$CONTROL_FILE" -echo "Maintainer: Open-Sankoré Developers team " >> "$CONTROL_FILE" +echo "Maintainer: Open-Sankore Developers team " >> "$CONTROL_FILE" echo "Homepage: http://dev.open-sankore.org" >> "$CONTROL_FILE" echo -n "Depends: " >> "$CONTROL_FILE" unset tab @@ -318,7 +323,7 @@ echo "Version=$VERSION" >> $SANKORE_SHORTCUT echo "Encoding=UTF-8" >> $SANKORE_SHORTCUT echo "Name=Open-Sankore ($VERSION)" >> $SANKORE_SHORTCUT echo "GenericName=Open-Sankore" >> $SANKORE_SHORTCUT -echo "Comment=Logiciel de création de présentations pour tableau numérique interactif (TNI)" >> $SANKORE_SHORTCUT +echo "Comment=Logiciel de creation de presentations pour tableau numerique interactif (TNI)" >> $SANKORE_SHORTCUT echo "Exec=/usr/local/$SANKORE_DIRECTORY_NAME/run.sh" >> $SANKORE_SHORTCUT echo "Icon=/usr/local/$SANKORE_DIRECTORY_NAME/sankore.png" >> $SANKORE_SHORTCUT echo "StartupNotify=true" >> $SANKORE_SHORTCUT @@ -353,4 +358,4 @@ cd $RELEASE_DIR rm ../../../install/linux/Open-Sankore.tar.gz tar cvzf ../../../install/linux/Open-Sankore.tar.gz Open-Sankore.$VERSION -C . -notify-send "Open-Sankore" "tar.gz Build done" +notify-send "Open-Sankore" "tar.gz Build done" \ No newline at end of file diff --git a/release.win7.vc9.64.bat b/release.win7.vc9.64.bat index 810f9b0d..b344d2f8 100644 --- a/release.win7.vc9.64.bat +++ b/release.win7.vc9.64.bat @@ -62,7 +62,7 @@ nmake release-install copy %BASE_QT_TRANSLATIONS_DIRECTORY%\qt_*.qm build\win32\release\product\i18n\ del build\win32\release\product\i18n\qt_help* -del ".\build\win32\release\product\Sankore.pdb" +del "build\win32\release\product\Sankore.pdb" set INSTALLER_NAME=Open-Sankore diff --git a/release.win7.vc9.bat b/release.win7.vc9.bat index 51885958..dbf91aa2 100644 --- a/release.win7.vc9.bat +++ b/release.win7.vc9.bat @@ -66,7 +66,7 @@ copy resources\customizations build\win32\release\product\ del build\win32\release\product\i18n\qt_help* -del ".\build\win32\release\product\Sankore.pdb" +del "build\win32\release\product\Sankore.pdb" set INSTALLER_NAME=Open-Sankore diff --git a/src/board/UBDrawingController.cpp b/src/board/UBDrawingController.cpp index e03ef408..a9e4b813 100644 --- a/src/board/UBDrawingController.cpp +++ b/src/board/UBDrawingController.cpp @@ -45,7 +45,7 @@ UBDrawingController::UBDrawingController(QObject * parent) , mActiveRuler(NULL) , mStylusTool((UBStylusTool::Enum)-1) , mLatestDrawingTool((UBStylusTool::Enum)-1) - , mDrawingMode(DRAWING_MODE) + , mDrawingMode(/*DRAWING_MODE*/eDrawingMode_Vector) { connect(UBSettings::settings(), SIGNAL(colorContextChanged()), this, SIGNAL(colorPaletteChanged())); @@ -114,7 +114,7 @@ void UBDrawingController::setStylusTool(int tool) UBApplication::mainWindow->actionPen->setChecked(true); else if (mStylusTool == UBStylusTool::Eraser){ UBApplication::mainWindow->actionEraser->setChecked(true); - mDrawingMode = eDrawingMode_Artistic; + //mDrawingMode = eDrawingMode_Artistic; } else if (mStylusTool == UBStylusTool::Marker) UBApplication::mainWindow->actionMarker->setChecked(true); diff --git a/src/board/UBDrawingController.h b/src/board/UBDrawingController.h index 21d4f78d..4c620f1c 100644 --- a/src/board/UBDrawingController.h +++ b/src/board/UBDrawingController.h @@ -27,7 +27,7 @@ typedef enum{ eDrawingMode_Vector }eDrawingMode; -#define DRAWING_MODE eDrawingMode_Artistic +#define DRAWING_MODE eDrawingMode_Vector class UBDrawingController : public QObject { diff --git a/src/domain/UBGraphicsDelegateFrame.cpp b/src/domain/UBGraphicsDelegateFrame.cpp index 54dc4650..027d35da 100644 --- a/src/domain/UBGraphicsDelegateFrame.cpp +++ b/src/domain/UBGraphicsDelegateFrame.cpp @@ -583,9 +583,9 @@ void UBGraphicsDelegateFrame::positionHandles() { QRectF itemRect = delegated()->boundingRect(); - if (mDelegate->getToolBarItem()->isVisibleOnBoard() - && mDelegate->getToolBarItem()->isShifting()) - itemRect.setHeight(itemRect.height() + mDelegate->getToolBarItem()->rect().height() * mDelegate->antiScaleRatio() * 1.1); +// if (mDelegate->getToolBarItem()->isVisibleOnBoard() +// && mDelegate->getToolBarItem()->isShifting()) +// itemRect.setHeight(itemRect.height() + mDelegate->getToolBarItem()->rect().height() * mDelegate->antiScaleRatio() * 1.1); QTransform itemTransform = delegated()->sceneTransform(); QPointF topLeft = itemTransform.map(itemRect.topLeft()); diff --git a/src/domain/UBGraphicsItemDelegate.cpp b/src/domain/UBGraphicsItemDelegate.cpp index ad352753..f167e9d9 100644 --- a/src/domain/UBGraphicsItemDelegate.cpp +++ b/src/domain/UBGraphicsItemDelegate.cpp @@ -118,7 +118,7 @@ UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObjec void UBGraphicsItemDelegate::init() { - mToolBarItem = new UBGraphicsToolBarItem(delegated()); + //mToolBarItem = new UBGraphicsToolBarItem(delegated()); mFrame = new UBGraphicsDelegateFrame(this, QRectF(0, 0, 0, 0), mFrameWidth, mRespectRatio); mFrame->hide(); @@ -168,7 +168,9 @@ UBGraphicsItemDelegate::~UBGraphicsItemDelegate() QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) { - if (change == QGraphicsItem::ItemSelectedHasChanged) { + if(change == QGraphicsItem::ItemChildAddedChange){ + + }else if (change == QGraphicsItem::ItemSelectedHasChanged) { bool ok; bool selected = value.toUInt(&ok); if (ok) { @@ -331,17 +333,17 @@ void UBGraphicsItemDelegate::positionHandles() updateButtons(true); - if (mToolBarItem->isVisibleOnBoard()) - { - updateToolBar(); - mToolBarItem->show(); - } +// if (mToolBarItem->isVisibleOnBoard()) +// { +// updateToolBar(); +// mToolBarItem->show(); +// } } else { foreach(DelegateButton* button, mButtons) button->hide(); mFrame->hide(); - mToolBarItem->hide(); +// mToolBarItem->hide(); } } @@ -381,7 +383,7 @@ void UBGraphicsItemDelegate::remove(bool canUndo) scene->removeItem(mFrame); scene->removeItem(mDelegated); - scene->removeItem(mToolBarItem); + //scene->removeItem(mToolBarItem); if (canUndo) { diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index da622bda..c5dafd02 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -317,9 +317,11 @@ UBGraphicsScene::~UBGraphicsScene() void UBGraphicsScene::selectionChangedProcessing() { - if (selectedItems().count()) + if (selectedItems().count()){ + qDebug() << "Selected item bounding rect: " << selectedItems().first()->boundingRect(); UBApplication::showMessage("ZValue is " + QString::number(selectedItems().first()->zValue(), 'f') + "own z value is " + QString::number(selectedItems().first()->data(UBGraphicsItemData::ItemOwnZValue).toReal(), 'f')); + } } void UBGraphicsScene::updateGroupButtonState() { @@ -792,6 +794,8 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth, void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) { +// QList itemList; + const QLineF line(mPreviousPoint, pEndPoint); const QPolygonF eraserPolygon = UBGeometryUtils::lineToPolygon(line, pWidth); @@ -838,24 +842,29 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) if (mShouldUseOMP) { - #pragma omp parallel for +// #pragma omp parallel for for (int i = 0; i < collidItemsSize; i++) { - UBGraphicsPolygonItem *collidingPolygonItem = dynamic_cast(collidItems.at(i)); + UBGraphicsPolygonItem *collidingPolygonItem = qgraphicsitem_cast(collidItems.at(i)); if (NULL != collidingPolygonItem) { + collidingPolygonItem->setColor(QColor(Qt::green)); + UBGraphicsStrokesGroup* pGroup = collidingPolygonItem->strokesGroup(); if(eraserInnerRect.contains(collidingPolygonItem->boundingRect())) { - #pragma omp critical +// #pragma omp critical + qDebug() << "case 1"; // Put the entire polygon into the remove list + collidingPolygonItem->setColor(QColor(Qt::blue)); toBeRemovedItems << collidingPolygonItem; } else { // Here we get the polygon of the colliding item + QPolygonF collidingPolygon = collidingPolygonItem->polygon(); QPainterPath collidingPath; collidingPath.addPolygon(collidingPolygon); @@ -864,32 +873,40 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) QPainterPath croppedPath = collidingPath.subtracted(eraserPath); QPainterPath croppedPathSimplified = croppedPath.simplified(); - if (croppedPath == collidingPath) + /*if (croppedPath == collidingPath) { // NOOP + qDebug() << "case 2"; + toBeRemovedItems << collidingPolygonItem; } - else if (croppedPathSimplified.isEmpty()) + else */if (croppedPathSimplified.isEmpty()) { - #pragma omp critical +// #pragma omp critical + qDebug() << "case 3"; // Put the entire polygon into the remove list if the eraser removes all its visible content + collidingPolygonItem->setColor(QColor(Qt::blue)); toBeRemovedItems << collidingPolygonItem; } else { + //qDebug() << "case 4"; // Then we convert the remaining path to a list of polygons that will be converted in // UBGraphicsPolygonItems and added to the scene foreach(const QPolygonF &pol, croppedPathSimplified.toFillPolygons()) { UBGraphicsPolygonItem* croppedPolygonItem = collidingPolygonItem->deepCopy(pol); - #pragma omp critical - // Add this new polygon to the 'added' list - toBeAddedItems << croppedPolygonItem; + croppedPolygonItem->setColor(QColor(Qt::black)); +// #pragma omp critical if(NULL != pGroup){ croppedPolygonItem->setStrokesGroup(pGroup); +// croppedPolygonItem->setTransform(pGroup->sceneTransform().inverted()); } + // Add this new polygon to the 'added' list + toBeAddedItems << croppedPolygonItem; } - #pragma omp critical +// #pragma omp critical // Remove the original polygonitem because it has been replaced by many smaller polygons + collidingPolygonItem->setColor(QColor(Qt::blue)); toBeRemovedItems << collidingPolygonItem; } } @@ -900,11 +917,12 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) { for (int i = 0; i < collidItemsSize; i++) { - UBGraphicsPolygonItem *collidingPolygonItem - = qgraphicsitem_cast (collidItems.at(i)); + UBGraphicsPolygonItem *collidingPolygonItem = dynamic_cast (collidItems.at(i)); if (collidingPolygonItem) { + UBGraphicsStrokesGroup* pGroup = collidingPolygonItem->strokesGroup(); + if(eraserInnerRect.contains(collidingPolygonItem->boundingRect())) { toBeRemovedItems << collidingPolygonItem; @@ -932,6 +950,9 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) { UBGraphicsPolygonItem* croppedPolygonItem = collidingPolygonItem->deepCopy(pol); toBeAddedItems << croppedPolygonItem; + if(NULL != pGroup){ + croppedPolygonItem->setStrokesGroup(pGroup); + } } toBeRemovedItems << collidingPolygonItem; @@ -941,28 +962,50 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth) } } - addItems(toBeAddedItems); - mAddedItems += toBeAddedItems; - if(eDrawingMode_Vector == DRAWING_MODE){ - foreach(QGraphicsItem* item, toBeAddedItems){ + foreach(QGraphicsItem* item, toBeRemovedItems){ UBGraphicsPolygonItem* poly = dynamic_cast(item); - if(NULL != poly && NULL != poly->strokesGroup()){ - poly->strokesGroup()->addToGroup(poly); + if(NULL != poly){ + if(NULL != poly->strokesGroup()){ + poly->strokesGroup()->removeFromGroup(poly); + removeItem(poly); + }else{ + qDebug() << "No group present"; + } } } + }else{ + removeItems(toBeRemovedItems); + mRemovedItems += toBeRemovedItems; } - removeItems(toBeRemovedItems); - mRemovedItems += toBeRemovedItems; - +// bool hack = false; +// UBGraphicsStrokesGroup* pG = new UBGraphicsStrokesGroup(); if(eDrawingMode_Vector == DRAWING_MODE){ - foreach(QGraphicsItem* item, toBeRemovedItems){ + foreach(QGraphicsItem* item, toBeAddedItems){ UBGraphicsPolygonItem* poly = dynamic_cast(item); if(NULL != poly && NULL != poly->strokesGroup()){ - poly->strokesGroup()->removeFromGroup(poly); +// if(!hack){ +// itemList = poly->strokesGroup()->childItems(); +// removeItem(poly->strokesGroup()); + +// foreach(QGraphicsItem* it, itemList){ +// pG->addToGroup(it); +// } +// hack = true; +// } + qreal dx = -poly->strokesGroup()->sceneTransform().inverted().dx(); + qreal dy = -poly->strokesGroup()->sceneTransform().inverted().dy(); + + //poly->setTransform(QTransform().translate(20, 0)); + poly->setTransform(QTransform().translate(dx, dy)); + poly->strokesGroup()/*pG*/->addToGroup(poly); } } + //addItem(pG); + }else{ + addItems(toBeAddedItems); + mAddedItems += toBeAddedItems; } } diff --git a/src/gui/UBFeaturesActionBar.cpp b/src/gui/UBFeaturesActionBar.cpp index 8311bfc9..a151406d 100644 --- a/src/gui/UBFeaturesActionBar.cpp +++ b/src/gui/UBFeaturesActionBar.cpp @@ -66,8 +66,8 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid mButtonGroup->addButton(mpRemoveFavoriteBtn); mButtonGroup->addButton(mpNewFolderBtn); // Connect signals & slots - connect(mpFavoriteAction,SIGNAL(triggered()), this, SLOT(onActionFavorite())); - /*connect(mpSocialAction,SIGNAL(triggered()), this, SLOT(onActionSocial())); + /*connect(mpFavoriteAction,SIGNAL(triggered()), this, SLOT(onActionFavorite())); + connect(mpSocialAction,SIGNAL(triggered()), this, SLOT(onActionSocial())); connect(mpSearchAction,SIGNAL(triggered()), this, SLOT(onActionSearch())); connect(mpDeleteAction,SIGNAL(triggered()), this, SLOT(onActionTrash())); connect(mpCloseAction, SIGNAL(triggered()), this, SLOT(onActionClose())); @@ -75,8 +75,11 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid connect(mSearchBar, SIGNAL(textChanged(QString)), this, SLOT(onSearchTextChanged(QString))); connect(mpNewFolderAction, SIGNAL(triggered()), this, SLOT(onActionNewFolder()));*/ + connect(mpFavoriteAction,SIGNAL(triggered()), this, SLOT(onActionFavorite())); connect(mSearchBar, SIGNAL(textChanged(QString)), this, SLOT(onSearchTextChanged(QString))); connect(mpNewFolderAction, SIGNAL(triggered()), this, SLOT(onActionNewFolder())); + connect(mpRemoveFavorite, SIGNAL(triggered()), this, SLOT(onActionRemoveFavorite())); + connect(mpDeleteAction,SIGNAL(triggered()), this, SLOT(onActionTrash())); // Build the default toolbar mLayout->addWidget(mpFavoriteBtn); @@ -148,6 +151,8 @@ void UBFeaturesActionBar::setButtons() mpFavoriteBtn->hide(); mpSocialBtn->hide(); mSearchBar->show(); + mpDeleteBtn->show(); + mpDeleteBtn->setEnabled(true); //mpSearchBtn->show(); //mpDeleteBtn->hide(); mpCloseBtn->hide(); @@ -175,6 +180,16 @@ void UBFeaturesActionBar::onActionFavorite() emit addElementsToFavorite(); } +void UBFeaturesActionBar::onActionRemoveFavorite() +{ + emit removeElementsFromFavorite(); +} + +void UBFeaturesActionBar::onActionTrash() +{ + emit deleteSelectedElements(); +} + /* void UBFeaturesActionBar::dragMoveEvent(QDragMoveEvent *event) { diff --git a/src/gui/UBFeaturesActionBar.h b/src/gui/UBFeaturesActionBar.h index 7aec99a9..99664a6d 100644 --- a/src/gui/UBFeaturesActionBar.h +++ b/src/gui/UBFeaturesActionBar.h @@ -31,10 +31,14 @@ signals: void addToFavorite( const QMimeData &data ); void removeFromFavorite( const QMimeData &data ); void addElementsToFavorite(); + void removeElementsFromFavorite(); + void deleteSelectedElements(); private slots: void onSearchTextChanged(QString txt); void onActionNewFolder(); void onActionFavorite(); + void onActionRemoveFavorite(); + void onActionTrash(); protected: //void dragMoveEvent(QDragMoveEvent *event); void dragEnterEvent( QDragEnterEvent *event ); diff --git a/src/gui/UBFeaturesWidget.cpp b/src/gui/UBFeaturesWidget.cpp index 7a71b555..889bc654 100644 --- a/src/gui/UBFeaturesWidget.cpp +++ b/src/gui/UBFeaturesWidget.cpp @@ -10,7 +10,7 @@ #include "globals/UBGlobals.h" #include "board/UBBoardController.h" -UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent) +UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent) { setObjectName(name); mName = "FeaturesWidget"; @@ -82,7 +82,6 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale //pathListView->setMovement( QListView::Static ); pathListView->setDragDropMode( QAbstractItemView::DropOnly ); - pathScene = new QGraphicsScene(this); //pathViewer = new UBFeaturesPathViewer( QPixmap(":images/libpalette/home.png"), controller->getRootPath(), pathScene, this ); featureProperties = new UBFeatureProperties(this); webView = new UBFeaturesWebView(this); @@ -121,7 +120,9 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale connect( mActionBar, SIGNAL( deleteElements(const QMimeData &) ), this, SLOT( deleteElements(const QMimeData &) ) ); connect( mActionBar, SIGNAL( addToFavorite(const QMimeData &) ), this, SLOT( addToFavorite(const QMimeData &) ) ); connect( mActionBar, SIGNAL( removeFromFavorite(const QMimeData &) ), this, SLOT( removeFromFavorite(const QMimeData &) ) ); - connect ( mActionBar, SIGNAL( addElementsToFavorite() ), this, SLOT ( addElementsToFavorite() ) ); + connect( mActionBar, SIGNAL( addElementsToFavorite() ), this, SLOT ( addElementsToFavorite() ) ); + connect( mActionBar, SIGNAL( removeElementsFromFavorite() ), this, SLOT ( removeElementsFromFavorite() ) ); + connect( mActionBar, SIGNAL( deleteSelectedElements() ), this, SLOT( deleteSelectedElements() ) ); connect( pathListView, SIGNAL(clicked( const QModelIndex & ) ), this, SLOT( currentPathChanged( const QModelIndex & ) ) ); connect( thumbSlider, SIGNAL( sliderMoved(int) ), this, SLOT(thumbnailSizeChanged( int ) ) ); @@ -131,6 +132,15 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale this, SLOT( onAddDownloadedFileToLibrary( bool, QUrl, QString,QByteArray ) ) ); } +UBFeaturesWidget::~UBFeaturesWidget() +{ + if ( thumbSlider != NULL ) + { + delete thumbSlider; + thumbSlider = NULL; + } +} + bool UBFeaturesWidget::eventFilter( QObject *target, QEvent *event ) { if ( target == featuresListView && event->type() == QEvent::Resize ) @@ -277,6 +287,37 @@ void UBFeaturesWidget::deleteElements( const QMimeData & mimeData ) model->invalidate(); } +void UBFeaturesWidget::deleteSelectedElements() +{ + QModelIndexList selected = featuresListView->selectionModel()->selectedIndexes(); + QList urls; + foreach ( QModelIndex sel, selected ) + { + UBFeature feature = sel.data( Qt::UserRole + 1 ).value(); + if ( feature.isDeletable() ) + urls.append( feature.getFullPath() ); + } + + foreach (QUrl url, urls) + { + if ( controller->isTrash( url ) ) + { + controller->deleteItem( url ); + } + else + { + UBFeature elem = controller->moveItemToFolder( url, controller->getTrashElement() ); + controller->removeFromFavorite( url ); + featuresModel->addItem( elem ); + featuresModel->deleteFavoriteItem( url.toString() ); + } + featuresModel->deleteItem( url.toString() ); + } + + QSortFilterProxyModel *model = dynamic_cast( featuresListView->model() ); + model->invalidate(); +} + void UBFeaturesWidget::addToFavorite( const QMimeData & mimeData ) { if ( !mimeData.hasUrls() ) @@ -335,14 +376,45 @@ void UBFeaturesWidget::onAddDownloadedFileToLibrary(bool pSuccess, QUrl sourceUr } void UBFeaturesWidget::addElementsToFavorite() +{ + if ( currentStackedWidget == ID_PROPERTIES ) + { + UBFeature feature = featureProperties->getCurrentElement(); + if ( feature != UBFeature() && !UBApplication::isFromWeb( feature.getFullPath().toString() ) ) + { + UBFeature elem = controller->addToFavorite( feature.getFullPath() ); + featuresModel->addItem( elem ); + } + } + else if ( currentStackedWidget == ID_LISTVIEW ) + { + QModelIndexList selected = featuresListView->selectionModel()->selectedIndexes(); + for ( int i = 0; i < selected.size(); ++i ) + { + UBFeature feature = selected.at(i).data( Qt::UserRole + 1 ).value(); + UBFeature elem = controller->addToFavorite( feature.getFullPath() ); + if ( !elem.getVirtualPath().isEmpty() && !elem.getVirtualPath().isNull() ) + featuresModel->addItem( elem ); + } + } + QSortFilterProxyModel *model = dynamic_cast( featuresListView->model() ); + model->invalidate(); +} + +void UBFeaturesWidget::removeElementsFromFavorite() { QModelIndexList selected = featuresListView->selectionModel()->selectedIndexes(); + //qSort( selected.begin(), selected.end(), qGreater() ); + QList items; for ( int i = 0; i < selected.size(); ++i ) { UBFeature feature = selected.at(i).data( Qt::UserRole + 1 ).value(); - UBFeature elem = controller->addToFavorite( feature.getFullPath() ); - if ( !elem.getVirtualPath().isEmpty() && !elem.getVirtualPath().isNull() ) - featuresModel->addItem( elem ); + items.append( feature.getFullPath() ); + } + foreach ( QUrl url, items ) + { + controller->removeFromFavorite( url ); + featuresModel->deleteFavoriteItem( url.toString() ); } QSortFilterProxyModel *model = dynamic_cast( featuresListView->model() ); model->invalidate(); @@ -380,9 +452,7 @@ void UBFeaturesWidget::currentPathChanged(const QString &path) */ -UBFeaturesWidget::~UBFeaturesWidget() -{ -} + UBFeaturesListView::UBFeaturesListView( QWidget* parent, const char* name ) : QListView(parent) @@ -435,7 +505,7 @@ void UBFeaturesListView::dropEvent( QDropEvent *event ) { event->setDropAction( Qt::MoveAction ); } - QListView::dropEvent( event ); + QListView::dropEvent( event ); } @@ -473,15 +543,18 @@ UBFeaturesWebView::UBFeaturesWebView(QWidget* parent, const char* name):QWidget( UBFeaturesWebView::~UBFeaturesWebView() { - if(NULL != mpSankoreAPI){ + if( NULL != mpSankoreAPI ) + { delete mpSankoreAPI; mpSankoreAPI = NULL; } - if(NULL != mpView){ + if( NULL != mpView ) + { delete mpView; mpView = NULL; } - if(NULL != mpLayout){ + if( NULL != mpLayout ) + { delete mpLayout; mpLayout = NULL; } @@ -597,6 +670,55 @@ UBFeatureProperties::UBFeatureProperties( QWidget *parent, const char *name ) : connect( mpAddToLibButton, SIGNAL( clicked() ), this, SLOT(onAddToLib() ) ); } +UBFeatureProperties::~UBFeatureProperties() +{ + if ( mpOrigPixmap ) + { + delete mpOrigPixmap; + mpOrigPixmap = NULL; + } + if ( mpElement ) + { + delete mpElement; + mpElement = NULL; + } + if ( mpThumbnail ) + { + delete mpThumbnail; + mpThumbnail = NULL; + } + if ( mpButtonLayout ) + { + delete mpButtonLayout; + mpButtonLayout = NULL; + } + if ( mpAddPageButton ) + { + delete mpAddPageButton; + mpAddPageButton = NULL; + } + if ( mpSetAsBackgroundButton ) + { + delete mpSetAsBackgroundButton; + mpSetAsBackgroundButton = NULL; + } + if ( mpAddToLibButton ) + { + delete mpAddToLibButton; + mpAddToLibButton = NULL; + } + if ( mpObjInfoLabel ) + { + delete mpObjInfoLabel; + mpObjInfoLabel = NULL; + } + if ( mpObjInfos ) + { + delete mpObjInfos; + mpObjInfos = NULL; + } +} + void UBFeatureProperties::resizeEvent( QResizeEvent *event ) { Q_UNUSED(event); @@ -609,6 +731,13 @@ void UBFeatureProperties::showEvent (QShowEvent *event ) adaptSize(); } +UBFeature UBFeatureProperties::getCurrentElement() const +{ + if ( mpElement ) + return *mpElement; + return UBFeature(); +} + void UBFeatureProperties::adaptSize() { if( NULL != mpOrigPixmap ) @@ -716,19 +845,7 @@ void UBFeatureProperties::onSetAsBackground() featuresWidget->getFeaturesController()->addItemAsBackground( *mpElement ); } -UBFeatureProperties::~UBFeatureProperties() -{ - if ( mpOrigPixmap ) - { - delete mpOrigPixmap; - mpOrigPixmap = NULL; - } - if ( mpElement ) - { - delete mpElement; - mpElement = NULL; - } -} + UBFeatureItemButton::UBFeatureItemButton(QWidget *parent, const char *name):QPushButton(parent) { @@ -854,7 +971,7 @@ void UBFeaturesModel::deleteFavoriteItem( const QString &path ) { for ( int i = 0; i < featuresList->size(); ++i ) { - if ( !QString::compare( featuresList->at(i).getUrl(), path, Qt::CaseInsensitive ) && + if ( !QString::compare( featuresList->at(i).getFullPath().toString(), path, Qt::CaseInsensitive ) && !QString::compare( featuresList->at(i).getVirtualPath(), "/root/favorites", Qt::CaseInsensitive ) ) { removeRow( i, QModelIndex() ); @@ -863,6 +980,18 @@ void UBFeaturesModel::deleteFavoriteItem( const QString &path ) } } +void UBFeaturesModel::deleteItem( const QString &path ) +{ + for ( int i = 0; i < featuresList->size(); ++i ) + { + if ( !QString::compare( featuresList->at(i).getFullPath().toString(), path, Qt::CaseInsensitive ) ) + { + removeRow( i, QModelIndex() ); + return; + } + } +} + bool UBFeaturesModel::removeRows( int row, int count, const QModelIndex & parent ) { if ( row < 0 ) @@ -889,6 +1018,7 @@ bool UBFeaturesModel::removeRow( int row, const QModelIndex & parent ) return true; } + Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const { Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index); diff --git a/src/gui/UBFeaturesWidget.h b/src/gui/UBFeaturesWidget.h index 85aaebbd..afd29c97 100644 --- a/src/gui/UBFeaturesWidget.h +++ b/src/gui/UBFeaturesWidget.h @@ -80,7 +80,7 @@ private: QSlider *thumbSlider; QVBoxLayout *layout; //UBFeaturesPathViewer *pathViewer; - QGraphicsScene *pathScene; + //QGraphicsScene *pathScene; UBFeaturesActionBar *mActionBar; UBFeatureProperties *featureProperties; UBFeaturesWebView *webView; @@ -88,7 +88,6 @@ private: int currentStackedWidget; - QModelIndex trashIndex; private slots: void currentSelected( const QModelIndex & ); //void currentPathChanged(const QString &); @@ -102,6 +101,8 @@ private slots: void onDisplayMetadata( QMap ); void onAddDownloadedFileToLibrary(bool, QUrl, QString, QByteArray); void addElementsToFavorite(); + void removeElementsFromFavorite(); + void deleteSelectedElements(); protected: bool eventFilter(QObject *target, QEvent *event); }; @@ -129,7 +130,7 @@ class UBFeaturesWebView : public QWidget Q_OBJECT public: UBFeaturesWebView(QWidget* parent = 0, const char* name = "UBFeaturesWebView"); - ~UBFeaturesWebView(); + virtual ~UBFeaturesWebView(); void showElement(const UBFeature &elem); @@ -151,8 +152,7 @@ public: ~UBFeatureProperties(); void showElement(const UBFeature &elem); - - + UBFeature getCurrentElement() const; protected: void resizeEvent(QResizeEvent *event); void showEvent(QShowEvent *event); @@ -200,6 +200,7 @@ public: void addItem( const UBFeature &item ); void deleteFavoriteItem( const QString &path ); + void deleteItem( const QString &path ); QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; QMimeData *mimeData( const QModelIndexList &indexes ) const; @@ -209,6 +210,8 @@ public: bool dropMimeData(const QMimeData *mimeData, Qt::DropAction action, int row, int column, const QModelIndex &parent); bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); bool removeRow(int row, const QModelIndex &parent = QModelIndex()); + //bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()); + //bool insertRow(int row, const QModelIndex &parent = QModelIndex()); Qt::DropActions supportedDropActions() const { return Qt::MoveAction | Qt::CopyAction; }