first page 0 handling fix

preferencesAboutTextFull
Claudio Valerio 11 years ago
parent 3cf0cc5e99
commit 348acb8e5a
  1. 5
      src/board/UBBoardPaletteManager.cpp
  2. 7
      src/core/UBPersistenceManager.cpp
  3. 6
      src/document/UBDocumentContainer.cpp
  4. 35
      src/document/UBDocumentController.cpp
  5. 4
      src/document/UBDocumentController.h
  6. 11
      src/frameworks/UBFileSystemUtils.cpp
  7. 5
      src/gui/UBDocumentNavigator.cpp
  8. 66
      src/gui/UBDocumentThumbnailWidget.cpp
  9. 153
      src/gui/UBNavigatorPalette.cpp
  10. 73
      src/gui/UBNavigatorPalette.h
  11. 14
      src/gui/UBPageNavigationWidget.cpp
  12. 2
      src/gui/UBPageNavigationWidget.h
  13. 48
      src/gui/UBThumbnailWidget.cpp
  14. 2
      src/gui/UBThumbnailWidget.h
  15. 2
      src/gui/gui.pri

@ -318,10 +318,7 @@ void UBBoardPaletteManager::pagePaletteButtonReleased()
mPagePalette = 0; mPagePalette = 0;
QList<QAction*>pageActions; QList<QAction*>pageActions;
pageActions << UBApplication::mainWindow->actionNewPage; pageActions << UBApplication::mainWindow->actionNewPage;
UBBoardController* boardController = UBApplication::boardController; pageActions << UBApplication::mainWindow->actionDuplicatePage;
if(UBApplication::documentController->pageCanBeDuplicated(UBDocumentContainer::pageFromSceneIndex(boardController->activeSceneIndex()))){
pageActions << UBApplication::mainWindow->actionDuplicatePage;
}
pageActions << UBApplication::mainWindow->actionImportPage; pageActions << UBApplication::mainWindow->actionImportPage;
mPagePalette = new UBActionPalette(pageActions, Qt::Horizontal , mContainer); mPagePalette = new UBActionPalette(pageActions, Qt::Horizontal , mContainer);

@ -655,7 +655,6 @@ int UBPersistenceManager::sceneCount(const UBDocumentProxy* proxy)
int pageIndex = 0; int pageIndex = 0;
bool moreToProcess = true; bool moreToProcess = true;
bool addedMissingZeroPage = false;
while (moreToProcess) while (moreToProcess)
{ {
@ -669,12 +668,6 @@ int UBPersistenceManager::sceneCount(const UBDocumentProxy* proxy)
moreToProcess = false; 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; return pageIndex;
} }

@ -62,11 +62,6 @@ void UBDocumentContainer::duplicatePages(QList<int>& pageIndexes)
bool UBDocumentContainer::movePageToIndex(int source, int target) bool UBDocumentContainer::movePageToIndex(int source, int target)
{ {
if (source==0)
{
// Title page - cant be moved
return false;
}
UBPersistenceManager::persistenceManager()->moveSceneToIndex(mCurrentDocument, source, target); UBPersistenceManager::persistenceManager()->moveSceneToIndex(mCurrentDocument, source, target);
deleteThumbPage(source); deleteThumbPage(source);
insertThumbPage(target); insertThumbPage(target);
@ -120,7 +115,6 @@ void UBDocumentContainer::reloadThumbnails()
if (mCurrentDocument) if (mCurrentDocument)
{ {
UBThumbnailAdaptor::load(mCurrentDocument, mDocumentThumbs); UBThumbnailAdaptor::load(mCurrentDocument, mDocumentThumbs);
qDebug() << "Reloading Thumbnails. new mDocumentThumbs size: " << mDocumentThumbs.size();
emit documentThumbnailsUpdated(this); emit documentThumbnailsUpdated(this);
} }
} }

