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. 90
      src/document/UBDocumentController.cpp
  10. 18
      src/document/UBDocumentController.h
  11. 2
      src/frameworks/UBPlatformUtils_mac.mm
  12. 40
      src/gui/UBDocumentNavigator.cpp
  13. 12
      src/gui/UBDocumentThumbnailWidget.cpp
  14. 5
      src/gui/UBDocumentThumbnailWidget.h

@ -29,6 +29,7 @@
#include "UBSvgSubsetAdaptor.h" #include "UBSvgSubsetAdaptor.h"
#include <QObject>
#include <QtCore> #include <QtCore>
#include <QtXml> #include <QtXml>
#include <QGraphicsTextItem> #include <QGraphicsTextItem>
@ -239,6 +240,7 @@ QString UBSvgSubsetAdaptor::uniboardDocumentNamespaceUriFromVersion(int mFileVer
UBGraphicsScene* UBSvgSubsetAdaptor::loadScene(UBDocumentProxy* proxy, const int pageIndex) 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); QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", pageIndex);
qDebug() << fileName; qDebug() << fileName;
QFile file(fileName); QFile file(fileName);

@ -54,6 +54,7 @@ void UBThumbnailAdaptor::generateMissingThumbnails(UBDocumentProxy* proxy)
for (int iPageNo = 0; iPageNo < existingPageCount; ++iPageNo) 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); QString thumbFileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", iPageNo);
QFile thumbFile(thumbFileName); 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); QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", pageIndex);
QFile file(fileName); QFile file(fileName);
@ -93,30 +95,21 @@ const QPixmap* UBThumbnailAdaptor::get(UBDocumentProxy* proxy, int pageIndex)
generateMissingThumbnails(proxy); generateMissingThumbnails(proxy);
} }
QPixmap* pix = new QPixmap(); QPixmap pix;
if (file.exists()) if (file.exists())
{ {
//Warning. Works only with modified Qt pix.load(fileName, 0, Qt::AutoColor);
#ifdef Q_OS_LINUX
pix->load(fileName, 0, Qt::AutoColor);
#else
pix->load(fileName, 0, Qt::AutoColor);
#endif
} }
return pix; 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(); list.clear();
for(int i=0; i<proxy->pageCount(); i++) 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) 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 void persistScene(UBDocumentProxy* proxy, UBGraphicsScene* pScene, int pageIndex, bool overrideModified = false);
static const QPixmap* get(UBDocumentProxy* proxy, int index); static QPixmap get(UBDocumentProxy* proxy, int index);
static void load(UBDocumentProxy* proxy, QList<const QPixmap*>& list); static void load(UBDocumentProxy* proxy, QList<std::shared_ptr<QPixmap>>& list);
private: private:
static void generateMissingThumbnails(UBDocumentProxy* proxy); static void generateMissingThumbnails(UBDocumentProxy* proxy);

@ -354,7 +354,7 @@ void UBApplicationController::showBoard()
int selectedSceneIndex = UBApplication::documentController->getSelectedItemIndex(); int selectedSceneIndex = UBApplication::documentController->getSelectedItemIndex();
if (selectedSceneIndex != -1) 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(thumbTmp).exists());
Q_ASSERT(QFileInfo(thumbTo).exists()); Q_ASSERT(QFileInfo(thumbTo).exists());
const QPixmap *pix = new QPixmap(thumbTmp); auto pix = std::make_shared<QPixmap>(thumbTmp);
UBDocumentController *ctrl = UBApplication::documentController; UBDocumentController *ctrl = UBApplication::documentController;
ctrl->addPixmapAt(pix, toIndex); ctrl->addPixmapAt(pix, toIndex);
ctrl->TreeViewSelectionChanged(ctrl->firstSelectedTreeIndex(), QModelIndex()); 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) 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--) for(int i = count - 1; i >= index; i--)
{
UBApplication::showMessage(tr("renaming pages (%1/%2)").arg(i).arg(count));
renamePage(proxy, i , i + 1); renamePage(proxy, i , i + 1);
}
mSceneCache.shiftUpScenes(proxy, index, count -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--) 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); internalMoveScene(proxy, i, i + 1);
} }
} }

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

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

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

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

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

@ -132,13 +132,32 @@ void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source)
} }
for(int i = 0; i < source->selectedDocument()->pageCount(); i++) for(int i = 0; i < source->selectedDocument()->pageCount(); i++)
{
UBApplication::showMessage(tr("generating thumbnails for board (%1/%2)").arg(i+1).arg(source->selectedDocument()->pageCount()));
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 //claudio This is a very bad hack and shows a architectural problem
// source->selectedDocument()->pageCount() != source->pageCount() // source->selectedDocument()->pageCount() != source->pageCount()
if(i>=source->pageCount() || !source->pageAt(i)) if(i>=source->pageCount() || !source->pageAt(i))
source->insertThumbPage(i); source->insertThumbPage(i);
}
const QPixmap* pix = source->pageAt(i); auto pix = source->pageAt(i);
Q_ASSERT(!pix->isNull()); Q_ASSERT(!pix->isNull());
int pageIndex = UBDocumentContainer::pageFromSceneIndex(i); int pageIndex = UBDocumentContainer::pageFromSceneIndex(i);
@ -193,12 +212,12 @@ void UBDocumentNavigator::onScrollToSelectedPage(int index)
*/ */
void UBDocumentNavigator::updateSpecificThumbnail(int iPage) 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); UBSceneThumbnailNavigPixmap* newItem = new UBSceneThumbnailNavigPixmap(*pix, UBApplication::boardController->selectedDocument(), iPage);
// Get the old thumbnail // Get the old thumbnail
UBSceneThumbnailNavigPixmap* oldItem = mThumbsWithLabels.at(iPage).getThumbnail(); UBSceneThumbnailNavigPixmap* oldItem = mThumbsWithLabels.at(iPage).getThumbnail();
if(NULL != oldItem) if(oldItem)
{ {
mScene->removeItem(oldItem); mScene->removeItem(oldItem);
mScene->addItem(newItem); mScene->addItem(newItem);
@ -209,6 +228,18 @@ void UBDocumentNavigator::updateSpecificThumbnail(int iPage)
oldItem = NULL; 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()) if (!event->isAccepted())
{ {
mLongPressTimer.start();
mLastPressedMousePos = event->pos(); mLastPressedMousePos = event->pos();
mLastClickedThumbnail = clickedThumbnail(mLastPressedMousePos); mLastClickedThumbnail = clickedThumbnail(mLastPressedMousePos);
@ -314,6 +344,8 @@ void UBDocumentNavigator::mousePressEvent(QMouseEvent *event)
UBApplication::boardController->setActiveDocumentScene(mLastClickedThumbnail->sceneIndex()); UBApplication::boardController->setActiveDocumentScene(mLastClickedThumbnail->sceneIndex());
UBApplication::boardController->centerOn(UBApplication::boardController->activeScene()->lastCenter()); UBApplication::boardController->centerOn(UBApplication::boardController->activeScene()->lastCenter());
} }
mLongPressTimer.start();
} }
} }

@ -297,6 +297,18 @@ bool UBDocumentThumbnailWidget::dragEnabled() const
return mDragEnabled; 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) void UBDocumentThumbnailWidget::hightlightItem(int index)
{ {
if (0 <= index && index < mLabelsItems.length()) if (0 <= index && index < mLabelsItems.length())

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

Loading…
Cancel
Save