preferencesAboutTextFull
Clément Fauconnier 3 years ago
commit fe95d069c1
  1. 2
      src/adaptors/UBSvgSubsetAdaptor.cpp
  2. 25
      src/adaptors/UBThumbnailAdaptor.cpp
  3. 4
      src/adaptors/UBThumbnailAdaptor.h
  4. 2
      src/core/UBApplicationController.cpp
  5. 7
      src/core/UBPersistenceManager.cpp
  6. 1
      src/core/UBSceneCache.cpp
  7. 40
      src/document/UBDocumentContainer.cpp
  8. 10
      src/document/UBDocumentContainer.h
  9. 102
      src/document/UBDocumentController.cpp
  10. 22
      src/document/UBDocumentController.h
  11. 2
      src/frameworks/UBPlatformUtils_mac.mm
  12. 48
      src/gui/UBDocumentNavigator.cpp
  13. 2
      src/gui/UBDocumentNavigator.h
  14. 12
      src/gui/UBDocumentThumbnailWidget.cpp
  15. 5
      src/gui/UBDocumentThumbnailWidget.h

@ -29,6 +29,7 @@
#include "UBSvgSubsetAdaptor.h"
#include <QObject>
#include <QtCore>
#include <QtXml>
#include <QGraphicsTextItem>
@ -239,6 +240,7 @@ QString UBSvgSubsetAdaptor::uniboardDocumentNamespaceUriFromVersion(int mFileVer
UBGraphicsScene* UBSvgSubsetAdaptor::loadScene(UBDocumentProxy* proxy, const int pageIndex)
{
UBApplication::showMessage(QObject::tr("Loading scene (%1/%2)").arg(pageIndex+1).arg(proxy->pageCount()));
QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", pageIndex);
qDebug() << fileName;
QFile file(fileName);

@ -54,6 +54,7 @@ void UBThumbnailAdaptor::generateMissingThumbnails(UBDocumentProxy* proxy)
for (int iPageNo = 0; iPageNo < existingPageCount; ++iPageNo)
{
UBApplication::showMessage(tr("check generateMissingThumbnails (%1/%2)").arg(iPageNo).arg(existingPageCount));
QString thumbFileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", iPageNo);
QFile thumbFile(thumbFileName);
@ -83,8 +84,9 @@ void UBThumbnailAdaptor::generateMissingThumbnails(UBDocumentProxy* proxy)
}
}
const QPixmap* UBThumbnailAdaptor::get(UBDocumentProxy* proxy, int pageIndex)
QPixmap UBThumbnailAdaptor::get(UBDocumentProxy* proxy, int pageIndex)
{
UBApplication::showMessage(tr("Loading thumbnail (%1/%2)").arg(pageIndex+1).arg(proxy->pageCount()));
QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", pageIndex);
QFile file(fileName);
@ -93,30 +95,21 @@ const QPixmap* UBThumbnailAdaptor::get(UBDocumentProxy* proxy, int pageIndex)
generateMissingThumbnails(proxy);
}
QPixmap* pix = new QPixmap();
QPixmap pix;
if (file.exists())
{
//Warning. Works only with modified Qt
#ifdef Q_OS_LINUX
pix->load(fileName, 0, Qt::AutoColor);
#else
pix->load(fileName, 0, Qt::AutoColor);
#endif
pix.load(fileName, 0, Qt::AutoColor);
}
return pix;
}
void UBThumbnailAdaptor::load(UBDocumentProxy* proxy, QList<const QPixmap*>& list)
void UBThumbnailAdaptor::load(UBDocumentProxy* proxy, QList<std::shared_ptr<QPixmap>>& list)
{
generateMissingThumbnails(proxy);
foreach(const QPixmap* pm, list){
delete pm;
pm = NULL;
}
list.clear();
for(int i=0; i<proxy->pageCount(); i++)
list.append(get(proxy, i));
{
list.append(std::make_shared<QPixmap>(get(proxy, i)));
}
}
void UBThumbnailAdaptor::persistScene(UBDocumentProxy* proxy, UBGraphicsScene* pScene, int pageIndex, bool overrideModified)

