|
|
@ -103,9 +103,7 @@ void UBDocumentController::createNewDocument() |
|
|
|
|
|
|
|
|
|
|
|
if (group) |
|
|
|
if (group) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QString path = group->buildEntirePath(); |
|
|
|
UBDocumentProxy *document = UBPersistenceManager::persistenceManager()->createDocument(group->groupName()); |
|
|
|
|
|
|
|
|
|
|
|
UBDocumentProxy *document = UBPersistenceManager::persistenceManager()->createDocument(path); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
selectDocument(document); |
|
|
|
selectDocument(document); |
|
|
|
} |
|
|
|
} |
|
|
@ -189,38 +187,21 @@ void UBDocumentController::selectDocument(UBDocumentProxy* proxy, bool setAsCurr |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool bullshitcode = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBDocumentController::createNewDocumentGroup() |
|
|
|
void UBDocumentController::createNewDocumentGroup() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(bullshitcode){ |
|
|
|
|
|
|
|
mDocumentUI->documentTreeWidget->selectedItems().at(0)->setSelected(false); |
|
|
|
|
|
|
|
mDocumentUI->documentTreeWidget->topLevelItem(0)->setSelected(true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBDocumentGroupTreeItem* docGroupItem = new UBDocumentGroupTreeItem(0); // deleted by the tree widget
|
|
|
|
UBDocumentGroupTreeItem* docGroupItem = new UBDocumentGroupTreeItem(0); // deleted by the tree widget
|
|
|
|
int i = 1; |
|
|
|
int i = 1; |
|
|
|
QString newFolderName = tr("New Folder"); |
|
|
|
QString newFolderName = tr("New Folder"); |
|
|
|
while (allGroupNames().contains(newFolderName)) |
|
|
|
while (allGroupNames().contains(newFolderName)) |
|
|
|
|
|
|
|
{ |
|
|
|
newFolderName = tr("New Folder") + " " + QVariant(i++).toString(); |
|
|
|
newFolderName = tr("New Folder") + " " + QVariant(i++).toString(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
docGroupItem->setGroupName(newFolderName); |
|
|
|
docGroupItem->setGroupName(newFolderName); |
|
|
|
|
|
|
|
|
|
|
|
int trashIndex = mDocumentUI->documentTreeWidget->indexOfTopLevelItem(mTrashTi); |
|
|
|
int trashIndex = mDocumentUI->documentTreeWidget->indexOfTopLevelItem(mTrashTi); |
|
|
|
|
|
|
|
|
|
|
|
UBDocumentGroupTreeItem* selected = selectedDocumentGroupTreeItem(); |
|
|
|
mDocumentUI->documentTreeWidget->insertTopLevelItem(trashIndex, docGroupItem); |
|
|
|
|
|
|
|
|
|
|
|
QString parentGroupName(""); |
|
|
|
|
|
|
|
if(selected->groupName().contains(mDefaultDocumentGroupName)) |
|
|
|
|
|
|
|
mDocumentUI->documentTreeWidget->insertTopLevelItem(trashIndex, docGroupItem); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
selected->addChild(docGroupItem); |
|
|
|
|
|
|
|
parentGroupName = docGroupItem->buildEntirePath(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mMapOfPaths.insert(parentGroupName,docGroupItem); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mDocumentUI->documentTreeWidget->setCurrentItem(docGroupItem); |
|
|
|
mDocumentUI->documentTreeWidget->setCurrentItem(docGroupItem); |
|
|
|
mDocumentUI->documentTreeWidget->expandItem(docGroupItem); |
|
|
|
mDocumentUI->documentTreeWidget->expandItem(docGroupItem); |
|
|
|
} |
|
|
|
} |
|
|
@ -312,7 +293,8 @@ void UBDocumentController::setupViews() |
|
|
|
mDocumentUI->documentZoomSlider->setValue(thumbWidth); |
|
|
|
mDocumentUI->documentZoomSlider->setValue(thumbWidth); |
|
|
|
mDocumentUI->thumbnailWidget->setThumbnailWidth(thumbWidth); |
|
|
|
mDocumentUI->thumbnailWidget->setThumbnailWidth(thumbWidth); |
|
|
|
|
|
|
|
|
|
|
|
connect(mDocumentUI->documentZoomSlider, SIGNAL(valueChanged(int)), this, SLOT(documentZoomSliderValueChanged(int))); |
|
|
|
connect(mDocumentUI->documentZoomSlider, SIGNAL(valueChanged(int)), this, |
|
|
|
|
|
|
|
SLOT(documentZoomSliderValueChanged(int))); |
|
|
|
|
|
|
|
|
|
|
|
connect(mMainWindow->actionOpen, SIGNAL(triggered()), this, SLOT(openSelectedItem())); |
|
|
|
connect(mMainWindow->actionOpen, SIGNAL(triggered()), this, SLOT(openSelectedItem())); |
|
|
|
connect(mMainWindow->actionNewFolder, SIGNAL(triggered()), this, SLOT(createNewDocumentGroup())); |
|
|
|
connect(mMainWindow->actionNewFolder, SIGNAL(triggered()), this, SLOT(createNewDocumentGroup())); |
|
|
@ -630,38 +612,6 @@ void UBDocumentController::moveDocumentToTrash(UBDocumentGroupTreeItem* groupTi, |
|
|
|
proxyTi->setFlags(proxyTi->flags() ^ Qt::ItemIsEditable); |
|
|
|
proxyTi->setFlags(proxyTi->flags() ^ Qt::ItemIsEditable); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QList<UBDocumentProxyTreeItem*> UBDocumentController::getProxies(QTreeWidgetItem* groupItem) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QList<UBDocumentProxyTreeItem*> result; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < groupItem->childCount(); i += 1){ |
|
|
|
|
|
|
|
UBDocumentProxyTreeItem* docProxy = dynamic_cast<UBDocumentProxyTreeItem*>(groupItem->child(i)); |
|
|
|
|
|
|
|
if(docProxy) |
|
|
|
|
|
|
|
result.append(docProxy); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
result << getProxies(groupItem->child(i)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QList<UBDocumentGroupTreeItem*> UBDocumentController::getGroupTreeItem(QTreeWidgetItem* groupItem) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QList<UBDocumentGroupTreeItem*> result; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < groupItem->childCount(); i += 1){ |
|
|
|
|
|
|
|
UBDocumentGroupTreeItem* group = dynamic_cast<UBDocumentGroupTreeItem*>(groupItem->child(i)); |
|
|
|
|
|
|
|
if(group) |
|
|
|
|
|
|
|
result.append(group); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
result << getGroupTreeItem(groupItem->child(i)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBDocumentController::moveFolderToTrash(UBDocumentGroupTreeItem* groupTi) |
|
|
|
void UBDocumentController::moveFolderToTrash(UBDocumentGroupTreeItem* groupTi) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool changeCurrentDocument = false; |
|
|
|
bool changeCurrentDocument = false; |
|
|
@ -675,9 +625,15 @@ void UBDocumentController::moveFolderToTrash(UBDocumentGroupTreeItem* groupTi) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QList<UBDocumentProxyTreeItem*> toBeDeleted; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QList<UBDocumentProxyTreeItem*> toBeDeleted = getProxies(groupTi); |
|
|
|
for (int i = 0; i < groupTi->childCount(); i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
UBDocumentProxyTreeItem* proxyTi = dynamic_cast<UBDocumentProxyTreeItem*>(groupTi->child(i)); |
|
|
|
|
|
|
|
if (proxyTi && proxyTi->proxy()) |
|
|
|
|
|
|
|
toBeDeleted << proxyTi; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < toBeDeleted.count(); i++) |
|
|
|
for (int i = 0; i < toBeDeleted.count(); i++) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -689,38 +645,21 @@ void UBDocumentController::moveFolderToTrash(UBDocumentGroupTreeItem* groupTi) |
|
|
|
proxyTi->proxy()->setMetaData(UBSettings::documentGroupName, UBSettings::trashedDocumentGroupNamePrefix + oldGroupName); |
|
|
|
proxyTi->proxy()->setMetaData(UBSettings::documentGroupName, UBSettings::trashedDocumentGroupNamePrefix + oldGroupName); |
|
|
|
UBPersistenceManager::persistenceManager()->persistDocumentMetadata(proxyTi->proxy()); |
|
|
|
UBPersistenceManager::persistenceManager()->persistDocumentMetadata(proxyTi->proxy()); |
|
|
|
|
|
|
|
|
|
|
|
UBDocumentGroupTreeItem* parentDirectory = dynamic_cast<UBDocumentGroupTreeItem*>(mMapOfPaths.value(oldGroupName)); |
|
|
|
groupTi->removeChild(proxyTi); |
|
|
|
parentDirectory->removeChild(proxyTi); |
|
|
|
|
|
|
|
mTrashTi->addChild(proxyTi); |
|
|
|
mTrashTi->addChild(proxyTi); |
|
|
|
proxyTi->setFlags(proxyTi->flags() ^ Qt::ItemIsEditable); |
|
|
|
proxyTi->setFlags(proxyTi->flags() ^ Qt::ItemIsEditable); |
|
|
|
|
|
|
|
|
|
|
|
showMessage(QString("%1 deleted").arg(groupTi->groupName())); |
|
|
|
showMessage(QString("%1 deleted").arg(groupTi->groupName())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QList<UBDocumentGroupTreeItem*> dirToDelete = getGroupTreeItem(groupTi); |
|
|
|
|
|
|
|
for(int i = dirToDelete.count() - 1; i >= 0 ; i -= 1){ |
|
|
|
|
|
|
|
UBDocumentGroupTreeItem* parent = dynamic_cast<UBDocumentGroupTreeItem*>(dirToDelete.at(i)->parent()); |
|
|
|
|
|
|
|
if(parent){ |
|
|
|
|
|
|
|
mMapOfPaths.remove(dirToDelete.at(i)->buildEntirePath()); |
|
|
|
|
|
|
|
parent->removeChild(dirToDelete.at(i)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// dont remove default group
|
|
|
|
// dont remove default group
|
|
|
|
if (!groupTi->isDefaultFolder()) |
|
|
|
if (!groupTi->isDefaultFolder()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int index = mDocumentUI->documentTreeWidget->indexOfTopLevelItem(groupTi); |
|
|
|
int index = mDocumentUI->documentTreeWidget->indexOfTopLevelItem(groupTi); |
|
|
|
|
|
|
|
|
|
|
|
if (index >= 0) |
|
|
|
if (index >= 0) |
|
|
|
|
|
|
|
{ |
|
|
|
mDocumentUI->documentTreeWidget->takeTopLevelItem(index); |
|
|
|
mDocumentUI->documentTreeWidget->takeTopLevelItem(index); |
|
|
|
else { |
|
|
|
|
|
|
|
UBDocumentGroupTreeItem* parent = dynamic_cast<UBDocumentGroupTreeItem*>(groupTi->parent()); |
|
|
|
|
|
|
|
if(parent){ |
|
|
|
|
|
|
|
mMapOfPaths.remove(groupTi->buildEntirePath()); |
|
|
|
|
|
|
|
parent->removeChild(groupTi); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -871,90 +810,109 @@ void UBDocumentController::documentZoomSliderValueChanged (int value) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBDocumentGroupTreeItem* UBDocumentController::getCommonGroupItem(QString &path) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QList<QString> paths = mMapOfPaths.keys(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(paths.count() == 0) |
|
|
|
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString commonPath = path; |
|
|
|
|
|
|
|
do{ |
|
|
|
|
|
|
|
if(paths.contains(commonPath)) |
|
|
|
|
|
|
|
return mMapOfPaths.value(commonPath); |
|
|
|
|
|
|
|
else{ |
|
|
|
|
|
|
|
int lastSeparatorIndex = commonPath.lastIndexOf("/"); |
|
|
|
|
|
|
|
if(lastSeparatorIndex>0) |
|
|
|
|
|
|
|
commonPath = commonPath.left(lastSeparatorIndex); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
commonPath = ""; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}while(commonPath.length() > 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBDocumentController::loadDocumentProxies() |
|
|
|
void UBDocumentController::loadDocumentProxies() |
|
|
|
{ |
|
|
|
{ |
|
|
|
QList<QPointer<UBDocumentProxy> > proxies = UBPersistenceManager::persistenceManager()->documentProxies; |
|
|
|
QList<QPointer<UBDocumentProxy> > proxies = UBPersistenceManager::persistenceManager()->documentProxies; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QStringList emptyGroupNames = UBSettings::settings()->value("Document/EmptyGroupNames", QStringList()).toStringList(); |
|
|
|
mDocumentUI->documentTreeWidget->clear(); |
|
|
|
mDocumentUI->documentTreeWidget->clear(); |
|
|
|
|
|
|
|
|
|
|
|
UBDocumentGroupTreeItem* emptyGroupNameTi = new UBDocumentGroupTreeItem(0, false); |
|
|
|
QMap<QString, UBDocumentGroupTreeItem*> groupNamesMap; |
|
|
|
emptyGroupNameTi->setGroupName(mDefaultDocumentGroupName); |
|
|
|
|
|
|
|
emptyGroupNameTi->setIcon(0, QIcon(":/images/toolbar/documents.png")); |
|
|
|
UBDocumentGroupTreeItem* emptyGroupNameTi = 0; |
|
|
|
mMapOfPaths.insert(mDefaultDocumentGroupName,emptyGroupNameTi); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mTrashTi = new UBDocumentGroupTreeItem(0, false); // deleted by the tree widget
|
|
|
|
mTrashTi = new UBDocumentGroupTreeItem(0, false); // deleted by the tree widget
|
|
|
|
mTrashTi->setGroupName(mDocumentTrashGroupName); |
|
|
|
mTrashTi->setGroupName(mDocumentTrashGroupName); |
|
|
|
mTrashTi->setIcon(0, QIcon(":/images/trash.png")); |
|
|
|
mTrashTi->setIcon(0, QIcon(":/images/trash.png")); |
|
|
|
mMapOfPaths.insert(mDocumentTrashGroupName,mTrashTi); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mDocumentUI->documentTreeWidget->addTopLevelItem(emptyGroupNameTi); |
|
|
|
|
|
|
|
mDocumentUI->documentTreeWidget->addTopLevelItem(mTrashTi); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (QPointer<UBDocumentProxy> proxy, proxies) |
|
|
|
foreach (QPointer<UBDocumentProxy> proxy, proxies) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (proxy) |
|
|
|
if (proxy) |
|
|
|
{ |
|
|
|
{ |
|
|
|
addDocumentInTree(proxy); |
|
|
|
QString docGroup = proxy->metaData(UBSettings::documentGroupName).toString(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool isEmptyGroupName = false; |
|
|
|
|
|
|
|
bool isInTrash = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (docGroup.isEmpty()) // #see https://trac.assembla.com/uniboard/ticket/426
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
docGroup = mDefaultDocumentGroupName; |
|
|
|
|
|
|
|
isEmptyGroupName = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else if (docGroup.startsWith(UBSettings::trashedDocumentGroupNamePrefix)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
isInTrash = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
QString docName = proxy->metaData(UBSettings::documentName).toString(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (emptyGroupNames.contains(docGroup)) |
|
|
|
|
|
|
|
emptyGroupNames.removeAll(docGroup); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!groupNamesMap.contains(docGroup) && !isInTrash) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
UBDocumentGroupTreeItem* docGroupItem = new UBDocumentGroupTreeItem(0, !isEmptyGroupName); // deleted by the tree widget
|
|
|
|
|
|
|
|
groupNamesMap.insert(docGroup, docGroupItem); |
|
|
|
|
|
|
|
docGroupItem->setGroupName(docGroup); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isEmptyGroupName) |
|
|
|
|
|
|
|
emptyGroupNameTi = docGroupItem; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBDocumentGroupTreeItem* docGroupItem; |
|
|
|
|
|
|
|
if (isInTrash) |
|
|
|
|
|
|
|
docGroupItem = mTrashTi; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
docGroupItem = groupNamesMap.value(docGroup); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QTreeWidgetItem* docItem = new UBDocumentProxyTreeItem(docGroupItem, proxy, !isInTrash); |
|
|
|
|
|
|
|
docItem->setText(0, docName); |
|
|
|
|
|
|
|
|
|
|
|
void UBDocumentController::itemClicked(QTreeWidgetItem * item, int column ) |
|
|
|
if (mBoardController->selectedDocument() == proxy) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Q_UNUSED(item); |
|
|
|
mDocumentUI->documentTreeWidget->expandItem(docGroupItem); |
|
|
|
Q_UNUSED(column); |
|
|
|
mDocumentUI->documentTreeWidget->setCurrentItem(docGroupItem); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
selectDocument(selectedDocumentProxy(), false); |
|
|
|
foreach (const QString emptyGroupName, emptyGroupNames) |
|
|
|
itemSelectionChanged(); |
|
|
|
{ |
|
|
|
|
|
|
|
UBDocumentGroupTreeItem* docGroupItem = new UBDocumentGroupTreeItem(0); // deleted by the tree widget
|
|
|
|
|
|
|
|
groupNamesMap.insert(emptyGroupName, docGroupItem); |
|
|
|
|
|
|
|
docGroupItem->setGroupName(emptyGroupName); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QList<QString> groupNamesList = groupNamesMap.keys(); |
|
|
|
|
|
|
|
qSort(groupNamesList); |
|
|
|
|
|
|
|
|
|
|
|
void UBDocumentController::treeGroupItemRenamed(QString& oldPath,QString& newPath) |
|
|
|
foreach (const QString groupName, groupNamesList) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(oldPath.isEmpty() || newPath.isEmpty()) |
|
|
|
UBDocumentGroupTreeItem* ti = groupNamesMap.value(groupName); |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QList<QString> keys = mMapOfPaths.keys(); |
|
|
|
if (ti != emptyGroupNameTi) |
|
|
|
for(int i = 0; i < keys.count(); i += 1){ |
|
|
|
mDocumentUI->documentTreeWidget->addTopLevelItem(ti); |
|
|
|
QString key = keys.at(i); |
|
|
|
|
|
|
|
if(key.startsWith(oldPath)){ |
|
|
|
|
|
|
|
UBDocumentGroupTreeItem* value = mMapOfPaths.take(key); |
|
|
|
|
|
|
|
key = key.remove(0,oldPath.size()); |
|
|
|
|
|
|
|
mMapOfPaths.insert(key.prepend(newPath),value); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (emptyGroupNameTi) |
|
|
|
|
|
|
|
mDocumentUI->documentTreeWidget->addTopLevelItem(emptyGroupNameTi); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mDocumentUI->documentTreeWidget->addTopLevelItem(mTrashTi); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void UBDocumentController::itemClicked(QTreeWidgetItem * item, int column ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Q_UNUSED(item); |
|
|
|
|
|
|
|
Q_UNUSED(column); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
selectDocument(selectedDocumentProxy(), false); |
|
|
|
|
|
|
|
itemSelectionChanged(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBDocumentController::itemChanged(QTreeWidgetItem * item, int column) |
|
|
|
void UBDocumentController::itemChanged(QTreeWidgetItem * item, int column) |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBDocumentProxyTreeItem* proxyItem = dynamic_cast<UBDocumentProxyTreeItem*>(item); |
|
|
|
UBDocumentProxyTreeItem* proxyItem = dynamic_cast<UBDocumentProxyTreeItem*>(item); |
|
|
|
|
|
|
|
|
|
|
|
disconnect(UBPersistenceManager::persistenceManager(), SIGNAL(documentMetadataChanged(UBDocumentProxy*)) , this, SLOT(updateDocumentInTree(UBDocumentProxy*))); |
|
|
|
disconnect(UBPersistenceManager::persistenceManager(), SIGNAL(documentMetadataChanged(UBDocumentProxy*)) |
|
|
|
|
|
|
|
, this, SLOT(updateDocumentInTree(UBDocumentProxy*))); |
|
|
|
|
|
|
|
|
|
|
|
if (proxyItem) |
|
|
|
if (proxyItem) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -986,7 +944,8 @@ void UBDocumentController::itemChanged(QTreeWidgetItem * item, int column) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
connect(UBPersistenceManager::persistenceManager(), SIGNAL(documentMetadataChanged(UBDocumentProxy*)), this, SLOT(updateDocumentInTree(UBDocumentProxy*))); |
|
|
|
connect(UBPersistenceManager::persistenceManager(), SIGNAL(documentMetadataChanged(UBDocumentProxy*)), |
|
|
|
|
|
|
|
this, SLOT(updateDocumentInTree(UBDocumentProxy*))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1375,48 +1334,42 @@ void UBDocumentController::addToDocument() |
|
|
|
QApplication::restoreOverrideCursor(); |
|
|
|
QApplication::restoreOverrideCursor(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBDocumentGroupTreeItem* UBDocumentController::getParentTreeItem(QString& documentGroup) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QString pathNotYetCreated = documentGroup; |
|
|
|
|
|
|
|
UBDocumentGroupTreeItem* result = getCommonGroupItem(documentGroup); |
|
|
|
|
|
|
|
if(result) |
|
|
|
|
|
|
|
pathNotYetCreated = pathNotYetCreated.remove(0,result->buildEntirePath().size()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(pathNotYetCreated.startsWith("/")) pathNotYetCreated = pathNotYetCreated.remove(0,1); |
|
|
|
|
|
|
|
QString completePath = result ? result->groupName() + "/" : ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QStringList folders = pathNotYetCreated.split("/"); |
|
|
|
|
|
|
|
for(int i = 0; i < folders.count(); i += 1 ){ |
|
|
|
|
|
|
|
if(!folders.at(i).isEmpty()){ |
|
|
|
|
|
|
|
completePath = completePath + folders.at(i); |
|
|
|
|
|
|
|
UBDocumentGroupTreeItem* newTreeItem = new UBDocumentGroupTreeItem(result, true); |
|
|
|
|
|
|
|
newTreeItem->setGroupName(folders.at(i)); |
|
|
|
|
|
|
|
if(completePath.indexOf("/") == -1) |
|
|
|
|
|
|
|
mDocumentUI->documentTreeWidget->insertTopLevelItem(0,newTreeItem); |
|
|
|
|
|
|
|
mMapOfPaths.insert(completePath,newTreeItem); |
|
|
|
|
|
|
|
result = newTreeItem; |
|
|
|
|
|
|
|
completePath += "/"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBDocumentController::addDocumentInTree(UBDocumentProxy* pDocument) |
|
|
|
void UBDocumentController::addDocumentInTree(UBDocumentProxy* pDocument) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QString documentName = pDocument->name(); |
|
|
|
QString documentName = pDocument->name(); |
|
|
|
QString documentGroup = pDocument->groupName(); |
|
|
|
QString documentGroup = pDocument->groupName(); |
|
|
|
|
|
|
|
|
|
|
|
if (documentGroup.isEmpty()) |
|
|
|
if (documentGroup.isEmpty()) |
|
|
|
|
|
|
|
{ |
|
|
|
documentGroup = mDefaultDocumentGroupName; |
|
|
|
documentGroup = mDefaultDocumentGroupName; |
|
|
|
|
|
|
|
|
|
|
|
UBDocumentGroupTreeItem* group = NULL; |
|
|
|
} |
|
|
|
|
|
|
|
UBDocumentGroupTreeItem* group = 0; |
|
|
|
|
|
|
|
|
|
|
|
if (documentGroup.startsWith(UBSettings::trashedDocumentGroupNamePrefix)) |
|
|
|
if (documentGroup.startsWith(UBSettings::trashedDocumentGroupNamePrefix)) |
|
|
|
|
|
|
|
{ |
|
|
|
group = mTrashTi; |
|
|
|
group = mTrashTi; |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
group = getParentTreeItem(documentGroup); |
|
|
|
{ |
|
|
|
|
|
|
|
for (int i = 0; i < mDocumentUI->documentTreeWidget->topLevelItemCount(); i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QTreeWidgetItem* item = mDocumentUI->documentTreeWidget->topLevelItem(i); |
|
|
|
|
|
|
|
UBDocumentGroupTreeItem* groupItem = dynamic_cast<UBDocumentGroupTreeItem*>(item); |
|
|
|
|
|
|
|
if (groupItem->groupName() == documentGroup) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
group = groupItem; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (group == 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
group = new UBDocumentGroupTreeItem(0); // deleted by the tree widget
|
|
|
|
|
|
|
|
group->setGroupName(documentGroup); |
|
|
|
|
|
|
|
mDocumentUI->documentTreeWidget->addTopLevelItem(group); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBDocumentProxyTreeItem *ti = new UBDocumentProxyTreeItem(group, pDocument, !group->isTrashFolder()); |
|
|
|
UBDocumentProxyTreeItem *ti = new UBDocumentProxyTreeItem(group, pDocument, !group->isTrashFolder()); |
|
|
|
ti->setText(0, documentName); |
|
|
|
ti->setText(0, documentName); |
|
|
@ -1445,24 +1398,11 @@ QStringList UBDocumentController::allGroupNames() |
|
|
|
{ |
|
|
|
{ |
|
|
|
QStringList result; |
|
|
|
QStringList result; |
|
|
|
|
|
|
|
|
|
|
|
UBDocumentGroupTreeItem* selectedGroup = selectedDocumentGroupTreeItem(); |
|
|
|
for (int i = 0; i < mDocumentUI->documentTreeWidget->topLevelItemCount(); i++) |
|
|
|
if(selectedGroup->isDefaultFolder()){ |
|
|
|
{ |
|
|
|
|
|
|
|
QTreeWidgetItem* item = mDocumentUI->documentTreeWidget->topLevelItem(i); |
|
|
|
for (int i = 0; i < mDocumentUI->documentTreeWidget->topLevelItemCount(); i++) |
|
|
|
UBDocumentGroupTreeItem* groupItem = dynamic_cast<UBDocumentGroupTreeItem*>(item); |
|
|
|
{ |
|
|
|
result << groupItem->groupName(); |
|
|
|
QTreeWidgetItem* item = mDocumentUI->documentTreeWidget->topLevelItem(i); |
|
|
|
|
|
|
|
UBDocumentGroupTreeItem* groupItem = dynamic_cast<UBDocumentGroupTreeItem*>(item); |
|
|
|
|
|
|
|
result << groupItem->groupName(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else{ |
|
|
|
|
|
|
|
for (int i = 0; i < selectedGroup->childCount(); i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QTreeWidgetItem* item = selectedGroup->child(i); |
|
|
|
|
|
|
|
UBDocumentGroupTreeItem* groupItem = dynamic_cast<UBDocumentGroupTreeItem*>(item); |
|
|
|
|
|
|
|
if(groupItem) |
|
|
|
|
|
|
|
result << groupItem->groupName(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
return result; |
|
|
|