@ -1082,7 +1082,7 @@ void UBDocumentController::moveSceneToIndex(UBDocumentProxy* proxy, int source,
{ {
proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(proxy); UBMetadataDcSubsetAdaptor::persist(proxy);
mDocumentUI->thumbnailWidget->hightlightItem(target); mDocumentUI->thumbnailWidget->hightlightItem(target);
} }
} }
@ -1147,11 +1147,11 @@ void UBDocumentController::selectionChanged()
else if(pageSelected){ else if(pageSelected){
QList<QGraphicsItem*> selection = mDocumentUI->thumbnailWidget->selectedItems(); QList<QGraphicsItem*> selection = mDocumentUI->thumbnailWidget->selectedItems();
if(pageCount == 1) if(pageCount == 1)
mMainWindow->actionDuplicate->setEnabled(!trashSelected && pageCanBeDuplicated(UBDocumentContainer::pageFromSceneIndex(0))); mMainWindow->actionDuplicate->setEnabled(!trashSelected);
else{ else{
for(int i = 0; i < selection.count() && !firstSceneSelected; i += 1){ for(int i = 0; i < selection.count() && !firstSceneSelected; i += 1){
if(dynamic_cast<UBSceneThumbnailPixmap*>(selection.at(i))->sceneIndex() == 0){ if(dynamic_cast<UBSceneThumbnailPixmap*>(selection.at(i))->sceneIndex() == 0){
mMainWindow->actionDuplicate->setEnabled(!trashSelected && pageCanBeDuplicated(UBDocumentContainer::pageFromSceneIndex(0))); mMainWindow->actionDuplicate->setEnabled(!trashSelected);
firstSceneSelected = true; firstSceneSelected = true;
} }
} }
@ -1630,26 +1630,6 @@ int UBDocumentController::getSelectedItemIndex()
else return -1; 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*) void UBDocumentController::refreshDocumentThumbnailsView(UBDocumentContainer*)
{ {
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
@ -1662,9 +1642,9 @@ void UBDocumentController::refreshDocumentThumbnailsView(UBDocumentContainer*)
QStringList labels; QStringList labels;
if (proxy) if (proxy)
{ {
setDocument(proxy); setDocument(proxy);
for (int i = 0; i < selectedDocument()->pageCount(); i++) for (int i = 0; i < selectedDocument()->pageCount(); i++)
{ {
@ -1678,10 +1658,7 @@ void UBDocumentController::refreshDocumentThumbnailsView(UBDocumentContainer*)
items << pixmapItem; items << pixmapItem;
int pageIndex = pageFromSceneIndex(i); int pageIndex = pageFromSceneIndex(i);
if(pageIndex) labels << tr("Page %1").arg(pageIndex);
labels << tr("Page %1").arg(pageIndex);
else
labels << tr("Title page");
itemsPath.append(QUrl::fromLocalFile(proxy->persistencePath() + QString("/pages/%1").arg(UBDocumentContainer::pageFromSceneIndex(i)))); itemsPath.append(QUrl::fromLocalFile(proxy->persistencePath() + QString("/pages/%1").arg(UBDocumentContainer::pageFromSceneIndex(i))));
} }

@ -59,10 +59,6 @@ class UBDocumentController : public UBDocumentContainer
void deletePages(QList<QGraphicsItem*> itemsToDelete); void deletePages(QList<QGraphicsItem*> itemsToDelete);
int getSelectedItemIndex(); int getSelectedItemIndex();
bool pageCanBeMovedUp(int page);
bool pageCanBeMovedDown(int page);
bool pageCanBeDuplicated(int page);
bool pageCanBeDeleted(int page);
QString documentTrashGroupName(){ return mDocumentTrashGroupName;} QString documentTrashGroupName(){ return mDocumentTrashGroupName;}
QString defaultDocumentGroupName(){ return mDefaultDocumentGroupName;} QString defaultDocumentGroupName(){ return mDefaultDocumentGroupName;}

@ -27,8 +27,6 @@
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "document/UBDocumentContainer.h"
#include "globals/UBGlobals.h" #include "globals/UBGlobals.h"
THIRD_PARTY_WARNINGS_DISABLE THIRD_PARTY_WARNINGS_DISABLE
@ -352,8 +350,7 @@ QString UBFileSystemUtils::normalizeFilePath(const QString& pFilePath)
QString UBFileSystemUtils::digitFileFormat(const QString& s, int digit) QString UBFileSystemUtils::digitFileFormat(const QString& s, int digit)
{ {
int pageDigit = UBDocumentContainer::pageFromSceneIndex(digit); return s.arg(digit, 3, 10, QLatin1Char('0'));
return s.arg(pageDigit, 3, 10, QLatin1Char('0'));
} }
@ -361,8 +358,7 @@ QString UBFileSystemUtils::thumbnailPath(const QString& path)
{ {
QFileInfo pathInfo(path); QFileInfo pathInfo(path);
return pathInfo.dir().absolutePath() + "/" + pathInfo.completeBaseName() return pathInfo.dir().absolutePath() + "/" + pathInfo.completeBaseName() + ".thumbnail.png";
+ ".thumbnail.png";
} }
QString UBFileSystemUtils::extension(const QString& fileName) 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, bool UBFileSystemUtils::compressDirInZip(const QDir& pDir, const QString& pDestPath, QuaZipFile *pOutZipFile, bool pRootDocumentFolder, UBProcessingProgressListener* progressListener)
QuaZipFile *pOutZipFile, bool pRootDocumentFolder, UBProcessingProgressListener* progressListener)
{ {
QFileInfoList files = pDir.entryInfoList(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot); QFileInfoList files = pDir.entryInfoList(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot);

@ -100,7 +100,7 @@ void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source)
UBSceneThumbnailNavigPixmap* pixmapItem = new UBSceneThumbnailNavigPixmap(*pix, source->selectedDocument(), i); 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); UBThumbnailTextItem *labelItem = new UBThumbnailTextItem(label);
UBImgTextThumbnailElement thumbWithText(pixmapItem, labelItem); UBImgTextThumbnailElement thumbWithText(pixmapItem, labelItem);
@ -138,9 +138,6 @@ void UBDocumentNavigator::onScrollToSelectedPage(int index)
*/ */
void UBDocumentNavigator::updateSpecificThumbnail(int iPage) void UBDocumentNavigator::updateSpecificThumbnail(int iPage)
{ {
// Generate the new thumbnail
//UBGraphicsScene* pScene = UBApplication::boardController->activeScene();
const QPixmap* pix = UBApplication::boardController->pageAt(iPage); const QPixmap* pix = UBApplication::boardController->pageAt(iPage);
UBSceneThumbnailNavigPixmap* newItem = new UBSceneThumbnailNavigPixmap(*pix, UBApplication::boardController->selectedDocument(), iPage); UBSceneThumbnailNavigPixmap* newItem = new UBSceneThumbnailNavigPixmap(*pix, UBApplication::boardController->selectedDocument(), iPage);

@ -65,7 +65,7 @@ void UBDocumentThumbnailWidget::mouseMoveEvent(QMouseEvent *event)
return; return;
if ((event->pos() - mMousePressPos).manhattanLength() < QApplication::startDragDistance()) if ((event->pos() - mMousePressPos).manhattanLength() < QApplication::startDragDistance())
return; return;
QList<QGraphicsItem*> graphicsItems = items(mMousePressPos); QList<QGraphicsItem*> graphicsItems = items(mMousePressPos);
@ -76,21 +76,18 @@ void UBDocumentThumbnailWidget::mouseMoveEvent(QMouseEvent *event)
if (sceneItem) if (sceneItem)
{ {
int pageIndex = UBDocumentContainer::pageFromSceneIndex(sceneItem->sceneIndex()); QDrag *drag = new QDrag(this);
if(pageIndex != 0){ QList<UBMimeDataItem> mimeDataItems;
QDrag *drag = new QDrag(this); foreach (QGraphicsItem *item, selectedItems())
QList<UBMimeDataItem> mimeDataItems; mimeDataItems.append(UBMimeDataItem(sceneItem->proxy(), mGraphicItems.indexOf(item)));
foreach (QGraphicsItem *item, selectedItems())
mimeDataItems.append(UBMimeDataItem(sceneItem->proxy(), mGraphicItems.indexOf(item)));
UBMimeData *mime = new UBMimeData(mimeDataItems); UBMimeData *mime = new UBMimeData(mimeDataItems);
drag->setMimeData(mime); drag->setMimeData(mime);
drag->setPixmap(sceneItem->pixmap().scaledToWidth(100)); drag->setPixmap(sceneItem->pixmap().scaledToWidth(100));
drag->setHotSpot(QPoint(drag->pixmap().width()/2, drag->pixmap().height() / 2)); drag->setHotSpot(QPoint(drag->pixmap().width()/2, drag->pixmap().height() / 2));
drag->exec(Qt::MoveAction); drag->exec(Qt::MoveAction);
}
} }
UBThumbnailWidget::mouseMoveEvent(event); UBThumbnailWidget::mouseMoveEvent(event);
@ -159,40 +156,31 @@ void UBDocumentThumbnailWidget::dragMoveEvent(QDragMoveEvent *event)
QGraphicsItem *underlyingItem = itemAt(event->pos()); QGraphicsItem *underlyingItem = itemAt(event->pos());
mClosestDropItem = dynamic_cast<UBSceneThumbnailPixmap*>(underlyingItem); mClosestDropItem = dynamic_cast<UBSceneThumbnailPixmap*>(underlyingItem);
int pageIndex = -1;
if(mClosestDropItem){
pageIndex = UBDocumentContainer::pageFromSceneIndex(mClosestDropItem->sceneIndex());
if(pageIndex == 0){
event->acceptProposedAction();
return;
}
}
if (!mClosestDropItem) if (!mClosestDropItem)
{ {
foreach (UBSceneThumbnailPixmap *item, pixmapItems) foreach (UBSceneThumbnailPixmap *item, pixmapItems)
{ {
qreal scale = item->transform().m11(); qreal scale = item->transform().m11();
QPointF itemCenter( QPointF itemCenter(
item->pos().x() + item->boundingRect().width() * scale / 2, item->pos().x() + item->boundingRect().width() * scale / 2,
item->pos().y() + item->boundingRect().height() * scale / 2); item->pos().y() + item->boundingRect().height() * scale / 2);
int distance = (itemCenter.toPoint() - mapToScene(event->pos()).toPoint()).manhattanLength(); int distance = (itemCenter.toPoint() - mapToScene(event->pos()).toPoint()).manhattanLength();
if (!mClosestDropItem || distance < minDistance) if (!mClosestDropItem || distance < minDistance)
{ {
mClosestDropItem = item; mClosestDropItem = item;
minDistance = distance; minDistance = distance;
pageIndex = UBDocumentContainer::pageFromSceneIndex(mClosestDropItem->sceneIndex());
} }
} }
} }
if (mClosestDropItem && pageIndex != 0) if (mClosestDropItem)
{ {
qreal scale = mClosestDropItem->transform().m11(); qreal scale = mClosestDropItem->transform().m11();
QPointF itemCenter( QPointF itemCenter(
mClosestDropItem->pos().x() + mClosestDropItem->boundingRect().width() * scale / 2, mClosestDropItem->pos().x() + mClosestDropItem->boundingRect().width() * scale / 2,
mClosestDropItem->pos().y() + mClosestDropItem->boundingRect().height() * scale / 2); mClosestDropItem->pos().y() + mClosestDropItem->boundingRect().height() * scale / 2);
mDropIsRight = mapToScene(event->pos()).x() > itemCenter.x(); mDropIsRight = mapToScene(event->pos()).x() > itemCenter.x();
@ -204,10 +192,10 @@ void UBDocumentThumbnailWidget::dragMoveEvent(QDragMoveEvent *event)
} }
QRectF dropCaretRect( QRectF dropCaretRect(
mDropIsRight ? mClosestDropItem->pos().x() + mClosestDropItem->boundingRect().width() * scale + spacing() / 2 - 1 : mClosestDropItem->pos().x() - spacing() / 2 - 1, mDropIsRight ? mClosestDropItem->pos().x() + mClosestDropItem->boundingRect().width() * scale + spacing() / 2 - 1 : mClosestDropItem->pos().x() - spacing() / 2 - 1,
mClosestDropItem->pos().y(), mClosestDropItem->pos().y(),
3, 3,
mClosestDropItem->boundingRect().height() * scale); mClosestDropItem->boundingRect().height() * scale);
if (mDropCaretRectItem) if (mDropCaretRectItem)
mDropCaretRectItem->setRect(dropCaretRect); mDropCaretRectItem->setRect(dropCaretRect);
@ -229,10 +217,6 @@ void UBDocumentThumbnailWidget::dropEvent(QDropEvent *event)
if (mClosestDropItem) if (mClosestDropItem)
{ {
int targetIndex = mDropIsRight ? mGraphicItems.indexOf(mClosestDropItem) + 1 : mGraphicItems.indexOf(mClosestDropItem); int targetIndex = mDropIsRight ? mGraphicItems.indexOf(mClosestDropItem) + 1 : mGraphicItems.indexOf(mClosestDropItem);
if(UBDocumentContainer::pageFromSceneIndex(targetIndex) == 0){
event->ignore();
return;
}
QList<UBMimeDataItem> mimeDataItems; QList<UBMimeDataItem> mimeDataItems;
if (event->mimeData()->hasFormat(UBApplication::mimeTypeUniboardPage)) if (event->mimeData()->hasFormat(UBApplication::mimeTypeUniboardPage))
@ -243,9 +227,9 @@ void UBDocumentThumbnailWidget::dropEvent(QDropEvent *event)
} }
if (1 == mimeDataItems.count() && if (1 == mimeDataItems.count() &&
(mimeDataItems.at(0).sceneIndex() == mGraphicItems.indexOf(mClosestDropItem) || (mimeDataItems.at(0).sceneIndex() == mGraphicItems.indexOf(mClosestDropItem) ||
targetIndex == mimeDataItems.at(0).sceneIndex() || targetIndex == mimeDataItems.at(0).sceneIndex() ||
targetIndex == mimeDataItems.at(0).sceneIndex() + 1)) targetIndex == mimeDataItems.at(0).sceneIndex() + 1))
{ {
return; return;
} }
@ -288,8 +272,8 @@ void UBDocumentThumbnailWidget::deleteDropCaret()
} }
void UBDocumentThumbnailWidget::setGraphicsItems(const QList<QGraphicsItem*>& pGraphicsItems, void UBDocumentThumbnailWidget::setGraphicsItems(const QList<QGraphicsItem*>& pGraphicsItems,
const QList<QUrl>& pItemPaths, const QStringList pLabels, const QList<QUrl>& pItemPaths, const QStringList pLabels,
const QString& pMimeType) const QString& pMimeType)
{ {
deleteDropCaret(); deleteDropCaret();
@ -303,7 +287,7 @@ void UBDocumentThumbnailWidget::setDragEnabled(bool enabled)
bool UBDocumentThumbnailWidget::dragEnabled() const bool UBDocumentThumbnailWidget::dragEnabled() const
{ {
return mDragEnabled; return true;// mDragEnabled;
} }
void UBDocumentThumbnailWidget::hightlightItem(int index) void UBDocumentThumbnailWidget::hightlightItem(int index)

@ -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 <http://www.gnu.org/licenses/>.
*/
#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));
}

@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef UBNAVIGATORPALETTE_H
#define UBNAVIGATORPALETTE_H
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QMouseEvent>
#include <QResizeEvent>
#include <QTimerEvent>
#include <QLabel>
#include <QString>
#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

@ -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 * \brief Notify a timer event
* @param event as the timer event * @param event as the timer event
@ -145,9 +135,7 @@ void UBPageNavigationWidget::timerEvent(QTimerEvent *event)
void UBPageNavigationWidget::updateTime() void UBPageNavigationWidget::updateTime()
{ {
if (mClock) if (mClock)
{
mClock->setText(QLocale::system().toString (QTime::currentTime(), mTimeFormat)); mClock->setText(QLocale::system().toString (QTime::currentTime(), mTimeFormat));
}
} }
/** /**
@ -157,7 +145,7 @@ void UBPageNavigationWidget::updateTime()
*/ */
void UBPageNavigationWidget::setPageNumber(int current, int total) 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));
} }
/** /**

@ -42,8 +42,6 @@ class UBPageNavigationWidget : public UBDockPaletteWidget
public: public:
UBPageNavigationWidget(QWidget* parent=0, const char* name="UBPageNavigationWidget"); UBPageNavigationWidget(QWidget* parent=0, const char* name="UBPageNavigationWidget");
~UBPageNavigationWidget(); ~UBPageNavigationWidget();
//void setDocument(UBDocumentProxy* document);
void refresh();
bool visibleInMode(eUBDockPaletteWidgetMode mode) bool visibleInMode(eUBDockPaletteWidgetMode mode)
{ {

@ -87,7 +87,7 @@ void UBThumbnailWidget::setGraphicsItems(const QList<QGraphicsItem*>& pGraphicsI
, const QStringList pLabels , const QStringList pLabels
, const QString& pMimeType) , const QString& pMimeType)
{ {
Q_ASSERT(pItemsPaths.count() == pLabels.count()); Q_ASSERT(pItemsPaths.count() == pLabels.count());
mGraphicItems = pGraphicsItems; mGraphicItems = pGraphicsItems;
mItemsPaths = pItemsPaths; mItemsPaths = pItemsPaths;
mMimeType = pMimeType; mMimeType = pMimeType;
@ -103,8 +103,7 @@ void UBThumbnailWidget::setGraphicsItems(const QList<QGraphicsItem*>& pGraphicsI
foreach (QGraphicsItem* item, pGraphicsItems) foreach (QGraphicsItem* item, pGraphicsItems)
{ {
if (item->scene() != &mThumbnailsScene) if (item->scene() != &mThumbnailsScene){
{
mThumbnailsScene.addItem(item); mThumbnailsScene.addItem(item);
} }
} }
@ -767,7 +766,6 @@ UBSceneThumbnailNavigPixmap::UBSceneThumbnailNavigPixmap(const QPixmap& pix, UBD
, bCanDelete(false) , bCanDelete(false)
, bCanMoveUp(false) , bCanMoveUp(false)
, bCanMoveDown(false) , bCanMoveDown(false)
, bCanDuplicate(false)
{ {
if(0 <= UBDocumentContainer::pageFromSceneIndex(pSceneIndex)){ if(0 <= UBDocumentContainer::pageFromSceneIndex(pSceneIndex)){
setAcceptsHoverEvents(true); setAcceptsHoverEvents(true);
@ -783,7 +781,16 @@ UBSceneThumbnailNavigPixmap::~UBSceneThumbnailNavigPixmap()
void UBSceneThumbnailNavigPixmap::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void UBSceneThumbnailNavigPixmap::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
event->accept(); 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(); update();
} }
@ -806,10 +813,9 @@ void UBSceneThumbnailNavigPixmap::paint(QPainter *painter, const QStyleOptionGra
painter->drawPixmap(0, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/close.svg")); painter->drawPixmap(0, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/close.svg"));
else else
painter->drawPixmap(0, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/closeDisabled.svg")); painter->drawPixmap(0, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/closeDisabled.svg"));
if(bCanDuplicate)
painter->drawPixmap(BUTTONSIZE + BUTTONSPACING, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/duplicate.svg")); painter->drawPixmap(BUTTONSIZE + BUTTONSPACING, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/duplicate.svg"));
else
painter->drawPixmap(BUTTONSIZE + BUTTONSPACING, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/duplicateDisabled.svg"));
if(bCanMoveUp) if(bCanMoveUp)
painter->drawPixmap(2*(BUTTONSIZE + BUTTONSPACING), 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/moveUp.svg")); painter->drawPixmap(2*(BUTTONSIZE + BUTTONSPACING), 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/moveUp.svg"));
else 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. // 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) if(bCanDelete && p.x() >= 0 && p.x() <= BUTTONSIZE && p.y() >= 0 && p.y() <= BUTTONSIZE)
deletePage(); 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(); duplicatePage();
if(bCanMoveUp && p.x() >= 2*(BUTTONSIZE + BUTTONSPACING) && p.x() <= 3*BUTTONSIZE + 2*BUTTONSPACING && p.y() >= 0 && p.y() <= BUTTONSIZE) if(bCanMoveUp && p.x() >= 2*(BUTTONSIZE + BUTTONSPACING) && p.x() <= 3*BUTTONSIZE + 2*BUTTONSPACING && p.y() >= 0 && p.y() <= BUTTONSIZE)
moveUpPage(); moveUpPage();
if(bCanMoveDown && p.x() >= 3*(BUTTONSIZE + BUTTONSPACING) && p.x() <= 4*BUTTONSIZE + 3*BUTTONSPACING && p.y() >= 0 && p.y() <= BUTTONSIZE) 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(); 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() 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()))){ 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()))){

@ -311,7 +311,6 @@ class UBSceneThumbnailNavigPixmap : public UBSceneThumbnailPixmap
void mousePressEvent(QGraphicsSceneMouseEvent *event); void mousePressEvent(QGraphicsSceneMouseEvent *event);
private: private:
void updateButtonsState();
void deletePage(); void deletePage();
void duplicatePage(); void duplicatePage();
void moveUpPage(); void moveUpPage();
@ -321,7 +320,6 @@ class UBSceneThumbnailNavigPixmap : public UBSceneThumbnailPixmap
bool bCanDelete; bool bCanDelete;
bool bCanMoveUp; bool bCanMoveUp;
bool bCanMoveDown; bool bCanMoveDown;
bool bCanDuplicate;
}; };
class UBThumbnailVideo : public UBThumbnailPixmap class UBThumbnailVideo : public UBThumbnailPixmap

@ -25,7 +25,6 @@ HEADERS += src/gui/UBThumbnailView.h \
src/gui/UBActionPalette.h \ src/gui/UBActionPalette.h \
src/gui/UBFavoriteToolPalette.h \ src/gui/UBFavoriteToolPalette.h \
src/gui/UBKeyboardPalette.h \ src/gui/UBKeyboardPalette.h \
src/gui/UBNavigatorPalette.h \
src/gui/UBDocumentNavigator.h \ src/gui/UBDocumentNavigator.h \
src/gui/UBDockPalette.h \ src/gui/UBDockPalette.h \
src/gui/UBPropertyPalette.h \ src/gui/UBPropertyPalette.h \
@ -68,7 +67,6 @@ SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBActionPalette.cpp \ src/gui/UBActionPalette.cpp \
src/gui/UBFavoriteToolPalette.cpp \ src/gui/UBFavoriteToolPalette.cpp \
src/gui/UBKeyboardPalette.cpp \ src/gui/UBKeyboardPalette.cpp \
src/gui/UBNavigatorPalette.cpp \
src/gui/UBDocumentNavigator.cpp \ src/gui/UBDocumentNavigator.cpp \
src/gui/UBDockPalette.cpp \ src/gui/UBDockPalette.cpp \
src/gui/UBPropertyPalette.cpp \ src/gui/UBPropertyPalette.cpp \

Loading…
Cancel
Save