@ -45,8 +45,8 @@ public:
static void persistScene(UBDocumentProxy* proxy, UBGraphicsScene* pScene, int pageIndex, bool overrideModified = false);
static const QPixmap* get(UBDocumentProxy* proxy, int index);
static void load(UBDocumentProxy* proxy, QList<const QPixmap*>& list);
static QPixmap get(UBDocumentProxy* proxy, int index);
static void load(UBDocumentProxy* proxy, QList<std::shared_ptr<QPixmap>>& list);
private:
static void generateMissingThumbnails(UBDocumentProxy* proxy);

@ -354,7 +354,7 @@ void UBApplicationController::showBoard()
int selectedSceneIndex = UBApplication::documentController->getSelectedItemIndex();
if (selectedSceneIndex != -1)
{
UBApplication::boardController->setActiveDocumentScene(UBApplication::documentController->selectedDocument(), selectedSceneIndex, true);
UBApplication::boardController->setActiveDocumentScene(UBApplication::documentController->selectedDocument(), selectedSceneIndex);
}
}

@ -809,7 +809,7 @@ void UBPersistenceManager::copyDocumentScene(UBDocumentProxy *from, int fromInde
Q_ASSERT(QFileInfo(thumbTmp).exists());
Q_ASSERT(QFileInfo(thumbTo).exists());
const QPixmap *pix = new QPixmap(thumbTmp);
auto pix = std::make_shared<QPixmap>(thumbTmp);
UBDocumentController *ctrl = UBApplication::documentController;
ctrl->addPixmapAt(pix, toIndex);
ctrl->TreeViewSelectionChanged(ctrl->firstSelectedTreeIndex(), QModelIndex());
@ -820,10 +820,13 @@ void UBPersistenceManager::copyDocumentScene(UBDocumentProxy *from, int fromInde
UBGraphicsScene* UBPersistenceManager::createDocumentSceneAt(UBDocumentProxy* proxy, int index, bool useUndoRedoStack)
{
int count = sceneCount(proxy);
int count = proxy->pageCount();
for(int i = count - 1; i >= index; i--)
{
UBApplication::showMessage(tr("renaming pages (%1/%2)").arg(i).arg(count));
renamePage(proxy, i , i + 1);
}
mSceneCache.shiftUpScenes(proxy, index, count -1);

@ -222,6 +222,7 @@ void UBSceneCache::shiftUpScenes(UBDocumentProxy* proxy, int startIncIndex, int
{
for(int i = endIncIndex; i >= startIncIndex; i--)
{
UBApplication::showMessage(QObject::tr("moving cached scenes (%1/%2)").arg(i).arg(endIncIndex));
internalMoveScene(proxy, i, i + 1);
}
}

@ -40,10 +40,7 @@ UBDocumentContainer::UBDocumentContainer(QObject * parent)
UBDocumentContainer::~UBDocumentContainer()
{
foreach(const QPixmap* pm, mDocumentThumbs){
delete pm;
pm = NULL;
}
}
void UBDocumentContainer::setDocument(UBDocumentProxy* document, bool forceReload)
@ -52,6 +49,8 @@ void UBDocumentContainer::setDocument(UBDocumentProxy* document, bool forceReloa
{
mCurrentDocument = document;
//qDebug() << documentThumbs();
clearThumbPage();
reloadThumbnails();
emit documentSet(mCurrentDocument);
}
@ -103,15 +102,14 @@ void UBDocumentContainer::addPage(int index)
}
void UBDocumentContainer::addPixmapAt(const QPixmap *pix, int index)
void UBDocumentContainer::addPixmapAt(std::shared_ptr<QPixmap> pix, int index)
{
mDocumentThumbs.insert(index, pix);
documentThumbs().insert(index, pix);
}
void UBDocumentContainer::clearThumbPage()
{
qDeleteAll(mDocumentThumbs);
mDocumentThumbs.clear();
}
@ -126,7 +124,6 @@ void UBDocumentContainer::initThumbPage()
void UBDocumentContainer::updatePage(int index)
{
updateThumbPage(index);
emit documentThumbnailsUpdated(this);
}
void UBDocumentContainer::deleteThumbPage(int index)
@ -138,8 +135,9 @@ void UBDocumentContainer::updateThumbPage(int index)
{
if (mDocumentThumbs.size() > index)
{
mDocumentThumbs[index] = UBThumbnailAdaptor::get(mCurrentDocument, index);
emit documentPageUpdated(index);
QPixmap pixmap = UBThumbnailAdaptor::get(mCurrentDocument, index);
mDocumentThumbs[index] = std::make_shared<QPixmap>(pixmap);
emit documentPageUpdated(index); //refresh specific thumbnail in board
}
else
{
@ -149,15 +147,24 @@ void UBDocumentContainer::updateThumbPage(int index)
void UBDocumentContainer::insertThumbPage(int index)
{
mDocumentThumbs.insert(index, UBThumbnailAdaptor::get(mCurrentDocument, index));
QPixmap newPixmap = UBThumbnailAdaptor::get(mCurrentDocument, index);
if (index < documentThumbs().size())
{
*documentThumbs().at(index) = newPixmap;
}
else
{
documentThumbs().insert(index, std::make_shared<QPixmap>(newPixmap));
}
}
void UBDocumentContainer::insertExistingThumbPage(int index, std::shared_ptr<QPixmap> thumbnailPixmap)
{
documentThumbs().insert(index, thumbnailPixmap);
}
void UBDocumentContainer::reloadThumbnails()
{
if (mCurrentDocument)
{
UBThumbnailAdaptor::load(mCurrentDocument, mDocumentThumbs);
}
emit documentThumbnailsUpdated(this);
}
@ -173,6 +180,5 @@ int UBDocumentContainer::sceneIndexFromPage(int page)
void UBDocumentContainer::addEmptyThumbPage()
{
const QPixmap* pThumb = new QPixmap();
mDocumentThumbs.append(pThumb);
mDocumentThumbs.append(std::shared_ptr<QPixmap>());
}

@ -45,8 +45,9 @@ class UBDocumentContainer : public QObject
void pureSetDocument(UBDocumentProxy *document) {mCurrentDocument = document;}
UBDocumentProxy* selectedDocument(){return mCurrentDocument;}
QList<std::shared_ptr<QPixmap>>& documentThumbs() { return mDocumentThumbs; }
int pageCount() const{return mCurrentDocument->pageCount();}
const QPixmap* pageAt(int index)
std::shared_ptr<QPixmap> pageAt(int index)
{
if (index < mDocumentThumbs.size())
return mDocumentThumbs[index];
@ -65,16 +66,17 @@ class UBDocumentContainer : public QObject
void clearThumbPage();
void initThumbPage();
void addPage(int index);
void addPixmapAt(const QPixmap *pix, int index);
void addPixmapAt(std::shared_ptr<QPixmap> pix, int index);
void updatePage(int index);
void addEmptyThumbPage();
void reloadThumbnails();
virtual void reloadThumbnails();
void insertThumbPage(int index);
void insertExistingThumbPage(int index, std::shared_ptr<QPixmap> thumbnailPixmap);
private:
UBDocumentProxy* mCurrentDocument;
QList<const QPixmap*> mDocumentThumbs;
QList<std::shared_ptr<QPixmap>> mDocumentThumbs;
protected:

@ -1034,6 +1034,16 @@ QString UBDocumentTreeModel::virtualPathForIndex(const QModelIndex &pIndex) cons
return virtualDirForIndex(pIndex) + "/" + curNode->nodeName();
}
QList<UBDocumentTreeNode*> UBDocumentTreeModel::nodeChildrenFromIndex(const QModelIndex &pIndex) const
{
UBDocumentTreeNode *node = nodeFromIndex(pIndex);
if (node)
return node->children();
else
return QList<UBDocumentTreeNode*>();
}
QStringList UBDocumentTreeModel::nodeNameList(const QModelIndex &pIndex, bool distinctNodeType) const
{
QStringList result;
@ -1545,7 +1555,7 @@ void UBDocumentTreeView::dropEvent(QDropEvent *event)
Q_ASSERT(QFileInfo(thumbTmp).exists());
Q_ASSERT(QFileInfo(thumbTo).exists());
const QPixmap *pix = new QPixmap(thumbTmp);
auto pix = std::make_shared<QPixmap>(thumbTmp);
UBDocumentController *ctrl = UBApplication::documentController;
ctrl->addPixmapAt(pix, toIndex);
}
@ -1668,14 +1678,20 @@ void UBDocumentTreeItemDelegate::commitAndCloseEditor()
void UBDocumentTreeItemDelegate::processChangedText(const QString &str) const
{
QLineEdit *editor = qobject_cast<QLineEdit*>(sender());
if (!editor) {
return;
}
if (!validateString(str)) {
editor->setStyleSheet("background-color: #FFB3C8;");
} else {
editor->setStyleSheet("background-color: #FFFFFF;");
if (editor)
{
if (editor->validator())
{
int pos = 0;
if (editor->validator()->validate(const_cast<QString&>(str), pos) != QValidator::Acceptable)
{
editor->setStyleSheet("background-color: #FFB3C8;");
}
else
{
editor->setStyleSheet("background-color: #FFFFFF;");
}
}
}
}
@ -1702,17 +1718,29 @@ QWidget *UBDocumentTreeItemDelegate::createEditor(QWidget *parent, const QStyleO
QModelIndex sourceIndex = proxy->mapToSource(index);
if (docModel) {
if (docModel)
{
mExistingFileNames = docModel->nodeNameList(sourceIndex.parent());
mExistingFileNames.removeOne(sourceIndex.data().toString());
UBDocumentTreeNode* sourceNode = docModel->nodeFromIndex(sourceIndex);
if (sourceNode)
{
QLineEdit *nameEditor = new QLineEdit(parent);
QList<UBDocumentTreeNode*> nodeChildren = docModel->nodeChildrenFromIndex(sourceIndex.parent());
nodeChildren.removeOne(sourceNode);
UBValidator* validator = new UBValidator(nodeChildren, sourceNode->nodeType());
nameEditor->setValidator(validator);
connect(nameEditor, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()));
connect(nameEditor, SIGNAL(textChanged(QString)), this, SLOT(processChangedText(QString)));
return nameEditor;
}
}
QLineEdit *nameEditor = new QLineEdit(parent);
UBValidator* validator = new UBValidator(mExistingFileNames);
nameEditor->setValidator(validator);
connect(nameEditor, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()));
connect(nameEditor, SIGNAL(textChanged(QString)), this, SLOT(processChangedText(QString)));
return nameEditor;
return nullptr;
}
//N/C - NNe - 20140407 : the other column are not editable.
@ -1731,8 +1759,17 @@ void UBDocumentTreeItemDelegate::setEditorData(QWidget *editor, const QModelInde
void UBDocumentTreeItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
QLineEdit *lineEditor = qobject_cast<QLineEdit*>(editor);
if (validateString(lineEditor->text())) {
model->setData(index, lineEditor->text());
if (lineEditor)
{
int pos;
QString input = lineEditor->text();
if (lineEditor->validator())
{
if (lineEditor->validator()->validate(input, pos) == QValidator::Acceptable)
{
model->setData(index, input);
}
}
}
}
@ -2201,7 +2238,6 @@ void UBDocumentController::sortDocuments(int kind, int order)
}
}
void UBDocumentController::onSortOrderChanged(bool order)
{
int kindIndex = mDocumentUI->sortKind->currentIndex();
@ -2260,9 +2296,6 @@ void UBDocumentController::show()
{
selectDocument(mBoardController->selectedDocument());
//to be sure thumbnails will be up-to-date
reloadThumbnails();
updateActions();
if(!mToolsPalette)
@ -3024,6 +3057,11 @@ void UBDocumentController::moveSceneToIndex(UBDocumentProxy* proxy, int source,
}
}
void UBDocumentController::updateThumbnailPixmap(int index, const QPixmap& newThumbnail)
{
mDocumentUI->thumbnailWidget->updateThumbnailPixmap(index, newThumbnail);
}
void UBDocumentController::thumbnailViewResized()
{
@ -3145,7 +3183,7 @@ void UBDocumentController::addToDocument()
UBMetadataDcSubsetAdaptor::persist(mBoardController->selectedDocument());
mBoardController->reloadThumbnails();
emit UBApplication::boardController->documentThumbnailsUpdated(this);
emit mBoardController->documentThumbnailsUpdated(this);
UBApplication::applicationController->showBoard();
mBoardController->setActiveDocumentScene(newActiveSceneIndex);
@ -3546,7 +3584,7 @@ void UBDocumentController::deletePages(QList<QGraphicsItem *> itemsToDelete)
}
}
UBDocumentContainer::deletePages(sceneIndexes);
emit UBApplication::boardController->documentThumbnailsUpdated(this);
emit mBoardController->documentThumbnailsUpdated(this);
proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(proxy);
@ -3687,7 +3725,7 @@ bool UBDocumentController::firstAndOnlySceneSelected() const
return false;
}
void UBDocumentController:: refreshDocumentThumbnailsView(UBDocumentContainer*)
void UBDocumentController:: refreshDocumentThumbnailsView(UBDocumentContainer* source)
{
UBDocumentTreeModel *docModel = UBPersistenceManager::persistenceManager()->mDocumentTreeStructureModel;
UBDocumentProxy *currentDocumentProxy = selectedDocument();
@ -3703,11 +3741,9 @@ void UBDocumentController:: refreshDocumentThumbnailsView(UBDocumentContainer*)
return;
}
QList<const QPixmap*> thumbs;
if (currentDocumentProxy)
{
UBThumbnailAdaptor::load(currentDocumentProxy, thumbs);
UBThumbnailAdaptor::load(currentDocumentProxy, documentThumbs());
}
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
@ -3723,7 +3759,9 @@ void UBDocumentController:: refreshDocumentThumbnailsView(UBDocumentContainer*)
{
for (int i = 0; i < currentDocumentProxy->pageCount(); i++)
{
const QPixmap* pix = thumbs.at(i);
UBApplication::showMessage(tr("Refreshing Document Thumbnails View (%1/%2)").arg(i+1).arg(source->selectedDocument()->pageCount()));
auto pix = documentThumbs().at(i);
QGraphicsPixmapItem *pixmapItem = new UBSceneThumbnailPixmap(*pix, currentDocumentProxy, i); // deleted by the tree widget
if (currentDocumentProxy == mBoardController->selectedDocument() && mBoardController->activeSceneIndex() == i)
@ -3755,9 +3793,9 @@ void UBDocumentController:: refreshDocumentThumbnailsView(UBDocumentContainer*)
if (selection)
{
disconnect(mDocumentUI->thumbnailWidget->scene(), SIGNAL(selectionChanged()), this, SLOT(pageSelectionChanged()));
UBSceneThumbnailPixmap *currentScene = dynamic_cast<UBSceneThumbnailPixmap*>(selection);
if (currentScene)
mDocumentUI->thumbnailWidget->hightlightItem(currentScene->sceneIndex());
UBSceneThumbnailPixmap *currentSceneThumbnailPixmap = dynamic_cast<UBSceneThumbnailPixmap*>(selection);
if (currentSceneThumbnailPixmap)
mDocumentUI->thumbnailWidget->hightlightItem(currentSceneThumbnailPixmap->sceneIndex());
connect(mDocumentUI->thumbnailWidget->scene(), SIGNAL(selectionChanged()), this, SLOT(pageSelectionChanged()));
}

@ -210,6 +210,7 @@ public:
QString virtualDirForIndex(const QModelIndex &pIndex) const;
QString virtualPathForIndex(const QModelIndex &pIndex) const;
QStringList nodeNameList(const QModelIndex &pIndex, bool distinctNodeType = false) const;
QList<UBDocumentTreeNode*> nodeChildrenFromIndex(const QModelIndex &pIndex) const;
bool newNodeAllowed(const QModelIndex &pSelectedIndex) const;
QModelIndex goTo(const QString &dir);
bool inTrash(const QModelIndex &index) const;
@ -324,22 +325,27 @@ private:
class UBValidator : public QValidator
{
const QStringList mExistingFileNames;
const QList<UBDocumentTreeNode*> mExistingNodes;
UBDocumentTreeNode::Type mEditedNodeType;
public:
UBValidator(const QStringList existingFileNames, QObject *parent = nullptr)
UBValidator(const QList<UBDocumentTreeNode*> existingNodes, UBDocumentTreeNode::Type editedNodeType, QObject *parent = nullptr)
: QValidator(parent)
, mExistingFileNames(existingFileNames)
, mExistingNodes(existingNodes)
, mEditedNodeType(editedNodeType)
{
}
QValidator::State validate(QString &input, int &pos) const
{
if (mExistingFileNames.contains(input))
return QValidator::Intermediate;
else
return QValidator::Acceptable;
for (auto node : mExistingNodes)
{
if (node->nodeName() == input && node->nodeType() == mEditedNodeType)
return QValidator::Intermediate;
}
return QValidator::Acceptable;
}
};
@ -495,6 +501,8 @@ class UBDocumentController : public UBDocumentContainer
void collapseAll();
void expandAll();
void updateThumbnailPixmap(int index, const QPixmap& newThumbnail);
protected:
virtual void setupViews();
virtual void setupToolbar();

@ -627,7 +627,7 @@ void UBPlatformUtils::showOSK(bool show)
{
@autoreleasepool {
CFDictionaryRef properties = (CFDictionaryRef)[NSDictionary
dictionaryWithObject: @"com.apple.keyboardViewer"
dictionaryWithObject: @"com.apple.KeyboardViewer"
forKey: (NSString *)kTISPropertyInputSourceID];
NSArray *sources = (NSArray *)TISCreateInputSourceList(properties, true);

@ -133,12 +133,31 @@ void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source)
for(int i = 0; i < source->selectedDocument()->pageCount(); i++)
{
//claudio This is a very bad hack and shows a architectural problem
// source->selectedDocument()->pageCount() != source->pageCount()
if(i>=source->pageCount() || !source->pageAt(i))
source->insertThumbPage(i);
UBApplication::showMessage(tr("generating thumbnails for board (%1/%2)").arg(i+1).arg(source->selectedDocument()->pageCount()));
const QPixmap* pix = source->pageAt(i);
bool found = false;
if (UBApplication::documentController)
{
if (UBApplication::documentController->selectedDocument() == source->selectedDocument())
{
if (UBApplication::documentController->pageAt(i))
{
found = true;
//thumbnail has already been loaded on the documentController so we don't need to do it again
source->insertExistingThumbPage(i, UBApplication::documentController->pageAt(i));
}
}
}
if (!found)
{
//claudio This is a very bad hack and shows a architectural problem
// source->selectedDocument()->pageCount() != source->pageCount()
if(i>=source->pageCount() || !source->pageAt(i))
source->insertThumbPage(i);
}
auto pix = source->pageAt(i);
Q_ASSERT(!pix->isNull());
int pageIndex = UBDocumentContainer::pageFromSceneIndex(i);
@ -193,12 +212,12 @@ void UBDocumentNavigator::onScrollToSelectedPage(int index)
*/
void UBDocumentNavigator::updateSpecificThumbnail(int iPage)
{
const QPixmap* pix = UBApplication::boardController->pageAt(iPage);
auto pix = UBApplication::boardController->pageAt(iPage);
UBSceneThumbnailNavigPixmap* newItem = new UBSceneThumbnailNavigPixmap(*pix, UBApplication::boardController->selectedDocument(), iPage);
// Get the old thumbnail
UBSceneThumbnailNavigPixmap* oldItem = mThumbsWithLabels.at(iPage).getThumbnail();
if(NULL != oldItem)
if(oldItem)
{
mScene->removeItem(oldItem);
mScene->addItem(newItem);
@ -209,6 +228,18 @@ void UBDocumentNavigator::updateSpecificThumbnail(int iPage)
oldItem = NULL;
}
ensureVisible(0, 0, 10, 10);
refreshScene();
if (UBApplication::documentController)
{
if (UBApplication::documentController->selectedDocument() == UBApplication::boardController->selectedDocument())
{
//update the pixmap in document mode
UBApplication::documentController->updateThumbnailPixmap(iPage, *pix);
}
}
}
/**
@ -302,7 +333,6 @@ void UBDocumentNavigator::mousePressEvent(QMouseEvent *event)
if (!event->isAccepted())
{
mLongPressTimer.start();
mLastPressedMousePos = event->pos();
mLastClickedThumbnail = clickedThumbnail(mLastPressedMousePos);
@ -314,6 +344,8 @@ void UBDocumentNavigator::mousePressEvent(QMouseEvent *event)
UBApplication::boardController->setActiveDocumentScene(mLastClickedThumbnail->sceneIndex());
UBApplication::boardController->centerOn(UBApplication::boardController->activeScene()->lastCenter());
}
mLongPressTimer.start();
}
}

@ -58,7 +58,7 @@ public:
public slots:
void onScrollToSelectedPage(int index);// { if (mCrntItem) centerOn(mCrntItem); }
void generateThumbnails(UBDocumentContainer* source);
void updateSpecificThumbnail(int iPage);
void updateSpecificThumbnail(int iPage);
void longPressTimeout();
void mousePressAndHoldEvent();

@ -297,6 +297,18 @@ bool UBDocumentThumbnailWidget::dragEnabled() const
return mDragEnabled;
}
void UBDocumentThumbnailWidget::updateThumbnailPixmap(int index, const QPixmap& newThumbnail)
{
if (index >= 0 && index < mGraphicItems.length())
{
UBSceneThumbnailPixmap *thumbnail = dynamic_cast<UBSceneThumbnailPixmap*>(mGraphicItems.at(index));
if (thumbnail)
{
thumbnail->setPixmap(newThumbnail);
}
}
}
void UBDocumentThumbnailWidget::hightlightItem(int index)
{
if (0 <= index && index < mLabelsItems.length())

@ -48,9 +48,8 @@ class UBDocumentThumbnailWidget: public UBThumbnailWidget
void hightlightItem(int index);
public slots:
virtual void setGraphicsItems(const QList<QGraphicsItem*>& pGraphicsItems,
const QList<QUrl>& pItemPaths, const QStringList pLabels = QStringList(),
const QString& pMimeType = QString(""));
void updateThumbnailPixmap(int index, const QPixmap& newThumbnail);
virtual void setGraphicsItems(const QList<QGraphicsItem*>& pGraphicsItems, const QList<QUrl>& pItemPaths, const QStringList pLabels = QStringList(), const QString& pMimeType = QString(""));
signals:
void sceneDropped(UBDocumentProxy* proxy, int source, int target);

Loading…
Cancel
Save