diff --git a/src/board/UBBoardPaletteManager.cpp b/src/board/UBBoardPaletteManager.cpp index 3df50416..c97e1952 100644 --- a/src/board/UBBoardPaletteManager.cpp +++ b/src/board/UBBoardPaletteManager.cpp @@ -318,10 +318,7 @@ void UBBoardPaletteManager::pagePaletteButtonReleased() mPagePalette = 0; QListpageActions; pageActions << UBApplication::mainWindow->actionNewPage; - UBBoardController* boardController = UBApplication::boardController; - if(UBApplication::documentController->pageCanBeDuplicated(UBDocumentContainer::pageFromSceneIndex(boardController->activeSceneIndex()))){ - pageActions << UBApplication::mainWindow->actionDuplicatePage; - } + pageActions << UBApplication::mainWindow->actionDuplicatePage; pageActions << UBApplication::mainWindow->actionImportPage; mPagePalette = new UBActionPalette(pageActions, Qt::Horizontal , mContainer); diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index c6add622..5b061ff2 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -655,7 +655,6 @@ int UBPersistenceManager::sceneCount(const UBDocumentProxy* proxy) int pageIndex = 0; bool moreToProcess = true; - bool addedMissingZeroPage = false; while (moreToProcess) { @@ -669,12 +668,6 @@ int UBPersistenceManager::sceneCount(const UBDocumentProxy* proxy) moreToProcess = false; } - if(pageIndex == 1 && addedMissingZeroPage){ - // increment is done only to check if there are other pages than the missing zero page - // This situation means -> no pages on the document - return 0; - } - return pageIndex; } diff --git a/src/document/UBDocumentContainer.cpp b/src/document/UBDocumentContainer.cpp index 6325d9c5..d0d669ea 100644 --- a/src/document/UBDocumentContainer.cpp +++ b/src/document/UBDocumentContainer.cpp @@ -62,11 +62,6 @@ void UBDocumentContainer::duplicatePages(QList& pageIndexes) bool UBDocumentContainer::movePageToIndex(int source, int target) { - if (source==0) - { - // Title page - cant be moved - return false; - } UBPersistenceManager::persistenceManager()->moveSceneToIndex(mCurrentDocument, source, target); deleteThumbPage(source); insertThumbPage(target); @@ -120,7 +115,6 @@ void UBDocumentContainer::reloadThumbnails() if (mCurrentDocument) { UBThumbnailAdaptor::load(mCurrentDocument, mDocumentThumbs); - qDebug() << "Reloading Thumbnails. new mDocumentThumbs size: " << mDocumentThumbs.size(); emit documentThumbnailsUpdated(this); } } diff --git a/src/document/UBDocumentController.cpp b/src/document/UBDocumentController.cpp index 77432c67..44e26da4 100644 --- a/src/document/UBDocumentController.cpp +++ b/src/document/UBDocumentController.cpp @@ -1082,7 +1082,7 @@ void UBDocumentController::moveSceneToIndex(UBDocumentProxy* proxy, int source, { proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); UBMetadataDcSubsetAdaptor::persist(proxy); - + mDocumentUI->thumbnailWidget->hightlightItem(target); } } @@ -1147,11 +1147,11 @@ void UBDocumentController::selectionChanged() else if(pageSelected){ QList selection = mDocumentUI->thumbnailWidget->selectedItems(); if(pageCount == 1) - mMainWindow->actionDuplicate->setEnabled(!trashSelected && pageCanBeDuplicated(UBDocumentContainer::pageFromSceneIndex(0))); + mMainWindow->actionDuplicate->setEnabled(!trashSelected); else{ for(int i = 0; i < selection.count() && !firstSceneSelected; i += 1){ if(dynamic_cast(selection.at(i))->sceneIndex() == 0){ - mMainWindow->actionDuplicate->setEnabled(!trashSelected && pageCanBeDuplicated(UBDocumentContainer::pageFromSceneIndex(0))); + mMainWindow->actionDuplicate->setEnabled(!trashSelected); firstSceneSelected = true; } } @@ -1630,26 +1630,6 @@ int UBDocumentController::getSelectedItemIndex() else return -1; } -bool UBDocumentController::pageCanBeMovedUp(int page) -{ - return page >= 1; -} - -bool UBDocumentController::pageCanBeMovedDown(int page) -{ - return page < selectedDocument()->pageCount() - 1; -} - -bool UBDocumentController::pageCanBeDuplicated(int page) -{ - return page != 0; -} - -bool UBDocumentController::pageCanBeDeleted(int page) -{ - return page != 0; -} - void UBDocumentController::refreshDocumentThumbnailsView(UBDocumentContainer*) { QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); @@ -1662,9 +1642,9 @@ void UBDocumentController::refreshDocumentThumbnailsView(UBDocumentContainer*) QStringList labels; - if (proxy) + if (proxy) { - setDocument(proxy); + setDocument(proxy); for (int i = 0; i < selectedDocument()->pageCount(); i++) { @@ -1678,10 +1658,7 @@ void UBDocumentController::refreshDocumentThumbnailsView(UBDocumentContainer*) items << pixmapItem; int pageIndex = pageFromSceneIndex(i); - if(pageIndex) - labels << tr("Page %1").arg(pageIndex); - else - labels << tr("Title page"); + labels << tr("Page %1").arg(pageIndex); itemsPath.append(QUrl::fromLocalFile(proxy->persistencePath() + QString("/pages/%1").arg(UBDocumentContainer::pageFromSceneIndex(i)))); } diff --git a/src/document/UBDocumentController.h b/src/document/UBDocumentController.h index 75608f41..607e906a 100644 --- a/src/document/UBDocumentController.h +++ b/src/document/UBDocumentController.h @@ -59,10 +59,6 @@ class UBDocumentController : public UBDocumentContainer void deletePages(QList itemsToDelete); int getSelectedItemIndex(); - bool pageCanBeMovedUp(int page); - bool pageCanBeMovedDown(int page); - bool pageCanBeDuplicated(int page); - bool pageCanBeDeleted(int page); QString documentTrashGroupName(){ return mDocumentTrashGroupName;} QString defaultDocumentGroupName(){ return mDefaultDocumentGroupName;} diff --git a/src/frameworks/UBFileSystemUtils.cpp b/src/frameworks/UBFileSystemUtils.cpp index 49f37cbd..fb594057 100644 --- a/src/frameworks/UBFileSystemUtils.cpp +++ b/src/frameworks/UBFileSystemUtils.cpp @@ -27,8 +27,6 @@ #include "core/UBApplication.h" -#include "document/UBDocumentContainer.h" - #include "globals/UBGlobals.h" THIRD_PARTY_WARNINGS_DISABLE @@ -352,8 +350,7 @@ QString UBFileSystemUtils::normalizeFilePath(const QString& pFilePath) QString UBFileSystemUtils::digitFileFormat(const QString& s, int digit) { - int pageDigit = UBDocumentContainer::pageFromSceneIndex(digit); - return s.arg(pageDigit, 3, 10, QLatin1Char('0')); + return s.arg(digit, 3, 10, QLatin1Char('0')); } @@ -361,8 +358,7 @@ QString UBFileSystemUtils::thumbnailPath(const QString& path) { QFileInfo pathInfo(path); - return pathInfo.dir().absolutePath() + "/" + pathInfo.completeBaseName() - + ".thumbnail.png"; + return pathInfo.dir().absolutePath() + "/" + pathInfo.completeBaseName() + ".thumbnail.png"; } QString UBFileSystemUtils::extension(const QString& fileName) @@ -632,8 +628,7 @@ QString UBFileSystemUtils::getFirstExistingFileFromList(const QString& path, con } -bool UBFileSystemUtils::compressDirInZip(const QDir& pDir, const QString& pDestPath, - QuaZipFile *pOutZipFile, bool pRootDocumentFolder, UBProcessingProgressListener* progressListener) +bool UBFileSystemUtils::compressDirInZip(const QDir& pDir, const QString& pDestPath, QuaZipFile *pOutZipFile, bool pRootDocumentFolder, UBProcessingProgressListener* progressListener) { QFileInfoList files = pDir.entryInfoList(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot); diff --git a/src/gui/UBDocumentNavigator.cpp b/src/gui/UBDocumentNavigator.cpp index 085203e2..baed7d67 100644 --- a/src/gui/UBDocumentNavigator.cpp +++ b/src/gui/UBDocumentNavigator.cpp @@ -100,7 +100,7 @@ void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source) UBSceneThumbnailNavigPixmap* pixmapItem = new UBSceneThumbnailNavigPixmap(*pix, source->selectedDocument(), i); - QString label = pageIndex == 0 ? tr("Title page") : tr("Page %0").arg(pageIndex); + QString label = tr("Page %0").arg(pageIndex); UBThumbnailTextItem *labelItem = new UBThumbnailTextItem(label); UBImgTextThumbnailElement thumbWithText(pixmapItem, labelItem); @@ -138,9 +138,6 @@ void UBDocumentNavigator::onScrollToSelectedPage(int index) */ void UBDocumentNavigator::updateSpecificThumbnail(int iPage) { - // Generate the new thumbnail - //UBGraphicsScene* pScene = UBApplication::boardController->activeScene(); - const QPixmap* pix = UBApplication::boardController->pageAt(iPage); UBSceneThumbnailNavigPixmap* newItem = new UBSceneThumbnailNavigPixmap(*pix, UBApplication::boardController->selectedDocument(), iPage); diff --git a/src/gui/UBDocumentThumbnailWidget.cpp b/src/gui/UBDocumentThumbnailWidget.cpp index 667e91f3..4650ba16 100644 --- a/src/gui/UBDocumentThumbnailWidget.cpp +++ b/src/gui/UBDocumentThumbnailWidget.cpp @@ -65,7 +65,7 @@ void UBDocumentThumbnailWidget::mouseMoveEvent(QMouseEvent *event) return; if ((event->pos() - mMousePressPos).manhattanLength() < QApplication::startDragDistance()) - return; + return; QList graphicsItems = items(mMousePressPos); @@ -76,21 +76,18 @@ void UBDocumentThumbnailWidget::mouseMoveEvent(QMouseEvent *event) if (sceneItem) { - int pageIndex = UBDocumentContainer::pageFromSceneIndex(sceneItem->sceneIndex()); - if(pageIndex != 0){ - QDrag *drag = new QDrag(this); - QList mimeDataItems; - foreach (QGraphicsItem *item, selectedItems()) - mimeDataItems.append(UBMimeDataItem(sceneItem->proxy(), mGraphicItems.indexOf(item))); + QDrag *drag = new QDrag(this); + QList mimeDataItems; + foreach (QGraphicsItem *item, selectedItems()) + mimeDataItems.append(UBMimeDataItem(sceneItem->proxy(), mGraphicItems.indexOf(item))); - UBMimeData *mime = new UBMimeData(mimeDataItems); - drag->setMimeData(mime); + UBMimeData *mime = new UBMimeData(mimeDataItems); + drag->setMimeData(mime); - drag->setPixmap(sceneItem->pixmap().scaledToWidth(100)); - drag->setHotSpot(QPoint(drag->pixmap().width()/2, drag->pixmap().height() / 2)); + drag->setPixmap(sceneItem->pixmap().scaledToWidth(100)); + drag->setHotSpot(QPoint(drag->pixmap().width()/2, drag->pixmap().height() / 2)); - drag->exec(Qt::MoveAction); - } + drag->exec(Qt::MoveAction); } UBThumbnailWidget::mouseMoveEvent(event); @@ -159,40 +156,31 @@ void UBDocumentThumbnailWidget::dragMoveEvent(QDragMoveEvent *event) QGraphicsItem *underlyingItem = itemAt(event->pos()); mClosestDropItem = dynamic_cast(underlyingItem); - int pageIndex = -1; - if(mClosestDropItem){ - pageIndex = UBDocumentContainer::pageFromSceneIndex(mClosestDropItem->sceneIndex()); - if(pageIndex == 0){ - event->acceptProposedAction(); - return; - } - } if (!mClosestDropItem) { foreach (UBSceneThumbnailPixmap *item, pixmapItems) { qreal scale = item->transform().m11(); QPointF itemCenter( - item->pos().x() + item->boundingRect().width() * scale / 2, - item->pos().y() + item->boundingRect().height() * scale / 2); + item->pos().x() + item->boundingRect().width() * scale / 2, + item->pos().y() + item->boundingRect().height() * scale / 2); int distance = (itemCenter.toPoint() - mapToScene(event->pos()).toPoint()).manhattanLength(); if (!mClosestDropItem || distance < minDistance) { mClosestDropItem = item; minDistance = distance; - pageIndex = UBDocumentContainer::pageFromSceneIndex(mClosestDropItem->sceneIndex()); } } } - if (mClosestDropItem && pageIndex != 0) + if (mClosestDropItem) { qreal scale = mClosestDropItem->transform().m11(); QPointF itemCenter( - mClosestDropItem->pos().x() + mClosestDropItem->boundingRect().width() * scale / 2, - mClosestDropItem->pos().y() + mClosestDropItem->boundingRect().height() * scale / 2); + mClosestDropItem->pos().x() + mClosestDropItem->boundingRect().width() * scale / 2, + mClosestDropItem->pos().y() + mClosestDropItem->boundingRect().height() * scale / 2); mDropIsRight = mapToScene(event->pos()).x() > itemCenter.x(); @@ -204,10 +192,10 @@ void UBDocumentThumbnailWidget::dragMoveEvent(QDragMoveEvent *event) } QRectF dropCaretRect( - mDropIsRight ? mClosestDropItem->pos().x() + mClosestDropItem->boundingRect().width() * scale + spacing() / 2 - 1 : mClosestDropItem->pos().x() - spacing() / 2 - 1, - mClosestDropItem->pos().y(), - 3, - mClosestDropItem->boundingRect().height() * scale); + mDropIsRight ? mClosestDropItem->pos().x() + mClosestDropItem->boundingRect().width() * scale + spacing() / 2 - 1 : mClosestDropItem->pos().x() - spacing() / 2 - 1, + mClosestDropItem->pos().y(), + 3, + mClosestDropItem->boundingRect().height() * scale); if (mDropCaretRectItem) mDropCaretRectItem->setRect(dropCaretRect); @@ -229,10 +217,6 @@ void UBDocumentThumbnailWidget::dropEvent(QDropEvent *event) if (mClosestDropItem) { int targetIndex = mDropIsRight ? mGraphicItems.indexOf(mClosestDropItem) + 1 : mGraphicItems.indexOf(mClosestDropItem); - if(UBDocumentContainer::pageFromSceneIndex(targetIndex) == 0){ - event->ignore(); - return; - } QList mimeDataItems; if (event->mimeData()->hasFormat(UBApplication::mimeTypeUniboardPage)) @@ -243,9 +227,9 @@ void UBDocumentThumbnailWidget::dropEvent(QDropEvent *event) } if (1 == mimeDataItems.count() && - (mimeDataItems.at(0).sceneIndex() == mGraphicItems.indexOf(mClosestDropItem) || - targetIndex == mimeDataItems.at(0).sceneIndex() || - targetIndex == mimeDataItems.at(0).sceneIndex() + 1)) + (mimeDataItems.at(0).sceneIndex() == mGraphicItems.indexOf(mClosestDropItem) || + targetIndex == mimeDataItems.at(0).sceneIndex() || + targetIndex == mimeDataItems.at(0).sceneIndex() + 1)) { return; } @@ -288,8 +272,8 @@ void UBDocumentThumbnailWidget::deleteDropCaret() } void UBDocumentThumbnailWidget::setGraphicsItems(const QList& pGraphicsItems, - const QList& pItemPaths, const QStringList pLabels, - const QString& pMimeType) + const QList& pItemPaths, const QStringList pLabels, + const QString& pMimeType) { deleteDropCaret(); @@ -303,7 +287,7 @@ void UBDocumentThumbnailWidget::setDragEnabled(bool enabled) bool UBDocumentThumbnailWidget::dragEnabled() const { - return mDragEnabled; + return true;// mDragEnabled; } void UBDocumentThumbnailWidget::hightlightItem(int index) diff --git a/src/gui/UBNavigatorPalette.cpp b/src/gui/UBNavigatorPalette.cpp deleted file mode 100644 index 6ad9505d..00000000 --- a/src/gui/UBNavigatorPalette.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour l'Education Numérique en Afrique (GIP ENA) - * - * This file is part of Open-Sankoré. - * - * Open-Sankoré 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, version 3 of the License, - * with a specific linking exception for the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the - * same license as the "OpenSSL" library). - * - * Open-Sankoré 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 Open-Sankoré. If not, see . - */ - - - -#include "UBNavigatorPalette.h" -#include "core/UBApplication.h" -#include "board/UBBoardController.h" - -#include "core/memcheck.h" - -/** - * \brief Constructor - * @param parent as the parent widget - * @param name as the object name - */ -UBNavigatorPalette::UBNavigatorPalette(QWidget *parent, const char *name): - UBDockPalette(eUBDockPaletteType_LEFT, parent, name) - , mNavigator(NULL) - , mLayout(NULL) - , mHLayout(NULL) - , mPageNbr(NULL) - , mClock(NULL) -{ - // Build the gui - mLayout = new QVBoxLayout(this); - mLayout->setContentsMargins(customMargin(), customMargin(), 2*border() + customMargin(), customMargin()); - setLayout(mLayout); - - mNavigator = new UBDocumentNavigator(this); - mNavigator->setStyleSheet(QString("background-color : transparent;")); - mLayout->addWidget(mNavigator, 1); - - mHLayout = new QHBoxLayout(); - mLayout->addLayout(mHLayout, 0); - - mPageNbr = new QLabel(this); - mClock = new QLabel(this); - mHLayout->addWidget(mPageNbr); - mHLayout->addWidget(mClock); - - // Configure the page number indicator - mPageNbr->setStyleSheet(QString("QLabel { color: white; background-color: transparent; border: none; font-family: Arial; font-weight: bold; font-size: 20px }")); - setPageNumber(0, 0); - mPageNbr->setAlignment(Qt::AlignHCenter); - - // Configure the clock - mClock->setStyleSheet(QString("QLabel {color: white; background-color: transparent; text-align: center; font-family: Arial; font-weight: bold; font-size: 20px}")); - mTimeFormat = QLocale::system().timeFormat(QLocale::ShortFormat); - mClock->setAlignment(Qt::AlignHCenter); - - //strip seconds - mTimeFormat = mTimeFormat.remove(":ss"); - mTimeFormat = mTimeFormat.remove(":s"); - mTimerID = startTimer(1000); - -} - -/** - * \brief Destructor - */ -UBNavigatorPalette::~UBNavigatorPalette() -{ - killTimer(mTimerID); - - if(NULL != mClock) - { - delete mClock; - mClock = NULL; - } - if(NULL != mPageNbr) - { - delete mPageNbr; - mPageNbr = NULL; - } - if(NULL != mHLayout) - { - delete mHLayout; - mHLayout = NULL; - } - if(NULL != mLayout) - { - delete mLayout; - mLayout = NULL; - } - if(NULL != mNavigator) - { - delete mNavigator; - mNavigator = NULL; - } -} - -/** - * \brief Set the current document in the navigator - * @param document as the given document - */ - -/** - * \brief Refresh the thumbnails widget - */ -void UBNavigatorPalette::refresh() -{ -} - -/** - * \brief Handle the resize event - * @param event as the resize event - */ -void UBNavigatorPalette::resizeEvent(QResizeEvent *event) -{ - UBDockPalette::resizeEvent(event); - if(NULL != mNavigator) - { - mNavigator->setMinimumHeight(height() - 2*border()); - } -} - -void UBNavigatorPalette::timerEvent(QTimerEvent *event) -{ - Q_UNUSED(event); - updateTime(); -} - -void UBNavigatorPalette::updateTime() -{ - if (mClock) - { - mClock->setText(QLocale::system().toString (QTime::currentTime(), mTimeFormat)); - } -} - -void UBNavigatorPalette::setPageNumber(int current, int total) -{ - mPageNbr->setText(QString("%1 / %2").arg(current).arg(total)); -} diff --git a/src/gui/UBNavigatorPalette.h b/src/gui/UBNavigatorPalette.h deleted file mode 100644 index b09cd08a..00000000 --- a/src/gui/UBNavigatorPalette.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour l'Education Numérique en Afrique (GIP ENA) - * - * This file is part of Open-Sankoré. - * - * Open-Sankoré 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, version 3 of the License, - * with a specific linking exception for the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the - * same license as the "OpenSSL" library). - * - * Open-Sankoré 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 Open-Sankoré. If not, see . - */ - - - -#ifndef UBNAVIGATORPALETTE_H -#define UBNAVIGATORPALETTE_H - -#include -#include -#include -#include -#include -#include -#include - -#include "UBDockPalette.h" -#include "UBDocumentNavigator.h" -#include "document/UBDocumentProxy.h" - - -class UBNavigatorPalette : public UBDockPalette -{ - Q_OBJECT -public: - UBNavigatorPalette(QWidget* parent=0, const char* name="navigatorPalette"); - ~UBNavigatorPalette(); - - void setDocument(UBDocumentProxy* document); - void refresh(); - -public slots: - void setPageNumber(int current, int total); - -protected: - virtual void resizeEvent(QResizeEvent *event); - virtual void timerEvent(QTimerEvent *event); - -private: - void updateTime(); - - /** The thumbnails navigator widget */ - UBDocumentNavigator* mNavigator; - /** The layout */ - QVBoxLayout* mLayout; - QHBoxLayout* mHLayout; - QLabel* mPageNbr; - QLabel* mClock; - QString mTimeFormat; - int mTimerID; - -}; - - -#endif // UBNAVIGATORPALETTE_H diff --git a/src/gui/UBPageNavigationWidget.cpp b/src/gui/UBPageNavigationWidget.cpp index 9d1646ee..eca3c674 100644 --- a/src/gui/UBPageNavigationWidget.cpp +++ b/src/gui/UBPageNavigationWidget.cpp @@ -119,16 +119,6 @@ UBPageNavigationWidget::~UBPageNavigationWidget() } } - -/** - * \brief Refresh the thumbnails widget - */ -void UBPageNavigationWidget::refresh() -{ - // TOLIK!!! - // mNavigator->setDocument(UBApplication::boardController->activeDocument()); -} - /** * \brief Notify a timer event * @param event as the timer event @@ -145,9 +135,7 @@ void UBPageNavigationWidget::timerEvent(QTimerEvent *event) void UBPageNavigationWidget::updateTime() { if (mClock) - { mClock->setText(QLocale::system().toString (QTime::currentTime(), mTimeFormat)); - } } /** @@ -157,7 +145,7 @@ void UBPageNavigationWidget::updateTime() */ void UBPageNavigationWidget::setPageNumber(int current, int total) { - mPageNbr->setText(QString("%1 / %2").arg(current).arg(UBDocumentContainer::sceneIndexFromPage(total))); + mPageNbr->setText(QString("%1 / %2").arg(current).arg(total)); } /** diff --git a/src/gui/UBPageNavigationWidget.h b/src/gui/UBPageNavigationWidget.h index 1299a9f4..a9c22233 100644 --- a/src/gui/UBPageNavigationWidget.h +++ b/src/gui/UBPageNavigationWidget.h @@ -42,8 +42,6 @@ class UBPageNavigationWidget : public UBDockPaletteWidget public: UBPageNavigationWidget(QWidget* parent=0, const char* name="UBPageNavigationWidget"); ~UBPageNavigationWidget(); - //void setDocument(UBDocumentProxy* document); - void refresh(); bool visibleInMode(eUBDockPaletteWidgetMode mode) { diff --git a/src/gui/UBThumbnailWidget.cpp b/src/gui/UBThumbnailWidget.cpp index 905fa15e..a6eba0ba 100644 --- a/src/gui/UBThumbnailWidget.cpp +++ b/src/gui/UBThumbnailWidget.cpp @@ -87,7 +87,7 @@ void UBThumbnailWidget::setGraphicsItems(const QList& pGraphicsI , const QStringList pLabels , const QString& pMimeType) { - Q_ASSERT(pItemsPaths.count() == pLabels.count()); + Q_ASSERT(pItemsPaths.count() == pLabels.count()); mGraphicItems = pGraphicsItems; mItemsPaths = pItemsPaths; mMimeType = pMimeType; @@ -103,8 +103,7 @@ void UBThumbnailWidget::setGraphicsItems(const QList& pGraphicsI foreach (QGraphicsItem* item, pGraphicsItems) { - if (item->scene() != &mThumbnailsScene) - { + if (item->scene() != &mThumbnailsScene){ mThumbnailsScene.addItem(item); } } @@ -767,7 +766,6 @@ UBSceneThumbnailNavigPixmap::UBSceneThumbnailNavigPixmap(const QPixmap& pix, UBD , bCanDelete(false) , bCanMoveUp(false) , bCanMoveDown(false) - , bCanDuplicate(false) { if(0 <= UBDocumentContainer::pageFromSceneIndex(pSceneIndex)){ setAcceptsHoverEvents(true); @@ -783,7 +781,16 @@ UBSceneThumbnailNavigPixmap::~UBSceneThumbnailNavigPixmap() void UBSceneThumbnailNavigPixmap::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { event->accept(); - updateButtonsState(); + bButtonsVisible = true; + bCanDelete = true; + bCanMoveDown = false; + bCanMoveUp = false; + if(sceneIndex() < proxy()->pageCount() - 1) + bCanMoveDown = true; + if(sceneIndex() > 0) + bCanMoveUp = true; + if(proxy()->pageCount() == 1) + bCanDelete = false; update(); } @@ -806,10 +813,9 @@ void UBSceneThumbnailNavigPixmap::paint(QPainter *painter, const QStyleOptionGra painter->drawPixmap(0, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/close.svg")); else painter->drawPixmap(0, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/closeDisabled.svg")); - if(bCanDuplicate) - painter->drawPixmap(BUTTONSIZE + BUTTONSPACING, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/duplicate.svg")); - else - painter->drawPixmap(BUTTONSIZE + BUTTONSPACING, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/duplicateDisabled.svg")); + + painter->drawPixmap(BUTTONSIZE + BUTTONSPACING, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/duplicate.svg")); + if(bCanMoveUp) painter->drawPixmap(2*(BUTTONSIZE + BUTTONSPACING), 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/moveUp.svg")); else @@ -828,8 +834,9 @@ void UBSceneThumbnailNavigPixmap::mousePressEvent(QGraphicsSceneMouseEvent *even // 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(bCanDuplicate && p.x() >= BUTTONSIZE + BUTTONSPACING && p.x() <= 2*BUTTONSIZE + BUTTONSPACING && p.y() >= 0 && p.y() <= BUTTONSIZE) + if(p.x() >= BUTTONSIZE + BUTTONSPACING && p.x() <= 2*BUTTONSIZE + BUTTONSPACING && p.y() >= 0 && p.y() <= BUTTONSIZE) duplicatePage(); + if(bCanMoveUp && p.x() >= 2*(BUTTONSIZE + BUTTONSPACING) && p.x() <= 3*BUTTONSIZE + 2*BUTTONSPACING && p.y() >= 0 && p.y() <= BUTTONSIZE) moveUpPage(); if(bCanMoveDown && p.x() >= 3*(BUTTONSIZE + BUTTONSPACING) && p.x() <= 4*BUTTONSIZE + 3*BUTTONSPACING && p.y() >= 0 && p.y() <= BUTTONSIZE) @@ -838,27 +845,6 @@ void UBSceneThumbnailNavigPixmap::mousePressEvent(QGraphicsSceneMouseEvent *even event->accept(); } -void UBSceneThumbnailNavigPixmap::updateButtonsState() -{ - - bCanDelete = false; - bCanMoveUp = false; - bCanMoveDown = false; - bCanDuplicate = false; - - if(proxy()){ - int pageIndex = UBDocumentContainer::pageFromSceneIndex(sceneIndex()); - UBDocumentController* documentController = UBApplication::documentController; - bCanDelete = documentController->pageCanBeDeleted(pageIndex); - bCanMoveUp = documentController->pageCanBeMovedUp(pageIndex); - bCanMoveDown = documentController->pageCanBeMovedDown(pageIndex); - bCanDuplicate = documentController->pageCanBeDuplicated(pageIndex); - } - - if(bCanDelete || bCanMoveUp || bCanMoveDown || bCanDuplicate) - bButtonsVisible = true; -} - void UBSceneThumbnailNavigPixmap::deletePage() { if(UBApplication::mainWindow->yesNoQuestion(QObject::tr("Remove Page"), QObject::tr("Are you sure you want to remove 1 page from the selected document '%0'?").arg(UBApplication::documentController->selectedDocument()->metaData(UBSettings::documentName).toString()))){ diff --git a/src/gui/UBThumbnailWidget.h b/src/gui/UBThumbnailWidget.h index 76a8a24e..97a493f8 100644 --- a/src/gui/UBThumbnailWidget.h +++ b/src/gui/UBThumbnailWidget.h @@ -311,7 +311,6 @@ class UBSceneThumbnailNavigPixmap : public UBSceneThumbnailPixmap void mousePressEvent(QGraphicsSceneMouseEvent *event); private: - void updateButtonsState(); void deletePage(); void duplicatePage(); void moveUpPage(); @@ -321,7 +320,6 @@ class UBSceneThumbnailNavigPixmap : public UBSceneThumbnailPixmap bool bCanDelete; bool bCanMoveUp; bool bCanMoveDown; - bool bCanDuplicate; }; class UBThumbnailVideo : public UBThumbnailPixmap diff --git a/src/gui/gui.pri b/src/gui/gui.pri index 50d2fdfe..f941edfe 100644 --- a/src/gui/gui.pri +++ b/src/gui/gui.pri @@ -25,7 +25,6 @@ HEADERS += src/gui/UBThumbnailView.h \ src/gui/UBActionPalette.h \ src/gui/UBFavoriteToolPalette.h \ src/gui/UBKeyboardPalette.h \ - src/gui/UBNavigatorPalette.h \ src/gui/UBDocumentNavigator.h \ src/gui/UBDockPalette.h \ src/gui/UBPropertyPalette.h \ @@ -68,7 +67,6 @@ SOURCES += src/gui/UBThumbnailView.cpp \ src/gui/UBActionPalette.cpp \ src/gui/UBFavoriteToolPalette.cpp \ src/gui/UBKeyboardPalette.cpp \ - src/gui/UBNavigatorPalette.cpp \ src/gui/UBDocumentNavigator.cpp \ src/gui/UBDockPalette.cpp \ src/gui/UBPropertyPalette.cpp \