|
|
|
@ -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,16 +1678,22 @@ void UBDocumentTreeItemDelegate::commitAndCloseEditor() |
|
|
|
|
void UBDocumentTreeItemDelegate::processChangedText(const QString &str) const |
|
|
|
|
{ |
|
|
|
|
QLineEdit *editor = qobject_cast<QLineEdit*>(sender()); |
|
|
|
|
if (!editor) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!validateString(str)) { |
|
|
|
|
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 { |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
editor->setStyleSheet("background-color: #FFFFFF;"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool UBDocumentTreeItemDelegate::validateString(const QString &str) const |
|
|
|
|
{ |
|
|
|
@ -1702,18 +1718,30 @@ 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); |
|
|
|
|
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); |
|
|
|
|
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.
|
|
|
|
|
return 0; |
|
|
|
@ -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())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|